bitmaps and wxListCtrl

Hi,

I have a bitmap file and I want to show it in a wxListCtrl. How do I do it??

Thanks

Jose wrote:

Hi,

I have a bitmap file and I want to show it in a wxListCtrl. How do I do it??

See the demo for details, but in a nutshell you add the image to a wxImageList, set the image list into the list ctrl, and then when adding items to the list ctrl you can specify the index of the image in the image list to associcate with that list item.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I have a bitmap file and I want to show it in a wxListCtrl. How do I do it??

Hi,

If your image is very small (i.e fits inside the ListCtrl's height), use
InsertImageItem or InsertImageStringItem. If it doesn't (you want to put
large images), you're more in troubles. I got the same problem and asked
it here:

http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?11:mss:15995:mjlbmbmhdkmmniieiich

The solution is either to use wxGrid, either to wait the next release
where this should be fixed, or writing your own widget. I think I'll do
the latter since the Grid isn't really what I wanted.

Alex.

···

--
http://www.gnurou.org

Hi again,

I saw the demo but the examples do "import images" and images.py has the
ASCII characters of the images.

How can I add an image file (x.gif) to the wxImagelist directly. Can I see
an example of code?

Thanks

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxPython-users@lists.wxwindows.org>
Sent: Monday, February 24, 2003 22:58
Subject: Re: [wxPython-users] bitmaps and wxListCtrl

Jose wrote:
>
> Hi,
>
> I have a bitmap file and I want to show it in a wxListCtrl. How do I do

it??

>

See the demo for details, but in a nutshell you add the image to a
wxImageList, set the image list into the list ctrl, and then when adding
items to the list ctrl you can specify the index of the image in the
image list to associcate with that list item.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---Publicidad--------------------------------------------------------
Juega con Ventura24.es, lotería inteligente y multiplica tus
posibilidades!! Última información publicada - iespaña

I saw the demo but the examples do "import images" and images.py has the
ASCII characters of the images.

How can I add an image file (x.gif) to the wxImagelist directly. Can I see
an example of code?

You have to load an image, then convert it to a bitmap and use
InsertImageItem or InsertImageTextItem from wxListCtrl. See the attached
example. First, all the images handlers are activated, in order to be
able to read from various image file formats. Then an image is created
from a file (I load a png since it's a free format - you can easily
adapt it to gif but there are patents problems with it and maybe your
wxPython version doesn't implement it). As said in the doc, a wxImage is
a generic image format that can't be displayed directly. You have to
convert it to a machine-dependent format, wxBitmap. This is done with
ConvertToBitmap. Note that before doing that I've scaled the image to
(100, 100). Then you can do whatever you want with the bitmap, either
display it in a wxStaticBitmap, or put it into a wxListCtrl.

The following manual pages contains everything you need - don't forget
to refer to it before anything:

http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin237.htm
http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin223.htm
http://www.lpthe.jussieu.fr/~zeitlin/wxWindows/docs/wxwin35.htm

Alex.

imagetest.py (973 Bytes)

···

--
http://www.gnurou.org

I'm hoping to write some expandalbe windows, similar to how
winamp handles their windows, and was hoping someone could
at least point me in the right direction to get started...

For those not familiar with winamp, it has several windows that corrouspond with a main window, these side windows can be separate
or docked, and can also appear to fold up into the main window..

Thanks for any help..

Gary

Jose wrote:

Hi again,

I saw the demo but the examples do "import images" and images.py has the
ASCII characters of the images.

How can I add an image file (x.gif) to the wxImagelist directly. Can I see
an example of code?

  bmp = wxBitmap("x.gif", wxBITMAP_TYPE_GIF)
  imageList.Add(bmp)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Gary MacDonald wrote:

I'm hoping to write some expandalbe windows, similar to how
winamp handles their windows, and was hoping someone could
at least point me in the right direction to get started...

For those not familiar with winamp, it has several windows that corrouspond with a main window, these side windows can be separate
or docked, and can also appear to fold up into the main window..

I'm not sure what you mean by "expandable" but a window with no frame, caption, etc. is easy to do. Just give a wxFrame a zero style and you've got it. You'll then need to handle moving the window yourself when the mouse is dragged across it, which is also fairly simple. Just capture the mouse in EVT_LEFT_DOWN, move the window in response to EVT_MOTION and release the mouse in EVT_LEFT_UP.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks for replying...

I'll try to explain better...

for example: I have a main window, a button at the right side and at the bottom. If I click the bottom
button, a window appears to slide out from the bottom, it appears to be attached, but it can moved separately, then docked to the bottom of the main window again. The button on the right would do the same. This windows have options on them that at times will be needed to make changes on the main window.. I'm curious if I'm going to have to have to write my own code to do this, or if there are some libs I'm not aware of...

I'm not sure what you mean by "expandable" but a window with no frame, caption, etc. is easy to do. Just give a wxFrame a zero style and you've got it. You'll then need to handle moving the window yourself when the mouse is dragged across it, which is also fairly simple. Just capture the mouse in EVT_LEFT_DOWN, move the window in response to EVT_MOTION and release the mouse in EVT_LEFT_UP.

Robin Dunn wrote:
Gary MacDonald wrote:

···

I'm hoping to write some expandalbe windows, similar to how
winamp handles their windows, and was hoping someone could
at least point me in the right direction to get started...

For those not familiar with winamp, it has several windows that corrouspond with a main window, these side windows can be separate
or docked, and can also appear to fold up into the main window..

Gary MacDonald wrote:

Thanks for replying...

I'll try to explain better...

for example: I have a main window, a button at the right side and at the bottom. If I click the bottom
button, a window appears to slide out from the bottom, it appears to be attached, but it can moved separately, then docked to the bottom of the main window again. The button on the right would do the same. This windows have options on them that at times will be needed to make changes on the main window.. I'm curious if I'm going to have to have to write my own code to do this, or if there are some libs I'm not aware of...

Catch the EVT_MOVE events and then move your "docked" windows such that they are still next to the main window after it has moved.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Gary MacDonald wrote:

Thanks for replying...

I'll try to explain better...

for example: I have a main window, a button at the right side and at the bottom. If I click the bottom
button, a window appears to slide out from the bottom, it appears to be attached, but it can moved separately, then docked to the bottom of the main window again. The button on the right would do the same. This windows have options on them that at times will be needed to make changes on the main window.. I'm curious if I'm going to have to have to write my own code to do this, or if there are some libs I'm not aware of...

Catch the EVT_MOVE events and then move your "docked" windows such that they are still next to the main window after it has moved.

Ok... Thanks... Is there a simple way for the two frames to talk to each other? The "docked" frame (frame1) will have selections on it that will makes changes to the other frame (frame2) ...

Thanks
Gary

Gary MacDonald wrote:

Ok... Thanks... Is there a simple way for the two frames to talk to each other? The "docked" frame (frame1) will have selections on it that will makes changes to the other frame (frame2) ...

The two classes can have a reference to each other, or perhaps better would be a "relationship" class that sits between them...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!