This is my current code, and I am struggling to understand where I need to put additional code to make sure that my tkinter window is fixed. Code taken from: https://pythonprogramming.net/change-show-new-frame-tkinter/
JavaScript
x
91
91
1
import tkinter as tk
2
3
4
LARGE_FONT= ("Verdana", 12)
5
6
7
class SeaofBTCapp(tk.Tk):
8
9
def __init__(self, *args, **kwargs):
10
11
tk.Tk.__init__(self, *args, **kwargs)
12
container = tk.Frame(self)
13
14
container.pack(side="top", fill="both", expand = False)
15
16
container.grid_rowconfigure(0, weight=1)
17
container.grid_columnconfigure(0, weight=1)
18
19
self.frames = {}
20
21
for F in (StartPage, PageOne, PageTwo):
22
23
frame = F(container, self)
24
25
self.frames[F] = frame
26
27
frame.grid(row=0, column=0, sticky="nsew")
28
29
30
self.show_frame(StartPage)
31
32
def show_frame(self, cont):
33
34
frame = self.frames[cont]
35
frame.tkraise()
36
37
38
class StartPage(tk.Frame):
39
40
def __init__(self, parent, controller):
41
tk.Frame.__init__(self,parent)
42
43
label = tk.Label(self, text="NC's Ice-Cream Shop", font=LARGE_FONT)
44
label.pack(pady=10,padx=10)
45
46
button = tk.Button(self, text=">>",
47
command=lambda: controller.show_frame(PageOne))
48
button.pack()
49
50
#button2 = tk.Button(self, text="Visit Page 2",
51
# command=lambda: controller.show_frame(PageTwo))
52
#button2.pack()
53
54
55
class PageOne(tk.Frame):
56
57
def __init__(self, parent, controller):
58
tk.Frame.__init__(self, parent)
59
label = tk.Label(self, text="Order Details", font=LARGE_FONT)
60
label.pack(pady=10,padx=10)
61
62
button1 = tk.Button(self, text="<<",
63
command=lambda: controller.show_frame(StartPage))
64
button1.pack()
65
66
button2 = tk.Button(self, text=">>",
67
command=lambda: controller.show_frame(PageTwo))
68
button2.pack()
69
70
71
class PageTwo(tk.Frame):
72
73
def __init__(self, parent, controller):
74
tk.Frame.__init__(self, parent)
75
label = tk.Label(self, text="Receipt", font=LARGE_FONT)
76
label.pack(pady=10,padx=10)
77
78
button1 = tk.Button(self, text="<<",
79
command=lambda: controller.show_frame(PageOne))
80
button1.pack()
81
82
button2 = tk.Button(self, text="New",
83
command=lambda: controller.show_frame(StartPage))
84
button2.pack()
85
86
87
88
89
app = SeaofBTCapp()
90
app.mainloop()
91
Advertisement
Answer
As mentioned in the comments, you simply need to set your root window resizable
method to false. In your case it is the SeaofBTCapp
class.
For Example:
JavaScript
1
74
74
1
import tkinter as tk
2
3
LARGE_FONT= ("Verdana", 12)
4
5
class SeaofBTCapp(tk.Tk):
6
7
def __init__(self, *args, **kwargs):
8
9
tk.Tk.__init__(self, *args, **kwargs)
10
self.resizable(False,False) # <------------------- added this
11
12
container = tk.Frame(self)
13
container.pack(side="top", fill="both", expand = False)
14
container.grid_rowconfigure(0, weight=1)
15
container.grid_columnconfigure(0, weight=1)
16
17
self.frames = {}
18
for F in (StartPage, PageOne, PageTwo):
19
frame = F(container, self)
20
self.frames[F] = frame
21
frame.grid(row=0, column=0, sticky="nsew")
22
23
self.show_frame(StartPage)
24
25
def show_frame(self, cont):
26
frame = self.frames[cont]
27
frame.tkraise()
28
29
30
class StartPage(tk.Frame):
31
32
def __init__(self, parent, controller):
33
tk.Frame.__init__(self,parent)
34
label = tk.Label(self, text="NC's Ice-Cream Shop", font=LARGE_FONT)
35
label.pack(pady=10,padx=10)
36
button = tk.Button(self, text=">>",
37
command=lambda: controller.show_frame(PageOne))
38
button.pack()
39
40
#button2 = tk.Button(self, text="Visit Page 2",
41
# command=lambda: controller.show_frame(PageTwo))
42
#button2.pack()
43
44
class PageOne(tk.Frame):
45
46
def __init__(self, parent, controller):
47
tk.Frame.__init__(self, parent)
48
label = tk.Label(self, text="Order Details", font=LARGE_FONT)
49
label.pack(pady=10,padx=10)
50
button1 = tk.Button(self, text="<<",
51
command=lambda: controller.show_frame(StartPage))
52
button1.pack()
53
button2 = tk.Button(self, text=">>",
54
command=lambda: controller.show_frame(PageTwo))
55
button2.pack()
56
57
58
class PageTwo(tk.Frame):
59
60
def __init__(self, parent, controller):
61
tk.Frame.__init__(self, parent)
62
label = tk.Label(self, text="Receipt", font=LARGE_FONT)
63
label.pack(pady=10,padx=10)
64
button1 = tk.Button(self, text="<<",
65
command=lambda: controller.show_frame(PageOne))
66
button1.pack()
67
68
button2 = tk.Button(self, text="New",
69
command=lambda: controller.show_frame(StartPage))
70
button2.pack()
71
72
app = SeaofBTCapp()
73
app.mainloop()
74