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 04, 2001 at 02: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 06, 2001 at 12: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

Re: refreshing a GTK widget
by stefan k (Curate) on Aug 05, 2001 at 00: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