Re: frozen GUI!!! urgent help required!



RevX gmx at writes:
 > Oh hell!!!
 > 
 > Now I'm scared! Why did nobody tell me before? Is that common
 > with all GUI toolkits?

Pretty much (it's true of all X toolits that I know of).  And every
new GUI programmer gets bitten by it.

 > > Not unless you create a separate thread for the calculations. When the
 > > calculations finish, you should be able to interact with the GUI again.
 > 
 > The problem is: I'm no (good) thread programmer and for what I've read
 > in here it seems that Gtk+ wasn't design to be used with threads and
 > there will be much trouble ahead. Am I right?
 > And the other thing is: it was planned that the calculations stop with
 > the click of a button (it's a continuos online calculation/data processing)
 > but thus the button is not clickable under heavy system load there
 > has to be another way around. 
 >
 > Isn't there a way to shortly stop calculations (for a necessary minimum
 > of time) and let the GUI gather possible events? Could this work
 > this way somehow? Any suggestions?

Yes.   See FAQ 5.14

5.14. Why doesn't my widget (e.g. progressbar) update?
Why doesn't my widget (e.g. progressbar) update?

You are probably doing all the changes within a function without
returning control to gtk_main(). This may be the case if you do some
lengthy calculation in your code. Most drawing updates are only placed
on a queue, which is processed within gtk_main(). You can force the
drawing queue to be processed using something like:

while (g_main_iteration(FALSE));

inside you're function that changes the widget.

What the above snippet does is run all pending events and high
priority idle functions, then return immediately (the drawing is done
in a high priority idle function).

-- 
Joseph J. Pfeiffer, Jr., Ph.D.       Phone -- (505) 646-1605
Department of Computer Science       FAX   -- (505) 646-1002
New Mexico State University          http://www.cs.nmsu.edu/~pfeiffer
Southwestern NM Regional Science and Engr Fair:  http://www.nmsu.edu/~scifair



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