Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter Python 3 scaling issue on MacOS

I am maintaining an application in Python3/Tkinter and add an issue opened by my first user on MacOS. This is the main screen on Windows in 1080p (Linux shows similar result) :

enter image description here

On MacOS in 2560 x 1600, everything in the UI is scaled approximatively with a 2x size :

enter image description here

The original code is that one :

self.window = Tk.Tk()
self.window.resizable(False,False)
if platform.system() == 'Windows' :
   self.window.iconbitmap('bestarcade.ico')
self.window.title(title)

I tried enforcing resolution :

self.scriptDir = scriptDir
self.window = Tk.Tk()
self.window.geometry("930x950")
self.window.resizable(False,False)

It makes things worse, the application window in MacOS is just cut a little more short

I tried scaling :

self.scriptDir = scriptDir
self.window = Tk.Tk()
self.window.tk.call('tk','scaling',0.5)
self.window.resizable(False,False)

And it doesn't change anything from the standard solution, as if it's not taken into account

Now from what I read, this seems to be Tkinter bug on MacOS, and the only solution I found require to hard set dimension for each fonts and UI components or something like that

Is there anything more simple I could try ?

like image 701
Voljega Avatar asked Sep 11 '26 03:09

Voljega


1 Answers

I have the exact same problem!! It would always be a little short, no matter what I tried.

In the end, this is what I did. See if it works for you.

from tkinter import *
window = Tk()
window.title("Whatever you want")

window.focus()

HEIGHT = window.winfo_screenwidth()
WIDTH = window.winfo_screenheight()
RESOL = str(HEIGHT) + "x" + str(WIDTH+7) + "+" + str(-7) + "+" + str(0)
window.geometry(RESOL)

Hope this helps you!

like image 52
10 Rep Avatar answered Sep 12 '26 16:09

10 Rep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!