Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Newbie Perl/Tk help

by cbro (Pilgrim)
on Jul 17, 2003 at 15:40 UTC ( #275253=note: print w/replies, xml ) Need Help??

in reply to Newbie Perl/Tk help

Here is a small example that hints answers towards both of your questions.
#!c:/perl/bin use Tk; use strict; my $main = MainWindow->new(); my $value; # # here is an example of how to catch the key return. # Again, this is just an example, but you will # see that you get into the calc() function every time # the user presses enter. $main->bind('<Key-Return>', \&calc); # O/K now that the Enter key is bound to the # window, let's bind $value to the Scale and # also give Scale a function where we can access # it's members (e.g. the value of $value) $main->Scale('orient' => 'horizontal', '-from' => 0, '-to' => 12, '-tickinterval' => 1, '-label' => 'Select Time Table', '-variable' => \$value, '-command' => \&calc)->pack; MainLoop; sub calc { # remember this is just an example. # This prints to the console, but # it shows that you have access to the value. print $value . "\n"; # # Now that you're in the function, I'll leave # it up to you how to do the calculations, and # draw up/print a new question. # just know that you still have access to all of the # widgets that are part of the MainWindow. }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://275253]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-06-28 11:00 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (632 votes). Check out past polls.