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


Python QVBoxLayout.count方法代码示例

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


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

示例1: InstallPage

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class InstallPage(QWidget):
    """Settings page for the installed plugins"""
    def __init__(self, parent, repo):
        """QWidget Dictionary -> Void
        Consumes the parent and the repository dictionary and sets up the
        install page in the settings area"""
        QWidget.__init__(self, parent)
        self._userPlugins = helper.getPlugins()
        self._repo = repo

        # Add a scrollArea that if they are more plugins that fit into the
        # settings page
        scrollArea = QScrollArea(self)
        scrollArea.setWidgetResizable(True)
        scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        baseLayout = QVBoxLayout()
        baseLayout.setAlignment(Qt.AlignTop)
        self.setLayout(baseLayout)
        baseWidget = QWidget()
        scrollArea.setWidget(baseWidget)
        baseLayout.addWidget(scrollArea)

        self._vbox = QVBoxLayout()
        baseWidget.setLayout(self._vbox)

    def update(self, userPlugins):
        """ListOfUserpluginEntry -> Void
        Consume a list of UserpluginEntry and repopulates the install page"""
        for i in reversed(range(self._vbox.count())):
            try:
                self._vbox.itemAt(i).widget().setParent(None)
            except AttributeError as e:
                qWarning("Can't call setParent of None type")

        labelText = "<h2>Install Plugins</h2>"
        if (len(self._repo["plugins"]) < 1):
            labelText += "<p>It seems we could not load the plugin repository.</p>"
            labelText += "<p style='color:red'>Make shure your internet connection is working and restart Enki.</p><p></p>"
        self._vbox.addWidget(QLabel(labelText))

        for entry in self._repo["plugins"]:
            isInstalled = helper.isPluginInstalled(entry["name"], userPlugins)
            if isInstalled:
                self._vbox.addWidget(pluginspage.PluginTitlecard(isInstalled))
            else:
                self._vbox.addWidget(InstallableTitlecard(entry, self))

    def addPluginToUserPlugins(self, installableTitlecard):
        """InstallableTitlecard -> Void
        Consumes an InstallableTitlecard and insert an PluginTitleCard instead
        of itself"""
        index = self._vbox.indexOf(installableTitlecard)
        name = installableTitlecard.modulename()
        pluginEntry = helper.initPlugin(name)

        if pluginEntry:
            self._userPlugins.append(pluginEntry)
            self._vbox.insertWidget(index,
                                    pluginspage.PluginTitlecard(pluginEntry))
开发者ID:bjones1,项目名称:enki,代码行数:61,代码来源:installpage.py

示例2: PluginFrame

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class PluginFrame(QFrame):
    def __init__(self, plugins, highlighted_plugins=None, parent=None):
        """
        :type plugins: list of Plugin
        :type highlighted_plugins: list of Plugin
        """
        super().__init__(parent)
        self.ui = Ui_FramePlugins()
        self.ui.setupUi(self)
        self.model = PluginListModel(plugins, highlighted_plugins=highlighted_plugins)
        self.ui.listViewPlugins.setModel(self.model)
        self.settings_layout = QVBoxLayout()
        self.ui.groupBoxSettings.setLayout(self.settings_layout)
        self.create_connects()

        try:
            self.restoreGeometry(constants.SETTINGS.value("{}/geometry".format(self.__class__.__name__)))
        except TypeError:
            pass


    def create_connects(self):
        self.ui.listViewPlugins.selectionModel().selectionChanged.connect(self.on_list_selection_changed)
        for plugin in self.model.plugins:
            if hasattr(plugin, "show_proto_sniff_dialog_clicked"):
                plugin.show_proto_sniff_dialog_clicked.connect(self.parent().parent().show_proto_sniff_dialog)

    def save_enabled_states(self):
        for plugin in self.model.plugins:
            constants.SETTINGS.setValue(plugin.name, plugin.enabled)

    @pyqtSlot()
    def on_list_selection_changed(self):
        i = self.ui.listViewPlugins.currentIndex().row()
        self.ui.txtEditPluginDescription.setText(self.model.plugins[i].description)

        if self.settings_layout.count() > 0:
            widget = self.settings_layout.takeAt(0).widget()
            self.settings_layout.removeWidget(widget)
            widget.setParent(None)

        self.settings_layout.addWidget(self.model.plugins[i].settings_frame)
开发者ID:NickMinnellaCS96,项目名称:urh,代码行数:44,代码来源:PluginFrame.py

