1#import module needed
2import tkinter as tk
3#write the new window function which
4#will be called when button pressed
5def new_window():
6 window = tk.Toplevel(root)
7 canvas = tk.Canvas(window, height=HEIGHT, width=WIDTH)
8 canvas.pack()
9
10HEIGHT = 400
11WIDTH = 300
12#create original window (title not need but why not?)
13root = tk.Tk()
14root.title("new window making machine: ")
15canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)
16canvas.pack()
17#create button that will be placed
18button = tk.Button(root, text="new window", bg='black', fg='#469A00',
19 command=lambda: new_window())
20#can use .grid() or .place() instead of pack .place()
21#is the best according to me if you want the most control of positions
22button.pack()
23root.mainloop()