I'm trying to generate some events in Tkinter but it doesn't seem to be working 
the way I expected. Here's an example of what I'm trying to do...
 
def click():
  print 'click'
 
from Tkinter import *
top=Tk()
b=Button(top, text='Hit me', command=click)
 
b.event_generate('<Button-1>', x=0, y=0)
b.event_generate('<ButtonRelease-1>', x=0, y=0)
 
The appearance of the button changes after the <Button-1> event (to depressed), 
and again after the <ButtonRelease-1> event (to normal again), but the 
associated button command (the click function) is not called. If I bind a 
function for the event to the button using the bind method, it gets called, but 
I really need the associated command to get called too.
 
Also, I tried doing this with a Pmw.ScrolledListBox with an associated 
dblclickcommand, so I tried to generate <Double-Button-1> and 
<Double-ButtonRelease-1> events, but to my surprise, I received the following 
error message for both cases:
 
_tkinter.TclError: Double or Triple modifier not allowed
 
These problems are getting in the way of my attempt to automate GUI testing 
with Tk. Am I missing something?
 
(Ok, I really don't need the first case, because I can simple call the button's 
invoke method. But in the second case, the associated action is only invoked 
via the double click action.)
 
Allen B. Taylor
MDA
9445 Airport Road
Brampton, ON  L6S 4J3
905-790-2800 ext. 4350
allen.tay...@mdacorporation.com
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to