How to check if window is fullscreen or not - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: How to check if window is fullscreen or not (/thread-28730.html) |
How to check if window is fullscreen or not - delphinis - Aug-01-2020 Hi, trying to play with fullscreen, to save the last configuration of the screen, i whanted to obtain the info if the window is in fullscreen or not. But nothing works. I tried with - .attributes('fullscreen') => this always results in 0 - .wm_state('zoomed') => this doesn'r return a value, or more exact: {str}'' How to check if the window is zoomed or fullscreen? Working with windows. Here's my (reduced) code: try: import tkinter as tk except ImportError: import Tkinter as tk class Window(tk.Frame): #def __init__(self, master, **kwargs): def __init__(self, master): self.master = master self.master.bind("<F11>", self.do_fullscreen) self.master.bind("<Escape>", self.end_fullscreen) self.master.geometry("400x500+0+0") def do_fullscreen(self, event=None): self.master.wm_state('zoomed') #fullscreen = self.master.attributes('-fullscreen') fullscreen = self.master.wm_state('zoomed') self.master.title('fullscreen=' + str(fullscreen)) def end_fullscreen(self, event=None): self.master.wm_state('normal') #fullscreen = self.master.attributes('-fullscreen') fullscreen = self.master.wm_state('zoomed') self.master.title('fullscreen=' + str(fullscreen)) if __name__ == "__main__": root = tk.Tk() frame = Window(root) root.mainloop()Note that storing the info in a variable is no option, because other events outside of <F11> and <Escape> can change the window, p.e. clicking on the head of the window and drag it down when fullscreen, is changing the window to 'normal' RE: How to check if window is fullscreen or not - Gribouillis - Aug-01-2020 I don't have windows but fullscreen = (self.master.wm_state() == 'zoomed') perhaps
RE: How to check if window is fullscreen or not - delphinis - Aug-01-2020 Well, if the <F11> is pressed and the function is called, it sets the wm_state to 'zoomed' and on <Esc> to 'normal', so it can be determined with your proposal. But in the case someone clicks on the Maximize or reduce area on the top right of the window, this isn't change the wm_state. So unfortunately there's no reliable info if the window is 'zoomed'/'maximized' or not. Maybe i must find out how to bind this action of the mouse click. BBut what other additional events can also affect the window fullscreen? (E.g. minimize?) I just whanted a reliable info about if the window is fullscreen or not. But it seems that there are different kinds of "fullscreen"s... |