Python PyQt5.QtCore.Qt.ItemIsUserCheckable() Examples

The following are 23 code examples of PyQt5.QtCore.Qt.ItemIsUserCheckable(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: parameter_tree.py    From Grabber with GNU General Public License v3.0 6 votes vote down vote up
def load_profile(self, profile: dict):
        self.blockSignals(True)
        self.setSortingEnabled(False)
        self.clear()

        for name, settings in profile.items():
            parent = self.make_option(name, self, settings['state'], 0, settings['tooltip'], settings['dependency'])
            if settings['options']:
                for number, choice in enumerate(settings['options']):
                    if settings['active option'] == number:
                        option = self.make_option(str(choice), parent, True, 1, subindex=number)
                        option.setFlags(option.flags() ^ Qt.ItemIsUserCheckable)
                    else:
                        option = self.make_option(str(choice), parent, False, 1, subindex=number)
            self.make_exclusive(parent)

        self.hock_dependency()
        self.update_size()
        self.setSortingEnabled(True)
        self.sortByColumn(0, Qt.AscendingOrder)
        self.blockSignals(False) 
Example #2
Source File: OptionsDialog.py    From urh with GNU General Public License v3.0 6 votes vote down vote up
def flags(self, index: QModelIndex):
        if not index.isValid():
            return None

        j = index.column()
        device = self.get_device_at(index.row())
        if j == 0 and not device.has_native_backend and not device.has_gnuradio_backend:
            return Qt.NoItemFlags

        if j in [1, 2, 3] and not device.is_enabled:
            return Qt.NoItemFlags

        if j == 2 and not device.has_native_backend:
            return Qt.NoItemFlags

        if j == 3 and not device.has_gnuradio_backend:
            return Qt.NoItemFlags

        flags = Qt.ItemIsEnabled

        if j in [0, 2, 3]:
            flags |= Qt.ItemIsUserCheckable

        return flags 
Example #3
Source File: tabmodel_z5.py    From python101 with MIT License 5 votes vote down vote up
def flags(self, index):
        """ Zwraca właściwości kolumn tabeli """
        flags = super(TabModel, self).flags(index)
        j = index.column()
        if j == 1:
            flags |= Qt.ItemIsEditable
        elif j == 3 or j == 4:
            flags |= Qt.ItemIsUserCheckable

        return flags 
Example #4
Source File: qtmodels.py    From QualCoder with MIT License 5 votes vote down vote up
def flags(self,index):
        if self.checkable:
            return  Qt.ItemIsUserCheckable | Qt.ItemIsEnabled 
        else:
            return  Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #5
Source File: qtmodels.py    From QualCoder with MIT License 5 votes vote down vote up
def flags(self,index):
        if self.checkable:
            return  Qt.ItemIsUserCheckable | Qt.ItemIsEnabled 
        else:
            return  Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #6
Source File: anchor_position_dialog.py    From crazyflie-clients-python with GNU General Public License v2.0 5 votes vote down vote up
def flags(self, index):
        if not index.isValid():
            return None

        if index.column() == 0:
            return Qt.ItemIsEnabled | Qt.ItemIsUserCheckable
        elif index.column() == 1:
            return Qt.ItemIsEnabled
        else:
            return Qt.ItemIsEnabled | Qt.ItemIsEditable 
Example #7
Source File: DyTreeWidget.py    From DevilYuan with MIT License 5 votes vote down vote up
def __InitFieldItem(self, parent, item):
        treeItem = QTreeWidgetItem(parent)
        treeItem.setText(0, item)
        treeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        treeItem.setCheckState(0, Qt.Unchecked)

        return treeItem 
Example #8
Source File: MessageTypeTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEditable 
Example #9
Source File: ProtocolTreeModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        if not index.isValid():
            return Qt.ItemIsDropEnabled
        return Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable | \
               Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled 
Example #10
Source File: GeneratorListModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        flags = Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable

        try:
            lbl = self.labels[index.row()]
        except IndexError:
            return flags

        if len(lbl.fuzz_values) > 1:
            flags |= Qt.ItemIsUserCheckable
        else:
            lbl.fuzz_me = False
        return flags 
Example #11
Source File: LabelValueTableModel.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index: QModelIndex):
        flags = super().flags(index)
        if index.column() in (0, 1, 2, 3):
            flags |= Qt.ItemIsEditable
        if index.column() == 0:
            flags |= Qt.ItemIsUserCheckable

        return flags 
