4

I want to create a Tkinter window but the following code does not line up with the top left corner of the screen:

import tkinter

class FullScreenWindow(tkinter.Frame):
    def __init__(self):
        self.root = tkinter.Tk()
        w = self.root.winfo_screenwidth()
        h = self.root.winfo_screenheight()
        x = 0
        y = 0
        self.root.geometry('%dx%d+%d+%d' % (w, h, x, y))

        self.root.mainloop()

if __name__ == "__main__":
    app = FullScreenWindow()

Can anyone let me know why? I thought geometry was measured from the top left corner.

enter image description here

Note that when I run PIL.ImageGrab.grab(bbox = (0,0,100,100)) the screen captures from the top left corner correctly.
I'm running Python 3.4 on Windows 10.

Edit: This is actually an issue with Windows 10. Pop-up windows (including the windows spawned by tkinter) are moved a few pixel to the right. For now I'll just manually nudge the windows to the left.

Tinoater
  • 41
  • 4
  • 1
    This might be a Windows 10 specific issue, since your code seems to be working fine for me on Windows 8.1. Note though that the width and height of the frame is measured without taking into account the window chrome, so on Windows 8.1, this takes up quite some pixels, making the position of the content also not 0/0. It’s maybe possible that this delta is kept on Windows 10 although there is a much thinner chrome. – poke Dec 29 '15 at 22:56
  • I thought that there was a full screen option in Tkinter, this just makes a screen that takes up most of the screen. – Untitled123 Dec 29 '15 at 23:00
  • Possible duplicate of [Display fullscreen mode on Tkinter](http://stackoverflow.com/questions/7966119/display-fullscreen-mode-on-tkinter) – Terry Jan Reedy Dec 30 '15 at 03:02
  • SO has a search box: use it. `[tkinter] fullscreen` returns several posts. https://stackoverflow.com/questions/7966119/display-fullscreen-mode-on-tkinter, for instance, gives two solutions. – Terry Jan Reedy Dec 30 '15 at 03:05

1 Answers1

0

After app=Full ScreenWindow(), insert app.state('zoomed').

Snippet:

    app=Full ScreenWindow()
    app.state('zoomed')
Greg G
  • 135
  • 1
  • 11