Is there any way to duplicate a window in tkinter ?
Here's the code:
from tkinter import *
root = Tk()
root.geometry("500x100")
def new_window():
# Code to duplicate the window
pass
button = Button(root , text = "Sample button")
button.pack(pady = 20)
mainmenu = Menu(root)
root.config(menu = mainmenu)
file_menu = Menu(mainmenu , tearoff = False)
menu_1 = Menu(mainmenu , tearoff = False)
menu_2 = Menu(mainmenu , tearoff = False)
menu_3 = Menu(mainmenu , tearoff = False)
menu_4 = Menu(mainmenu , tearoff = False)
mainmenu.add_cascade(label = "File" , menu = file_menu)
mainmenu.add_cascade(label = "Menu 1" , menu = menu_1)
mainmenu.add_cascade(label = "Menu 2" , menu = menu_2)
mainmenu.add_cascade(label = "Menu 3" , menu = menu_3)
mainmenu.add_cascade(label = "Menu 4" , menu = menu_4)
file_menu.add_command(label = "Duplicate window" , command = new_window)
menu_1.add_command(label = "Sub-menu 1")
menu_2.add_command(label = "Sub-menu 2")
menu_3.add_command(label = "Sub-menu 3")
menu_4.add_command(label = "Sub-menu 4")
mainloop()
What I want is to create a new window and all the elements that are in the first window should be there in the new window as well.
Is there any way to achieve this in tkinter without using classes ?
It would be great if anyone could help me out.
question from:https://stackoverflow.com/questions/65640872/duplicating-a-window-in-tkinter