wx.Button - vertical alignment of bitmap and text ?

Is it possible to place the text label below the bitmap label in a wx.Button (or wx.BitmapButton) ? Thanks.

Tim Grove

Is this what you mean ? See the attached demo app.

Ray Pasco

Bitmaped_Button.py (4.57 KB)

···

On Mon, Dec 13, 2010 at 10:08 AM, Timothy W. Grove tim_grove@sil.org wrote:

Is it possible to place the text label below the bitmap label in a wx.Button (or wx.BitmapButton) ? Thanks.

Tim Grove

In 2.9 you should be able to do it by passing wx.TOP for the 2nd parameter to SetBitmap. I've never tried it however so I'm not sure if it is supported on all platforms.

···

On 12/13/10 7:08 AM, Timothy W. Grove wrote:

Is it possible to place the text label below the bitmap label in a
wx.Button (or wx.BitmapButton) ? Thanks.

--
Robin Dunn
Software Craftsman

Sorry, my attempts with 2.9 (python 2.7 on Windows 7) have failed, using the code:

btn.SetBitmapLabel(bitmap, wx.TOP )

Or should it be entered as some keyword argument?? Anyway, the resulting error shows as follows:

  File "C:\Python27\lib\site-packages\wx-2.9.1-msw\wx\_controls.py", line 121, in SetBitmapLabel
return _controls_.Button_SetBitmapLabel(*args, **kwargs)
TypeError: Button_SetBitmapLabel() takes at most 2 arguments (3 given)

Best regards,
Tim Grove

···

On 13/12/2010 6:11 PM, Robin Dunn wrote:

On 12/13/10 7:08 AM, Timothy W. Grove wrote:

Is it possible to place the text label below the bitmap label in a
wx.Button (or wx.BitmapButton) ? Thanks.

In 2.9 you should be able to do it by passing wx.TOP for the 2nd parameter to SetBitmap. I've never tried it however so I'm not sure if it is supported on all platforms.

Try SetBitmap. SetBitmapLabel has a slightly different purpose.

     // show the image in the button in addition to the label: this method is
     // supported on all (major) platforms
     void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT);
     wxBitmap GetBitmap() const;
     %property(Bitmap, GetBitmap, SetBitmap);

     // Methods for setting individual images for different states: normal,
     // selected (meaning pushed or pressed), focused (meaning normal state for
     // a focused button), disabled or hover (a.k.a. hot or current).
     //
     // Remember that SetBitmap() itself must be called before any other
     // SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym
     // for it anyhow) and that all bitmaps passed to these functions should be
     // of the same size.
     void SetBitmapLabel(const wxBitmap& bitmap);
     void SetBitmapPressed(const wxBitmap& bitmap);
     void SetBitmapDisabled(const wxBitmap& bitmap);
     void SetBitmapCurrent(const wxBitmap& bitmap);
     void SetBitmapFocus(const wxBitmap& bitmap);

I just noticed that there is also this method to just change the position:

     // set the image position relative to the text, i.e. wxLEFT means that the
     // image is to the left of the text (this is the default)
     void SetBitmapPosition(wxDirection dir);

···

On 12/13/10 12:09 PM, Timothy W. Grove wrote:

On 13/12/2010 6:11 PM, Robin Dunn wrote:

On 12/13/10 7:08 AM, Timothy W. Grove wrote:

Is it possible to place the text label below the bitmap label in a
wx.Button (or wx.BitmapButton) ? Thanks.

In 2.9 you should be able to do it by passing wx.TOP for the 2nd
parameter to SetBitmap. I've never tried it however so I'm not sure if
it is supported on all platforms.

Sorry, my attempts with 2.9 (python 2.7 on Windows 7) have failed, using
the code:

btn.SetBitmapLabel(bitmap, wx.TOP )

Or should it be entered as some keyword argument?? Anyway, the resulting
error shows as follows:

File "C:\Python27\lib\site-packages\wx-2.9.1-msw\wx\_controls.py", line
121, in SetBitmapLabel
return _controls_.Button_SetBitmapLabel(*args, **kwargs)
TypeError: Button_SetBitmapLabel() takes at most 2 arguments (3 given)

