disabling mouse clicks to ToggleButton

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

disabling mouse clicks to ToggleButton

Roland King
Very new to wxPython so still tons to learn. 

I have a row of ToggleButtons all but one of which do exactly that, toggle something on and off. The last one however is really an indicator of state, I used a ToggleButton for consist look with the rest but I only want to set it programatically and don't want it to be clickable. That of itself may be a horrible misuse. 

If I disable it then it doesn't receive events, however it also greys out .. not what I wanted. Is there a way to turn of the ToggleButtons response to mouse clicks so it just ignores them entirely and I can use it like an indicator in this way? I could receive the click event, let the button toggle and then toggle it back again but that's pretty horrible and it'll probably flash and look nasty. 

If not - is there something which looks pretty much exactly like a ToggleButton (so it looks like the other ones) but is better for a pure indicator? 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: disabling mouse clicks to ToggleButton

Dietmar Schwertberger-2
On 5/28/2018 1:29 PM, [hidden email] wrote:
If I disable it then it doesn't receive events, however it also greys out .. not what I wanted. Is there a way to turn of the ToggleButtons response to mouse clicks so it just ignores them entirely and I can use it like an indicator in this way? I could receive the click event, let the button toggle and then toggle it back again but that's pretty horrible and it'll probably flash and look nasty. 

Before an EVT_TOGGLEBUTTON is created and sent, a mouse event is sent.

Try registering a handler for mouse click events and then in the handler just do nothing. That should avoid the events to be processed further.

https://wxpython.org/Phoenix/docs/html/wx.MouseEvent.html

E.g. just to ignore a left mouse click:

        self.button_1.Bind(wx.EVT_LEFT_DOWN, self.ignore)
    def ignore(self, event):
        pass

You may just register a handler for EVT_MOUSE_EVENTS to receive all kinds of mouse events and call event.Skip() except when event.ButtonDown() is True. Maybe you need to check some other methods/properties as well, e.g. ButtonDClick.


You can find more information about event handling here: https://wxpython.org/Phoenix/docs/html/events_overview.html


If you attach a small sample program, usually you will get quicker answers...

Regards,

Dietmar


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: disabling mouse clicks to ToggleButton

Roland King
Thanks for that - I’d gotten fairly close to it myself last night but had subclassed and now I see the event system in wxWidgets is pretty dynamic so I don’t need to. Yes you do need to deal with double click too, but that was easily done. 

Sure there will be more questions soon but at least I got started, now to hook this rudimentary UI up to the code which actually generates the events. 


On 30 May 2018, at 05:52, Dietmar Schwertberger <[hidden email]> wrote:

On 5/28/2018 1:29 PM, [hidden email] wrote:
If I disable it then it doesn't receive events, however it also greys out .. not what I wanted. Is there a way to turn of the ToggleButtons response to mouse clicks so it just ignores them entirely and I can use it like an indicator in this way? I could receive the click event, let the button toggle and then toggle it back again but that's pretty horrible and it'll probably flash and look nasty. 

Before an EVT_TOGGLEBUTTON is created and sent, a mouse event is sent.

Try registering a handler for mouse click events and then in the handler just do nothing. That should avoid the events to be processed further.

https://wxpython.org/Phoenix/docs/html/wx.MouseEvent.html

E.g. just to ignore a left mouse click:

        self.button_1.Bind(wx.EVT_LEFT_DOWN, self.ignore)
    def ignore(self, event):
        pass

You may just register a handler for EVT_MOUSE_EVENTS to receive all kinds of mouse events and call event.Skip() except when event.ButtonDown() is True. Maybe you need to check some other methods/properties as well, e.g. ButtonDClick.


You can find more information about event handling here: https://wxpython.org/Phoenix/docs/html/events_overview.html


If you attach a small sample program, usually you will get quicker answers...

Regards,

Dietmar



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.