Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm not really seeing any major delays on the Solaris SPARC system I am using here (the only thing that has Perl and Tk on it). Quite frankly, you are not doing that much, so why it is taking so long is a mystery to me. I'm not not sure if you are running it with "-w" but if so then is the Tk module generating a lot of warnings? I don't know if it was written with warnings in mind or not and I believe the "-w" will force warnings on everywhere. You might want to try running the script without warnings or just switch to "use warnings" which will affect just your code. Also, you shouldn't need a "require Tk". If it only works with that then you may want to look into why that's the case.

There is one Tk trick I have heard of that could help as well. The trick is to hide the window, create the rest of the GUI, and then display it. The changes for this are shown below.

#.... my $main = MainWindow->new(); # Add this line to hide the window $main->withdraw; $main->title("Button Window"); $main->configure(-background=>'#c0c0c0'); $main->optionAdd('*BorderWidth' => 1); my $bottom = $main->Frame(-background=>'#c0c0c0')->pack(-expand=>0, -f +ill=>'both'); my $sub_button=$bottom->Button(-width=>40, -background=>"#c0c0c0", -fg +=>'black', -text=>'CLICK ME', -font => ['Courier', 10], -command=>\&c +lick); $sub_button->pack(-side => "bottom", -anchor => "s", -expand => "n", - +fill => "none"); # Add these two lines to display the window after you have finished cr +eating the GUI $main->deiconify; $main->raise; MainLoop(); #...

Elda Taluta; Sarks Sark; Ark Arks


In reply to Re: Why so slow when using Perl/Tk? by Argel
in thread Why so slow when using Perl/Tk? by RAS230

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-19 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found