updating textCtrl from a list dynamically

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.

I would really appreciate any help and a working code for the same.

Regards,
Hans

ok, first , make a sample app http://wiki.wxpython.org/MakingSampleApps

then email it to the list.

second, how are you processing and passing the lines from the file to the TextCtrl?

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

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:

  LongRunningTasks - wxPyWiki
  http://wiki.wxpython.org/Non-Blocking_Gui

···

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.

--
Robin Dunn
Software Craftsman

thanks for the reply.

i figured it out.

···

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:

    [http://wiki.wxpython.org/LongRunningTasks](http://wiki.wxpython.org/LongRunningTasks)

    [http://wiki.wxpython.org/Non-Blocking_Gui](http://wiki.wxpython.org/Non-Blocking_Gui)

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


Hans