Re: Update progress bar without returning to main loop?



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. 
 
Bob Caryl
 
-------Original Message-------
 
Date: 09/26/05 14:59:44
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 mailing list


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