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

I was wondering how to get a file menu working, ive got the basics but cant get the new, open, save and save as working :(. Any ideas? Cheers

i need new to clear a text area, open to create a window which will allow me to open files on my computer that are pl files, and the save to save the text in my textarea on my pc. I dont know how to use gui libraries-sorry

my $mw12= $mw->configure(-menu=> my $menubar = $mw->Menu); my $file = $menubar->cascade(-label =>'~File'); my $help = $menubar->cascade(-label =>'~Help'); my $new = $file ->command(-label=>'New', -underline=>0); my $open = $file ->command(-label=>'Open', -underline=>0); my $save = $file ->command(-label=>'Save', -underline=>0); my $saveas = $file ->command(-label=>'Save As..', -<br>underline=>1); my $exit = $file ->command(-label=>'Exit', -underline=>0, -command =>\ +&exit);

janitored by ybiC: Minor format tweaks, including <code> tags around code snippet

Replies are listed 'Best First'.
Re: How to write file menu
by moot (Chaplain) on Mar 28, 2005 at 21:35 UTC
    You might want to a) tell us what GUI library you are using, and b) tell us what you expect your 'new', 'open', 'save', and 'save as' functions to do. You do realise of course that you will need to write those functions, they are likely to be specific to your app, and if your question is "How do I trigger a function from a menu option", you should probably state that explicitly rather than expecting us to read your mind.
Re: How to write file menu
by moot (Chaplain) on Mar 28, 2005 at 22:45 UTC
      It looks like you're trying to use Tk. You should probably take a look at http://www.oreilly.com/catalog/mastperltk/, if so.
      You forgot <voice style="clippy">...</voice> around that. {grin}

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Heh. I'd like to say I have no idea what you're talking about, but sadly it's all too familiar... *shudder*
Re: How to write file menu
by InfiniteLoop (Hermit) on Mar 29, 2005 at 04:07 UTC
    This site, www.perltk.org has good articles on perl Tk, especially one on menus, and also quite a few applications, that use perl Tk.