medium to large programmatic updates to a wxTextCtrl Topic is solved

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.
Post Reply
User avatar
bsenftner
Experienced Solver
Experienced Solver
Posts: 74
Joined: Thu May 26, 2016 9:19 pm

medium to large programmatic updates to a wxTextCtrl

Post by bsenftner » Thu Jan 09, 2020 4:24 pm

I have a multi-line wxTextCtrl that sits in a wxPanel next to a wxGlCanvas. The wxGlCanvas updates at a 30 fps rate, and the wxTextCtrl displays information messages generated by the wxGlCanvas code as it runs.

One if the things that can be sent to the wxTextCtrl are text files (scripts) associated with the logic driving the wxGlCanvas. This is done with a programmatic loop adding each line of the text file to the wxTextCtrl. The end result is a brief pause in the application and then the wxTextCtrl appears with the complete text added. (These text scripts can be long.)

Wanting to avoid that pause as a text file is added to the wxTextCtrl, I have tried adding a wxYield() after the addition of every 5 lines of text to get the wxTextCtrl to appear with the text visually growing as it is added. Is this the best method, using wxYield(), when programmatically adding text to a wxTextCtrl to both avoid application pause and to see the text addition incrementally?

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

Re: medium to large programmatic updates to a wxTextCtrl

Post by doublemax » Thu Jan 09, 2020 4:53 pm

As you can't do GUI updates from a secondary thread, there are not many other ways to do it. I probably would have done it from a timer event to avoid the wxYield, but the result is the same.
Use the source, Luke!

Post Reply