Re: Update progress bar without returning to main loop?



Bob Caryl wrote:

I would suggest that you connect a callback slot to the idle loop that will advance the progress bar. This will preclude a separate thread to do it... If that is not satisfactory, create a timer and connect a callback slot to that, having it update the progress bar periodically. Again, no thread.

Perhaps, but doesn't this also imply executing the update "in the background"? If I wanted to do that, I wouldn't object that much to threads, either - although what you suggest probably is simpler in terms of not having to worry about the overheads, and also syncing/shared data issues. In any case, parallel execution is precisely what I do not want. In principle, I want the application to "lock up" while it's doing the job discussed here - with the small exception that I want some indication in the UI that it hasn't died completely on the poor user waiting for it.

Anyhow, I didn't mean to work with this now. More tests tomorrow.


- Toralf

Bob Caryl /-------Original Message-------/ /*From:*/ Toralf Lund <mailto:toralf procaptura com>
/*Date:*/ 09/26/05 14:59:44
/*To:*/ Paul Davis <mailto:pjdavis engineering uiowa edu>
/*Cc:*/ GTK-- Mailing List <mailto:gtkmm-list gnome org>
/*Subject:*/ Re: Update progress bar without returning to main loop?
Paul Davis wrote: > Threads are easy enough.
>
> Oh, and I forgot to attach the tar file.
>
> Its not hard at all.
Threads are not that hard to program, but they still represent a major
complexity "behind the scenes". One that shouldn't be introduced just
like that, IMO, and, if the toolkit requires me to do it just to achieve
a *simple* GUI update, then I really think there is something
fundamentally wrong with its design.  But I'm thinking there must be
another way...
>
> Toralf Lund wrote:
>
>> Paul Davis wrote:
>>
>>> No time to explain. I'm running late.
>>>
>>> Here it is.  Use threads.  Email questions.
>>
>>
>>
>> It's a very simple app, the complexity of threads has no place in it.
>> Especially if it's just to make the GUI behave. In fact, introducing
>> threads just for this seems very wrong for any program...
>>
>>>
>>> Good luck.
>>>
>>> Toralf Lund wrote:
>>>
>>>> I have what I believe is a classic issue with progress bars, but I
>>>> have never found a good solution in the docs or via a web search:
>>>>
>>>> I'm trying to indicate progress of a signal handler that takes a
>>>> *long* time via a Gtk::ProgressBar and multiple calls (as the work
>>>> progresses) using the set_fraction() method. The problem is that
>>>> these calls have no real effect, since the actual GUI update isn't
>>>> done until after the application returns to the main loop (i.e.
>>>> when the handler is done and the progress has reached 100%). The
>>>> only way I've found to ensure it's redrawn as the work progresses,
>>>> is to flush events using something like:
>>>>
>>>> while(Gtk::Main::events_pending())
>>>>   Gtk::Main::iteration(false);
>>>>
>>>> But this has some nasty side effects. In particular, it means that
>>>> user input like button clicks, text field updates also handled,
>>>> which is not what I want; I need the window to be unresponsive
>>>> while the above mentioned callback is being executed.
>>>>
>>>> Is there an alternative?
>>>>
>>>> - Toralf
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> gtkmm-list mailing list
>>>> gtkmm-list gnome org <mailto:gtkmm-list gnome org>
>>>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>>>
>>>
>>>
>>>
>>>
>>
>
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org <mailto:gtkmm-list gnome org>
http://mail.gnome.org/mailman/listinfo/gtkmm-list

	
	

------------------------------------------------------------------------

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]