hi,

is there anyway to display a .jpg (or other type) images in Tkinter with Python 3.1?

From what I read here in the forum, for Python 2.6 I could use the PIL package. But the PIL packages doesnt support Pyton 3.1 yet (from what I read on the PIL website).

Are there perhaps other packages or other way to do it without using PIL?

Thanks.

Right now you simply have to use one of the many image view utilities to convert your jpg files to gif files.

I see. So right now there are not available packages yet for Tkinter in Python 3.1

I want to display preview, or let a user browse and select his own picture, and I dont want to limit it to GIF files (well, not all user are power users that understand the difference, for them a picture is a picture). But I guess I have to wait for now until I can do that with Tkinter. The best I can do for now is combining the program with other packages (like pygame).

Thanks again.

The other GUI toolkit that works with Python 3.1 and can display a number of image formats including .jpg is PyQT. There is a note about getting the Windows installer that Henri left at:
http://www.daniweb.com/forums/post922737-26.html

Here is a sample code in simple (no class) style ...

# display an image using PyQT (simple coding)
# PyQT free from:
# http://www.riverbankcomputing.co.uk/software/pyqt/download
# Windows installer as of 27jul2009: PyQt-Py3.1-gpl-4.6rc1-1.exe
# tested with PyQT4.6 and Python3.1

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)

# create the window/frame
win = QWidget()

# the image file can be a .jpg, .png, ,gif, .bmp image file
# if not in the working directory, give the full path
# (filenames are case sensitive on Ubuntu/Linux)
image_file = "Dimension.jpg"
image = QPixmap(image_file)
width = image.width()
height = image.height()
# show the image name and size in the window title
info = "%s (%dx%d)" % (image_file, width, height) 
win.setWindowTitle(info)

# use a label to display the image in
label = QLabel(win)
label.setGeometry(10, 10, width, height)
label.setPixmap(image)

win.show()

app.exec_()

From the thread GUI programming, I see a lot of examples using PyQt.

Is it more powerfull than Tkinter? Should I stick with Tkinter or should I learn PyQt? The problem with the JPG stuff is only something minor. Im referring to more general (all in one) thing.

Im a python newbie. I want to focus on one thing first before learning all other packages. Currently I'm just using Tkinter and pygame. If PyQt is better than Tkinter, than I would switch to it and focus to it.

To get your feet wet with GUI programming, I would stick with Tkinter at first, if you can handle the somewhat limited image file formats that Python31 will give you right now.

PyQT is more powerful, but has its own learning curve. Certain things will be similar to Tkinter, so switching later will be made easier if you have Tkinter knowledge.

The PyQT installation comes with a GUI designer that goes through XML code, some folks like those, others don't.

commented: Thanks for the advice! +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.