Unable to Change Font Size in Toga Label
See original GitHub issueDescribe the bug
I’m building my first proper BeeWare app. My problem is fairly straightforward, but no less infuriating. I can’t seem to increase the font size within any given Label
widget. This is what my app.py file looks like:
To Reproduce As per the tutorial, build a basic BeeWare app, and then amend app.py as follows:
import toga
from toga.fonts import Font, SANS_SERIF
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
class Charon(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN))
title_label = toga.Label("Hello, world!")
title_label.font = Font(family=SANS_SERIF, size=50)
main_box.add(title_label)
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
def main():
result = Charon()
return result
Then run the app using briefcase dev
. (Running the app using briefcase run
, or using briefcase run android
- the app is intended for Android - seems to reproduce the same error.)
Expected behavior
I expected setting title_label.font = Font(family=SANS_SERIF, size=50)
would increase the size of the “Hello, world!” label. However, no matter what I do with the snippet size=50
- whether I set the font size to 5 or 500 - the size of the text remains unchanged. If I run the same code within an Android emulator, I run into the same issue: the font size doesn’t change.
Environment:
- Operating System: Linux (Ubuntu 20.04.1 LTS)
- Python version: 3.8.5
- Software versions:
- Briefcase: 0.3.4
- Toga: 0.3.0
Additional context I’ve also raised this issue as a StackOverflow question.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
I’ve also tried this:
The
padding=50
works as intended, butfont_size=50
still does nothing. No exceptions are raised.@Vipul-Cariappa Okay, I seem to have found a functional stop-gap method for fixing this bug, namely replacing my beeware-env/lib/python3.8/site-packages/toga_gtk/widgets folder with your toga_gtk/widgets folder. It would be awesome if your fix could get incorporated into the master branch. It works!