
Jukari
Novice
Oct 28, 2011, 7:28 AM
Post #2 of 2
(5193 views)
|
Re: [Jukari] PERL TKX Troubles....
[In reply to]
|
Can't Post
|
|
Well if anyone's interested I found a solution... It's not clean looking but it works... still getting used to TKX. Below is working frame code. #!/usr/bin/perl -w ###Headers### use strict; use Tkx; Tkx::package_require("Tktable"); Tkx::package_require("tile"); Tkx::package_require("style"); Tkx::style__use("as", -priority => 70); our $VERSION = "1.00"; (my $progname = $0) =~ s,.*[\\/],,; ###Main Window###### my $mw = Tkx::widget->new("."); $mw->g_wm_title("Wikiget"); $mw->g_wm_minsize(500, 200); $mw->configure(-menu => mk_menu($mw)); ###Global Variables###### my @open_windows; my $frame1 = $mw->new_frame(); my $frame2 = $mw->new_frame(); my $frame3 = $mw->new_frame(); Tkx::MainLoop(); exit; #################################################### sub mk_menu { my $mw = shift; my $menu = $mw->new_menu; my $file = $menu->new_menu(-tearoff => 0,); $menu->add_cascade(-label => "File",-underline => 0,-menu => $file,); $file->add_command(-label => "Frame1",-underline => 1,-command => \&frame1,); $file->add_command(-label => "Frame2",-underline => 1,-command => \&frame2,); $file->add_command(-label => "Frame3",-underline => 1,-command => \&frame3,); $file->add_command(-label => "Exit",-underline => 1,-command => [\&Tkx::destroy, $mw],); return $menu; } #################################################################### sub frame1 { foreach my $open_window (@open_windows) { $open_window->g_destroy; } $frame1 = $mw->new_frame(); $frame1->g_pack(-side => 'right',-expand => 1,-fill => 'both'); $frame1->configure(-borderwidth => 7, -relief => "sunken"); push(@open_windows, $frame1); my $title = $frame1->new_label(-text => 'Frame1'); $title->g_pack;#(-column => 0, -row => 0, -sticky => 'w'); } sub frame2 { foreach my $open_window (@open_windows) { $open_window->g_destroy; } $frame2 = $mw->new_frame(); $frame2->g_pack(-side => 'right',-expand => 1,-fill => 'both'); $frame2->configure(-borderwidth => 7, -relief => "sunken"); push(@open_windows, $frame2); my $title = $frame2->new_label(-text => 'Frame2'); $title->g_pack;#(-column => 0, -row => 0, -sticky => 'w'); } sub frame3 { foreach my $open_window (@open_windows) { $open_window->g_destroy; } $frame3 = $mw->new_frame(); $frame3->g_pack(-side => 'right',-expand => 1,-fill => 'both'); $frame3->configure(-borderwidth => 7, -relief => "sunken"); push(@open_windows, $frame3); my $title = $frame3->new_label(-text => 'Frame3'); $title->g_pack;#(-column => 0, -row => 0, -sticky => 'w'); }
|