Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl TK question

Status
Not open for further replies.

spydermonkey

Programmer
May 24, 2004
31
US
I have a CMD script I'm rebuilding to work into Perl TK. One problem I am having is printing back to the UI itself. I know it has to be done within a label but I can't seem to get variables to print inside of one.<p>

Can someone show me how to make scalars (and other variables) work within a label? The code I have to date is

Code:
#!/usr/bin/perl

use strict;
use Tk;

my $mw = new MainWindow;
    $mw->geometry('150x200');
    my $menubar = $mw->Menu;
    my $file_menu = $menubar->cascade(-label => "~File");
    #$file_menu->command(-label => 'Exit',-command => \&do_this);
    my $edit_menu = $menubar->cascade(-label => "~Edit");
    my $help_menu = $menubar->cascade(-label => "~Help");
    $help_menu->command(-label => 'About..',-command => \&do_this);
    $mw->configure(-menu => $menubar);
MainLoop;

my $this = "that";
sub do_this
{
  $mw->Label(-text=>\$this)->pack;
}

Thank you!
 
#!/usr/bin/perl

use strict;
use Tk;
my $this = "that"; ## NOTHING beyond MainLoop is (directly) executed

my $mw = new MainWindow;
$mw->geometry('150x200');
my $menubar = $mw->Menu;
my $file_menu = $menubar->cascade(-label => "~File");
#$file_menu->command(-label => 'Exit',-command => \&do_this);
my $edit_menu = $menubar->cascade(-label => "~Edit");
my $help_menu = $menubar->cascade(-label => "~Help");
$help_menu->command(-label => 'About..',-command => \&do_this);
$mw->configure(-menu => $menubar);
MainLoop;

my $this = "that";
sub do_this
{
$mw->Label(-text=>$this)->pack; # NOT ref
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top