while in wxwidgets

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
hirnfrei
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jan 11, 2018 3:51 pm

while in wxwidgets

Postby hirnfrei » Thu Jan 11, 2018 4:00 pm

Hi,

I try to use wxWidgets to show a simple game to show the results of a neuronal network. The game image is generated with opencv and shown with wxWisgets.

If I click the start button, the neuronal network should run in a while function. But the result only shown if while is finished.

What I have to do to show all changes from the neural networt?

User avatar
doublemax
Moderator
Moderator
Posts: 11584
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: while in wxwidgets

Postby doublemax » Thu Jan 11, 2018 4:12 pm

The quick-and-dirty solution is to call ::wxYield() inside the while loop once in a while so that the event loop gets the opportunity to do its job and e.g. redraw controls.

A better solution is to move the calculations into a worker thread (-> wxThread). But you're not allowed to make GUI updates from inside a worker thread. For that you can either send an event from the worker thread to the main thread if you want something updated, or you can use a timer with a resonable frequency (e.g. 50-100 ms) and just update the GUI regularly.
Use the source, Luke!

hirnfrei
In need of some credit
In need of some credit
Posts: 2
Joined: Thu Jan 11, 2018 3:51 pm

Re: while in wxwidgets

Postby hirnfrei » Thu Jan 11, 2018 9:27 pm

Many thanx! It work fine with wxYield()!


Return to “C++ Development”

Who is online

Users browsing this forum: Google [Bot] and 19 guests