Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

subwindwo command using event generate

7 views
Skip to first unread message

Aditya gupta

unread,
Sep 5, 2007, 1:50:51 AM9/5/07
to
Hi guys ...

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

Aric Bills

unread,
Sep 5, 2007, 2:03:04 AM9/5/07
to

$mybutton invoke

Aditya gupta

unread,
Sep 5, 2007, 2:06:59 AM9/5/07
to

My question is a event generate statement which simulates the opening
of the subwindow.

Aric Bills

unread,
Sep 5, 2007, 3:07:00 AM9/5/07
to
> 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


Aditya gupta

unread,
Sep 5, 2007, 4:18:01 AM9/5/07
to

thnx man...

Bryan Oakley

unread,
Sep 5, 2007, 6:34:16 AM9/5/07
to
Aric Bills wrote:
>>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).

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.

Aric Bills

unread,
Sep 5, 2007, 12:31:38 PM9/5/07
to
> 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>

Gerald W. Lester

unread,
Sep 5, 2007, 4:09:57 PM9/5/07
to

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|
+------------------------------------------------------------------------+

Bryan Oakley

unread,
Sep 5, 2007, 4:50:48 PM9/5/07
to
Gerald W. Lester wrote:
> Bryan Oakley wrote:
>> Aric Bills wrote:
>>>> 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).
>>
>> 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.
>
> This is true on Unix.
>
> For widgets which are implemented as native widgets on Windows it is not
> always true.
>

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

Gerald W. Lester

unread,
Sep 5, 2007, 5:33:41 PM9/5/07
to

Yes, menus.

0 new messages