0

In my Tkinter application I use diagrams, texts and images with a fixed length and height. If I run the application on another computer with the same screen resolution as the computer on which I wrote the Tkinter application, everything will be displayed correctly.

If the Tkinter application is run on a computer with a lower screen resolution, the images, texts and diagrams are partly cut off. They are therefore no longer displayed fully.

To illustrate this, I have created a minimal example, where I use buttons with fixed lengths:

from tkinter import *

root = Tk()
root.attributes('-zoomed', True)          # For Linux user: maximaizes window
#root.state('zoomed')                     # For windows user use root.state('zoomed') 
                                          #instead         

Button(root, text = "Replacement for the main content ", padx = 450, pady=30).grid(row = 0, column = 0)
Button(root, text = "Replacement for an image, diagram, text", pady = 20).grid(row = 0, column = 1, padx = 5)


mainloop()

If I use the same screen resolution as I used when creating the application (in this case 1366 x 768), everything will be displayed correctly:

enter image description here

For a lower resolution (1280 x 720) a part is cut off:

enter image description here

Do either of you know how I can fix this problem?

  • The obvious solution is "don't use fixed size widgets". Is there a reason you specifically want to force such huge amounts of padding? – Bryan Oakley Aug 05 '20 at 12:48
  • The button widget is just an example. in my application i instead use plots for example. –  Aug 05 '20 at 16:21
  • The question remains: is there a reason you're using fixed-width plots? Does the code you're using for plots support growing and shrinking the plots to fit the space allocated to them? Also what exactly are you looking for as a "fix"? If your plots can be stretched or shrunk, is that a good solution? Or, are you asking how to make scrollbars? The question you're asking is highly dependent on exactly what sort of things you have in the UI and what limitations they have. – Bryan Oakley Aug 05 '20 at 16:45

0 Answers0