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

refreshing a GTK widget

by melguin (Pilgrim)
on Aug 03, 2001 at 20:20 UTC ( [id://102139]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

I've been working on a recipe organizer for my wife using Perl and GTK. It's been really fun, and I've learned a lot. However, I can't figure out how to update a CList in a window. Here's my code to initially create the clist and put it in the window (this works fine):
#get the recipe list in the main windows my $recipe_clist = show_recipe_list(); ## pack everything in ## $window_main->set_contents( $recipe_clist); ## show everything in the main windows ## show_all $window_main;
Here is my subroutine to refresh it (doesn't work):
sub refresh_main_window { $recipe_clist->hide(); $recipe_clist = show_recipe_list() || die "Problem on exchange +: $!"; $recipe_clist->show_now() || die "Problem on show: $!"; }
My instinct was to hide the CList (which happens), redefine the CList, then redisplay it in the window (never happens -- thus my problem).

The error message returned from the "$recipe_clist->show_now()" line says Resource temporarily unavailable .

Any solutions or ideas for further investigation?

Replies are listed 'Best First'.
Re: refreshing a GTK widget
by Monky Python (Scribe) on Aug 03, 2001 at 22:05 UTC
    hmm... I'm not sure about the right solution for your problem, but the perl-gtk guide says:

    There are also two convenience functions that should be used when a lot of changes have to be made to the list. This is to prevent the list flickering while being repeatedly updated, which may be highly annoying to the user. So instead it is a good idea to freeze the list, do the updates to it, and finally thaw it which causes the list to be updated on the screen.

    $clist->freeze();
    $clist->thaw();

    Maybe you should try these functions instead.

    MP

Re: refreshing a GTK widget
by stefan k (Curate) on Aug 04, 2001 at 20:00 UTC
    Hi,
    as far as I can remember from the back of my head I did it using the freeze and thaw methods mentioned above then delete the wole content of the list and rebuild it from scratch when I once used a CList

    Unfortunately I'm at home right now (well, it's not _that_ bad here ;-) and don't have any code examples at hand. If you're still in trouble on monday drop me a message in CB and I will look at the code I have at work...

    Regards... Stefan

Re: refreshing a GTK widget
by stefan k (Curate) on Aug 06, 2001 at 08:19 UTC
    Hi,
    as promised on the perl-gtk mailinglist here is a piece of code that worked for me. If you still have problems you could sent me your full programm ...
    ### update messages in news ticker sub update_msg { # anti-flicker; msg is a CList... $msg->freeze(); $msg->clear(); my @Loglines = read_log_file(); # setting up the list foreach my $l (@Loglines) { my ($date,$level,$subs,$prg,$code,$text) = split /\s/,$l,6; $date = format_time($date); $text =~ s/\n.*/ [more\.\.\.]/s; $msg->append($text,$prg,$date,$level,$code); } # release $msg->thaw(); }

    Another thing that strikes me is that you use

    my $recipe_clist = show_recipe_list();
    obviously to create the CList and then later use it again:
    $recipe_clist = show_recipe_list() || die "..."
    which may well lead to confusion if you're not very tricky in show_recipe_list() itself. Sorry if I'm talking like a confused apeman this morning: it's monday and my english circuits are not under full steam yet...

    Good Luck!

    Regards... Stefan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://102139]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.