lundi 23 février 2015

Refreshing Image label via Tkinter (Python) [duplicate]


This question already has an answer here:




So I want to build a screen sharing program. I have the code that sends the screen. Now, I have to constantly present the image somehow, so I've built something in Tkinter. The code presents the Image but I didn't find the way to refresh it let's say.. every three seconds. I've tried while true and time.sleep(3) but it crashes. Thanks for the helpers :)



import Tkinter
from PIL import Image, ImageTk

class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()

def initialize(self):
self.grid()
image = Image.open("Image2.pgm")
photo = ImageTk.PhotoImage(image)
lbl = Label(image=photo)
lbl.image = photo
lbl.pack()
lbl.grid()


if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('Screen Sharing')
app.mainloop()

Aucun commentaire:

Enregistrer un commentaire