3State CheckBox and XRC how can I do (2.5.2.8u)

Is It possible to specified a 3State Checkbox with XRC resources?
Since its'nt possible to specified style directly in the resource file edited by
Xrced, I'have tried to create my own subclass to add style to control but that don't work.

class XRC3StateCheckBoxCtrl(wx.CheckBox):
    """
    This allows us to use XRC subclassing for CheckBox.
    """
    _firstEventType = wx.EVT_SIZE

    def __init__(self):
        pre = wx.PreCheckBox()
  self.PostCreate(pre)
  self.Bind(self._firstEventType, self.OnCreate)

    def OnCreate(self, evt):
        self.SetWindowStyle(wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.Refresh()
        self.Unbind(self._firstEventType)

What's the solution?

Mignon Laurent wrote:

Is It possible to specified a 3State Checkbox with XRC resources?
Since its'nt possible to specified style directly in the resource file edited by
Xrced, I'have tried to create my own subclass to add style to control but that don't work.

class XRC3StateCheckBoxCtrl(wx.CheckBox):
    """
    This allows us to use XRC subclassing for CheckBox.
    """
    _firstEventType = wx.EVT_SIZE

    def __init__(self):
        pre = wx.PreCheckBox()
  self.PostCreate(pre)
  self.Bind(self._firstEventType, self.OnCreate)

    def OnCreate(self, evt):
        self.SetWindowStyle(wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.Refresh()
        self.Unbind(self._firstEventType)

What's the solution?

I think the only way to do it is to set the styles when the widget is created, because it has to create the native widget differently... I'll add support to XRC and XRCed for the new styles.

···

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

Since there's currently no support for the extra styles, you can write your
own xml handler and register it with xrc. Read the docs on custom xml
handlers, it's actually quite easy (and you can copy a skeleton from the
demo). This would allow you do use your subclassed version to create the
control.

  UC

- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

···

On Wednesday 01 September 2004 02:36 am, Mignon Laurent wrote:

Is It possible to specified a 3State Checkbox with XRC resources?
Since its'nt possible to specified style directly in the resource file
edited by Xrced, I'have tried to create my own subclass to add style to
control but that don't work.

class XRC3StateCheckBoxCtrl(wx.CheckBox):
    """
    This allows us to use XRC subclassing for CheckBox.
    """
    _firstEventType = wx.EVT_SIZE

    def __init__(self):
        pre = wx.PreCheckBox()
  self.PostCreate(pre)
  self.Bind(self._firstEventType, self.OnCreate)

    def OnCreate(self, evt):
        self.SetWindowStyle(wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.Refresh()
        self.Unbind(self._firstEventType)

What's the solution?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Is It possible to specified a 3State Checkbox with XRC resources?
> Since its'nt possible to specified style directly in the resource file
> edited by Xrced, I'have tried to create my own subclass to add style to
> control but that don't work.
>
> class XRC3StateCheckBoxCtrl(wx.CheckBox):
> """
> This allows us to use XRC subclassing for CheckBox.
> """
> _firstEventType = wx.EVT_SIZE
>
> def __init__(self):
> pre = wx.PreCheckBox()
> self.PostCreate(pre)
> self.Bind(self._firstEventType, self.OnCreate)
>
>
> def OnCreate(self, evt):
> self.SetWindowStyle(wx.CHK_3STATE|wx.CHK_ALLOW_3RD_STATE_FOR_USER)
> self.Refresh()
> self.Unbind(self._firstEventType)
>
> What's the solution?

Since there's currently no support for the extra styles, you can write your
own xml handler and register it with xrc. Read the docs on custom xml
handlers, it's actually quite easy (and you can copy a skeleton from the
demo). This would allow you do use your subclassed version to create the
control.

        UC

Note also that if you Insert() instead of Append()ing handlers, you
can override the built in ones. Sadly, you can't inherit from the
built in handlers, but I did this to add support for wx.CLIP_CHILDREN
to wxNotebook. The handlers are quite simple and porting the C++ code
for the notebook handler only took a few minutes.

···

On Wed, 1 Sep 2004 11:09:12 -0700, Uwe C. Schroeder <uwe@oss4u.com> wrote:

On Wednesday 01 September 2004 02:36 am, Mignon Laurent wrote:

- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFBNhBIjqGXBvRToM4RAsxpAKCi1LBqjQWN7z8U7aZmnCqnXtJcCQCgsy+G
qh3b5W6JkxSkRRS/1V6EpDo=
=GHy+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org