Skip to content

Commit 720d63b

Browse files
committed
new examples
1 parent b0dba9d commit 720d63b

File tree

1 file changed

+63
-0
lines changed
  • tkinter/__window__/replace-window

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
# date: 2019.05.04
3+
# author: Bartłomiej 'furas' Burek
4+
5+
import tkinter as tk
6+
7+
# --- function ---
8+
9+
def main_window():
10+
global root
11+
12+
if root is not None:
13+
root.destroy()
14+
15+
root = tk.Tk()
16+
17+
button = tk.Button(root, text="Frame #1", command=window_1)
18+
button.pack()
19+
20+
button = tk.Button(root, text="Frame #2", command=window_2)
21+
button.pack()
22+
23+
root.mainloop()
24+
25+
def window_1():
26+
global root
27+
28+
if root is not None:
29+
root.destroy()
30+
31+
root = tk.Tk()
32+
33+
l = tk.Label(root, text="It is Frame #1", bg='red')
34+
l.pack()
35+
36+
b = tk.Button(root, text="BACK", command=main_window)
37+
b.pack()
38+
39+
root.mainloop()
40+
41+
def window_2():
42+
global root
43+
44+
if root is not None:
45+
root.destroy()
46+
47+
root = tk.Tk()
48+
49+
l = tk.Label(root, text="It is Frame #2", bg='green')
50+
l.pack()
51+
52+
b = tk.Button(root, text="BACK", command=main_window)
53+
b.pack()
54+
55+
root.mainloop()
56+
57+
# --- main ---
58+
59+
#global value to keep access to open window
60+
root = None
61+
62+
main_window()
63+

0 commit comments

Comments
 (0)