如何使用 pyi_splash.update_text("message") 在启动屏幕上显示文本消息?

问题描述 投票:0回答:1

我正在尝试使用命令

pyi_splash.update_text('message')

在启动屏幕上显示短信

此处的示例代码展示了如何使用 pyinstaller 来显示启动画面图像,然后稍后关闭添加启动画面

该示例和 pyi_splash 文档提到了 .update_text() 命令文档

但我在启动屏幕上没有看到任何文字。

在调用update_text之前我已确认

pyi_spalsh.isalive()
True
但仍然没有成功

我运行在Windows系统上。它只能在 Linux 上运行吗?

有什么建议吗?

复制上面链接的示例,我运行

pyinstaller --splash myimage.png
来构建可执行文件。 我的主函数顶部有这段代码:

if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
    import pyi_splash
    if (pyi_splash.is_alive()):
        print('Splash found alive')
    else:
        print('splash not found')
    pyi_splash.update_text('UI Loaded ...')

命令提示符显示

Splash found alive
update_text
不会显示任何文本。 然后主函数在调用
pyi_splash.close()
之前继续执行其他操作,这会正确关闭启动屏幕

我是否需要设置一些其他参数来设置文本大小/位置/颜色/不透明度,以便它在启动屏幕中可见

python pyinstaller splash-screen
1个回答
0
投票

答案是默认情况下关闭文本显示,如使用规范文件中所述,特别请参阅Splash Target

部分

您必须手动编辑 pyinstaller 首次运行时生成的 .spec 文件。

text_pos=None,
替换为
text_pos=(10,50),

等坐标位置

然后运行

pysintaller yourFile.spec
从规范文件构建 exe

© www.soinside.com 2019 - 2024. All rights reserved.