Button press and release simulation

Hi all,
there is a way to simulate programmatically the press and the release of a wx.Button? Expecially from the graphic point of view, in my case the trigger of a EVT_BUTTON dont care. In other words, I want "to press" the button from the program and in another point of the program to release it. Thanks for any help.

···

--
Cheers,
F. Pollastri

The short answer is that you can't. Can you explain why you want to do this?

···

On Dec 4, 2007 4:06 AM, Fabrizio Pollastri <f.pollastri@inrim.it> wrote:

Robin Dunn wrote:
> Fabrizio Pollastri wrote:
>> Hi all,
>> there is a way to simulate programmatically the press and the release
>> of a wx.Button? Expecially from the graphic point of view, in my case
>> the trigger of a EVT_BUTTON dont care. In other words, I want "to
>> press" the button from the program and in another point of the program
>> to release it. Thanks for any help.
>
> wx.Button is not meant to be used this way, but wx.ToggleButton is.
>

I try to explain it better.

One can easily simulate a user action over a wx.ToggleButton (a mouse
click over ToggleButton) from the program by setting/resetting the
ToggleButton status with SetValue method. One can do the same for almost
other widgets in a similar way.

Now there is the wx.Button that is a memoryless button, so it has no
status and no Set/GetValue methods.

When I click on a wx.Button, it becomes darker and stay darker until I
release the mouse button. This means that wx.Button has an internal
status that tell to it if it is pressed or no. If one want to simulate a
wx.Button click and release, he need to control this internal status in
some way. This is what I am looking for.

Robin Dunn wrote:

Fabrizio Pollastri wrote:

Robin Dunn wrote:

Fabrizio Pollastri wrote:

Hi all,
there is a way to simulate programmatically the press and the release of a wx.Button? Expecially from the graphic point of view, in my case the trigger of a EVT_BUTTON dont care. In other words, I want "to press" the button from the program and in another point of the program to release it. Thanks for any help.

wx.Button is not meant to be used this way, but wx.ToggleButton is.

I try to explain it better.

One can easily simulate a user action over a wx.ToggleButton (a mouse click over ToggleButton) from the program by setting/resetting the ToggleButton status with SetValue method. One can do the same for almost other widgets in a similar way.

Now there is the wx.Button that is a memoryless button, so it has no status and no Set/GetValue methods.

When I click on a wx.Button, it becomes darker and stay darker until I release the mouse button. This means that wx.Button has an internal status that tell to it if it is pressed or no. If one want to simulate a wx.Button click and release, he need to control this internal status in some way. This is what I am looking for.

There is no way to do that with native button widgets. If you use the generics in wx.lib.buttons then that is a different story since all the code is out in the open. :wink:

Ok. I can't do it natively. So, may I ask for a wx.Button widget improvement? A rationale for my request follows.

Let consider each class of control widgets of wxWindows as a visual representation of an application variable of a certain type, i.e. wx.ToggleButton for a boolean, wx.TextCtrl for a string, wx.Choice for an index (integer) of the choice, etc.
The variable can be changed from the human user side by keyboard/mouse interaction with the widget and from the application side by assigning it a new value, may be after some computation, i.e. using the SetValue method.

This good (I think) general rule is broken by the wx.Button that has no Get/SetValue.

Why to control wx.Button status from the application? For the same reasons that one want to have full control over all the other control widgets. For example, imagine an application running in an "auto mode" where its GUI shows all the application activity.

Another concrete example of this need. I developed a python module that connects automatically values displayed by widgets with application variables by matching their names (http://avc.inrim.it). I have already developed it for gtk, qt3, qt4 and tk. Now I am porting it to wxWindows that was missing to my collection :). In my test/demo programs each supported widget displays an associated application variable that is cyclically changed, but when it comes to the wx.Button ... no way to do it.

My ideal wx.Button has a status variable with Get/SetValue methods, the variable is normally False and comes True only when the wx.Button is kept clicked.

Thanks for your attention.

···

--
Cheers,
F. Pollastri

Robin Dunn wrote:
> Fabrizio Pollastri wrote:
>> Robin Dunn wrote:
>>> Fabrizio Pollastri wrote:
>>>> Hi all,
>>>> there is a way to simulate programmatically the press and the
>>>> release of a wx.Button? Expecially from the graphic point of view,
>>>> in my case the trigger of a EVT_BUTTON dont care. In other words, I
>>>> want "to press" the button from the program and in another point of
>>>> the program to release it. Thanks for any help.
>>>
>>> wx.Button is not meant to be used this way, but wx.ToggleButton is.
>>>
>>
>> I try to explain it better.
>>
>> One can easily simulate a user action over a wx.ToggleButton (a mouse
>> click over ToggleButton) from the program by setting/resetting the
>> ToggleButton status with SetValue method. One can do the same for
>> almost other widgets in a similar way.
>>
>> Now there is the wx.Button that is a memoryless button, so it has no
>> status and no Set/GetValue methods.
>>
>> When I click on a wx.Button, it becomes darker and stay darker until I
>> release the mouse button. This means that wx.Button has an internal
>> status that tell to it if it is pressed or no. If one want to simulate
>> a wx.Button click and release, he need to control this internal status
>> in some way. This is what I am looking for.
>
> There is no way to do that with native button widgets. If you use the
> generics in wx.lib.buttons then that is a different story since all the
> code is out in the open. :wink:
>

Ok. I can't do it natively. So, may I ask for a wx.Button widget
improvement? A rationale for my request follows.

Let consider each class of control widgets of wxWindows as a visual
representation of an application variable of a certain type, i.e.
wx.ToggleButton for a boolean, wx.TextCtrl for a string, wx.Choice for
an index (integer) of the choice, etc.
The variable can be changed from the human user side by keyboard/mouse
interaction with the widget and from the application side by assigning
it a new value, may be after some computation, i.e. using the SetValue
method.

This good (I think) general rule is broken by the wx.Button that has no
Get/SetValue.

Buttons don't hold values. The concept doesn't even make sense -
toggle buttons do, because they hold a state, but a button is a
stateless action interface.

Why to control wx.Button status from the application? For the same
reasons that one want to have full control over all the other control
widgets. For example, imagine an application running in an "auto mode"
where its GUI shows all the application activity.

You can't really do this from wx, but you can do it using native tools
and it doesn't require trying to manhandle value semantics onto
buttons.

Another concrete example of this need. I developed a python module that
connects automatically values displayed by widgets with application
variables by matching their names (http://avc.inrim.it). I have already
developed it for gtk, qt3, qt4 and tk. Now I am porting it to wxWindows
that was missing to my collection :). In my test/demo programs each
supported widget displays an associated application variable that is
cyclically changed, but when it comes to the wx.Button ... no way to do it.

That's because buttons don't bind to values, they bind to actions. You
want a different type of control.

My ideal wx.Button has a status variable with Get/SetValue methods, the
variable is normally False and comes True only when the wx.Button is
kept clicked.

"clicked" is not a status, it is an event.

···

On Dec 6, 2007 5:48 AM, Fabrizio Pollastri <f.pollastri@inrim.it> wrote: