Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

While I haven't any experience with Win32::GUI, I've used Perl/Tk successfully for this exact problem. The key methods are getOpenFile and getSaveFile Here's a short example:

#!/usr/bin/perl -w use Tk 8.0; use strict; my $mw = MainWindow->new( -title => 'File Test' ); my $menu_bar = $mw->Menu; $mw->configure( -menu => $menu_bar ); my $file_mb = $menu_bar->cascade( -label => '~File', -tearoff => 0 ); $file_mb->command( -label => 'Open', -underline => 0, -command => \&f_ +open ); $file_mb->command( -label => 'Save', -underline => 0, -command => \&f_ +save ); $file_mb->separator; $file_mb->command( -label => 'Exit', -underline => 1, -command => sub{ +exit} ); MainLoop; sub f_open { my $filename = $mw->getOpenFile( -title => 'Open File:', -defaultextension => '.txt', -initialdir => '.' ); ### do something with $filename warn "Opened $filename\n"; } sub f_save { my $filename = $mw->getSaveFile( -title => 'Save File:', -defaultextension => '.txt', -initialdir => '.' ); ### do something with $filename warn "Saved $filename\n"; } #

Note that Question 16.2. - Is there a file selector? of the (somewhat stale) Perl/Tk FAQ lists several alternatives. Which, if any, of these is what got built into the Tk of ActiveState Perl, I don't know...


In reply to Re: How do I make Open and Save As file dialogs? (Win32) by ase
in thread How do I make Open and Save As file dialogs? (Win32) by Buckaroo Buddha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-25 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found