Hi,
to my understanding there is a
self._pressed = state
missing in PlateButton.SetState (wx 2.8.11) to make toggle buttons ork correctly. What do you think?
Christian
Hi,
to my understanding there is a
self._pressed = state
missing in PlateButton.SetState (wx 2.8.11) to make toggle buttons ork correctly. What do you think?
Christian
Hi,
Hi,
to my understanding there is a
self._pressed = state
missing in PlateButton.SetState (wx 2.8.11) to make toggle buttons ork
correctly. What do you think?
This is a little vague as to what issue your having but I am not
seeing any issue with how the toggle style of the button works.
Need to create the button with the PB_STYLE_TOGGLE style flag. See
attached sample.
If your experiencing some other issue please make a minimal sample to
show the problem.
Cody
toggleplate.py (561 Bytes)
On Sun, May 15, 2011 at 6:32 AM, Christian K. <ckkart@hoc.net> wrote:
Here you go. This sample implements a group of radio toggle buttons. Try toggling some buttons and you will see what I am talking about. Setting the button state in the code seems to work at first but actually the PlateButton._pressed attribute is never changed.
import wx
import wx.lib.platebtn as platebtn
class Toolbar(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
toggle = platebtn.PB_STYLE_TOGGLE
for i in range(10):
btn = platebtn.PlateButton(self, -1, label='btn%02d'%i,
style=toggle, name='btn%02d'%i)
sizer.Add(btn, 0)
self.SetSizer(sizer)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle)
def OnToggle(self, evt):
self.SetEvtHandlerEnabled(False)
btns = ['btn%02d'%q for q in range(10)]
btn = evt.GetEventObject()
btns.remove(btn.GetName())
if btn.IsPressed():
for b in btns:
wx.FindWindowByName(b).SetState(False)
self.SetEvtHandlerEnabled(True)
if __name__ == '__main__':
app = wx.PySimpleApp(0)
f = wx.Frame(None)
p = Toolbar(f)
f.Show()
app.MainLoop()
Regards, Chrisitian
Am 15.05.11 16:07, schrieb Cody Precord:
Hi,
On Sun, May 15, 2011 at 6:32 AM, Christian K.<ckkart@hoc.net> wrote:
Hi,
to my understanding there is a
self._pressed = state
missing in PlateButton.SetState (wx 2.8.11) to make toggle buttons ork
correctly. What do you think?If your experiencing some other issue please make a minimal sample to
show the problem.
Hi,
Here you go. This sample implements a group of radio toggle buttons. Try
toggling some buttons and you will see what I am talking about. Setting the
button state in the code seems to work at first but actually the
PlateButton._pressed attribute is never changed.
<snip>
def OnToggle(self, evt):
self.SetEvtHandlerEnabled(False)
btns = ['btn%02d'%q for q in range(10)]
btn = evt.GetEventObject()
btns.remove(btn.GetName())
if btn.IsPressed():
for b in btns:
wx.FindWindowByName(b).SetState(False)
PlateButton.SetState does not take a boolean argument. It takes a
PLATE_* state indicator value. Though this does work by accident since
the two (normal, pressed) states are currently equal to 0 and 1
respectively.
doc: editra.org
The SetState method was intended for internal use only and to just as
a helper method to update the visual aspect of the control. I have
renamed it and ToggleState with a leading underscore to properly
indicate this now.
Cody
On Sun, May 15, 2011 at 2:04 PM, Christian K. <ckkart@hoc.net> wrote:
Am 15.05.11 16:07, schrieb Cody Precord:
Hi,
Here you go. This sample implements a group of radio toggle buttons. Try
toggling some buttons and you will see what I am talking about. Setting the
button state in the code seems to work at first but actually the
PlateButton._pressed attribute is never changed.<snip>
def OnToggle(self, evt):
self.SetEvtHandlerEnabled(False)
btns = ['btn%02d'%q for q in range(10)]
btn = evt.GetEventObject()
btns.remove(btn.GetName())
if btn.IsPressed():
for b in btns:
wx.FindWindowByName(b).SetState(False)PlateButton.SetState does not take a boolean argument. It takes a
PLATE_* state indicator value. Though this does work by accident since
the two (normal, pressed) states are currently equal to 0 and 1
respectively.
I know, I was lazy here.
The SetState method was intended for internal use only and to just as
a helper method to update the visual aspect of the control. I have
renamed it and ToggleState with a leading underscore to properly
indicate this now.
So how would I then change the toggle state? The solution I proposed works very well, btw.
Christian
Am 17.05.11 03:42, schrieb Cody Precord:
On Sun, May 15, 2011 at 2:04 PM, Christian K.<ckkart@hoc.net> wrote:
Am 15.05.11 16:07, schrieb Cody Precord:
Hi,
On Tue, May 17, 2011 at 12:20 AM, Christian K. <ckkart@hoc.net> wrote:
Am 17.05.11 03:42, schrieb Cody Precord:
The SetState method was intended for internal use only and to just as
a helper method to update the visual aspect of the control. I have
renamed it and ToggleState with a leading underscore to properly
indicate this now.So how would I then change the toggle state? The solution I proposed works
very well, btw.
The solution you proposed breaks the ability to quickly click on the
button repetitively.
Programmaticly setting the state of the button is currently not
supported. If you want to work around it and use your solution then
you can create a subclass and override the method.
Cody
Thanks for clarifying, Cody. Nevertheless, I need to remark that I would consider the implementation as incomplete. Any plans to solve this?
Regards, Christian
Am 17.05.11 15:13, schrieb Cody Precord:
Hi,
On Tue, May 17, 2011 at 12:20 AM, Christian K.<ckkart@hoc.net> wrote:
Am 17.05.11 03:42, schrieb Cody Precord:
The SetState method was intended for internal use only and to just as
a helper method to update the visual aspect of the control. I have
renamed it and ToggleState with a leading underscore to properly
indicate this now.So how would I then change the toggle state? The solution I proposed works
very well, btw.The solution you proposed breaks the ability to quickly click on the
button repetitively.Programmaticly setting the state of the button is currently not
supported. If you want to work around it and use your solution then
you can create a subclass and override the method.
Hi,
On Wed, May 18, 2011 at 11:06 AM, Christian K. <ckkart@hoc.net> wrote:
Am 17.05.11 15:13, schrieb Cody Precord:
Thanks for clarifying, Cody. Nevertheless, I need to remark that I would
consider the implementation as incomplete. Any plans to solve this?
Not currently, the toggle mode was added as a patch from someone and
was never part of the initial design nor purpose of this control.
I would however, except a patch that adds the functionality if the
patch doesn't break any of the existing behavior for the normal use
case.
Cody