[wxPython-users] Button press and release simulation

Robin Dunn robin at alldunn.com
Wed Dec 5 15:16:29 PST 2007


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. ;-)

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list