当前位置: 首页>>代码示例>>Python>>正文


Python QTextBrowser.setSearchPaths方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QTextBrowser.setSearchPaths方法的典型用法代码示例。如果您正苦于以下问题:Python QTextBrowser.setSearchPaths方法的具体用法?Python QTextBrowser.setSearchPaths怎么用?Python QTextBrowser.setSearchPaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QTextBrowser的用法示例。


在下文中一共展示了QTextBrowser.setSearchPaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HelpForm

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setSearchPaths [as 别名]
class HelpForm(QDialog):
    def __init__(self,  page,  parent=None):
        super(HelpForm, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowModality(Qt.WindowModal)
        # actions
        backAction = QAction(QIcon(":/back.png"), "&Back", self)
        backAction.setShortcut(QKeySequence.Back)
        homeAction = QAction(QIcon(":/home.png"), "&Home", self)
        homeAction.setShortcut("Home")
        self.pageLabel = QLabel()
        #toolbar
        toolBar = QToolBar()
        toolBar.addAction(backAction)
        toolBar.addAction(homeAction)
        toolBar.addWidget(self.pageLabel)
        self.textBrowser = QTextBrowser()
        # layout
        layout = QVBoxLayout()
        layout.addWidget(toolBar)
        layout.addWidget(self.textBrowser, 1)
        self.setLayout(layout)
        # signals and slots
        backAction.triggered.connect(self.textBrowser.backward)
        homeAction.triggered.connect(self.textBrowser.home)
        self.textBrowser.sourceChanged.connect(self.updatePageTitle)
        self.textBrowser.setSearchPaths([":/help"])
        self.textBrowser.setSource(QUrl(page))
        self.resize(400, 600)
        self.setWindowTitle("{0} Help".format(
            QApplication.applicationName()))
    def updatePageTitle(self):
        self.pageLabel.setText(self.textBrowser.documentTitle())
开发者ID:imagingearth,项目名称:Rapid-GUI-Programming-with-Python-and-Qt---PyQt5-codes,代码行数:35,代码来源:helpform.py

示例2: THelpForm

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setSearchPaths [as 别名]
class THelpForm(QWidget):
    
    def __init__(self, parent, title, path):
        #super().__init__(parent, Qt.WA_DeleteOnClose )
        super().__init__(parent, Qt.Window)
        
        self.text_browser   = QTextBrowser(self)
        #self.text_browser  = QWebEngineView(self)
        self.back_button    = QPushButton('Back', self)
        self.forward_button = QPushButton('Forward', self)
        self.close_button   = QPushButton('Close', self)
        
        self.layout = QVBoxLayout(self)
        self.btn_widget = QWidget(self)
        self.btn_layout = QHBoxLayout(self.btn_widget)
        self.btn_layout.addWidget(self.back_button)
        self.btn_layout.addWidget(self.forward_button)
        self.btn_layout.addStretch(1)
        self.btn_layout.addWidget(self.close_button)
        
        self.shortcutEscape  = QShortcut(QKeySequence(Qt.Key_Escape), self)
        self.shortcutEscape.activated.connect(self.close)
        
        self.layout.addWidget(self.btn_widget)
        self.layout.addWidget(self.text_browser)
        
        self.back_button.clicked.connect(self.text_browser.backward)
        self.forward_button.clicked.connect(self.text_browser.forward)
        self.close_button.clicked.connect(self.close)
        
        
        self.text_browser.setSearchPaths([os.path.join(resources_path, 'doc')])
        self.text_browser.setSource(QUrl(path))
#       f = QFont()
#       f.setPointSize(14)
#       self.text_browser.setFont(f)
        
        Settings = QSettings('kicad-tools', 'Schematic Component Manager')

        if Settings.contains('help-window'):
            self.restoreGeometry(Settings.value('help-window'))
            #pos_x, pos_y, width, height = Settings.value('help-window')
        else:
            pos_x, pos_y, width, height = 0, 0, 640, 640
            self.setGeometry(pos_x, pos_y, width, height)
        
        self.window().setWindowTitle(title)
        self.show()
    #--------------------------------------------------------------------------------
    def closeEvent(self, event):
        Settings = QSettings('kicad-tools', 'Schematic Component Manager')
        Settings.setValue( 'help-window', self.saveGeometry() )
开发者ID:harryzhurov,项目名称:kicad-tools,代码行数:54,代码来源:scmgr.py


注:本文中的PyQt5.QtWidgets.QTextBrowser.setSearchPaths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。