I am trying to make my own bitmapbutton XRC class. I am using the
standard genbitmapbutton as my basis with the toggle mixin.
Now I am running into something strange. When I look at the images for
label, selected etc in the init, they are all not OK (IsOK() returns
False). However when the OnCreate code is run, the bitmap for the label
is OK but the rest is not.
So what happens between these two moments in time and what do I need to
do to make the other bitmaps OK as well?
A bit of code might be handy too, see below the text:
Paul Sijben wrote:
I am trying to make my own bitmapbutton XRC class. I am using the
standard genbitmapbutton as my basis with the toggle mixin.
Now I am running into something strange. When I look at the images for
label, selected etc in the init, they are all not OK (IsOK() returns
False). However when the OnCreate code is run, the bitmap for the label
is OK but the rest is not.
So what happens between these two moments in time and what do I need to
do to make the other bitmaps OK as well?
where:
import wx.lib.buttons as wlbuttons
class TransGenBitmapButton(wlbuttons.GenBitmapButton): #and then TransGenBitmapButton has some features to make it transparent
on winXP
A bit of code might be handy too, see below the text:
Paul Sijben wrote:
I am trying to make my own bitmapbutton XRC class. I am using the
standard genbitmapbutton as my basis with the toggle mixin.
Now I am running into something strange. When I look at the images for
label, selected etc in the init, they are all not OK (IsOK() returns
False). However when the OnCreate code is run, the bitmap for the label
is OK but the rest is not.
So what happens between these two moments in time and what do I need to
do to make the other bitmaps OK as well?
Paul
class ToggleGenBitmapButton(wlbuttons.__ToggleMixin,TransGenBitmapButton):
def __init__(self):
pre=wx.PreBitmapButton()
It's not going to work like this. You are creating a wx.BitmapButton here, but tring to mix it with the generic button classes, which are mostly unrelated and which expect to be used on a class that is derived from wx.PyControl.
Instead make your button class normally by deriving from the wx.lib.buttons classes and implementing your additional features however you need it. Then once that is working you can worry about how to load it from XRC. I suggest making a XmlResourceHandler that knows how to load the required attributes from the XRC object, and then create the button using your class. See the demo for an example of an XmlResourceHandler. If you are using XRCed to edit your XRC file then there is a way to make it aware of your handler class with a bit of plugin code.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!