Here's a simple script to show my problem. I am running ActivePerl 5.8.1.807, Tk 800.024, W2K.
If you click on the save button, and select an existing file, a dialog box appears asking if you want to overwrite the file.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}
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,
I got the following error:sub save {my $file = $mw -> getSaveFile (-force => 1)}
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |