ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I have a gui application which takes a xml file as input from command line and constructs the gui object parsing the xml file.
So the steps are :
1. tk_gui.pl test.xml (this command launches the gui) 2. In the script tk_gui.pl , it parses the test.xml (i.e $ARGV[0])if it is a valid one and makes the frame, entry boxes , buttons by reading the xml. So when the gui is launched, it has all the gui objects created on it as per the xml.

Now, I want it to launch the gui without the xml and keep a provision to load the xml file from a menu. I need a help here how to launch the gui just with the top level menu. Once the file is selected by browsing the menu button then the rest of the gui objects should be constructed.
By the way, I know how to build a menubar and button as I already have the following function.

sub setup_menu { my ($top) = @_; my $menubar = $top->Menu(); $top->configure(-menu => $menubar); my $input = $menubar=>Menubutton ( -text => 'File', + -menuitems => [Button => 'load xml', -command => sub {$use +r_xml = $menubar->getOpenFile();}] );

Right now it is crashing before launching the gui as the variable does not get the xml file from command line. Please help me in launching the blank gui with the menu only,so that I can select the xml and put that file name in $user_xml and rest of the gui can be built after that.

Replies are listed 'Best First'.
Re: How to launch a gui and then load a file
by Anonymous Monk on Apr 30, 2013 at 09:39 UTC
    sub not_from_argv { my $filename = get_filename(); my $widget = build_widget( $filename ); $widget->pack...; }