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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.