--
Robin Dunn
Software Craftsman

btn.SetBitmap(bitmap, wx.TOP)

Thanks. My mistake was using .SetBitmapLabel().

···

On 14/12/2010 9:23 AM, Bo�tjan Mejak wrote:

btn.SetBitmap(bitmap, wx.TOP)

Thanks Robin. This was what I was looking for.

Best regards,
Tim Grove

···

On 13/12/2010 9:16 PM, Robin Dunn wrote:

On 12/13/10 12:09 PM, Timothy W. Grove wrote:

On 13/12/2010 6:11 PM, Robin Dunn wrote:

On 12/13/10 7:08 AM, Timothy W. Grove wrote:

Is it possible to place the text label below the bitmap label in a
wx.Button (or wx.BitmapButton) ? Thanks.

In 2.9 you should be able to do it by passing wx.TOP for the 2nd
parameter to SetBitmap. I've never tried it however so I'm not sure if
it is supported on all platforms.

Sorry, my attempts with 2.9 (python 2.7 on Windows 7) have failed, using
the code:

btn.SetBitmapLabel(bitmap, wx.TOP )

Or should it be entered as some keyword argument?? Anyway, the resulting
error shows as follows:

File "C:\Python27\lib\site-packages\wx-2.9.1-msw\wx\_controls.py", line
121, in SetBitmapLabel
return _controls_.Button_SetBitmapLabel(*args, **kwargs)
TypeError: Button_SetBitmapLabel() takes at most 2 arguments (3 given)

Try SetBitmap. SetBitmapLabel has a slightly different purpose.

    // show the image in the button in addition to the label: this method is
    // supported on all (major) platforms
    void SetBitmap(const wxBitmap& bitmap, wxDirection dir = wxLEFT);
    wxBitmap GetBitmap() const;
    %property(Bitmap, GetBitmap, SetBitmap);

    // Methods for setting individual images for different states: normal,
    // selected (meaning pushed or pressed), focused (meaning normal state for
    // a focused button), disabled or hover (a.k.a. hot or current).
    //
    // Remember that SetBitmap() itself must be called before any other
    // SetBitmapXXX() methods (except for SetBitmapLabel() which is a synonym
    // for it anyhow) and that all bitmaps passed to these functions should be
    // of the same size.
    void SetBitmapLabel(const wxBitmap& bitmap);
    void SetBitmapPressed(const wxBitmap& bitmap);
    void SetBitmapDisabled(const wxBitmap& bitmap);
    void SetBitmapCurrent(const wxBitmap& bitmap);
    void SetBitmapFocus(const wxBitmap& bitmap);

I just noticed that there is also this method to just change the position:

    // set the image position relative to the text, i.e. wxLEFT means that the
    // image is to the left of the text (this is the default)
    void SetBitmapPosition(wxDirection dir);

      Is it possible to place the text label

below the bitmap label in a wx.Button (or wx.BitmapButton) ?
Thanks.

      Tim Grove

Is this what you mean ? See the attached demo app.

Not quite what I was looking for, but thanks, your code taught me a

few other things!!! With wxPython 2.9 the wx.Button class allows
for both a bitmap and text label, and I was just asking how to align
these vertically as well as horizontally; see other posts for the
answer if you are interested. The days of wx.BitmapButton are
numbered…

Best regards,

Tim Grove
···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en

Not quite what I was looking for, but thanks, your code taught me a few
other things!!!

That's why I like good demo apps.

With wxPython 2.9 the wx.Button class allows for both a
bitmap and text label, and I was just asking how to align these
vertically as well as horizontally; see other posts for the answer if
you are interested. The days of wx.BitmapButton are numbered...

Not really. What if you want your caption text to be *within* the
bitmap ?

Besides, manipulating bitmaps with dc's is a powerful graphics
manipulation capability. But, you don't seem to have a need for
this... yet.

Ray

···

On Dec 14, 7:01 am, "Timothy W. Grove" <tim_gr...@sil.org> wrote:

On 13/12/2010 6:09 PM, Ray Pasco wrote: