I wrote this code in windows and it worked but when i copied it to my raspberry pi(running Jessie Debian based) it give runtime error
my code:
from Tkinter import *
from PIL import ImageTk,Image
from time import sleep
import thread
root = Tk()
img=ImageTk.PhotoImage(Image.open("1.jpg").resize((root.winfo_screenwidth()-3,root.winfo_screenheight()-3)))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
if __name__ == '__main__':
thread.start_new_thread(root.mainloop,())
for i in xrange(1,5):
sleep(1)
img2 = ImageTk.PhotoImage(Image.open(str(i)+".jpg").resize((root.winfo_screenwidth()-3,root.winfo_screenheight()-3)))
panel.configure(image = img2)
panel.image = img2
when executed in linux it gives error:
Unhandled exception in thread started by <bound method Tk.mainloop of <Tkinter.Tk instance at 0x75b605d0>>
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1124, in mainloop
self.tk.mainloop(n)
RuntimeError: Calling Tcl from different appartment
what should i do to run this code on both platforms