Posts: 10
Joined: Thu Dec 08, 2016 4:28 am

Tkinter based UI in yocto has only one font size

Sat May 27, 2023 2:28 pm

I have a python 3 app with a TKInter interface. Very simple UI, there are 4 frames each with a headline (big text) and a status (small text). It works well on my Ubuntu 22.04 desktop.

Code: Select all

fr = Frame(root, width=width / 2, height=height / 2, background='black')
self.headline_label = Label(fr, textvariable=self.headline, background='black', foreground='green', font=("Arial", 40))
self.stats_label = Label(fr, textvariable=self.stats, background='black', foreground='green', font=("Arial", 25)), relx=0.5, rely=0.3), relx=0.5, rely=0.6)
column = int(position / 2)
fr.grid(column=column, row=position % 2)
Final deployment is a Raspberry Pi 3B, Official 7in LVDS display, Yocto Poky Dunfell. Base image is core-image-x11. My recipe is very minimal, add a user, install my python script, install python libraries it depends on, install config file for my python script (api token, etc) and install mini_x session script which auto-launches my script inside of matchbox-window-manager as the new user.

The problem is both the headline and the status label are the same size. I'm not sure either are the correct size. I have attempted to change the font sizes and the font name ("Mono", "Liberation", "LiberationMono-Regular") but it stays the same. I'm not picky about what font is used, it just need to be big enough to see from a few feet away.

User avatar
Posts: 5615
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: Tkinter based UI in yocto has only one font size

Fri Jun 30, 2023 4:30 pm

I suspect your super-minimal installation doesn't have (the rather large) fontconfig system. If the fc-list command doesn't work, then you don't have it for sure. You might want to look at adding the liberation-fonts package to get an Arial-compatible scalable font.

Otherwise you're stuck very very simple bitmap fonts of the kind viewable with xfontsel and listed by xlsfonts.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Advanced users”