tkinker:Simulating GUI Button Press
Tim Daneliuk
tundra at tundraware.com
Wed Jan 8 20:20:07 EST 2003
Jeff Epler wrote:
> On Thu, Jan 09, 2003 at 12:40:07AM +0000, Tim Daneliuk wrote:
>
>>Is there a way to programmatically generate the event that acts like
>>CmdBtn or DirBtn have been pressed? I am familiar with keyboard events,
>>but cannot seem to figure out how to activate a Menubutton element as if
>>it has been clicked by the user...
>
>
> These classes have an 'invoke' method:
> Button Checkbutton Menu Radiobutton
>
> For whatever reason, Menubutton doesn't (and if you read the Tcl
> procedures called by the builtin bindings, they operate by calling
> internal Tk procedures, and depend on the type of OS where your program
> is running, in the name of "native feel"). However, the tk_popup method
> (on menu widgets) can be used to post a menu at the desired position.
> It does not handle mouse/keyboard grab entirely like clicking a
> menubutton, though.
>
> Jeff
>
I was afraid of that (I had discovered much of what you say before posting
here). I guess its back to doing pixel arithmetic to get the menus placed
properly.
The only reason I even need to do this is because Tkinter does not seem
to automatically create Accelerator keys for these buttons on Win32 like it
does on X. If I could solve *that* problem, I wouldn't have to fiddle with
synthesizing button pushes. Sigh...
Thanks for your help.
--
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com
More information about the Python-list
mailing list