Per/Tk - text widget does not get updated

Discussion in 'Perl Misc' started by MoshiachNow, Aug 9, 2006.

  1. MoshiachNow

    MoshiachNow Guest

    HI,

    I define the window :
    my $mw = new MainWindow; # Main Window
    my $frm_name = $mw -> Frame() -> pack();
    my $lab1 = $frm_name -> Label(-text=>"Enter the remote hostname or
    IP:") -> pack();
    my $ent1 = $frm_name -> Entry() -> pack();
    my $lab2 = $frm_name -> Label(-text=>"Enter the number of iterations to
    run [5]:") -> pack();
    my $ent2 = $frm_name -> Entry() -> pack();
    my $but = $mw -> Button(-text=>"Start nettest", -command =>\&start) ->
    pack(); #Text Area
    $txt = $mw -> Text(-width=>70, -height=>20) -> pack();

    MainLoop;
    ###################################
    Then in subroutine "start" I write tesxt:


    $txt -> delete("1.0",'end');
    $txt -> insert('end',"Remote Hostname:\t$REMOTE_HOST\n");
    $txt -> insert('end',"Remote IP address:\t$REMADDR\n");
    $txt -> insert('end',"My IP address:\t\t$MYADDRESS\n\n");
    ###################################
    Then later in the same sub I create a file :

    open(FILE,">$FILE1");
    print FILE ' ' x (100 * (1024 * 1024));
    close FILE;
    chmod 0777 => $FILE1;

    The problem is that the text widget is not updated till the file
    creation is over (couple of minutes).Printing to STDOUT at the same
    time completes immediately.
    Setting "$|" to "1" did not change much,as I expected to ...

    Appreciate any input.

    Thanks
     
    MoshiachNow, Aug 9, 2006
    #1
    1. Advertising

  2. MoshiachNow

    MoshiachNow Guest

    Actualy,I now have found out that the text widget will not get updated
    at all till I "return" from the "start" subroitine...
    Does it mean that while the subroitine is running,I will not be able to
    update the text widget ?
     
    MoshiachNow, Aug 9, 2006
    #2
    1. Advertising

  3. MoshiachNow

    Dave Guest

    "MoshiachNow" <> wrote in message
    news:...
    > HI,
    >
    > I define the window :
    > my $mw = new MainWindow; # Main Window
    > my $frm_name = $mw -> Frame() -> pack();
    > my $lab1 = $frm_name -> Label(-text=>"Enter the remote hostname or
    > IP:") -> pack();
    > my $ent1 = $frm_name -> Entry() -> pack();
    > my $lab2 = $frm_name -> Label(-text=>"Enter the number of iterations to
    > run [5]:") -> pack();
    > my $ent2 = $frm_name -> Entry() -> pack();
    > my $but = $mw -> Button(-text=>"Start nettest", -command =>\&start) ->
    > pack(); #Text Area
    > $txt = $mw -> Text(-width=>70, -height=>20) -> pack();
    >
    > MainLoop;
    > ###################################
    > Then in subroutine "start" I write tesxt:
    >
    >
    > $txt -> delete("1.0",'end');
    > $txt -> insert('end',"Remote Hostname:\t$REMOTE_HOST\n");
    > $txt -> insert('end',"Remote IP address:\t$REMADDR\n");
    > $txt -> insert('end',"My IP address:\t\t$MYADDRESS\n\n");
    > ###################################
    > Then later in the same sub I create a file :
    >
    > open(FILE,">$FILE1");
    > print FILE ' ' x (100 * (1024 * 1024));
    > close FILE;
    > chmod 0777 => $FILE1;
    >
    > The problem is that the text widget is not updated till the file
    > creation is over (couple of minutes).Printing to STDOUT at the same
    > time completes immediately.
    > Setting "$|" to "1" did not change much,as I expected to ...
    >
    > Appreciate any input.
    >
    > Thanks
    >


    try adding a $mw->update; after your set of insert commands, I suspect that
    the text is added to the widget but that the window is not being repainted
    to reflect this.
     
    Dave, Aug 9, 2006
    #3
  4. MoshiachNow

    MoshiachNow Guest

    Thanks,this was just it.
     
    MoshiachNow, Aug 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guadala Harry
    Replies:
    4
    Views:
    426
    =?Utf-8?B?QnJhZCBSb2JlcnRz?=
    Aug 24, 2004
  2. Clara
    Replies:
    4
    Views:
    368
    Clara
    Apr 20, 2005
  3. Alex9968
    Replies:
    0
    Views:
    591
    Alex9968
    Mar 19, 2008
  4. Alex9968
    Replies:
    0
    Views:
    1,564
    Alex9968
    Mar 19, 2008
  5. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    423
    Dmitry Korolyov
    Sep 22, 2003
Loading...

Share This Page