Change a button's bitmap?

I'd like to change a button's bitmap each time the user clicks on it
(between an up arrow and a down arrow). I can't seem to find anything
in the wx.BitmapButton docs for this and my call to SetBitmap() barfs
(I was guessing/hoping that SetBitmap existed).

Anyone ever do this?

Any suggested work arounds? Do I have to make 2 buttons and detach and
reattach them?

Could we add this for 2.5? :slight_smile: I'm surprised it can't be done, but
maybe I'm missing it, or thinking in the wrong terms for wx....

路路路

--
Chuck
http://ChuckEsterbrook.com

I'd like to change a button's bitmap each time the user clicks on it
(between an up arrow and a down arrow). I can't seem to find anything
in the wx.BitmapButton docs for this and my call to SetBitmap() barfs
(I was guessing/hoping that SetBitmap existed).

Anyone ever do this?

Any suggested work arounds? Do I have to make 2 buttons and detach and
reattach them?

Could we add this for 2.5? :slight_smile: I'm surprised it can't be done, but
maybe I'm missing it, or thinking in the wrong terms for wx....

Hello, you should take a look at the various wxBitmapButton.SetBitmap*
methods, that set the bitmaps for each state. I think that what you are
looking for is SetBitmapSelected.

HTH,
Alberto

Another interesting misunderstanding. :slight_smile:

I passed on trying SetBitmapSelected because my up/down button doesn't
favor one or the other as being selected (and therefore "depressed" as
the docs indicate).

I *completely* skipped over SetBitmapLabel() without even noticing that
its argument was a bitmap. Why? Because "in my universe" a label is
text like "new" or "delete", not an image. I think it was that way in
my old gui lib (NeXTstep AppKit).

Ah! The real solution just came in from Kevin Altis:
        button.SetBitmapLabel(bmp)
        if wx.wxPlatform!="__WXMSW__":
            button.SetBitmapDisabled(bmp)
            button.SetBitmapFocus(bmp)
            button.SetBitmapSelected(bmp)

Works as expected.

So in the summary, the constructor allows you to pass one bitmap for all
the states, but no corresponding method does the same. Perhaps the
above can be added as a method? The name "SetBitmap()" would make sense
and does not yet exist.

路路路

On Thursday 20 March 2003 12:09 am, Alberto Griggio wrote:

> I'd like to change a button's bitmap each time the user clicks on
> it (between an up arrow and a down arrow). I can't seem to find
> anything in the wx.BitmapButton docs for this and my call to
> SetBitmap() barfs (I was guessing/hoping that SetBitmap existed).
>
> Anyone ever do this?
>
> Any suggested work arounds? Do I have to make 2 buttons and detach
> and reattach them?
>
> Could we add this for 2.5? :slight_smile: I'm surprised it can't be done,
> but maybe I'm missing it, or thinking in the wrong terms for wx....

Hello, you should take a look at the various
wxBitmapButton.SetBitmap* methods, that set the bitmaps for each
state. I think that what you are looking for is SetBitmapSelected.

--
Chuck
http://ChuckEsterbrook.com