Image slider

Hi all,

I want to build an image slider in wxpython, with a preview of the images on one side. I saw some examples in the internet and I am trying to put together the widgets, but I have found some difficulties to manage, so I decided to ask for help.
I have found this example [0] that could be applied in my case for the preview of images stored in a folder, and [1] to display the selected image. The image to be displayed should be selected from the preview with a mouse click.
So what I thought is to use a main frame (wx.Frame) containing the widgets, a wx.Listbook for sliding the preview images and a wx.Panel to visualize the selected image. Am I on the right way? Does anyone have more examples for me?
I have found difficulties in using the sample code of Demo (listbook.py), because it imports

import ColorPanel
import images

so when I try to change the code in order to analyze/customize it, I get error:

import ColorPanel

ImportError: No module named ColorPanel

where does ColorPanel come from?
Thanks for any suggestion,

madi

[0] http://wiki.wxpython.org/Listbook
[1] http://www.blog.pythonlibrary.org/2010/03/26/creating-a-simple-photo-viewer-with-wxpython/

Ciao Margherita,

Hi all,

I want to build an image slider in wxpython, with a preview of the images on one side. I saw some examples in the internet and I am trying to put together the widgets, but I have found some difficulties to manage, so I decided to ask for help.

I have found this example [0] that could be applied in my case for the preview of images stored in a folder, and [1] to display the selected image. The image to be displayed should be selected from the preview with a mouse click.

So what I thought is to use a main frame (wx.Frame) containing the widgets, a wx.Listbook for sliding the preview images and a wx.Panel to visualize the selected image. Am I on the right way? Does anyone have more examples for me?

I have found difficulties in using the sample code of Demo (listbook.py), because it imports

import ColorPanel
import images

so when I try to change the code in order to analyze/customize it, I get error:

import ColorPanel

ImportError: No module named ColorPanel

where does ColorPanel come from?
Thanks for any suggestion,

ColorPanel comes from the wxPython demo, as far as I can see. If you want to customize it, your best bet is to copy over your folder the images.py, Colorpanel.py and run.py files (I may be forgetting some of the files here, but I think these 3 should be enough). If you didn’t install the wxPython demo, I strongly suggest you to do so. It’s an incredible resource when writing new code.

Other than that, I humbly suggest you to take a look at my implementation of ThumbnailCtrl in wx.lib.agw.thumbnailctrl. I believe it does exactly what you are asking for. The demo is contained in the wxPython demo, under “Advanced Generic Widgets”. More docs here:

http://xoomer.virgilio.it/infinity77/AGW_Docs/thumbnailctrl.ThumbnailCtrl.html#thumbnailctrl-thumbnailctrl

Hope this helps.

Andrea.

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

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

···

On 14 August 2011 20:06, Margherita Di Leo wrote:

import wx

Ciao Andrea,

thank you very much for your answer.
Sorry I see that my post has been published twice, that's my fault.

Ciao Margherita,

ColorPanel comes from the wxPython demo, as far as I can see. If you want to
customize it, your best bet is to copy over your folder the images.py,
Colorpanel.py and run.py files (I may be forgetting some of the files here,
but I think these 3 should be enough).

It works now, thanks!

If you didn't install the wxPython

demo, I strongly suggest you to do so. It's an incredible resource when
writing new code.

I guessed so, but actually didn't find the way to "install" it, so I
just run the code in terminal..

Other than that, I humbly suggest you to take a look at my implementation of
ThumbnailCtrl in wx.lib.agw.thumbnailctrl. I believe it does exactly what
you are asking for. The demo is contained in the wxPython demo, under
"Advanced Generic Widgets".

I downloaded wxPython-2.8.1.1 and wxPython-2.9.1.1 demos for linux but
i didn't find that folder. Anyway I will check tomorrow the code and
the documentation online, thank you very much.

madi

···

On Aug 14, 10:22 pm, Andrea Gavana <andrea.gav...@gmail.com> wrote:

>>> import PyQt4.QtGui

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named PyQt4.QtGui

>>> import pygtk

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named pygtk

Completely off topic. With the hope the rendering is ok.

Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit
(Intel)] on win32

running qsizero.py...
...qsizero has been executed
...
...

Ελληνικά = 'Wi'
Беларуская = 'ki'
中文 = 'pe'
français = 'dia'

...
...

print(Ελληνικά + Беларуская + 中文 + français)

Wikipedia

jmf

It is.

jmf

···

On 15 août, 08:52, jmfauth <wxjmfa...@gmail.com> wrote:

... With the hope the rendering is ok.

Ciao Margherita,

Ciao Andrea,

thank you very much for your answer.

Sorry I see that my post has been published twice, that’s my fault.

Ciao Margherita,

ColorPanel comes from the wxPython demo, as far as I can see. If you want to

customize it, your best bet is to copy over your folder the images.py,

Colorpanel.py and run.py files (I may be forgetting some of the files here,

but I think these 3 should be enough).

It works now, thanks!

If you didn’t install the wxPython

demo, I strongly suggest you to do so. It’s an incredible resource when

writing new code.

I guessed so, but actually didn’t find the way to “install” it, so I

just run the code in terminal…

My apologies, I didn’t understand you were running on Linux.

Other than that, I humbly suggest you to take a look at my implementation of

