Adjust Tkinter window and widjets according to screen resolution

Asked

Viewed 2,903 times

0

Hi, I’m developing a python GUI with Tkinter. I’m trying to get the widgets setup I set up to fit the monitor resolution.

I applied the following code.

    janela = tk.Tk()

    lado, cima = (janela.winfo_screenwidth()), (janela.winfo_screenheight())

    janela.geometry('%dx%d+0+0' % (lado,cima))

But this only assures me that the window will open at the resolution of the monitor but does not adjust the pixel dimensions of widgets with the window.

such adjustment is possible with Tkinter?

  • Tkinter is not very powerful but you will have to use the layout pack manager, search on the pack you will understand better.

  • Patrick Machado, good morning! I bought some Kivy courses and, from what I’ve seen, it’s possible to adjust the widgets by resizing them by percentage. In Tkinter I have the same doubt as you.

1 answer

0

Hi, sorry I didn’t answer right away, I was too busy. But the thing is, there’s no code that I know of that widgets, frames or/and label’s as a dimension in which it fits to the monitor. Because think with me, if you pass a IDLE pro parameter to adjust the main screen to the monitor is ok, but then you should set a size for the objects placed inside the screen that will print, as, widgets, frames and label’s. Then the best output at the moment would be to organize your objects with layout manager Pack or Grid, could be in Row and Column, if you do not set size or do not set the place where it should stand, will give error, but its output is here:

Assemble your code structure, put buttons, label, etc., but at the end you pack everything and centralize. So when another user or yourself will open the program on another computer with another monitor resolution, always the buttons, widgets and label’s will be in the center.

Well I hope I’ve really helped, and I’m sorry again for not responding so soon.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.