Closed andrewarrow closed 8 years ago
Hi, I have tested on Linux and it works well without Refresh
and Update
, but I think it is implementation-dependent: calling GUI functions in secondary threads is not recommanded (http://docs.wxwidgets.org/trunk/overview_thread.html). Briefly, try sending events to the GUI thread. However I am not sure whether it is caused by wxGo's bug. I will have a test on OS X using C++.
By the way, calling Update
will cause an XWindowSystem error in Linux.
oh! I see, there's a better way to tell it to update on the main thread. thank u, i'll try that!
well I tried a bunch of stuff, the cloest I got that compiles fine and I thought would work was:
b := wx.NewPaintEvent()
f.GetEventHandler().QueueEvent(b)
but still same problem. Gauge is not repainted until I manually resize window with mouse. Maybe I need to use wxThreadHelper? But I couldn't get that to compile. Could I trouble you for a new file in examples/src/
called something like gauge_with_thread/main.go
?
SetValue
itself is a "GUI function", which means we should call it in the GUI thread, and the window will be automatically updated without any additional operation.
I have created an example named threadevent
, it uses wxThreadEvent
to communicate between goroutines.
works great! Thanks again. closing.
Here's some sample code that puts a Gauge on the screen and make the progress bar increase 1 value every second. On MacOS I don't see the progress bar update unless I drag the window around or resize it manually with the mouse. Any idea how to force the whole thing to repaint? I'm calling f.Refresh() and f.Update()