1import tkinter as tk
2
3
4def new_window1():
5 " new window"
6 try:
7 if win1.state() == "normal": win1.focus()
8 except NameError as e:
9 print(e)
10 win1 = tk.Toplevel()
11 win1.geometry("300x300+500+200")
12 win1["bg"] = "navy"
13 lb = tk.Label(win1, text="Hello")
14 lb.pack()
15
16
17win = tk.Tk()
18win.geometry("200x200+200+100")
19button = tk.Button(win, text="Open new Window")
20button['command'] = new_window1
21button.pack()
22win.mainloop()
23