954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Multiple window using Perl TK

I've got a text file in this following format :

Field Data
1 2
1 3
1 4
2 5
2 6
3 2
3 3
3 4

I would like to open separate windows for each of the field...
meaning :
window1 (for field1) will display 2,3,4
window2 (for field2) will display 5,6
window3 (for field3) will display 2,3,4

I've read the file and load into two separate arrays - @field and @data.

I'm using window1 as the main window and the rest as toplevel windows.
I've managed to do window1 but the still having problem to proceed with the rest. Appreciate any snippets or guidance to start with as still new with Perl n Tk. Thanks in advance...

terrylau77
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 
#!/usr/bin/perl -w
    use Tk;
    use strict;

    my $mw = MainWindow->new;
    fill_window($mw, 'Main');
    my $top1 = $mw->Toplevel;
    fill_window($top1, 'First top-level');
    my $top2 = $mw->Toplevel;
    fill_window($top2, 'Second top-level');
    MainLoop;

    sub fill_window {
        my ($window, $header) = @_;
        $window->Label(-text => $header)->pack;
        $window->Button(
            -text    => 'close',
            -command => [$window => 'destroy']
        )->pack(-side => 'left');
        $window->Button(
            -text    => 'exit',
            -command => [$mw => 'destroy']
        )->pack(-side => 'right');
    }


This was taken from the module doc. on cspan TK module doc.

wickedxter
Newbie Poster
20 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: