CLI+GUI
Eric Brunel
eric.brunel at pragmadev.com
Mon Aug 11 10:12:16 EDT 2003
Michele Simionato wrote:
> Eric Brunel <eric.brunel at pragmadev.com> wrote in message news:<bh7hs3$dtk$1 at news-reader3.wanadoo.fr>...
>
>>I don't know if this is the problem, because you didn't say exactly when the
>>script hangs, but Tkinter apparently has problems when calls to it are made
>>from a thread different from the one into which it was initialized. I'd use
>>an Event between Tkinter's thread and Cmd's thread, checking it regularly
>>with Tkinter's after method.
>>
>>HTH
>
>
> It hangs immediately when I start the script by clicking on its icon.
> What do you mean with "I'd use an Event" ? I thought an Event object
> is automatically generated when I click on a widget, or press a key,
> or something.
I wasn't thinking about this Event class. I thought about the one described here:
http://www.python.org/doc/current/lib/event-objects.html
It allows very basic communications between threads.
> Are you saying can I can programmatically generate an
> Event, faking a real mouse/key press? How so? That is something I
> always wanted to know ;)
Generating a *Tk* event is quite easy: just use the event_generate method that
exists on all widgets. I used it to generate simple events, often user-defined
one. The syntax is simple:
myWidget.event_generate("<<MyEvent>>")
If you have a binding for "<<MyEvent>>" for myWidget, you can trigger it this way.
I never tried to pass event detail, though.
HTH
--
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list