Hi,
I'm new to wxWidgets, but equipped with experience in MS VC++. For a software dealing with a camera input and some data processing, I'd like to add a GUI in wx. The demands are rather low; some slider bars and selection boxes / toggle switches are just fine. My plan is to just write a "parental class" that accesses all the important data from my main program and changes it according to what's being done in the GUI.
The question is, especially for displaying parameters, how to start properly. One thing I could do is, as the image acquisition of the camera sets the overall speed of the program, to update the display after each cycle explictely. But: In MS VC, this could also be handled by something like
BEGIN_EVENTSINK_MAP(Dialog, CDialogEx)
ON_EVENT(Dialog, ID, 1, Function, ReturnValueOfFunction)
END_EVENTSINK_MAP()
where the ``Function`` handles the printing. Is there any advice you can give to me about it?
Another question is about threading: I can either start the wx app as my main thread and launch the actual application as a thread. Or, I start, as I'm doing it now, the main application and include a thread (using C++ STL threads) for the wx GUI. Is the one or the other preferential?
Last, I'd like to know whether there is an example for a threading application like the one outlined here. So far, I found this one http://docs.wxwidgets.org/trunk/page_sa ... les_thread
Thanks for ideas!
Advice on creating GUI with wxWidgets Topic is solved
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: Advice on creating GUI with wxWidgets
wxWidgets static event tables are actually modeled after this design, and mostly works the same, but none of this actually has anything to do with threading.Clemens09 wrote:BEGIN_EVENTSINK_MAP(Dialog, CDialogEx)
ON_EVENT(Dialog, ID, 1, Function, ReturnValueOfFunction)
END_EVENTSINK_MAP()
Yes, this is actually pretty explicit. It's required for you to let wxWidgets use the main thread for it's event loop, and you absolutely must not call any GUI-related methods from any secondary thread (with some small exceptions for thread-safe methods like adding pending events, etc).Clemens09 wrote:Another question is about threading: I can either start the wx app as my main thread and launch the actual application as a thread. Or, I start, as I'm doing it now, the main application and include a thread (using C++ STL threads) for the wx GUI. Is the one or the other preferential?
Besides the "thread" sample, both the "net" and "socket" samples contain examples of using secondary threads for blocking network/socket operations, including passing events back to the main thread to handle GUI updates.Clemens09 wrote:Last, I'd like to know whether there is an example for a threading application like the one outlined here.
The wiki also has some additional examples of inter-thread communication that might be helpful:
https://wiki.wxwidgets.org/Inter-Thread ... munication