473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Tkinter.PhotoIm age

Hi,

I can only load gif images with Tkinter.PhotoIm age and none with BitmapImage.
I tried png, jpg, bmp and xpm and always got this errors :
>>img = Tkinter.PhotoIm age(file='/home/omer/fgfs/fgsync/map.xpm')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 3206, in __init__
Image.__init__( self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 3162, in __init__
self.tk.call((' image', 'create', imgtype, name,) + options)
_tkinter.TclErr or: couldn't recognize data in image
file "/home/omer/fgfs/fgsync/map.xpm"

(or _tkinter.TclErr or: format error in bitmap data with BitmapImage)

I also tried the imageview demo with the bitmaps in Demo/tix/bitmaps and same
result (only works with tix.gif). Sounds weird that tkinter only supports a
non-free format... Am I lacking some packages or config ? I'm on a debian sid
and have the following python packages installed :

libboost-python1.34.1
python
python-central
python-doc
python-imaging
python-imaging-tk
python-minimal
python-mode
python-newt
python-selinux
python-semanage
python-support
python-tk
python2.4
python2.4-doc
python2.4-minimal

thanks,
--
Cédric Lucantis
Jan 10 '08 #1
2 5501
Cédric Lucantis wrote:
Hi,

I can only load gif images with Tkinter.PhotoIm age and none with BitmapImage.
I tried png, jpg, bmp and xpm and always got this errors :
That's because Tk only supports the gif format natively. You need to
install an additional photo library to support additional images (Tk has
an Img extension, and Python Image Library is also very good).

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Jan 10 '08 #2
Cédric Lucantis wrote:
Hi,

I can only load gif images with Tkinter.PhotoIm age and none with BitmapImage.
I tried png, jpg, bmp and xpm and always got this errors :
That's because Tk only supports the gif format natively. You need to
install an additional photo library to support additional images (Tk has
an Img extension, and Python Image Library is also very good).

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Jan 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6317
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF image in the central area of a simple menu-bar app as shown below in the first code sample. But, when I set up my app with a class, as shown below in...
5
2128
by: eesun | last post by:
Hi, I've downloaded the dislin package for the scientific plotting. And I have already created the application window with Tkinter (menu, canvas, status bar..). I want to integrate the Dislin plotting into the Tkinter application. For ex: show the dislin result on the Tkinter Canvas. Anyone can help? thx
0
1745
by: erkidevries | last post by:
Problem compiling Tkinter program with bmp images (using py2exe) I have a Tkinter gui program that uses bmp as backgrounds. The program itself works when I run from the source. I placed the .bmp files in the same folder as the script. I run my .py script (from IDLE) and all the backgrounds are loaded as intended. in my script I load the...
6
3327
by: Dustan | last post by:
Nobody answered last time. I guess they wanted me to give it a shot. Well, here is how I download the image (it's a class method): def download_image(self): web_download=self.opener.open(self.url) save=open("image.jpg","w") save.writelines(web_download.readlines()) save.close() web_download.close()
2
9412
by: sj | last post by:
I am just learning to use Tkinter and am having problems displaying image files. I am able to display an image using tutorials (such as http://www.daniweb.com/code/snippet296.html) But when I try my own code all I get is an empty widget. What is wrong with the following program? from Tkinter import *
2
2296
by: Kevin Walzer | last post by:
I am trying to create a number of Tk PhotoImages from a single directory. Currently I am hard-coding file names and image names, like so: def makeImages(self): self.imagedir = (os.getcwd() + '/images/') self.folder_new=PhotoImage(file=self.imagedir + 'folder_new.gif') self.save=PhotoImage(file = self.imagedir + 'save.gif')...
3
4946
by: Nebulism | last post by:
Hi everyone, I am working on a module for my GUI that shows one image with an index value below and would use a scrollbar to control which of the images are displayed. The images are stored in a successive folder in the format Pic#, i,e. Pic1, Pic2 etc. What I want to do is make a slider that is attached to a label which would output the...
2
1466
by: skanemupp | last post by:
why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk()
1
1799
by: jimgardener | last post by:
hi I am using Python 2.5.1. In my code i want to use self.myimage=PhotoImage (file=self.myfile) so i can create the image in a canvas self.mycanv.create_image(70,100,image=self.myimg) it works when i add, from ImageTk import PhotoImage
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.