I am very new to wxpython. I am building a small application and most
of the parts are almost done. But I am stuck up with one issue. I
would appreciate any help as it is very urgent.
I am reading a file and storing the files content in a list (file
contains 50-100 lines). When the user clicks "RUN" button I will take
one element at a time, process it and display it on TextCtrl field and
continue same for all the elements in the list.
But wxpython is not displaying the results in TextCtrl on the fly. It
waits for the even function to complete and shows only the last
processed element from list.
I would really appreciate any help and a working code for the same.
Your problem is most likely that you are not returning control to the event loop from the button event handler while you are processing the items from the file. If control doesn't return to the main loop then no more events can be processed during that time, including the text ctrl's paint event handler. In other words, your "long running task" is blocking the processing of events and so the UI is going to appear to be frozen while your task is running. There are several ways to work around this, but the most important concept in each of them is that you need to provide a way to not block the return to the event loop for long enough for the user to notice it. These pages in the wiki may help:
I am very new to wxpython. I am building a small application and most
of the parts are almost done. But I am stuck up with one issue. I
would appreciate any help as it is very urgent.
I am reading a file and storing the files content in a list (file
contains 50-100 lines). When the user clicks "RUN" button I will take
one element at a time, process it and display it on TextCtrl field and
continue same for all the elements in the list.
But wxpython is not displaying the results in TextCtrl on the fly. It
waits for the even function to complete and shows only the last
processed element from list.
On Wed, Dec 22, 2010 at 6:46 PM, Robin Dunn robin@alldunn.com wrote:
On 12/21/10 5:14 PM, Sham A wrote:
Hi all,
I am very new to wxpython. I am building a small application and most
of the parts are almost done. But I am stuck up with one issue. I
would appreciate any help as it is very urgent.
I am reading a file and storing the files content in a list (file
contains 50-100 lines). When the user clicks “RUN” button I will take
one element at a time, process it and display it on TextCtrl field and
continue same for all the elements in the list.
But wxpython is not displaying the results in TextCtrl on the fly. It
waits for the even function to complete and shows only the last
processed element from list.
Your problem is most likely that you are not returning control to the event loop from the button event handler while you are processing the items from the file. If control doesn’t return to the main loop then no more events can be processed during that time, including the text ctrl’s paint event handler. In other words, your “long running task” is blocking the processing of events and so the UI is going to appear to be frozen while your task is running. There are several ways to work around this, but the most important concept in each of them is that you need to provide a way to not block the return to the event loop for long enough for the user to notice it. These pages in the wiki may help: