Bitmap alignment using genBitmapTextButton

Hello,

Is there a way to control the position of the bitmap and the label in a genBitmapTextButton object ?

Attached is an picture that shows my problem (genBitmapButton.jpg) and how I'd like it to be (howItShouldBe.jpg).
Here is the code:

genBitmapButton.jpg

howItShouldBe.jpg

···

------------------------
import wx.lib.buttons as buttons
...
    self.button1 = buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " Short label ", size = (130, -1))
    self.button2 = buttons.ThemedGenBitmapTextButton(self.panel, -1, None, " A much longer label ", size = (130, -1))
    self.allFltDieButton1.SetBitmapLabel(self.images['red_cross'])

...
-------------------------

I'd like the bitmap to be always aligned to the left and the label to be centered in the remaining space, and still have the width of each button to be the same (in this case 130).

Running on Windows XP, Python 2.6.3, wxPython 2.8.10.1

Thanks.

Raphael

You can override the DrawLabel method in a derived class and draw it however you want.

···

On 11/30/09 2:32 PM, Raphael Mayoraz wrote:

Hello,

Is there a way to control the position of the bitmap and the label in a
genBitmapTextButton object ?

Attached is an picture that shows my problem (genBitmapButton.jpg) and
how I'd like it to be (howItShouldBe.jpg).

--
Robin Dunn
Software Craftsman

Robin Dunn wrote:

  

Hello,

Is there a way to control the position of the bitmap and the label in a
genBitmapTextButton object ?

Attached is an picture that shows my problem (genBitmapButton.jpg) and
how I'd like it to be (howItShouldBe.jpg).
    
You can override the DrawLabel method in a derived class and draw it however you want.

Thanks Robin, got it.

In the same kind of problem, is there a way, or where could I go, to change/add something in wx.ListCtrl so that the background color of a cell, and not the entire row, could be changed ? We have SetItemBackgroundColour, but the idea would be a kind of SetSubItemBackgroundColour(item, subitem, colour).

I'm actually using ObjectListView (great !), but it is derived from ListCtrl, so has the same limitation.

Raphael

···

On 11/30/09 2:32 PM, Raphael Mayoraz wrote:

Hi,

2009/12/9 Raphael Mayoraz:

Robin Dunn wrote:

Hello,

Is there a way to control the position of the bitmap and the label in a
genBitmapTextButton object ?

Attached is an picture that shows my problem (genBitmapButton.jpg) and
how I'd like it to be (howItShouldBe.jpg).

You can override the DrawLabel method in a derived class and draw it
however you want.

Thanks Robin, got it.

In the same kind of problem, is there a way, or where could I go, to
change/add something in wx.ListCtrl so that the background color of a
cell, and not the entire row, could be changed ? We have
SetItemBackgroundColour, but the idea would be a kind of
SetSubItemBackgroundColour(item, subitem, colour).

I'm actually using ObjectListView (great !), but it is derived from
ListCtrl, so has the same limitation.

You can't with the standard wx.ListCtrl.

As an alternative consider UltimateListCtrl (in SVN only at the
moment, under 3rd Party/AGW).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 11/30/09 2:32 PM, Raphael Mayoraz wrote:

Andrea Gavana wrote:

Hi,

2009/12/9 Raphael Mayoraz:
  

Robin Dunn wrote:
    

Hello,

Is there a way to control the position of the bitmap and the label in a
genBitmapTextButton object ?

Attached is an picture that shows my problem (genBitmapButton.jpg) and
how I'd like it to be (howItShouldBe.jpg).

You can override the DrawLabel method in a derived class and draw it
however you want.

Thanks Robin, got it.

In the same kind of problem, is there a way, or where could I go, to
change/add something in wx.ListCtrl so that the background color of a
cell, and not the entire row, could be changed ? We have
SetItemBackgroundColour, but the idea would be a kind of
SetSubItemBackgroundColour(item, subitem, colour).

I'm actually using ObjectListView (great !), but it is derived from
ListCtrl, so has the same limitation.
    
You can't with the standard wx.ListCtrl.

As an alternative consider UltimateListCtrl (in SVN only at the
moment, under 3rd Party/AGW).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/

Thanks, got ULC through your website (infinity77), working on it. Is there any kind of documentation ? For example, when populating the list, in your "report demo", you have:

index = self.list.InsertImageStringItem(sys.maxint, data[0], self.idx1)

and I just wonder why I should call a method that seems to have to do with inserting an image for returning a number that seems to be only the row index in the list.

Also, should those question about non-official wxPython classes be passed through the wxPython email list ? If not, where ?

Many thanks,

Raphael

···

On 11/30/09 2:32 PM, Raphael Mayoraz wrote:

Hi,

2009/12/10 Raphael Mayoraz:

Andrea Gavana wrote:

You can't with the standard wx.ListCtrl.

As an alternative consider UltimateListCtrl (in SVN only at the
moment, under 3rd Party/AGW).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/

Thanks, got ULC through your website (infinity77),

Please use the version in SVN, is much more up to date and bugfixed:

http://svn.wxwidgets.org/svn/wx/wxPython/3rdParty/AGW/

working on it. Is
there any kind of documentation ?

Just released today, shiny and bright:

http://xoomer.virgilio.it/infinity77/AGW_Docs/index.html

For example, when populating the list,
in your "report demo", you have:

index = self.list.InsertImageStringItem(sys.maxint, data[0], self.idx1)

and I just wonder why I should call a method that seems to have to do
with inserting an image for returning a number that seems to be only the
row index in the list.

This is how InsertImageStringItem, InsertStringItem and InsertItem
work on wx.ListCtrl. The method inserts a string item (the label is
specified in data[0]) with an image (image index = self.idx1), and
returns the row at which the item has been inserted. In this case, a
new row is appended to UltimateListCtrl as we are passing sys.maxint
as an index where to insert the new item.

Also, should those question about non-official wxPython classes be
passed through the wxPython email list ? If not, where ?

You can send your question here, as AGW is now part of wxPython.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/