[Glade-users] Animation



On Wed, Oct 15, 2008 at 3:04 PM, PEYMAN ASKARI <paskari007 at yahoo.ca> wrote:
One thing I can't get my head around is how to set up a loop to run along
side the event driven nature of GUIs.

You dont ! ... when in doubt, always call "return" :D

For example, I have a simulator which simulates neurons. now I have files
which implement all the neurons, and synapses, and updates them. When the
user clicks 'next' it figures out which ones generate action potentials, and
then the drawing area changes that neurons color from black to red. Pretty
standard stuff

But if the user clicks 'Play', then the simulator goes into a loop, and
checks for action potentials continuously. The problem with this is that
control is not returned to the GUI until the loop exits, and therefore the
GUI is never updated it.

Am I going to have to make my program multithreaded, or is there a way of
having GTK call the function every 1 second for example.

g_timeout_add().

Cheers,
                       -Tristan

NOTE: in a time critical situation, you may be taking measures like:
   - implementing your time critical code in a thread
   - locking in memory on the said process.
   - telling the kernel that your time critical thread has a higher
     priority than the GUI...




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