1 year ago

#333123

test-img

user13017933

Why does the font on my tkinter app look bumpy or unclear?

The font on my Debian bullseye OS normally looks just fine. However, when I create an app using tkinter and place text on it, the text looks awful. I expect my tkinter apps in general to show nice font. A screenshot of how the font appears is posted at the bottom.

These are the steps I've taken to try and resolve this issue.

  1. I installed: ttf-mscorefonts-installer
  2. I created a fonts.conf file in the directory .config/fontconfig/fonts.conf with the code as follows:

fontconfig

While my fonts do looks much better on my OS after taking these steps, the text on my tkinter apps still look awful. For additional information, here is the code I used to my app on tkinter:

from tkinter import *
from quiz_brain import QuizBrain


THEME_COLOR = "#375362"


class QuizInterface:

    def __init__(self, quiz_brain: QuizBrain):
        self.quiz = quiz_brain
        self.window = Tk()
        self.window.title("Quizzler")
        self.window.config(padx=20, pady=20, bg=THEME_COLOR)

        self.score_label = Label(text="Score: 0", fg="white", bg=THEME_COLOR)
        self.score_label.grid(row=0, column=1)

        self.canvas = Canvas(width=300, height=250, bg="white")
        self.question_text = self.canvas.create_text(
            150,
            125,
            width=280,
            text="Some Question Text",
            fill=THEME_COLOR,
            font=("Courier", 20, "italic"))
        self.canvas.grid(row=1, column=0, columnspan=2, pady=50)

        true_img = PhotoImage(file="images/true.png")
        self.true_button = Button(
            image=true_img,
            command=self.true_pressed,
            highlightthickness=0
        )
        self.true_button.grid(row=2, column=0)

        false_img = PhotoImage(file="images/false.png")
        self.false_button = Button(
            image=false_img,
            command= self.false_pressed,
            highlightthickness=0
        )
        self.false_button.grid(row=2, column=1)

        self.get_next_question()

        self.window.mainloop()

python

linux

debian

tkinter-text

0 Answers

Your Answer

Accepted video resources