Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77329

Re: Sequencing images using tkinter?

Newsgroups comp.lang.python
Date 2014-08-30 13:11 -0700
References <dcff98af-47cd-4dbc-9fa1-02dc6813df81@googlegroups.com>
Message-ID <215ce6a7-2b67-4386-ad09-0e448091d903@googlegroups.com> (permalink)
Subject Re: Sequencing images using tkinter?
From theteacher.info@gmail.com

Show all headers | View raw


Peter - Thanks! I've had a play around and followed your advice and have something that should take me on to the next step! This is what I have so far and it works, Thanks.

from tkinter import *
from tkinter import ttk
import random

root = Tk()
root.title("Messing about")

def next_image(): 
    myLabel.config(image=random.choice(monster_images)) 
    # tell tkinter to invoke next_image() again after 200 miliseconds 
    root.after(200, next_image) 

mainframe = ttk.Frame(root, padding="3 3 12 12", width="800", height="600", borderwidth="120", relief="sunken")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

mon1 = PhotoImage(file="MonsterImages/Converted/py01.gif")
mon2 = PhotoImage(file="MonsterImages/Converted/py02.gif")
mon3 = PhotoImage(file="MonsterImages/Converted/py03.gif")

#A list of object pictures
monster_images = [mon1, mon2, mon3]

#Set up one label
myLabel=ttk.Label(mainframe, image=mon1)
myLabel.grid(column=1, row=1, sticky=W)


next_image()

root.mainloop()

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 08:54 -0700
  Re: Sequencing images using tkinter? Terry Reedy <tjreedy@udel.edu> - 2014-08-30 15:52 -0400
  Re: Sequencing images using tkinter? Peter Otten <__peter__@web.de> - 2014-08-30 21:54 +0200
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:11 -0700
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:27 -0700
    Re: Sequencing images using tkinter? "Albert Visser" <albert.visser@gmail.com> - 2014-08-30 22:49 +0200
  Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-30 13:37 -0700
    Re: Sequencing images using tkinter? Peter Otten <__peter__@web.de> - 2014-08-30 23:14 +0200
      Re: Sequencing images using tkinter? theteacher.info@gmail.com - 2014-08-31 02:51 -0700

csiph-web