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


Messages In This Thread
How to check if window is fullscreen or not - by delphinis - Aug-01-2020, 10:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 770 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  Background Image FullScreen oguzcan 5 8,835 Apr-26-2020, 10:13 PM
Last Post: Larz60+
  tkinter window and turtle window error 1885 3 6,862 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,336 Oct-25-2019, 06:13 PM
Last Post: Huudzz
  [Tkinter] Python 3.5 tk fullscreen nuska012 2 8,092 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,369 Sep-20-2018, 01:27 AM
Last Post: eabs86
  update a variable in parent window after closing its toplevel window gray 5 9,276 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