Oh Joy! - I just remembered I emailed myself the code a while ago and it's stored on an IMAP server - quick login and here it is:
This defines the mainwindow:
$top = MainWindow->new();
$top->title("Window Title");
$main_frame = $top->Frame()->pack(
-fill=>'both',
-expand=>1
);
Here's the OpenBox Code:
sub openfile {
#print "You clicked Open..\n";
my $opentypes = [
['CSV Files', '.csv', ],
['TXT Files', '.txt', ],
['All Files', '*', ],
];
$csvfile = $top->getOpenFile(-filetypes=>$opentypes, -title=> "Select
+ a CSV File");
if ($csvfile ne "") {
$csv_entry_box->delete(0,99999);
$csv_entry_box->insert(0,$csvfile);
ui $main_frame;
}
}
Here's the SaveFile Sub
sub savefile {
#print "You clicked Save As..\n";
my $savetypes = [
['All Files', '*', ],
];
$outfile = $top->getSaveFile(-filetypes=>$savetypes, -title=> "Type a
+n output filename");
if ($outfile ne "") {
$save_entry_box->delete(0,99999);
$save_entry_box->insert(0,$outfile);
ui $main_frame;
}
}
ui is the sub which has all the unpacked widgets. so ui $main_frame packs all the widgets in ui into $mainframe Then you just need the Tk::MainLoop; call.
Sorry if this is not very clear, I can email you the full listing if you need it. I found that SpecTcl is a nice little tool to help build the GUI. I am sure I can dig out the URL for it.
Good Luck |