Tkinter .geometry() function is not channging the size of the window even though it should when i press and I know the function is running cause i asked it to print that it's running to the console. Here is the code.
import tkinter
class FullScreenWindow():
def __init__(self):
self.window = tkinter.Tk()
self.window.attributes('-zoomed', True)
self.frame = tkinter.Frame(self.window)
self.frame.pack()
self.state = False
self.window.bind("<F11>", self.toggleFullscreen)
self.window.bind("<Escape>", self.smallScreen)
def toggleFullscreen(self, event=None):
self.state = not self.state
self.window.attributes("-fullscreen", self.state)
def smallScreen(self, event=None):
self.state = False
self.window.attributes("-fullscreen", self.state)
print("I am running")
self.window.geometry("600x525")
fsw = FullScreenWindow()
fsw.window.mainloop()
@CommonSense got it right. The '-zoomed' was overriding the changes that i wanted to make with .geometry. By adding
self.window.atrributes('-zoomed', False)
into the smallScreen function.
Here is the fixed code
import tkinter
class FullScreenWindow():
def __init__(self):
self.window = tkinter.Tk()
self.window.attributes('-zoomed', True)
self.frame = tkinter.Frame(self.window)
self.frame.pack()
self.state = False
self.window.bind("<F11>", self.toggleFullscreen)
self.window.bind("<Escape>", self.smallScreen)
def toggleFullscreen(self, event=None):
self.state = not self.state
self.window.attributes("-fullscreen", self.state)
def smallScreen(self, event=None):
self.state = False
self.window.attributes("-fullscreen", self.state)
self.window.attrebutes("-zoomed", self.state)
self.window.geometry("600x525")
fsw = FullScreenWindow()
fsw.window.mainloop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.