Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

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

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;

In reply to How to change a Hlist column value randomly 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 making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found