示例3: PluginsPage

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class PluginsPage(QWidget):
    """Settings page for the installed plugins"""
    def __init__(self, parent):
        QWidget.__init__(self, parent)

        # Add a scrollArea that if they are more plugins that fit into the
        # settings page
        scrollArea = QScrollArea(self)
        scrollArea.setWidgetResizable(True)
        scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        baseLayout = QVBoxLayout()
        self.setLayout(baseLayout)
        baseWidget = QWidget()
        scrollArea.setWidget(baseWidget)
        baseLayout.addWidget(scrollArea)

        self._vbox = QVBoxLayout()
        baseWidget.setLayout(self._vbox)

    def update(self, userPlugins):
        """ListOfUserpluginEntry -> Void
        Consume a list of UserpluginEntry and repopulates the plugins page"""
        for i in reversed(range(self._vbox.count())):
            try:
                self._vbox.itemAt(i).widget().setParent(None)
            except AttributeError as e:
                qWarning("Can't call setParent of None type")

        self._vbox.addWidget(QLabel(
            """<h2>Installed Plugins: <code>%i</code></h2>
            <p>Add plugins by putting them into <code>%s</code></p>
            <p></p>""" % (len(userPlugins), PLUGIN_DIR_PATH)))
        for entry in userPlugins:
            self._vbox.addWidget(PluginTitlecard(entry))

        self._vbox.addStretch(1)
开发者ID:hlamer,项目名称:enki,代码行数:38,代码来源:pluginspage.py

示例4: Contacts

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class Contacts(QWidget):
    def __init__(self, db):
        self.dic_wind = {}
        self.dic_button = {}
        self.dic_err_win = {}
        self.layout = None
        self.mygroupbox = QGroupBox('Contacts list')
        self.myform = QFormLayout()
        self.scroll = QScrollArea()
        self.db = db
        self.google_api = Google()
        super().__init__()

    def init_ui(self):
        sender = self.sender()
        error = None
        if sender is not None:
            if sender.text() == '&VK':
                if not self.db.db_exists():
                    error = self.db.create(download_data(sender.text()))
                else:
                    error = self.db.update_database(
                        download_data(sender.text()))
            if sender.text() == '&Facebook':
                if not self.db.db_exists():
                    error = self.db.create(download_data(sender.text()))
                else:
                    error = self.db.update_database(
                        download_data(sender.text()))

        if error is not None:
            self.dic_err_win[error] = ErrorWindow(error)
            self.dic_err_win[error].init_ui()
        else:
            for friend in self.db.get_list_users():
                button = self.create_button(friend)
                self.myform.addRow(button)

            self.mygroupbox.setLayout(self.myform)

            self.scroll.setWidget(self.mygroupbox)
            self.scroll.setWidgetResizable(True)
            self.scroll.setFixedHeight(600)
            self.layout = QVBoxLayout(self)
            self.layout.addWidget(self.scroll)

    def create_button(self, friend):
        name = friend
        button = QPushButton(name, self)
        self.dic_button[name] = button
        inf_friend = self.db.get_user_inf(friend)
        if inf_friend['picture'] != '':
            logo = inf_friend['picture']

        self.dic_wind[name] = Window(name, logo,
                                     inf_friend, self, self.google_api)
        button.clicked.connect(lambda: self.dic_wind[name].init_ui())
        return button

    def import_all_contacts(self):
        list_users = self.db.get_list_users()
        if len(list_users) != 0:
            open_new('https://contacts.google.com')
            for contact in list_users:
                contact_data = self.db.get_user_inf(contact)
                self.google_api.create_contact(
                    self.google_api.create_xml(contact_data))

    def redrawing(self):
        self.clear_window()
        self.init_ui()

    def clear_layout(self, layout):
        for i in range(layout.count()):
            if layout.itemAt(i) is not None:
                layout.itemAt(i).widget().setParent(None)

    def clear_window(self):
        for i in range(self.layout.count()):
            if self.layout.itemAt(i) is not None:
                if self.layout.itemAt(i).layout() is not None:
                    self.clear_layout(self.layout.itemAt(i).layout())
                    self.layout.itemAt(i).layout().setParent(None)
                if self.layout.itemAt(i).widget() is not None:
                    self.layout.itemAt(i).widget().setParent(None)
开发者ID:vakyym07,项目名称:export_contacts,代码行数:87,代码来源:export_contacts.py

示例5: MenuView

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class MenuView(QScrollArea):

    def __init__(self, parent=None, update_func=None, params=None):
        super().__init__(parent)

        self.setMaximumWidth(200)

        self.params = params

        self.H1_HEIGHT = 50
        self.H2_HEIGHT = 50
        self.SIDE_MARGIN = 5
        self.H1_FONT_SIZE = 18
        self.H2_FONT_SIZE = 18
        self.H3_FONT_SIZE = 16
        self.TEXT_FONT_SIZE = 14

        style = '''
            QPushButton:flat{
                text-align: left;
                padding: 1ex;
            }
            QPushButton:pressed{
                background-color: silver;
            }
            QPushButton:hover:!pressed{
                font: bold;
            }
            '''
        self.setStyleSheet(style)

        self.update_func = update_func

        self.inner = QWidget(self)

        self.vbox = QVBoxLayout(self.inner)
        self.vbox.setSpacing(0)
        self.vbox.setContentsMargins(0, 0, 0, 0)
        self.vbox.setAlignment(Qt.AlignTop)

        topframe = QFrame()
        topframe.setStyleSheet('background-color: white')
        topframe.setFixedHeight(self.H1_HEIGHT)

        lbl_h1 = QLabel('Contents', topframe)
        fnt = lbl_h1.font()
        fnt.setPointSize(self.H1_FONT_SIZE)
        lbl_h1.setFont(fnt)
        lbl_h1.setFixedHeight(self.H1_HEIGHT)
        lbl_h1.setMargin(self.SIDE_MARGIN)

        self.vbox.addWidget(topframe)

        self.list_button = []
        if self.params.lang == 'en':
            self.edit_button('Introduction')
        else:
            self.edit_button('はじめに')

        self.inner.setLayout(self.vbox)

        self.setWidget(self.inner)

    def buttonClicked(self, text):
        if self.update_func is not None:
            self.update_func(text)

    def edit_button(self, text, delete=False):
        if delete:
            for i in range(self.vbox.count()):
                widget = self.vbox.itemAt(i).widget()
                if type(widget) == QPushButton:
                    if widget.text() == '-' + text:
                        self.vbox.removeWidget(widget)
                        widget.deleteLater()
                        widget = None
            return

        if text not in self.list_button:
            self.list_button.append(text)
            btn = QPushButton('-' + text, self.inner)
            btn.setFlat(True)
            fnt = btn.font()
            fnt.setPointSize(self.TEXT_FONT_SIZE)
            btn.setFont(fnt)
            btn.clicked.connect(lambda: self.buttonClicked(text))
            self.vbox.addWidget(btn)

        self.buttonClicked(text)
