chrisn89
chrisn89

Reputation: 3

Tkinter Screen Change as Altered Display - Easy way to rectify?

I understand that a few others have asked similar questions although i cant find any that match my specific issue so please be gentle.

My issue is every display i use results in my Tkinter display completely changing and im having to reposition and resize everything again through trial and error which is massively time consuming. Is there an easy way around this? I've used place and pixel sizes in the script so i think its everytime the resolution changes im having to start over.

Anyway I thought i set the resolution to the Rpi touchscreen and built the GUI to that. However, now i've bought the touchscreen the GUI isn't even close to fitting it.

I'm not that keen on having to resize and reposition everything again so if there is an easy way to achieve what i'm after i'd be grateful if someone could share it. If not, i'll just have to get on with it.

Cheers chris

Upvotes: 0

Views: 813

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 385800

The problem is that you are using place. place should be avoided for exactly this reason. If you learn to use grid and pack properly, and do not call pack_propagate(0) or grid_propagate(0) unless you are certain it is the only solution to your problem, tkinter will do a fantastic job of adapting to different screen resolutions, font sizes, and user preferences.

In other words, the answer to "[is there] an easy way to achieve what I'm after" is "use grid and pack, and avoid place".

Upvotes: 1

SneakyTurtle
SneakyTurtle

Reputation: 1857

You probably want to utilize the width and height aspects of your screen, and make your program relative to those instead of making everything fixed/static.

You can do this by calling winfo_width() or winfo_height() on your widget to get it's size. After you have this, instead of making an oval at 200 pixels if your screen is 400 pixels in width, you can make it relative, i.e. at width/2 (if you declare winfo_width()as a variable).

Upvotes: 0

Related Questions