Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am just including a very very simplified code which is just one perl file only. Please change the repeat frequency to test it. The gui would show better performance if the repeat frequency is increased to 1sec , currently it is 1ms only.
My requirement is :

1. what is the reason for the gui to get hung when we are trying to change some 100 rows on it every 1 ms . Can not perl tk handle this ? is this a limitation ?

2. is their any other mechanism to make it work, provided i will repeat it every 1 ms and would try to change 100 rows of it randomly.

use Tk; use Tk::HList; use Time::HiRes qw/usleep/; my $mw = MainWindow->new(); my $hlistframe = $mw->Frame()->pack( -fill => 'both', -expand => 1 ); my $font = "{helvetica} -12 bold"; my $hl = $hlistframe->Scrolled( 'HList', -scrollbars => 'ose', -columns => 7, -header => 1, #-height => 10, -width => 50, -command => sub { print "test\n"; }, )->pack( -fill => 'both', -expand => 1 ); my $num = $hl->Label( -text => "Number", -anchor => 'w', -font => $fon +t ); $hl->headerCreate( 0, -itemtype => 'window', -widget => $num ); my $name = $hl->Label( -text => "ID", -anchor => 'w', -font => $font ) +; $hl->headerCreate( 1, -itemtype => 'window', -widget => $name ); my $DOB = $hl->Label( -text => "Job", -anchor => 'w', -font => $font ) +; $hl->headerCreate( 2, -itemtype => 'window', -widget => $DOB ); my $Address = $hl->Label( -text => "status", -anchor => 'w', -font => +$font ); $hl->headerCreate( 3, -itemtype => 'window', -widget => $Address ); my $style1 = $hl->ItemStyle( 'text', -selectforeground => 'black', -anchor => 'nw', -background => 'green', -font => $font ); my $style2 = $hl->ItemStyle( 'text', -selectforeground => 'black', -anchor => 'nw', -background => 'red', -font => $font ); my $style3 = $hl->ItemStyle( 'text', -selectforeground => 'black', -anchor => 'nw', -background => 'blue', -font => $font ); sub populate { my $path = 0; foreach my $entry ( 1 .. 100 ) { insertData( $path, $entry ); $path++; } } &populate(); sub insertData { my ( $path, $entry ) = @_; $hl->add($path); # print "path $path \n"; $hl->itemCreate( $path, 0, -text => "$path" ); # , -style => $ +style1); $hl->itemCreate( $path, 1, -text => "someid" ); # , -style => $ +style1); $hl->itemCreate( $path, 2, -text => "test" ); #, -style => $s +tyle1); $hl->itemCreate( $path, 3, -text => "running", -style => $style1 ) +; } $mw->repeat( 1, \&changeItem ); my $flag; sub changeItem { my %flag; foreach ( 1 .. 100 ) { my $randRow = int( rand(20) ); print "randRow $randRow \n"; if ( $flag{$randRow} ) { $hl->itemConfigure( $randRow, 3, -text => "pending", -style => $style2 ); $hl->itemConfigure( $randRow, 3, -text => "waiting", -style => $style2 ); $flag{$randRow} = 0; print "if flag ", $flag{$randRow}, "\n"; } else { print "else flag 0\n"; $hl->itemConfigure( $randRow, 3, -text => "finished", -style => $style3 ); $hl->itemConfigure( $randRow, 3, -text => "aborted", -style => $style3 ); $flag{$randRow} = 1; print "else flag ", $flag{$randRow}, " \n"; } #usleep(100); #sleep 2 ; } } MainLoop;

In reply to Re^4: Perl tk gui hangs when large data thrown to it by ghosh123
in thread Perl tk gui hangs when large data thrown to it by ghosh123

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 about the Monastery: (7)
As of 2024-04-18 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found