Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Perl/Tk on Windows 7

by pmbp (Initiate)
on Feb 06, 2012 at 20:55 UTC ( #952156=perlquestion: print w/replies, xml ) Need Help??

pmbp has asked for the wisdom of the Perl Monks concerning the following question:

I've installed perl v5.14.2 and Tk v804.030.0.0 under Windows 7. When I double click on the name of a perl script, it launches a window called "C:\perl64\bin\perl.exe". This is fine for text only scripts, but for Tk I'd like to just see the main window, not the "perl.exe" window. Is this possible?

Replies are listed 'Best First'.
Re: Perl/Tk on Windows 7
by thunders (Priest) on Feb 06, 2012 at 21:45 UTC
    You distribution should come with an executable called wperl.exe. If you use that it should get rid of the console window.
    Just edit the first line of your script to use

      I tried both of your suggestions and neither did the trick, but the 'wperl' part did give me the hint I needed. The procedure seems to be to right click on the script file and select 'properties'. From there you can change "opens with" to wperl instead of just perl.

      Thanks for the suggestion!

        Oh yeah, that makes sense. I forgot that at the GUI level windows relies on file associations based on file extensions, and probably ignores the shebang line entirely.
Re: Perl/Tk on Windows 7
by kcott (Bishop) on Feb 06, 2012 at 22:08 UTC

    While I don't have Windows 7, this looks like the same behaviour as Windows XP.

    If you use the commandline (something like C:\> perl tk_scriptname) you won't get the extra window. You'll find this useful for debugging when developing your Tk applications because that extra window will disappear when the Tk app finishes and you won't get any feedback if something goes awry.

    When everything works the way you want, the only way I know of to run (via double-click) without that extra window is to compile your script. I use pp for this under Windows XP. The -gui option gets rid of the extra window; there's also an -icon option if you want a custom icon for your Tk app. Note: the executable created can be quite large: a script of a few kilobytes becomes an exe of a few megabytes.

    -- Ken

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://952156]
Approved by kcott
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-10-16 21:37 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (70 votes). Check out past polls.