Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

How to change a Hlist column value randomly

by ghosh123 (Monk)
on Aug 30, 2013 at 15:35 UTC ( [id://1051655]=perlquestion: print w/replies, xml ) Need Help??

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

Hi
I have HList tree with three columns and ten rows.
After launching the gui, I want to change the value of one column
randomly (after every 2,3 or 5 secs). Maximum interval would be 5 but not more than that.

Following is my code, please help me with the last part .
The gui should get launched first. And then every 2,3 or 5 sec the value should start getting changed.
Never mind the values of the cells.

use strict; use warnings; use Tk; use Tk::HList; use Tk::ItemStyle; 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, -width => 50, -command => sub {print "AAA\n";}, )->pack(-fill => 'both',-expand =>1 ); my $name = $hl->Label(-text => "Name", -anchor => 'w',-font => $font); $hl->headerCreate(0,-itemtype => 'window',-widget => $name) ; my $DOB = $hl->Label(-text => "DOB", -anchor => 'w',-font => $font); $hl->headerCreate(1,-itemtype => 'window',-widget => $DOB); my $Address = $hl->Label(-text => "Address", -anchor => 'w',-font => +$font); $hl->headerCreate(2,-itemtype => 'window',-widget => $Address); my $style1 = $hl->ItemStyle('text', -selectforeground =>'black', -an +chor =>'nw',-background =>'green',-font => $font); my $style2 = $hl->ItemStyle('text', -selectforeground =>'black', -an +chor =>'nw',-background =>'red',-font => $font); &populate(); sub populate { my $path = 0; foreach my $entry (1 .. 10) { insertData($path,$entry); $path++; } } sub insertData { my ($path,$entry) = @_; $hl->add($path); $hl->itemCreate($path,0,-text => "thomas"); $hl->itemCreate($path,1,-text => "20-10-2000"); $hl->itemCreate($path,2,-text => "102 street" , -style => $style1); } =cut # please help me with how to change value of two cells randomly while(rand) { $hl->itemConfigure( 2, 2, -text => "202 street", -style => $style2 ); $hl->itemConfigure( 3, 2, -text => "202 street", -style => $style2 ); } =cut MainLoop;

Replies are listed 'Best First'.
Re: How to change a Hlist column value randomly
by kcott (Archbishop) on Aug 31, 2013 at 01:35 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1051655]
Approved by hdb
Front-paged by sparkyichi
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found