#!/usr/local/bin/perl use strict; use Tk; use Tk::BrowseEntry; my $obj = bless {mw => new MainWindow}; $obj->{mw}->title("Main Window"); $obj->{frame1} = $obj->{mw}->Frame()->pack(-side => 'top' ); my $Win_value; #List for Browse Entry my @List = ("First window", "Second Window", "Third Window", "Last Window"); my $browseentry = $obj->{frame1}->BrowseEntry ( -label => "Select Window:", -listheight=> 4, -variable => \$Win_value, -browsecmd => [\&Create_Window, $obj], ) ->pack(-side =>'left', -ipady => 5, -pady=>15); $browseentry->insert('end', @List); my $frame2 = $obj->{mw}->Frame()->pack (-side => 'bottom'); my $lbl1 = $frame2->Button (-text => 'Close', -command =>sub {$obj->{mw}->destroy()}) ->pack (-pady =>10); MainLoop; sub Create_Window { my $self = shift; my $myId = $_[1]; my $caption = join '', $_[1],"_Details"; if (exists $self->{windows}{$myId} and Exists ($self->{windows}{$myId}{win})) { $self->{windows}{$myId}{win}->deiconify (); $self->{windows}{$myId}{win}->raise (); return; } my $info = $self->{windows}{$myId} = {}; $info->{win} = $self->{mw}->Toplevel(); $info->{win}->title("$caption"); $info->{win}->minsize(qw(800 500)); $info->{win}->focus(); $info->{frame} = $info->{win}->Frame()->pack(-side => 'bottom' ); #opens the save file dialog wrt the selected toplevel. $info->{frame}->Button( -text => 'Save', -command =>sub {SaveFile($info->{win})} )->pack(-side=>'left'); #closes the selected window $info->{frame}->Button ( -text => 'Close', -command => [\&closeChild, $self, $myId], )->pack(-side=>'left'); } sub closeChild { my ($self, $winId) = @_; $self->{windows}{$winId}{win}->destroy (); delete $self->{windows}{$winId}; }