ThumbnailCtrl in wx.lib.agw.thumbnailctrl. I believe it does exactly what

you are asking for. The demo is contained in the wxPython demo, under

“Advanced Generic Widgets”.

I downloaded wxPython-2.8.1.1 and wxPython-2.9.1.1 demos for linux but

i didn’t find that folder. Anyway I will check tomorrow the code and

the documentation online, thank you very much.

Sorry, I should have been more clear. In the wxPython demo folder, the file for the whole wxPython demo is called Main.py. If you run that demo you’ll see a tree of available sub-demos on the left. ThumbnailCtrl is one of these tree items, under the “Advanced Generic Widgets” main category.

Otherwise, the ThumbnailCtrl standalone demo lives inside a subfolder of the demo folder, called “agw”.

Hope this helps.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.alice.it/infinity77/

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

···

On 15 August 2011 01:06, madi wrote:

On Aug 14, 10:22 pm, Andrea Gavana andrea.gav...@gmail.com wrote:

import wx

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

Completely off topic. With the hope the rendering is ok.

Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit

(Intel)] on win32

running qsizero.py…

…qsizero has been executed

Ελληνικά = ‘Wi’

Беларуская = ‘ki’

中文 = ‘pe’

français = ‘dia’

print(Ελληνικά + Беларуская + 中文 + français)

Wikipedia

I remember that this issue sparkled one of the longest thread in the Python mailing list back in 2007, about PEP 3131:

http://mail.python.org/pipermail/python-list/2007-May/491458.html

It was funny enough to read, I believe especially for those of us who have to deal with non-English languages every day while coding. As far as I remember, the whole thread contained more than 300 messages :slight_smile:

Andrea.

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

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

···

On 15 August 2011 08:52, jmfauth wrote:

import wx

Madi, You haven’t explained what is an “image slider”. I’m guessing that it’s some kind of Window that provides some kind of scrolling or panning for a bitmap that’s too big to fit into its Window. There are extremely few reasonably working examples. Both wx.ScrolledWindow and wx.PyScrolledWindow require a fixed Window size. Their Windows are not able to be resized.

The only example using a resizable window is possibly wx.lib.floatcanvas.FloatCanvas, but it is not apparent that is it will handle a bitmap rather than drawn graphics. You will have to play with it to find out for yourself. See the attached demo

I am currently working on a resizable image window that uses scrollbars, but don’t expect this soon.

Ray Pasco

FloatCanvas_Test_A.py (2.48 KB)

FloatCanvas_Test_B.py (3.28 KB)

Hi Ray,

Thank you very much for your answer. My purpose was not so sophisticated, I just was building something like this [0].

Cheers,

madi

[0] http://svn.osgeo.org/grass/grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/ImageViewer.py

···

2011/8/15 Ray Pasco pascor22234@gmail.com

Madi, You haven’t explained what is an “image slider”. I’m guessing that it’s some kind of Window that provides some kind of scrolling or panning for a bitmap that’s too big to fit into its Window. There are extremely few reasonably working examples. Both wx.ScrolledWindow and wx.PyScrolledWindow require a fixed Window size. Their Windows are not able to be resized.

The only example using a resizable window is possibly wx.lib.floatcanvas.FloatCanvas, but it is not apparent that is it will handle a bitmap rather than drawn graphics. You will have to play with it to find out for yourself. See the attached demo

I am currently working on a resizable image window that uses scrollbars, but don’t expect this soon.

Ray Pasco

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

When the Frame is resized (an wx.EVT_SIZE event occurs) the Frame needs a Refresh(). See the attached image. Also consider what will your viewer do if the image is much bigger than the Frame.

Ray

ImageViewer.png

When the Frame is resized (an wx.EVT_SIZE event occurs) the Frame needs a
Refresh().

Yes, that it's normal. You can use double or triple-buffering as much
as you wish but you still have to take into account the change in size
for the image. I never considered it to be a problem.

See the attached image. Also consider what will your viewer do if
the image is much bigger than the Frame.

Either you use a wx.ScrolledWindow/wx.lib.scrolledpabel.ScrolledPanel,
or you resize the image yourself to fit the frame size. Caching
different scaled images at the beginning (in the __init__ method) also
helps.

Andrea.

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

import PyQt4.QtGui

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named pygtk

···

On 17 August 2011 00:30, Ray Pasco wrote:

import wx

Ray,

Thank you for your hints! I am really learning a lot from this
community.
Actually i didn't consider the problem of images' different sizes
because this image viewer has been designed to be integrated in a main
software that produces by itself the png files with a standard size
(i'm still working on this other part).

Ciao,

madi

···

On Aug 16, 11:30 pm, Ray Pasco <pascor22...@gmail.com> wrote:

When the Frame is resized (an wx.EVT_SIZE event occurs) the Frame needs a
Refresh(). See the attached image. Also consider what will your viewer do if
the image is much bigger than the Frame.

Ray

ImageViewer.png
256KViewDownload

Use the wx.FULL_REPAINT_ON_RESIZE style on the window that is painting the image.

···

On 8/16/11 2:30 PM, Ray Pasco wrote:

When the Frame is resized (an wx.EVT_SIZE event occurs) the Frame needs
a Refresh(). See the attached image.

--
Robin Dunn
Software Craftsman