This is the code that I have written. As you can see, it has a button which when clicked opens up a Text
where one can enter something. It works, the window resizes if you click the button.
But I have noticed that, if I maximize and minimize the window just after starting the program (i.e. the first thing I do is to maximize and minimize the window), then the window doesn't resize to fit the whole frame (on clicking the button) and my widgets get hidden.
from tkinter import *
def Home():
global homeP
homeP = Tk()
homeP.title('Grades')
enterButton = Button(homeP, text='Enter Grades', bg='blue', fg='white', command=enterG)
enterButton.grid(row=1, column=0, padx=(5,5), pady=(5,2), sticky="e")
homeP.mainloop()
curFrame = ''
def enterG():
global homeP
global eGrade
global curFrame
if curFrame == 'e':
return
if 'eGrade' not in globals(): #Prevent frames from stacking up on one another
eGrade = Frame(homeP)
enterGrades = Text(eGrade, width=64, height=10)
enterGrades.grid(row=0, column=0)
eGrade.grid(row=2, column=0, columnspan=2, padx=(10,10), pady=(1,5))
else:
eGrade.grid(row=2, column=0, columnspan=2, padx=(10,10), pady=(1,5))
curFrame = 'e'
# for name, value in globals().copy().items():
# print(name, value)
Home()
Any help as to why this is happening and how I can prevent this?