Why there is a problem while displaying image in GUI called from another GUI in python tkinter??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why there is a problem while displaying image in GUI called from another GUI in python tkinter???

First a wrote a module which has a function that just reads and display the image in GUI. The I wrote another module which imports the first module and makes call to that function when the button is clicked. But it gives me error. Code : #button GUI from tkinter import * import testimg as ti def click(): ti.disp() root = Tk() Button(text = 'Click me',command=click).pack() root.mainloop() #module from tkinter import * def disp(): root1 = Tk() root1.geometry("400x500") image = PhotoImage(file = 'png2.png') Label(root1,image=image).pack() root1.mainloop()

2nd Feb 2020, 7:32 AM
Prathamesh Ramane
Prathamesh Ramane - avatar
1 Answer
+ 1
You can have only a single root window in a tkinter application. The root window is created when you call Tk() https://effbot.org/tkinterbook/tkinter-application-windows.htm
2nd Feb 2020, 7:54 AM
Tibor Santa
Tibor Santa - avatar