Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Tk: How to configure the cancel button

Status
Not open for further replies.

Cambridge10

Programmer
May 5, 2008
18
NL
Hi,

I've created a file dialog where an user can choose a txt file.
There is also a cancel button which I need to configure but I don't know how to approach it?
Disabling the cancel button will also be fine.

Code:
sub Load_file
{
	$file_path_entry -> delete('0.0', 'end');
	my $file;
    
	my @types = (["Text files", '.txt', 'TEXT'],[""] );
  	$file = $mw->getOpenFile(-filetypes => \@types);
	
	open IN,$file;
	my @tfile = <IN>;
	chop @tfile;
	close (IN);
	
	#convert / to \ filepath
	$file =~ s/\//\\/g; 
	$file_path_entry -> insert(0,"$file");
	$file_path = $file;
	$passing_path = $file_path;
}
 
On Windows, getOpenFile uses the native Win32 file selection dialog. On non-Windows, it uses a pure Tk alternative.

The Windows dialog box it uses doesn't provide an interface to configure it at that level of detail from your program. The non-Windows version doesn't provide this either because there would be no equivalent to it from a Windows OS.

Try one of the other Tk file selection dialog widgets. Disabling the cancel button doesn't seem like a very common need though so if you can't find any existing module that will let you do that, you'll have to handle the file selection dialog on your own.

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top