[wxPython] Stock Button

Hum .. First a quick hello from France (It's my first post :).

I have a small question. I have to build some toolbar. So I lanch my
gimp .. draw some _nice_ icons .. and save all this in a big xpm
file. Now I want to build buttons from this xpm. but I can't find the
way to build a button from a piece of the xpm . (I usually do that in
C/Gtk .. and a bit new to wx_pyton)

Is that clear ? (My english is a bit awfull .. you know )

Thanks

Bye Bye Jérôme

···

--
---------------------------------------------------------------------
LinuX Tricks & Tips by SoiF http://www.linux-france.org/article/ltt/
Mp3 Server BoX (Mp3SB) http://www.mp3sb.org/
---------------------------------------------------------------------

I think wxBitmapButton is what you want.
I generally run the wxPythonDemo (a symbolic link to
.../python1.5/site-packages/wxPython/demo/demo.py) and look at the
controls there. Click on controls and then wxButton and it will give a
demonstration of common buttons and also the sample code.

Brendan Simon.

SoiF at Home wrote:

···

Hum .. First a quick hello from France (It's my first post :).

I have a small question. I have to build some toolbar. So I lanch my
gimp .. draw some _nice_ icons .. and save all this in a big xpm
file. Now I want to build buttons from this xpm. but I can't find the
way to build a button from a piece of the xpm . (I usually do that in
C/Gtk .. and a bit new to wx_pyton)

Is that clear ? (My english is a bit awfull .. you know )

Thanks

Bye Bye Jérôme

--
---------------------------------------------------------------------
LinuX Tricks & Tips by SoiF http://www.linux-france.org/article/ltt/
Mp3 Server BoX (Mp3SB) http://www.mp3sb.org/
---------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

I have a small question. I have to build some toolbar. So I lanch my
gimp .. draw some _nice_ icons .. and save all this in a big xpm
file. Now I want to build buttons from this xpm. but I can't find the
way to build a button from a piece of the xpm . (I usually do that in
C/Gtk .. and a bit new to wx_pyton)

Nomally separate image files would be used, but I think it is possible to do
what you want. You can load your big XMP into a wxImage, and use
image.GetSubImage to extract part of it, and then convert to a wxBitmap with
subimage.ConvertToBitmap.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

Thanks .. that what I'm looking for :))
but I have a small pb
img = wxImage('stock.xpm',wxBITMAP_TYPE_XPM)

return me a error saying that xpm isn't supported (I try w/ other
format png ) ("No image handler for type 9 defined") .

but it work in the demo code

So I use this :
xpm = wxBitmap('stock.xpm', wxBITMAP_TYPE_XPM)
img = wxImageFromBitmap(xpm)

while i<7 :
      temp = img.GetSub.....

....

That works but it's a bit awfull

A ++ Jérôme

···

On Mon, Sep 11, 2000 at 07:02:41PM -0700, Robin Dunn wrote:

I have a small question. I have to build some toolbar. So I lanch my
gimp .. draw some _nice_ icons .. and save all this in a big xpm
file. Now I want to build buttons from this xpm. but I can't find the
way to build a button from a piece of the xpm . (I usually do that in
C/Gtk .. and a bit new to wx_pyton)

Nomally separate image files would be used, but I think it is possible to do
what you want. You can load your big XMP into a wxImage, and use
image.GetSubImage to extract part of it, and then convert to a wxBitmap with
subimage.ConvertToBitmap.

--
---------------------------------------------------------------------
LinuX Tricks & Tips by SoiF http://www.linux-france.org/article/ltt/
Mp3 Server BoX (Mp3SB) http://www.mp3sb.org/
[Portishead] - [Toy Box] [01:37/05:43] [ 28%] [100]
---------------------------------------------------------------------

Thanks .. that what I'm looking for :))
but I have a small pb
img = wxImage('stock.xpm',wxBITMAP_TYPE_XPM)

return me a error saying that xpm isn't supported

I'm not sure why there is not an image handler for XPM. I suppose they
thought that XMPs would only be used for bitmaps.

(I try w/ other
format png ) ("No image handler for type 9 defined") .

You can get around this by calling wxInitAllImageHandlers() during program
initialization.

but it work in the demo code

So I use this :
xpm = wxBitmap('stock.xpm', wxBITMAP_TYPE_XPM)
img = wxImageFromBitmap(xpm)

while i<7 :
      temp = img.GetSub.....

That works but it's a bit awfull

I just noticed that wxBitmap has GetSubBitmap() so you can do the same thing
without having to convert to and from wxImage.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

Thanks .. that what I'm looking for :))
but I have a small pb
img = wxImage('stock.xpm',wxBITMAP_TYPE_XPM)

return me a error saying that xpm isn't supported

I'm not sure why there is not an image handler for XPM. I suppose they
thought that XMPs would only be used for bitmaps.

(I try w/ other
format png ) ("No image handler for type 9 defined") .

You can get around this by calling wxInitAllImageHandlers() during program
initialization.

Hum .. it doesn't change anything ..
img = wxImage('stock.xpm',wxBITMAP_TYPE_XPM)

always give me the same result .
"No image handler for type XX defined" even when I use a jpeg / png
.. or what you want .. I really can't find why .. or even call the
InitAllImageHandlers()

I just noticed that wxBitmap has GetSubBitmap() so you can do the same thing
without having to convert to and from wxImage.

And I don't get this on my wxPython package .. :frowning:

···

On Tue, Sep 12, 2000 at 04:03:48PM -0700, Robin Dunn wrote:

---------------------------------------------------------------------
dpkg -l | grep wxWin
ii python-wxwin 2.1.11-2 Python binding for wxWindows, a cross-platform C++ toolkit
ii wxgtk2.1 2.1.11-2 wxWindows Cross-platform C++ GUI toolkit (GTK+ runtime)

gtk-config --version = 1.2.8
Running Debian 2.2
---------------------------------------------------------------------

---------------------------------------------------------------------
grep GetSub *.py
image.py: def GetSubImage(self, *_args, **_kwargs):
image.py: val = apply(imagec.wxImage_GetSubImage,(self,) + _args, _kwargs)
windows.py: def GetSubMenu(self, *_args, **_kwargs):
windows.py: val = apply(windowsc.wxMenuItem_GetSubMenu,(self,) + _args, _kwargs)
---------------------------------------------------------------------

A ++ Jérôme

--
---------------------------------------------------------------------
LinuX Tricks & Tips by SoiF http://www.linux-france.org/article/ltt/
Mp3 Server BoX (Mp3SB) http://www.mp3sb.org/
[Portishead] - [Over] [03:27/04:13] [ 81%] [100]
---------------------------------------------------------------------