Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi,
I'm trying to build a relatively complex window with a grid of 50x17 widgets. It works fine but it takes about 6 seconds to open up on my AMD Phenom II x4 2.6GHz running Linux (this is a child window spawned by the main program window when the user presses a button).
I do realise Perl TK is an interpreted language and that therefore performance is often lower than if it was written in C or C++, but I would much appreciate it if you could have a look at the code and tell me if there is any way to optimise it so to speed up the creation of this window.

Here is the code:

sub KitEditWin { $rywin=$mw->Toplevel; $rywin->geometry("930x600"); $rywin->title('RM50 Rhythm Kit Editor'); my $ryw=$rywin->Scrolled('Frame', -scrollbars=>'e' )->pack(-side=>'top', -anchor=>'n', -fill=>'both', -expand=>1); $ryw->Label( -text=>'Bank' )->grid(-row=>0, -column=>1); $ryw->Label( -text=>'Voice 1' )->grid(-row=>0, -column=>2); $ryw->Label( -text=>'Attenuation')->grid(-row=>0, -column=>3); $ryw->Label( -text=>'Bank' )->grid(-row=>0, -column=>5); $ryw->Label( -text=>'Voice 2' )->grid(-row=>0, -column=>6); $ryw->Label( -text=>'Attenuation')->grid(-row=>0, -column=>7); $ryw->Label( -text=>'Mod' )->grid(-row=>0, -column=>9); $ryw->Label( -text=>'Bal' )->grid(-row=>0, -column=>10); $ryw->Label( -text=>'Flt' )->grid(-row=>0, -column=>11); $ryw->Label( -text=>'Pan' )->grid(-row=>0, -column=>12); $ryw->Label( -text=>'Dcy' )->grid(-row=>0, -column=>13); $ryw->Label( -text=>'Vol' )->grid(-row=>0, -column=>14); $ryw->Label( -text=>'P.b' )->grid(-row=>0, -column=>15); $ryw->Label( -text=>'Key' )->grid(-row=>0, -column=>16); for (my $a=1; $a<=49; $a++) { my $end; if ($a<=24) { $end=1; } else { $end=0; } for (my $v=0; $v<=$end; $v++) { my $aa=$a; my $vv=$v; # bank selection $ry_bank_sel[$a][$v]=$ryw->BrowseEntry(%BEntry_defaults, -variable => \$ry_bank[$a][$v], -choices => \@banks_array, -font => 'Sans 9', -width => 6, -listheight => 10, -browsecmd => sub{ RefreshVceList($aa, $vv);} )->grid(-row=>$a, -column=>1+($v*4), -padx=>4); $ry_bank_sel[$a][$v]->Subwidget("choices")->configure(%cho +ices_defaults); $ry_bank_sel[$a][$v]->Subwidget("arrow")->configure(%arrow +_defaults); # voice selection $ry_voice_sel[$a][$v]=$ryw->BrowseEntry(%BEntry_defaults, -variable => \$ry_voice[$a][$v], -choices => $voiceshash{$ry_bank[$a][$v]}, -font => 'Sans 9', -width => 12, -listheight => 10 )->grid(-row=>$a, -column=>2+($v*4), -padx=>4); $ry_voice_sel[$a][$v]->Subwidget("choices")->configure(%ch +oices_defaults); $ry_voice_sel[$a][$v]->Subwidget("arrow")->configure(%arro +w_defaults); # Attenuation $ryw->Scale(%Scale_defaults, -variable => \$ry_att[$a][$v], -to => 15, -from => 0, -tickinterval => 3, -length => 100, -command => sub{ } )->grid(-row=>$a, -column=>3+($v*4), -padx=>4); $ryw->Label(%Scale_label_defaults, -textvariable => \$ry_att[$a][$v], -width=>2 )->grid(-row=>$a, -column=>4+($v*4), -padx=>4); } # Modulation $ryw->Checkbutton( -variable => \$ry_mod[$a] )->grid(-row=>$a, -column=>9); # Balance $ryw->Checkbutton( -variable => \$ry_bal[$a] )->grid(-row=>$a, -column=>10); # Filter $ryw->Checkbutton( -variable => \$ry_flt[$a] )->grid(-row=>$a, -column=>11); # Pan $ryw->Checkbutton( -variable => \$ry_pan[$a] )->grid(-row=>$a, -column=>12); # Decay $ryw->Checkbutton( -variable => \$ry_dcy[$a] )->grid(-row=>$a, -column=>13); # Volume $ryw->Checkbutton( -variable => \$ry_vol[$a] )->grid(-row=>$a, -column=>14); # Pitch bend $ryw->Checkbutton( -variable => \$ry_pbd[$a] )->grid(-row=>$a, -column=>15); # Key off $ryw->Checkbutton( -variable => \$ry_kyo[$a] )->grid(-row=>$a, -column=>16); } }


Just to give you an idea this is how the window looks like:
http://www.linuxtech.net/files/rm_manager_ryed.png

Thanks a lot in advance for any suggestions!

In reply to Perl TK performance issue by perltux

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (10)
    As of 2015-07-07 23:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (93 votes), past polls