无法更改BeeWare标签中的字体大小

2024-05-17 05:05:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在构建我的第一个BeeWare应用程序。这个应用程序本身是为一个Android设备设计的,我正在Linux(Ubuntu)机器上开发它

我的问题相当简单,但同样令人愤怒我似乎无法在任何给定的Label小部件中增加字体大小。这就是我的app.py文件的外观:

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

根据the tutorial,如果我移动到beeware venv环境,然后运行briefcase dev,那么应用程序运行时不会抛出异常。但是,无论我如何处理代码段size=50,无论我将字体大小设置为5还是500-文本大小保持不变。如果我在Android仿真器中运行相同的代码,我会遇到相同的问题:字体大小不变


Tags: fromimportselfbox应用程序titlestylemain