GUI内的打开指南

时间:2018-07-12 12:53:16

标签: python user-interface python-sphinx

我用Python编写了一个GUI,并使用Sphinx编写了文档。

我想尝试放置一个帮助按钮,以使用指南打开HTML文件。

有帮助吗?

1 个答案:

答案 0 :(得分:1)

这是对我有用的解决方案: 我首先在GUI(使用QT设计器创建)中添加了菜单选项

self.actionHelp.triggered.connect(self.handle_help_menu)

然后在GUI初始化时

os.chdir('docs')
import subprocess
subprocess.check_output('make html',shell=True)
subprocess.check_output('make latex',shell=True)

与打开包含该指南的html的菜单相关的功能是:

def handle_help_menu(self):
    import webbrowser
    url='file://' + os.path.realpath('./docs/build/html/index.html')
    webbrowser.get(using='google-chrome').open(url,new=2);
相关问题