使用Pyqt做了一个小工具,现在想在小工具中添加一个label,点击label可以使用默认浏览器打开html文件,请问应该如何实现呢
可以调用 ShellExecute API函数(仅限Windows),这样可以调用你的系统默认的浏览器打开网页
import subprocess
# 假设你的html文件路径和文件名如下
html_file_path = r'C:\Users\username\Desktop\test.html'
# 调用系统cmd命令打开本地HTML文件
subprocess.run(['cmd', '/c', 'start', html_file_path], check=True)
不知道你这个问题是否已经解决, 如果还没有解决的话:虽然是pyqt,但是API都看C++的.
查看scaledContents : bool
的属性
This property holds whether the label will scale its contents to fill all available space.
When enabled and the label shows a pixmap, it will scale the pixmap to fill the available space.
This property’s default is false.
这个属性呢保存是否让标签缩放其内容来填充整个可用空间.
当我们启用这个属性标签显示一个图片.它就会缩放图片填充可用空间.
这个属性默认是false.