Am I missing something or can I only create the event for turning off
the toggle?
Thanks,
Hello Ben,
could you provide a small runnable sample program
of your problem?
I suspect, the IsChecked applies only for Menuitems and
Checkbox events.
--
Franz Steinhaeusler
See the sample attached. What I really would like to happen is to toggle
the button by sending an event to it...
Maybe I should be creating a mouse click on the button instead ?
Maybe I should just check the actual value of the button after an event
is received (which seems redundant because I have to set it directly
sometimes anyway).
But since a user button click toggles the event.IsChecked() value I
figured that I should be able to set it somewhere.
(even though _core.py does not mention this functionality for a toggle.)
Franz Steinhäusler wrote:
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wxPython-user...@lists.wxwidgets.org
>For additional commands, e-mail: wxPython-...@lists.wxwidgets.org
>
>
>
>
>
>
>Thanks Franz,
>
>See the sample attached. What I really would like to happen is to toggle
>the button by sending an event to it...
>Maybe I should be creating a mouse click on the button instead ?
>Maybe I should just check the actual value of the button after an event
>is received (which seems redundant because I have to set it directly
>sometimes anyway).
>
>But since a user button click toggles the event.IsChecked() value I
>figured that I should be able to set it somewhere.
>(even though _core.py does not mention this functionality for a toggle.)
>
>Franz Steinhäusler wrote:
>
Hello Ben,
I hope, I understood you right.
The problem is, that the IsChecked always returns false, if the toggle
button is changed with "Change value w/ Event"?
What if you use the SetInt and GetInt?
def OnToggle(self, event):
self.txtValue.SetValue(str(self.toggleButton.GetValue()))
self.txtChecked.SetValue(str(event.GetInt() == 1)) #changed
event.Skip()
def OnBtnValue(self, event):
self.toggleButton.SetValue(1-self.toggleButton.GetValue())
self.txtValue.SetValue(str(self.toggleButton.GetValue()))
self.txtChecked.SetValue('no event')
event.Skip()
def OnBtnEvent(self, event):
self.toggleButton.SetValue(1-self.toggleButton.GetValue())
self.txtValue.SetValue(str(self.toggleButton.GetValue()))
self.toggleEvent =
wx.CommandEvent(wx.wxEVT_COMMAND_TOGGLEBUTTON_CLICKED,
self.toggleButton.GetId())
self.toggleEvent.SetEventObject(self.toggleButton)
self.toggleEvent.SetInt(self.toggleButton.GetValue()) #changed
self.toggleButton.GetEventHandler().ProcessEvent(self.toggleEvent)
#self.txtChecked.SetValue(str(self.toggleEvent.IsChecked()))
#changed
self.txtChecked.SetValue(str(self.toggleEvent.GetInt() == 1))
#changed
event.Skip()
I tried it and it work for toggling button by mouse click and for the
button "change value".
BTW: nice example.
--
Franz Steinhaeusler
Franz Steinhäusler wrote:
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wxPython-user...@lists.wxwidgets.org
>For additional commands, e-mail: wxPython-...@lists.wxwidgets.org
>
>
>
>
GetInt() and IsChecked() return the same - and SetInt() sets the checked
/ IsChecked - who woulda thunk it ...
Brilliant - simple solutions are my favorite,
many thanks