开发者ID:canard0328,项目名称:malss,代码行数:91,代码来源:menuview.py

示例6: TopicsTab

# 需要导入模块: from PyQt5.QtWidgets import QVBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QVBoxLayout import count [as 别名]
class TopicsTab(QWidget):
    configChanged = pyqtSignal()
    def __init__(self):
        super(QWidget, self).__init__()
        self.config = None
        self.count = 0
        self.topicRows = {}

        self.nameEdit = QLineEdit()
        self.dataTypeComboBox = QComboBox()
        self.fillDataTypes()
        self.opTypeComboBox = QComboBox()
        self.opTypeComboBox.addItem('sub', 'Subscribe')
        self.opTypeComboBox.addItem('pub', 'Publish')
        self.addButton = QPushButton('Add')
        self.addButton.clicked.connect(self.addClicked)

        self.mainLayout = QVBoxLayout()
        rowLayout = QHBoxLayout()
        rowLayout.addWidget(self.nameEdit)
        rowLayout.addWidget(self.dataTypeComboBox)
        rowLayout.addWidget(self.opTypeComboBox)
        rowLayout.addWidget(self.addButton)
        rowContainer = QWidget()
        rowContainer.setLayout(rowLayout)
        rowContainer.setObjectName('titleRow')
        self.mainLayout.addWidget(rowContainer)
        self.setLayout(self.mainLayout)


    def fillDataTypes(self):
        rosTypes = Interfaces.getRosMessageTypes()
        for type in rosTypes:
            concatType = type['typeDir'] + '/' + type['type']
            self.dataTypeComboBox.addItem(concatType, concatType)


    def addTopicRow(self, name, type, opType):
        rowLayout = QHBoxLayout()
        rowLayout.addWidget(QLabel(name))
        rowLayout.addWidget(QLabel(type))
        rowLayout.addWidget(QLabel(opType))
        removeButton = QPushButton('Remove')
        removeButton.clicked.connect(self.removeTopicClicked)
        removeButton.setObjectName(str(self.count))
        rowLayout.addWidget(removeButton)
        rowContainer = QWidget()
        rowContainer.setLayout(rowLayout)
        rowContainer.setObjectName('row' + str(self.count))
        self.mainLayout.addWidget(rowContainer)
        self.topicRows[self.count] = rowContainer
        self.count += 1


    def addClicked(self):
        if self.config is not None:
            self.config.addTopic(self.count, self.nameEdit.text(), self.dataTypeComboBox.currentData(), self.opTypeComboBox.currentData())
            self.addTopicRow(self.nameEdit.text(), self.dataTypeComboBox.currentData(), self.opTypeComboBox.currentData())
            self.nameEdit.setText('')
            self.configChanged.emit()

    def removeTopicClicked(self):
        if self.config is not None:
            itemToRemove = None
            for i in range(self.mainLayout.count()):
                if self.mainLayout.itemAt(i).widget().objectName() == 'row' + self.sender().objectName():
                    itemToRemove = self.mainLayout.itemAt(i)
                    break
            if itemToRemove is not None:
                self.mainLayout.removeItem(itemToRemove)
                itemToRemove.widget().setParent(None)
                self.mainLayout.update()
                self.configChanged.emit()
            self.config.removeTopic(int(self.sender().objectName()))
            del self.topicRows[int(self.sender().objectName())]


    def clearAllRows(self):
        clearList = []
        for i in range(self.mainLayout.count()):
            item = self.mainLayout.itemAt(i)
            if item.widget().objectName() != 'titleRow':
                clearList.append(item)

        for item in clearList:
            self.mainLayout.removeItem(item)
            item.widget().setParent(None)

        self.mainLayout.update()
        self.count = 0


    def setConfig(self, config):
        self.config = config
        self.clearAllRows()
        for topic in self.config.getTopics():
            topic['id'] = self.count
            self.addTopicRow(topic['name'], topic['type'], topic['opType'])
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:100,代码来源:rosconfigdialog.py


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