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


Python QTextBrowser.setProperty方法代码示例

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


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

示例1: NewProjectManager

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setProperty [as 别名]
class NewProjectManager(QDialog):

    def __init__(self, parent=None):
        super(NewProjectManager, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_NEW_PROJECT)
        self.setMinimumHeight(500)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel(translations.TR_CHOOSE_TEMPLATE))
        vbox.addWidget(QLabel(translations.TR_TAB_PROJECTS))

        hbox = QHBoxLayout()
        self.list_projects = QListWidget()
        self.list_projects.setProperty("wizard", True)
        hbox.addWidget(self.list_projects)

        self.list_templates = QListWidget()
        self.list_templates.setProperty("wizard", True)
        hbox.addWidget(self.list_templates)

        self.text_info = QTextBrowser()
        self.text_info.setProperty("wizard", True)
        hbox.addWidget(self.text_info)

        vbox.addLayout(hbox)

        hbox2 = QHBoxLayout()
        cancel = QPushButton(translations.TR_CANCEL)
        choose = QPushButton(translations.TR_CHOOSE)
        hbox2.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding,
                            QSizePolicy.Fixed))
        hbox2.addWidget(cancel)
        hbox2.addWidget(choose)
        vbox.addLayout(hbox2)

        self.template_registry = IDE.get_service("template_registry")
        categories = self.template_registry.list_project_categories()
        for category in categories:
            self.list_projects.addItem(category)

        cancel.clicked['bool'].connect(self.close)
        choose.clicked['bool'].connect(self._start_wizard)
        self.list_projects.itemSelectionChanged.connect(self._project_selected)
        self.list_templates.itemSelectionChanged.connect(self._template_selected)

    def _project_selected(self):
        self.list_templates.clear()
        item = self.list_projects.currentItem()
        category = item.text()
        for template in self.template_registry.list_templates_for_cateogory(
                category):
            item = QListWidgetItem(template.type_name)
            item.setData(Qt.UserRole, template)
            item = self.list_templates.addItem(item)

    def _template_selected(self):
        item = self.list_templates.currentItem()
        ptype = item.data(Qt.UserRole)
        self.text_info.setText(ptype.description)

    def _start_wizard(self):
        return QMessageBox.critical(self, "Beta Info", "Can not construct this segment!")
        item = self.list_templates.currentItem()
        if item is not None:
            ptype = item.data(Qt.UserRole)
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:66,代码来源:new_project_manager.py

示例2: NewProjectManager

# 需要导入模块: from PyQt5.QtWidgets import QTextBrowser [as 别名]
# 或者: from PyQt5.QtWidgets.QTextBrowser import setProperty [as 别名]
class NewProjectManager(QDialog):

    def __init__(self, parent=None):
        super(NewProjectManager, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_NEW_PROJECT)
        self.setMinimumHeight(500)
        vbox = QVBoxLayout(self)
        vbox.addWidget(QLabel(translations.TR_CHOOSE_TEMPLATE))
        vbox.addWidget(QLabel(translations.TR_TAB_PROJECTS))

        hbox = QHBoxLayout()
        self.list_projects = QListWidget()
        self.list_projects.setProperty("wizard", True)
        hbox.addWidget(self.list_projects)

        self.list_templates = QListWidget()
        self.list_templates.setProperty("wizard", True)
        hbox.addWidget(self.list_templates)

        self.text_info = QTextBrowser()
        self.text_info.setProperty("wizard", True)
        hbox.addWidget(self.text_info)

        vbox.addLayout(hbox)

        button_box = QDialogButtonBox(
            QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
        choose_button = button_box.button(QDialogButtonBox.Ok)
        choose_button.setText(translations.TR_CHOOSE)
        # hbox2 = QHBoxLayout()
        # cancel = QPushButton(translations.TR_CANCEL)
        # choose = QPushButton(translations.TR_CHOOSE)
        # hbox2.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding,
        #                    QSizePolicy.Fixed))
        # hbox2.addWidget(cancel)
        # hbox2.addWidget(choose)
        # vbox.addLayout(button_box)
        vbox.addWidget(button_box)

        self.template_registry = IDE.get_service("template_registry")
        categories = self.template_registry.list_project_categories()
        for category in categories:
            self.list_projects.addItem(category)

        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        # cancel.clicked.connect(self.close)
        # choose.clicked.connect(self._start_wizard)
        self.list_projects.itemSelectionChanged.connect(
            self._project_selected)
        self.list_templates.itemSelectionChanged.connect(
            self._template_selected)
        self.list_projects.setCurrentRow(0)

    def accept(self):
        logger.debug("Accept...")
        self._start_wizard()
        super().accept()

    def _project_selected(self):
        self.list_templates.clear()
        item = self.list_projects.currentItem()
        category = item.text()
        for template in self.template_registry.list_templates_for_cateogory(
                category):
            item = QListWidgetItem(template.type_name)
            item.setData(Qt.UserRole, template)
            item = self.list_templates.addItem(item)
        self.list_templates.setCurrentRow(0)

    def _template_selected(self):
        item = self.list_templates.currentItem()
        ptype = item.data(Qt.UserRole)
        self.text_info.setText(ptype.description)

    def _start_wizard(self):
        item = self.list_templates.currentItem()
        if item is not None:
            project_type = item.data(Qt.UserRole)

        ninja = IDE.get_service("ide")
        wizard = WizardProject(project_type, ninja)
        wizard.show()
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:85,代码来源:new_project_manager.py


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