简体   繁体   中英

Python tkinter button font is getting pixelated in bigger sizes

First of all, thank you for trying to help me out. I am currently programming my first GUI with tkinter and i try to create buttons with big fonts, cause i want to create a program for visually impaired people. Sadly I have two problems i can't solve with the internet on my own ..

This is the relevant part of my code: (sorry for the german variables)

import tkinter
from tkinter import *
from tkinter import font
import tkinter.messagebox

class Oberflaeche(tkinter.Frame):
    def __init__(self, master=None):
        tkinter.Frame.__init__(self, master)
        self.pack()

        MyFont = font.Font(family='times', size=50)

        self.close_window = tkinter.Button(self, font=MyFont, text="Programm \nbeenden", command=self.close_window, bg="white", height = 3, width = 18, bd=3, relief="solid")
        self.close_window.pack()

    def close_window(self): 
        root.destroy()
root = tkinter.Tk()
root.title("Prototyp MVP")
root.minsize(width=300, height=300)
root.configure(background='white')
oberflaeche = Oberflaeche(master=root)
oberflaeche.mainloop()

when I try to change the font tkFont.Font is not working. There is the Error: NameError: name 'tkFont' is not defined

That is the reason I tryed font.Font. But no matter how I change the font family or type, it always looks awful and pixelated....

Picture of the failed Button
I am using python 3.5.5, Ubuntu 16.04 and tk 8.6.8.

I am using Spyder(python 3.6) here is the result; i.hizliresim.com/6NgZlW.jpg Maybe because of version? Actually your program is working succesfully ı did not change any codes ı tried on my pc and the result is perfect(Win10 Spyder(Python 3.6).)

i am also used to Jupyter notebook and i was trying with VS Code everything is working well. I suggest you trying to play around with scaling and let me know is it working for you?

Scaling of Tkinter GUI in 4k (3840*2160) resolution

Results

Jupyter

Jupyter笔记本

VS Code

VS代码

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM