Python Forum
How to check if window is fullscreen or not
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if window is fullscreen or not
#1
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'
Reply
#2
I don't have windows but fullscreen = (self.master.wm_state() == 'zoomed') perhaps
Reply
#3
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...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 344 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  Background Image FullScreen oguzcan 5 8,446 Apr-26-2020, 10:13 PM
Last Post: Larz60+
  tkinter window and turtle window error 1885 3 6,624 Nov-02-2019, 12:18 PM
Last Post: 1885
  [pyglet] Why is screen blank when displaying a gif when setting fullscreen = True ? Huudzz 0 2,251 Oct-25-2019, 06:13 PM
Last Post: Huudzz
  [Tkinter] Python 3.5 tk fullscreen nuska012 2 7,945 Dec-11-2018, 06:56 AM
Last Post: jfong
  [Tkinter] Multiple frames with tkinter - How to make them run on fullscreen mode eabs86 3 18,205 Sep-20-2018, 01:27 AM
Last Post: eabs86
  update a variable in parent window after closing its toplevel window gray 5 8,977 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020