I think I'm missing something obvious but I can't figure it out myself.
I'm building a Mac App from Python 2.7 using PyInstaller (running the dev3.3 version). The app works fine, no issues. At the beginning there's a small window for updates which is built using Tkinter.
After building the app with PyInstaller (running the oneflie option) I get two files( ls -al
outcome):
-rwxr-xr-x 1 karoldra staff 62756614 8 lis 11:08 mac
drwxr-xr-x 3 karoldra staff 102 8 lis 11:09 mac.app
Here's the structure of that folder:
Basically - the mac.app package contains exactly the same mac file as the main folder.
The issues is that I get a different resolution in my Tkinter window depending on which file I actually run. Here's a sample of the Tkiter window:
mac
filemac.app
file As you can see the bottom ones resolution is much lower for some reason...
Can somebody tell me why this is happening and how to solve this issue?
Executed 'tkinter._text ()' in a shell and it appears to work fine. All my uses of tkinter also appear to work fine under all versions of 3.5 under normal use of python. Only tkinter problem I'm having is with PyInstaller. Verified the exact version of Tcl/Tk installed with 'tkinter.Tcl ().eval ('info patchlevel')' and it reported '8.6.4'.
The second method is the use of the ctypes Python library. This following setting in the ctypes library sets “DPI” awareness. DPI stands for Dots per inch, another way of measuring screen resolution. Keep in mind this will also effect the size of the tkinter window.
Keep in mind this will also effect the size of the tkinter window. Basically, you increasing the pixel density by increasing scaling, hence you will have to increase the number of pixels to maintain the same size as before. Adjust the value in the brackets to see what suits your screen the best.
I have a Tkinter GUI battleship game application I wrote that I am trying to convert to a .app file so I can run it easily on Mac OS X computers. After cd ing to the directory with both the main .py file, and all the subfiles (three other python files, a json file, and an icon file), I am executing the following command:
Eventually I found the answer by...carefully reading the docs ;) There's this one line which solve my problem:
For example, when you use PyQt5, you can set NSHighResolutionCapable to True to let your app also work in retina screen
In case someone else is seeing this problem on MacOs here's the answer:
My spec file was missing the High Resolution setting specified by the info_plist
parameter. Here's an example:
app = BUNDLE(exe,
name='myscript.app',
icon=None,
bundle_identifier=None
info_plist={
'NSHighResolutionCapable': 'True'
},
)
Hope it will help someone else too!!! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With