Example #12
Source File: tabmodel_z6.py    From python101 with MIT License 5 votes vote down vote up
def flags(self, index):
        """ Zwraca właściwości kolumn tabeli """
        flags = super(TabModel, self).flags(index)
        j = index.column()
        if j == 1:
            flags |= Qt.ItemIsEditable
        elif j == 3 or j == 4:
            flags |= Qt.ItemIsUserCheckable

        return flags 
Example #13
Source File: extract_dialog.py    From restatic with GNU General Public License v3.0 5 votes vote down vote up
def fill_item(item, value):
    global n
    # item.setExpanded(True)
    if type(value) is dict:
        for key, val in sorted(value.items()):
            child = QTreeWidgetItem()
            child.setText(0, str(key))
            child.setText(1, str(key))
            child.setText(2, str(key))
            child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
            child.setCheckState(0, Qt.Unchecked)
            item.addChild(child)
            n += 1
            fill_item(child, val)
    elif type(value) is list:
        for val in value:
            child = QTreeWidgetItem()
            child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
            child.setCheckState(0, Qt.Unchecked)
            item.addChild(child)
            n += 1
            if type(val) is dict:
                child.setText(0, "[dict]")
                fill_item(child, val)
            elif type(val) is list:
                child.setText(0, "[list]")
                fill_item(child, val)
            else:
                child.setText(0, str(val))
    else:
        child = QTreeWidgetItem()
        child.setText(0, str(value))
        child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
        child.setCheckState(0, Qt.Unchecked)
        item.addChild(child)
        n += 1 
Example #14
Source File: qt.py    From mint-amazon-tagger with GNU General Public License v3.0 5 votes vote down vote up
def flags(self, index):
        if not index.isValid():
            return None
        if index.column() == 0:
            return (
                Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                Qt.ItemIsUserCheckable)
        else:
            return Qt.ItemIsEnabled | Qt.ItemIsSelectable 
Example #15
Source File: settingswindow.py    From bluesky with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, value, changed_fun, avail_plugins):
        super().__init__()
        self.changed_fun = changed_fun
        self.curvalue = {v.upper() for v in value}
        if avail_plugins:
            for name in avail_plugins:
                row = QListWidgetItem(name)
                row.name = name
                row.setFlags(row.flags()|Qt.ItemIsUserCheckable)
                row.setCheckState(Qt.Checked if name in self.curvalue else Qt.Unchecked)
                self.addItem(row)
        self.itemChanged.connect(self.onitemchanged) 
Example #16
Source File: parameter_tree.py    From Grabber with GNU General Public License v3.0 5 votes vote down vote up
def make_exclusive(self, item: QTreeWidgetItem):
        """
        Handles changes to self. Ensure options are expand_options, and resizes self when needed.
        """
        if self.signalsBlocked():
            unblock = False
        else:
            unblock = True

        if item.data(0, 33) == 0:
            self.expand_options(item)
            self.resizer(item)

        elif item.data(0, 33) == 1:
            self.blockSignals(True)
            for i in range(item.parent().childCount()):

                TWI = item.parent().child(i)
                try:
                    if TWI == item:
                        TWI.setFlags(TWI.flags() ^ Qt.ItemIsUserCheckable)
                    else:
                        TWI.setCheckState(0, Qt.Unchecked)
                        TWI.setFlags(TWI.flags() | Qt.ItemIsUserCheckable)
                except Exception as e:
                    # Log error
                    print(e)
        elif item.data(0, 33) == 2:
            pass  # Custom options should not have options, not now at least.
        else:
            pass  # TODO: Log error: state state not set.

        if unblock:
            self.blockSignals(False) 
Example #17
Source File: macros.py    From guppy-proxy with MIT License 5 votes vote down vote up
def flags(self, index):
        f = Qt.ItemIsEnabled | Qt.ItemIsSelectable
        if index.column() == 0:
            f = f | Qt.ItemIsUserCheckable | Qt.ItemIsEditable
        return f 
Example #18
Source File: import_export.py    From mhw_armor_edit with The Unlicense 5 votes vote down vote up
def dialog_helper_init(self):
        self.check_all_button.clicked.connect(self.handle_check_all_clicked)
        self.check_none_button.clicked.connect(self.handle_check_none_clicked)
        for attr in self.get_attrs():
            it = QListWidgetItem()
            it.setText(attr)
            it.setData(Qt.UserRole, attr)
            it.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            it.setCheckState(
                Qt.Checked if self.is_default_attr(attr) else Qt.Unchecked)
            self.attr_list.addItem(it) 
Example #19
Source File: object_tree.py    From CQ-editor with Apache License 2.0 5 votes vote down vote up
def __init__(self,
                 name,
                 ais=None,
                 shape=None,
                 shape_display=None,
                 sig=None,
                 alpha=0.,
                 color='f4a824',
                 **kwargs):

        super(ObjectTreeItem,self).__init__([name],**kwargs)
        self.setFlags( self.flags() | Qt.ItemIsUserCheckable)
        self.setCheckState(0,Qt.Checked)

        self.ais = ais
        self.shape = shape
        self.shape_display = shape_display
        self.sig = sig

        self.properties = Parameter.create(name='Properties',
                                           children=self.props)

        self.properties['Name'] = name
        self.properties['Alpha'] = ais.Transparency()
        self.properties['Color'] = get_occ_color(ais) if ais else color
        self.properties.sigTreeStateChanged.connect(self.propertiesChanged) 
Example #20
Source File: DyTreeWidget.py    From DevilYuan with MIT License 5 votes vote down vote up
def __InitFieldItem(self, parent, item):
        treeItem = QTreeWidgetItem(parent)
        treeItem.setText(0, item)
        treeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        treeItem.setCheckState(0, Qt.Unchecked)

        return treeItem 
Example #21
Source File: config_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def on_action_new_connection_triggered(self):
        cfg = DashNetworkConnectionCfg('rpc')
        cfg.testnet = True if self.cboDashNetwork.currentIndex() == 1 else False
        self.connections_current.append(cfg)

        # add config to the connections list:
        item = QListWidgetItem(cfg.get_description())
        item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
        item.setCheckState(Qt.Checked if cfg.enabled else Qt.Unchecked)
        item.checkState()
        self.lstConns.addItem(item)
        self.lstConns.setCurrentItem(item)
        self.set_modified() 
Example #22
Source File: config_dlg.py    From dash-masternode-tool with MIT License 5 votes vote down vote up
def display_connection_list(self):
        self.lstConns.clear()
        for cfg in self.connections_current:
            item = QListWidgetItem(cfg.get_description())
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            item.setCheckState(Qt.Checked if cfg.enabled else Qt.Unchecked)
            item.checkState()
            self.lstConns.addItem(item) 
Example #23
Source File: qcheckcombobox.py    From artisan with GNU General Public License v3.0 4 votes vote down vote up
def eventFilter(self, obj, event):
        """Reimplemented."""
        if self.__popupIsShown and \
                event.type() == QEvent.MouseMove and \
                self.view().isVisible() and self.__initialMousePos is not None:
            diff = obj.mapToGlobal(event.pos()) - self.__initialMousePos
            if diff.manhattanLength() > 9 and \
                    self.__blockMouseReleaseTimer.isActive():
                self.__blockMouseReleaseTimer.stop()
            # pass through

        if self.__popupIsShown and \
                event.type() == QEvent.MouseButtonRelease and \
                self.view().isVisible() and \
                self.view().rect().contains(event.pos()) and \
                self.view().currentIndex().isValid() and \
                self.view().currentIndex().flags() & Qt.ItemIsSelectable and \
                self.view().currentIndex().flags() & Qt.ItemIsEnabled and \
                self.view().currentIndex().flags() & Qt.ItemIsUserCheckable and \
                self.view().visualRect(self.view().currentIndex()).contains(event.pos()) and \
                not self.__blockMouseReleaseTimer.isActive():
            model = self.model()
            index = self.view().currentIndex()
            state = model.data(index, Qt.CheckStateRole)
            model.setData(index,
                          Qt.Checked if state == Qt.Unchecked else Qt.Unchecked,
                          Qt.CheckStateRole)
            self.view().update(index)
            self.update()
            self.flagChanged.emit(index.row(),state == Qt.Unchecked)
            return True

        if self.__popupIsShown and event.type() == QEvent.KeyPress:
            if event.key() == Qt.Key_Space:
                # toogle the current items check state
                model = self.model()
                index = self.view().currentIndex()
                flags = model.flags(index)
                state = model.data(index, Qt.CheckStateRole)
                if flags & Qt.ItemIsUserCheckable and \
                        flags & Qt.ItemIsTristate:
                    state = Qt.CheckState((int(state) + 1) % 3)
                elif flags & Qt.ItemIsUserCheckable:
                    state = Qt.Checked if state != Qt.Checked else Qt.Unchecked
                model.setData(index, state, Qt.CheckStateRole)
                self.view().update(index)
                self.update()
                self.flagChanged.emit(index.row(),state != Qt.Unchecked)
                return True
            # TODO: handle Qt.Key_Enter, Key_Return?

        return super(CheckComboBox, self).eventFilter(obj, event)