22

I have developed a python app with Tkinter on a Mac. It involves forms, and canvas drawings. On the Mac, it looks great. However on my Dell laptop (4K display, and more powerful than my Mac), the Tkinter ui appears very pixelated and certain elements are located slightly differently. What is this problem known as and what can I do to render Tkinter better on Dell Windows 10 or other platforms in general? Here is a screen shot of the same part of the UI (showing form and canvas drawing)...

Windows(bad) enter image description here

Mac(normal)

enter image description here

Taku
  • 31,927
  • 11
  • 74
  • 85
Caspar Wylie
  • 2,818
  • 3
  • 18
  • 32
  • 3
    I have a qhd device , i am having the same issue with my apps , this thing is called scaling. You moved from a lower resolution to a 4k , python should auto scale but it doesn't. You can't do much but you can change your pc resolution to full hd instead of 4k. I starred your question i also want to know a proper solution without lowering my resolution – Dimitrios Filippou Mar 19 '17 at 13:58
  • A screenshot of the situation may help future users identify themselves (or not) with your situation. Moreover, it may help people here to reproduce your problem. – nbro Mar 19 '17 at 17:16
  • updated. cheers. – Caspar Wylie Mar 19 '17 at 17:30
  • Can you provide a code example of 1 or 2 lines being drawn so I can test it on my end. [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). I may have a work around but I need some code to test with. – Mike - SMT Jun 26 '17 at 18:26
  • Will You please give us your code, So that we should test. –  Jun 29 '17 at 09:57
  • The code is basic widgets such as Button(), etc. And a few line and circle canvas drawings. Nothing special. – Caspar Wylie Jun 29 '17 at 12:57
  • You may be running into limitations of the OS. The Windows API won't draw nice anti-aliased lines and shapes like you show in the Mac example. – Mark Ransom Jun 29 '17 at 15:41
  • Mac using TCL (built-in) but windows can do this performance without full source(Library). Windows used DLL as TCL source, did you know all DLL compiled for your machine ? Need hook graphic card resource if want same quality. – dsgdfg Jun 30 '17 at 05:16

3 Answers3

2

Antialiasing is only enabled for Tkinter canvas object in OSX . You can get the aggDraw lib: http://effbot.org/zone/tkinter-aggdraw.htm as a workaround, but otherwise you will get jagged lines when trying to draw on a canvas. Fonts however should be anti-aliased on all major platforms.

BHawk
  • 2,382
  • 1
  • 16
  • 24
  • 1
    Even with antialiasing the fonts will look different between Mac and Windows. See https://blog.codinghorror.com/font-rendering-respecting-the-pixel-grid/ which also has links to other discussions. – Mark Ransom Jun 29 '17 at 20:38
  • 1
    I agree. The more aggregious problem seems to be the jagged circles and lines though. I assumed that was the problem being asked about, not the fact that the fonts look different. – BHawk Jun 29 '17 at 21:11
0

enter image description here

The differences in the display of the same application are due to differences in render engines used by each Operating system.

This is coverd in a Pakt pub ebook called Tkinter GUI Application Development Blueprints

passage regarding this topic available here.

It may be a pain to do but it looks like the most common fix for this is to detect your enviroment and write independent styles using the external option database more info is available in the documentation here.

Seth Wahle
  • 166
  • 1
  • 2
  • 12
  • 2
    It's good to have a link to show where you got your quotes, but you should try and pull out the relevant passage into your answer. Otherwise if the link is taken down in future you answer is rendered meaningless. – Sam Redway Jun 30 '17 at 10:25
0

Setting your DPI awareness to 1 should resolve your issue

from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
758Gianni
  • 73
  • 1
  • 2
  • 6