def __init__(self, gifdir=gifdir, parent=None):
     Frame.__init__(self, parent)
     self.pack()
     self.lbl = Label(self, text="none", bg='blue', fg='red')
     self.pix = Button(self, text="Press me", command=self.draw, bg='white')
     self.lbl.pack(fill=BOTH)
     self.pix.pack(pady=10)
     demoCheck.Demo(self, relief=SUNKEN, bd=2).pack(fill=BOTH)
     files = glob(gifdir + "*.gif")
     self.images = map(lambda x: (x, PhotoImage(file=x)), files)
     print files
예제 #2
0
 def __init__(self, gifdir=gifdir, parent=None):
     Frame.__init__(self, parent)
     self.pack()
     self.lbl = Label(self, text='none', bg='blue', fg='red')
     self.pix = Button(self, text='Press me', command=self.draw, bg='white')
     self.lbl.pack(fill=BOTH)
     self.pix.pack(pady=10)
     demoCheck.Demo(self, relief=SUNKEN, bd=2).pack(fill=BOTH)
     files = glob(gifdir + '*')
     self.images = [(x, PhotoImage(file=x)) for x in files]
     print(files)
예제 #3
0
 def __init__(self, master=None, gifdir=gifdir, cnf={}, **kw):
     super(ButtonPicsDemo, self).__init__(master)
     self.pack()
     self.lbl = Label(self, text='None', bg='blue', fg='red')
     self.pix = Button(self, text='Press me', command=self.draw, bg='white')
     self.lbl.pack(fill=BOTH)
     self.pix.pack(pady=10)
     demoCheck.Demo(self, relief=SUNKEN, bd=2).pack(fill=BOTH)
     files = glob(gifdir + '/*.gif')
     self.images = [(x, PhotoImage(file=x)) for x in files]
     print(files)
예제 #4
0
from tkinter import *  # get base widget set
from glob import glob  # filename expansion list
import demoCheck  # attach checkbutton demo to me
import random  # pick a picture at random

gifdir = '../gifs/'  # where to look for GIF files


def draw():
    name, photo = random.choice(images)
    lbl.config(text=name)
    pix.config(image=photo)


root = Tk()
lbl = Label(root, text="none", bg='blue', fg='red')
pix = Button(root, text="Press me", command=draw, bg='white')
lbl.pack(fill=BOTH)
pix.pack(pady=10)
demoCheck.Demo(root, relief=SUNKEN, bd=2).pack(fill=BOTH)

files = glob(gifdir + "*.gif")  # GIFs for now
images = [(x, PhotoImage(file=x)) for x in files]  # load and hold
print(files)
root.mainloop()