Hello World!

Here's a simple script to show my problem. I am running ActivePerl 5.8.1.807, Tk 800.024, W2K.

use strict; use warnings; use Tk; my $mw = MainWindow -> new; my $button = $mw -> Button (-command => \&save, -text => "save") -> pa +ck;<br> MainLoop; sub save {my $file = $mw -> getSaveFile}
If you click on the save button, and select an existing file, a dialog box appears asking if you want to overwrite the file.

In my application, selecting an existing file implies that you want to append to that file, rather than overwrite it. As this dialog box is then inappropriate and confusing, I want to stop it from appearing. I have tried to do this, but have had no luck, so I was hoping someone would help me out.

I had a look through c:\perl\site\lib\Tk\FBox.pm and found mention of a -force option, but when I tried to use it,

sub save {my $file = $mw -> getSaveFile (-force => 1)}
I got the following error:

Tk::Error: unknown option "-force", must be -defaultextension, -filetypes, -initialdir, -initialfile, -parent or -title at C:/Perl/site/lib/Tk.pm line 276.
Tk callback for tk_getSaveFile
[\&main::load]
Tk callback for .button
Tk::__ANON__ at C:/Perl/site/lib/Tk.pm line 228
Tk::Button::butUp at C:/Perl/site/lib/Tk/Button.pm line 111
(command bound to event)

In FBox.pm sub Done, I found the area of code that checks whether the file exists, and causes the dialog box to appear. In my naivety, I assumed that commenting this section out would stop the dialog box from appearing, but it didn't.

So, what I would like to do, is to be able to use the -force option. Failing that I would like to have my own getSaveFile called getSaveFileNC which doesn't cause a popup if the file exists, and failing that, I would like to be able to comment that section of code out of FBox.pm, and have the change make a difference.

Unfortunately, I have no idea how to go about doing any of these things. Please help!

Thanks.

Spike.

janitored by ybiC: Balanced <code> tags around codeblock, and other wee tiny format tweaks for legibility


In reply to How to change a Tk module? by spikey_wan

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.