If I instantiate a wx.Button with wx.ID_ANY, it has a label but no image.
If I instantiate a wx.BitmapButton it has an image but no label.
If I instantiate a wx.Button with a "stock" ID, like wx.ID_OK, it is
perfect; Image plus label.
What I'd like to do is create buttons with my own images and labels (i.e.
not be restricted to the "stock" ones). How do I go about this please?
Try running the wxPython demo and searching on button, you will find
lots of examples.
Gadget/Steve
···
On 14/01/2012 9:09 PM, Walter Hurry wrote:
If I instantiate a wx.Button with wx.ID_ANY, it has a label but no image.
If I instantiate a wx.BitmapButton it has an image but no label.
If I instantiate a wx.Button with a "stock" ID, like wx.ID_OK, it is
perfect; Image plus label.
What I'd like to do is create buttons with my own images and labels (i.e.
not be restricted to the "stock" ones). How do I go about this please?
1.
import the module like this:
import wx.lib.platebtn as platebtn
2.
prepare your bitmap like this:
bMap =wx.Bitmap('/your/file/goes/here.png', type=wx.BITMAP_TYPE_ANY)
3.
now create your platebutton:
platebtn.PlateButton(self*, label="My Button Label",bmp=bMap,
style=platebtn.PB_STYLE_DEFAULT)
* or whatever its parent is (e.g. a frame or a panel)
Like the previous poster says, there are tons of examples on the demo;
use them to help you get the look you want.
Note that in wxPython 2.9.3.1 you can do this with the wx.Button, check out the Button demo.
Werner
···
On 01/14/2012 10:09 PM, Walter Hurry wrote:
If I instantiate a wx.Button with wx.ID_ANY, it has a label but no image.
If I instantiate a wx.BitmapButton it has an image but no label.
If I instantiate a wx.Button with a "stock" ID, like wx.ID_OK, it is
perfect; Image plus label.
What I'd like to do is create buttons with my own images and labels (i.e.
not be restricted to the "stock" ones). How do I go about this please?
Correct. In 2.9 the various C++ button classes were reorganized such that wx.Button and wx.ToggleButton both derive from a common base class that allows either a bitmap or label or both, and wx.BitmapButton is now a very simple class derived from wx.Button that essentially just changes the default to be a bitmap instead of a label.
···
On 1/15/12 2:48 AM, werner wrote:
On 01/14/2012 10:09 PM, Walter Hurry wrote:
If I instantiate a wx.Button with wx.ID_ANY, it has a label but no image.
If I instantiate a wx.BitmapButton it has an image but no label.
If I instantiate a wx.Button with a "stock" ID, like wx.ID_OK, it is
perfect; Image plus label.
What I'd like to do is create buttons with my own images and labels (i.e.
not be restricted to the "stock" ones). How do I go about this please?
Note that in wxPython 2.9.3.1 you can do this with the wx.Button, check
out the Button demo.
Thanks for the responses. First of all, shame on me for not mentioning
the version; it's 2.8.12 here, and I'd rather wait for my distribution to
deliver 2.9 than go there myself. I'm sure it won't be long though, and
in the meantime I'll look at wx.lib.platebtn. Thanks again!
···
On Mon, 16 Jan 2012 15:20:26 -0800, Robin Dunn wrote:
On 1/15/12 2:48 AM, werner wrote:
On 01/14/2012 10:09 PM, Walter Hurry wrote:
If I instantiate a wx.Button with wx.ID_ANY, it has a label but no
image.
If I instantiate a wx.BitmapButton it has an image but no label.
If I instantiate a wx.Button with a "stock" ID, like wx.ID_OK, it is
perfect; Image plus label.
What I'd like to do is create buttons with my own images and labels
(i.e.
not be restricted to the "stock" ones). How do I go about this please?
Note that in wxPython 2.9.3.1 you can do this with the wx.Button, check
out the Button demo.
Correct. In 2.9 the various C++ button classes were reorganized such
that wx.Button and wx.ToggleButton both derive from a common base class
that allows either a bitmap or label or both, and wx.BitmapButton is now
a very simple class derived from wx.Button that essentially just changes
the default to be a bitmap instead of a label.