my aim is to make a button and attach a subwindow to it , which opens
by clicking on it .now i want to simulate this event ,using event
generate command . I want such a event generate statement ,which opens
the subwindow , attached to the button .
Thanks guys
Aditya
$mybutton invoke
My question is a event generate statement which simulates the opening
of the subwindow.
[event generate] can trigger bindings, but the -command option of a
button isn't a binding (i.e. you didn't link the code to the button by
calling the [bind] command). Instead, a button's -command can be
invoked programmatically by calling the button's command:
proc subwindow {} {
destroy .subwindow
toplevel .subwindow
set l [label .subwindow.l -text "Subwindow"]
grid $l -sticky nsew
}
set mybutton [button .button -text "Button" -command subwindow]
grid $mybutton
$mybutton invoke
thnx man...
I think that's a bit misleading. bindings are indeed what cause the
-command to be executed. It's just that the bindings are on the Button
class rather than each individual widget.
I stand corrected (and enlightened--thanks).
So then I guess the answer the OP was looking for would go something
like this:
event generate $mybutton <Enter>
event generate $mybutton <Button-1>
event generate $mybutton <ButtonRelease-1>
This is true on Unix.
For widgets which are implemented as native widgets on Windows it is not
always true.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
Are you thinking of menu commands? I think what you say is true for
menus on Windows, but not for buttons. If I remove "Button" from the
bindtags for a button, that button no longer responds to mouse clicks.
--
Bryan Oakley
http://www.tclscripting.com
Yes, menus.