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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Perl for interactive Windows apps 1

Status
Not open for further replies.

dulux

Programmer
Sep 4, 2002
36
GB
Hi there,

I am looking to code a basic file modification application that runs from a separate window and not command line - any ideas how I go about this?

I am running Windows 2k and wish to simply rename files, giving the user a chance to search for the file to be renamed and then entering their chosen name change.

Thanks.
 
Take a look at the the Tk module. In particular, Tk::FileSelect may be what you are looking for.
 
Thanks

I have downloaded and installed TK okay, I think, but cannot make head nor tail of the instructions and there is no beginners readme that i can find...

I have ascertained that any files do not simply run from the perl interpreter, and I do not have a clue what else I need to be doing.

Is anyone else using TK or has experience with it? I'm a newbie so be gentle with me...

Cheers
 
This is a silly and trivial example but it shows building a simple interface and with some buttons. And, connecting those buttons to some desired actions. Tk takes a little playing with to figure out "how you do" what "you want to do". A very good book is "Learning Perl/Tk" by Nancy Walsh published by O'Reilly.

Code:
#!/usr/local/bin/perl
use Tk;
use strict;

my $mw = new MainWindow;
$mw->Label(-text=>'Some Text in a Label')
        ->pack(-side=>'top');

my $frame = $mw->Frame(-borderwidth=>'5', 
               -background=>'white')
        ->pack(-side=>'top', 
                      -fill=>'both');

$frame->Button(-text=>'Exit',
               -command=> sub {exit} )
               ->pack(-side=>'left');

my $add_button = $frame->Button(
		-text=>'Add File',
		-command=>\&file_select)
		->pack(-side=>'left');


MainLoop;
#---------------------------------------------

sub file_select
{ 
my $getFile = $mw->getOpenFile(
                   -title=>"Select a File", 
		   -filetypes=>[['All files', '*',]]);
$mw->Label(-textvariable=>\$getFile)
        ->pack(-side=>'bottom');

}
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Brilliant!

Thanks for the example, I will examine it at my leisure for what I need. Looks like a good starting point, though.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top