Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Tkinter application fit on screen

I have designed an application using the Tkinter module from Python, on my 17" screen.

Is there a way to make this app fit on lower resolution screens? I have tried to run it on a 14" screen, and the app doesn`t fit well.

Thank you.

like image 724
Nick Dragosh Avatar asked Jun 21 '15 13:06

Nick Dragosh


2 Answers

You can get the screen resolution then input them in your root.geometry, this way:

from Tkinker import *

root = Tk()

width, height = root.winfo_screenwidth(), root.winfo_screenheight()

root.geometry('%dx%d+0+0' % (width,height))

root.mainloop()
like image 134
Iron Fist Avatar answered Oct 29 '22 20:10

Iron Fist


You need to use this one line:

root.state('zoomed') #works on all operating systems

root = tkinter.Tk()
root.state('zoomed')

This will fit the window perfectly to the display. (Note: This is not full screen function. Full screen means the window will also cover the taskbar, but in this code window fits all over the screen except the taskbar)

like image 42
user20254366 Avatar answered Oct 29 '22 21:10

user20254366