The code is such that when I click on the button with an image on it. The second button must be added onto the window. But when I click on the button the second button doesn't have the same image on it.
(main.py)
from tkinter import *
import second
def main():
root = Tk()
first(root)
# first UI
class first:
def __init__(self, root):
self.root = root
self.root.title("Demo UI")
self.root.geometry("500x500")
# sample button
photo = PhotoImage(file="rot13.png")
btn = Button(root, image=photo, command=self.switch)
btn.pack()
self.root.mainloop()
def switch(self):
second.newUI(self.root)
return None
pass
# run the program
main()
(second.py)
from tkinter import *
class newUI:
def __init__(self, root):
self.root = root
# sample button
photo = PhotoImage(file="rot13.png")
btn = Button(root, image=photo)
btn.pack()
pass
RESULT: [1]: https://i.stack.imgur.com/3HFL1.png