CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
PERL TKX Troubles....

 



Jukari
Novice

Oct 28, 2011, 2:55 AM

Post #1 of 2 (3705 views)
PERL TKX Troubles.... Can't Post

Hello,

Very rarely can I not find an answer just by searching google but literally spent the last two days trying to find an answer with no result.

Problem: Need to kill a subroutine, while opening another, or another solution not thought of yet. Basically I want to kill one frame, when opening another.

#!/usr/bin/perl -w

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,.*[\\/],,;





my $mw = Tkx::widget->new(".");
$mw->g_wm_title("Wikiget");
$mw->g_wm_minsize(500, 200);
$mw->configure(-menu => mk_menu($mw));
my $frame1 = $mw->new_frame();
my $frame2 = $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 => "Exit",-underline => 1,-command => [\&Tkx::destroy, $mw],);


return $menu;
}
####################################################################
sub frame1
{
#Closes Frame2

$frame1->g_pack(-side => 'right',-expand => 1,-fill => 'both');
$frame1->configure(-borderwidth => 7, -relief => "sunken");



}

sub frame2
{
#closes Frame1
$frame2->g_pack(-side => 'right',-expand => 1,-fill => 'both');
$frame2->configure(-borderwidth => 7, -relief => "sunken");

}

Thank you.


(This post was edited by Jukari on Oct 28, 2011, 6:21 AM)


Jukari
Novice

Oct 28, 2011, 7:28 AM

Post #2 of 2 (3689 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');

}

In Reply To

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives