Do you use mtTkinter Michael? Best package since "sliced bread" (as the saying goes) - I haven't had any issues with GUI elements and tasking since using it. It has cured ALL of my issues with tasks and Tkinter GUI's freezing and behaving weirdly since I first discovered it.
In my threads (checked my latest program), I just pass the progress bar as an argument to the thread - the argument is actually a class wrapper that "hides" the GUI progress bar from the thread program. So the thread performs the actual GUI updates directly. The class interface uses the same calls as a Queue provides - that way I can invoke the thread program from either a GUI or a command line interface - in the later case I use a Queue instance as the argument and have the command line part of the program read the data out and print it directly to the screen. I think that is all I do to get Tkinter and threads working together... Hope this makes sense :-) Peter On Thu, May 19, 2011 at 8:28 AM, Michael O'Donnell <michael.odonn...@uam.es>wrote: > yes, Threading is the other solution. > > One needs to be very careful not to call any Tkinter elements > from the child threads, as it seems this can cause freezes. > > I used threads for a while, but could not solve the odd cases > where my interface froze until the child thread finished. > > In any case, see an example at: > > > http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/ > > On Wed, May 18, 2011 at 11:14 PM, Peter Milliken > <peter.milli...@gmail.com> wrote: > > Michael offers excellent solutions. > > When the work being done is cpu intensive (and the application allows > :-)), > > I often use threading i.e. the button runs a command that starts a Python > > thread which goes off and does what needs to be done. > > If the job being performed is that intensive then you probably want GUI > > elements to show progress - in which case you can communicate to the > thread > > via pipes/queues and run another task that looks after the > "communications" > > and is responsible for updating GUI elements - such as progress bars. > > I do this sort of thing a lot in my GUI's - just depends on what you are > > doing though. But threading isn't for everyone - if you are used to > straight > > "linear" thinking in your programming then threads can take a bit of mind > > bending to get your head around - but once you have then all problems > seem > > to be solved better through using threads :-) > > > > > > On Thu, May 19, 2011 at 2:08 AM, Michael O'Donnell < > michael.odonn...@uam.es> > > wrote: > >> > >> <snip> > > > > > >> > >> if the work done by the command invoked by the button is quite cpu > >> intensive, > >> I do somethink like the following: > >> > >> <snip> > > > > _______________________________________________ > > Tkinter-discuss mailing list > > Tkinter-discuss@python.org > > http://mail.python.org/mailman/listinfo/tkinter-discuss > > > > >
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss