hebes_99 has asked for the wisdom of the Perl Monks concerning the following question:
How do I pass the $txt widget into a subroutine that is outside of the main program (seperate .pm file) so that I can call $txt->insert? My knowledge of Perl is still novice, so please be nice in responding. I have set up subroutines in the past, with little or no problem. However, I can't seem to get it to work with Tk. Thoughts?use Tk; # Main Window my $mw = new MainWindow; #GUI Building Area my $frm_name = $mw -> Frame()->pack(); my $lab = $frm_name -> Label(-text=>"Name:")->pack(-side=>'left'); my $ent = $frm_name -> Entry(-textvariable=>\$entry_var)->pack(); $ent->bind('<Return>'=> \&subbie_1); #Text Area my $textarea = $mw -> Frame()->pack(); my $txt = $textarea -> Text(-width=>40, -height=>10)->pack(); MainLoop(); sub subbie_1 { $txt->insert('end', "$entry_var\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Newbie TK question
by liverpole (Monsignor) on Jun 07, 2006 at 15:22 UTC | |
by hebes_99 (Acolyte) on Jun 07, 2006 at 15:32 UTC | |
|
Re: Newbie TK question
by GrandFather (Saint) on Jun 07, 2006 at 18:50 UTC | |
by hebes_99 (Acolyte) on Jun 30, 2006 at 19:05 UTC | |
by GrandFather (Saint) on Jul 21, 2006 at 23:09 UTC |