I'm trying to make my tri-state button fire events (similar to normal buttons) when
clicked. I actually changed from the code I posted here where the button was subclassed
off a wxBitmapButton to a wxPanel. I did this for two reasons:
1-I didn't like that the bitmapButton depressed when clicked(since I really want a checkbox
with three states and checkboxes don't indent when you click them)
2-When I clicked it rapidly, it appeared to alternate between two of the states (ie, go from
checked to unsure back to checked, etc)
If anyone is interested in the new code let me know.
I'm now trying to make it fire events, so here's my code that gets called when the
tri-state button is clicked. When I try and use EVT_TRI_CLICK in the parent of the
button as I would use with EVT_BUTTON, it doesn't work (the function bound with the
event is never called). I've tried all combinations of replacing the -1s in
win.Connect with id and still no go. I've also looked at the examples in /demo
and they don't seem to help either.
def click( self, event ):
self.state = (self.state + 1)%3
self.printState()
self.setStateForNextClick()
self.Refresh() #redraw to make sure button is in correct state
event.Skip()
evt = TriClick( wxEVT_TRI_CLICK, self)
wxPostEvent(self.GetParent(), evt)
del evt
wxEVT_TRI_CLICK = 6600
class TriClick( wxPyEvent ):
def __init__( self, msg="", button=None ):
wxPyEvent.__init__(self)
self.SetEventType(wxEVT_TRI_CLICK)
self.msg = msg
#self.id = wxEVT_TRI_CLICK
self.id = button.id
def EVT_TRI_CLICK(win, id, func):
win.Connect(-1, -1, wxEVT_TRI_CLICK, func)
Any wxPyEvent people out there care to impart their knowledge with me? Thanks
matt