• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Entering data using a TKperl widget

What is the best way to Input data into a perl script using a TKperl widget. (something analogical to: $some_parameter = <stdin>;)
  • 2
1 Solution
Huh, are you trying to retrieve the value from a TK widget?

ronpoAuthor Commented:
Actually Yes, i'm trying to assign a value to a parameter using a TkPerl widget. By now I could only figure out how to enter and edit text in a text wigdet but I couldn't assign it to a parameter (there is no command property in the Text or Entry widgets).

Let's suppose that your parameter is stored in $parm.
Why don't you create an Entry widget as follows:

my $entry = $widget->Entry(-textvariable=>\$parm);

This way $parm is automagically updated whenever the text in the Entry widget is changed by the user.  If it is initially undefined and you want to act on it when the user is finished filling it in, then you may also want to define a button so the user can tell your program when the entry has been filled in.  Otherwise, simply checking periodically whether it has become defined may result in grabbing a partial input before all the input has been specified.

ronpoAuthor Commented:
Thanks Mikky, it works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now