[Tkinter-discuss] Button

Michael O'Donnell michael.odonnell at uam.es
Thu May 19 00:28:24 CEST 2011


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.milliken at 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.odonnell at 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 at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>


More information about the Tkinter-discuss mailing list