Forum: Poser Python Scripting


Subject: wxpython - add label to wx.BitmapButton?

Netherworks opened this issue on May 08, 2010 · 6 posts


Netherworks posted Sat, 08 May 2010 at 6:58 PM

Heyas,

I am trying to work with Poser 8/Pro 2010 wxpython.  I created a blank button .bmp that I'm using as a template for buttons in a panel.  I am wondering if there is a way to add text to the blank buttons without having to use a different graphic for each button.

I am using wx.BitmapButton to utilize the buttons but can't seem to figure out a simple way, other than making a dozen different graphics, to add text to them.

I haven't been able to find a lot of information or examples of this.  The wxpython documentation online reads worse than stereo instructions.

.


semidieu posted Tue, 11 May 2010 at 4:40 AM

I dont think it's possible (at least not easily - you will perhaps need to 'completely' rework the class).

Depending on what you do, why not using a simple button with different background colors ?


Netherworks posted Tue, 11 May 2010 at 1:18 PM

Yeah, I went with wx.lib.buttons.GenButton instead of Button (or BitmapButton) because you can customize it a bit more.  I'm a stickler for having things look halfway decent visually.   I first tried Button but it wants to use windows colors.  I set fore and background colors but there's still a border around the buttons and I prefer them in this case to be flat.

If I didn't need it to be a panel, I'd be using tkinter instead because in some ways tkinter is easier to deal with.  It's something that I wanted to be out all the time and dock.

What I made, if you're curious, is a "toolbar" (a panel with no caption) that can quickly switch camera views.

.


semidieu posted Tue, 11 May 2010 at 2:06 PM

Oh, that would be very nice :)

By the way, for the question you asked me by email, I didn't made something similar, so I don't know. From what I searched, it should behave the same way... But Mac never behave the same :)


Netherworks posted Tue, 11 May 2010 at 6:54 PM

Yeah, I haven't been able to figure out how to make the buttons on the bar reorder.  There's 12 buttons and they are horizontal on one row.  I can't make them go 3x4 and so on by changing the pane size but would be cool if I could get it to work.

I could put it out there as a freebie and leave the code exposed if you are anyone wants to fiddle with it.  However, you might shriek in terror when you see my coding style :D

I've attached an image.  It does remember it's layout and if it's docked or not (using pickle).  You can right click in an empty space to get the floating/docked menu.  I tried to make it visually fit in with the UI.

.


semidieu posted Wed, 12 May 2010 at 7:34 AM

That's really nice !

Why don't get the panel width and, depending of the size, make it two-three rows ?

Another way would be... to use a wx.listctrl, using icons ? (Dbl)-Click an item would select the camera and it does reorder automatically...