473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Tkinter: How can I update an image display?

I've got a small batch image-processing program (it adds the time a
digital photo was taken to the lower right of the image), and as a
feature, I wanted to show a thumbnail of each image it was being
processed. I can't get the image to update, though.

I trimmed it down to a basic app indicating the problem and the code
is at the end of this message. It should display the three listed
sample images, one after another.

The thing is, if I uncomment the raw_input call, it works. But I
don't want to have to hit ENTER after each image.

At first I wondered whether maybe the image data was bad, but that
doesn't explain why it works fine with the raw_input call in place.

I've hardly played with Tkinter, so I'm probably missing something
obvious. I tried adding pack() calls for F2 and ImageLabel, and that
made no difference.

Ideas?

Here's the code:

==========================
import Tkinter as Tk
import os, sys, time
import Image, ImageTk

class MyApp:

def __init__(self, root):
"""initializer for Tkinter-based application"""
self.root=root
F1 = Tk.Frame(self.root)
F1.pack()
SelButton = Tk.Button(F1, text="Go", command=self.go)
SelButton.pack(side="left")
QuitButton = Tk.Button(F1, text="Quit", command=F1.quit)
QuitButton.pack(side="left")
F2 = Tk.Frame(self.root)
F2.pack()
self.ImageLabel = Tk.Label(F2)
self.ImageLabel.pack()
self.FilenameLabel = Tk.Label(F2)
self.FilenameLabel.pack()
def go(self):
filenames = ["DSCN0184.JPG", "DSCN0185.JPG", "DSCN0186.JPG"]
for name in filenames:
im=Image.open(name)
im.thumbnail((100,75))
Tkimage = ImageTk.PhotoImage(im)
self.ImageLabel.config(image=Tkimage)
self.FilenameLabel.config(text=name)
time.sleep(2)
raw_input("Press ENTER for next...")

root = Tk.Tk()
myapp = MyApp(root)
root.mainloop()
==========================

Jul 19 '05 #1
3 8678
On Sun, 05 Jun 2005 20:39:04 -0700, Terry Carroll
<ca*****@nospam-tjc.com> wrote:
The thing is, if I uncomment the raw_input call, it works. But I
don't want to have to hit ENTER after each image.


And the, just to be confusing, I posted the uncommented version.

To make my example more consistent with my post, I should have said
that, when the raw_input call is commented out, it no longer works.
Jul 19 '05 #2
Terry Carroll <ca*****@nospam-tjc.com> writes:
I trimmed it down to a basic app indicating the problem and the code
is at the end of this message. It should display the three listed
sample images, one after another.

The thing is, if I uncomment the raw_input call, it works. But I
don't want to have to hit ENTER after each image.


Try using root.update()?
Jul 19 '05 #3
On 05 Jun 2005 21:04:40 -0700, Paul Rubin
<http://ph****@NOSPAM.invalid> wrote:
Try using root.update()?


Thanks!
Jul 19 '05 #4

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

Similar topics

8
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus...
1
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...
2
by: Michael Zhang | last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images from server and display those images. I created a thread (also a separate toplevel window) for displaying images and another...
2
by: Tuvas | last post by:
I've been trying to use a canvas to display different pictures on a Tkinter interface. However, it doesn't seem to update the information. Ei, I have something like this. ...
1
by: C D Wood | last post by:
To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder....
6
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):...
1
by: apriebe47 | last post by:
Hello, I have created a simple canvas in Tkinter to display a number of PhotoImages, I then bind a key (in my case, <Up>) to start a loop that plays through a list of PhotoImages to make it an...
2
by: Kevin Walzer | last post by:
I'm trying to decide whether I need threads in my Tkinter application or not. My app is a front end to a command-line tool; it feeds commands to the command-line program, then reads its output and...
3
TMS
by: TMS | last post by:
Hey all: I'm working on this 'pac man' like game I've been writing in Tkinter. The temporary gif I'm using (I can't attach it, sorry) goes around the maze based on a dictionary that has each path...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.