Python PyQt5.QtCore.Qt.Checked() Examples

The following are 30 code examples of PyQt5.QtCore.Qt.Checked(). 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: DyTreeWidget.py    From DevilYuan with MIT License 7 votes vote down vote up
def __GetFields(self, parent):
        fields = []
        for i in range(parent.childCount()):
            childItem = parent.child(i)

            # leaf
            if childItem.childCount() == 0:
                if childItem.checkState(0) == Qt.Checked:
                    field = self.__GetFieldByShowName(self._fields, childItem.text(0))
                    fields.append(field)
                continue
            
            if childItem.checkState(0) == Qt.Checked or childItem.checkState(0) == Qt.PartiallyChecked:
                field = self.__GetFields(childItem)
                fields.extend(field)

        return fields 
Example #2
Source File: idealimagerdialog.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def value_change(self, imager_key):
        label, lineEdit, checkBox = self.dlog_attrs[imager_key]

        try:
            value = float(lineEdit.text())
        except ValueError:
            value = None
        finally:
            imager_inputs = self.specsheet.imager_inputs
            if value is not None:
                if imager_key in imager_inputs or len(imager_inputs) < 2:
                    imager_inputs[imager_key] = value
                    if not checkBox.isChecked():
                        checkBox.setCheckState(qt.Checked)
            else:
                if imager_key in imager_inputs:
                    del imager_inputs[imager_key]
                    if checkBox.isChecked():
                        checkBox.setChecked(False)
            self.parent.update_values() 
Example #3
Source File: tabmodel_z5.py    From python101 with MIT License 6 votes vote down vote up
def data(self, index, rola=Qt.DisplayRole):
        """ Wyświetlanie danych """
        i = index.row()
        j = index.column()

        if rola == Qt.DisplayRole:
            return '{0}'.format(self.tabela[i][j])
        elif rola == Qt.CheckStateRole and (j == 3 or j == 4):
            if self.tabela[i][j]:
                return Qt.Checked
            else:
                return Qt.Unchecked
        elif rola == Qt.EditRole and j == 1:
            return self.tabela[i][j]
        else:
            return QVariant() 
Example #4
Source File: param_panel.py    From BORIS with GNU General Public License v3.0 6 votes vote down vote up
def ok(self):

        selectedSubjects = []
        for idx in range(self.lwSubjects.count()):
            cb = self.lwSubjects.itemWidget(self.lwSubjects.item(idx))
            if cb.isChecked():
                selectedSubjects.append(cb.text())
        self.selectedSubjects = selectedSubjects

        selectedBehaviors = []
        for idx in range(self.lwBehaviors.count()):
            if self.lwBehaviors.item(idx).checkState() == Qt.Checked:
                selectedBehaviors.append(self.lwBehaviors.item(idx).text())
        self.selectedBehaviors = selectedBehaviors

        self.accept() 
Example #5
Source File: param_panel.py    From BORIS with GNU General Public License v3.0 6 votes vote down vote up
def behavior_item_clicked(self, item):
        """
        check / uncheck behaviors belonging to the clicked category
        """

        if item.data(33) == "category":
            category = item.data(34)
            for i in range(self.lwBehaviors.count()):
                if self.lwBehaviors.item(i).data(34) == category and self.lwBehaviors.item(i).data(33) != "category":

                    if item.data(35):
                        self.lwBehaviors.item(i).setCheckState(Qt.Unchecked)
                    else:
                        self.lwBehaviors.item(i).setCheckState(Qt.Checked)

            item.setData(35, not item.data(35)) 
Example #6
Source File: tabmodel_z6.py    From python101 with MIT License 6 votes vote down vote up
def data(self, index, rola=Qt.DisplayRole):
        """ Wyświetlanie danych """
        i = index.row()
        j = index.column()

        if rola == Qt.DisplayRole:
            return '{0}'.format(self.tabela[i][j])
        elif rola == Qt.CheckStateRole and (j == 3 or j == 4):
            if self.tabela[i][j]:
                return Qt.Checked
            else:
                return Qt.Unchecked
        elif rola == Qt.EditRole and j == 1:
            return self.tabela[i][j]
        else:
            return QVariant() 
Example #7
Source File: param_panel.py    From BORIS with GNU General Public License v3.0 6 votes vote down vote up
def cb_changed(self):
        selectedSubjects = []
        for idx in range(self.lwSubjects.count()):
            cb = self.lwSubjects.itemWidget(self.lwSubjects.item(idx))
            if cb and cb.isChecked():
                selectedSubjects.append(cb.text())

        # FIX ME
        observedBehaviors = self.extract_observed_behaviors(self.selectedObservations, selectedSubjects)

        logging.debug(f"observed behaviors: {observedBehaviors}")

        for idx in range(self.lwBehaviors.count()):

            if self.lwBehaviors.item(idx).data(33) != "category":
                if self.lwBehaviors.item(idx).text() in observedBehaviors:
                    self.lwBehaviors.item(idx).setCheckState(Qt.Checked)
                else:
                    self.lwBehaviors.item(idx).setCheckState(Qt.Unchecked) 
Example #8
Source File: qt.py    From mint-amazon-tagger with GNU General Public License v3.0 6 votes vote down vote up
def data(self, index, role):
        if not index.isValid():
            return None
        if index.column() == 0:
            value = ('' if self.my_data[index.row()][index.column() + 1]
                     else 'Skip')
        else:
            value = self.my_data[index.row()][index.column() + 1]
        if role == Qt.EditRole:
            return value
        elif role == Qt.DisplayRole:
            return value
        elif role == Qt.CheckStateRole:
            if index.column() == 0:
                return (
                    Qt.Checked if self.my_data[index.row()][index.column() + 1]
                    else Qt.Unchecked) 
Example #9
Source File: notes.py    From wonambi with GNU General Public License v3.0 6 votes vote down vote up
def get_selected_events(self, time_selection=None):
        """Returns which events are present in one time window.

        Parameters
        ----------
        time_selection : tuple of float
            start and end of the window of interest

        Returns
        -------
        list of dict
            list of events in the window of interest
        """
        events = []
        for checkbox in self.idx_eventtype_list:
            if checkbox.checkState() == Qt.Checked:
                events.extend(self.annot.get_events(name=checkbox.text(),
                                                    time=time_selection))

        return events 
Example #10
Source File: fuzzer.py    From pbtk with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, item, name, val, app):
        super().__init__(item, [name + '  '])
        self.name = name
        self.app = app
        self.required = '{%s}' % name in self.app.base_url
        
        if not self.required:
            self.setCheckState(0, Qt.Checked)
            self.last_check_state = Qt.Checked

        self.widget = QLineEdit()
        self.widget.setFrame(False)
        self.widget.setStyleSheet('padding: 1px 0')
        self.widget.textEdited.connect(self.value_changed)
        self.app.fuzzer.getTree.setItemWidget(self, 1, self.widget)
        
        self.widget.setText(val)
        self.value = val
        
        self.widget.setMouseTracking(True)
        self.widget.enterEvent = self.edit 
Example #11
Source File: parameter_tree.py    From Grabber with GNU General Public License v3.0 6 votes vote down vote up
def _del_option(self, parent: QTreeWidgetItem, child: QTreeWidgetItem):

        self.blockSignals(True)

        parent.removeChild(child)
        selected_option = False
        for i in range(parent.childCount()):
            parent.child(i).setData(0, 35, i)
            if parent.child(i).checkState(0) == Qt.Checked:
                selected_option = True

        if parent.childCount() > 0 and not selected_option:
            parent.child(0).setCheckState(0, Qt.Checked)

        # Deselects if no options left
        if not parent.childCount():
            parent.setCheckState(0, Qt.Unchecked)

        self.blockSignals(False)

        self.update_size() 
Example #12
Source File: core.py    From Grabber with GNU General Public License v3.0 6 votes vote down vote up
def download_name_handler(self):
        """ Formats download names and removes the naming string for ytdl. """
        item = self.tab2.download_option

        item.treeWidget().blockSignals(True)
        for number in range(item.childCount()):
            path = self.settings['Download location']['options'][number]
            item.child(number).setToolTip(0, path)
            item.child(number).setText(0, path_shortener(path))

        if item.checkState(0) == Qt.Checked:
            for number in range(item.childCount()):
                if item.child(number).checkState(0) == Qt.Checked:
                    self.tab2.download_lineedit.setText(item.child(number).data(0, 0))
                    self.tab2.download_lineedit.setToolTip(item.child(number).data(0, 32))
                    break
            else:
                # TODO: Add error handling here
                print('WARNING! No selected download item, this should not happen.... ')
                print('You messed with the settings... didn\'t you?!')
                # raise SettingsError('Error, no active option!')
        else:
            self.tab2.download_lineedit.setText(path_shortener(self.local_dl_path))
            self.tab2.download_lineedit.setToolTip(self.local_dl_path)
        item.treeWidget().blockSignals(False) 
Example #13
Source File: core.py    From Grabber with GNU General Public License v3.0 6 votes vote down vote up
def move_item(self, item: QTreeWidgetItem, favorite: bool):
        """ Move an time to or from the favorites tree. """

        if favorite:
            tree = self.tab2.options
            self.settings.user_options['favorites'].remove(item.data(0, 0))
        else:
            tree = self.tab2.favorites
            self.settings.user_options['favorites'].append(item.data(0, 0))

        self.tab2.enable_favorites(bool(self.settings.user_options['favorites']))
        tree.blockSignals(True)
        tree.addTopLevelItem(item)

        self.tab2.options.update_size()
        self.tab2.favorites.update_size()

        self.file_handler.save_settings(self.settings.settings_data)

        if item.checkState(0) == Qt.Checked:
            item.setExpanded(True)
        else:
            item.setExpanded(False)

        tree.blockSignals(False) 
Example #14
Source File: plotview.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_draw_rays_groupbox(app, pc):
    tb = QToolBar()
    fig = pc.figure

    def attr_check(fig, attr, state):
        checked = state == qt.Checked
#        cur_value = getattr(fig, attr, None)
        setattr(fig, attr, checked)
        fig.refresh()

    parax_checkBox = QCheckBox("&paraxial rays")
    parax_checkBox.setChecked(fig.do_paraxial_layout)
    parax_checkBox.stateChanged.connect(
        lambda checked: attr_check(fig, 'do_paraxial_layout', checked))
    edge_checkBox = QCheckBox("&edge rays")
    edge_checkBox.setChecked(fig.do_draw_rays)
    edge_checkBox.stateChanged.connect(
        lambda checked: attr_check(fig, 'do_draw_rays', checked))

    tb.addWidget(parax_checkBox)
    tb.addWidget(edge_checkBox)

    return tb 
Example #15
Source File: idealimagerdialog.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def chkbox_change(self, state, imager_key):
        label, lineEdit, checkBox = self.dlog_attrs[imager_key]

        checked = state == qt.Checked
        if checked:
            try:
                value = float(lineEdit.text())
            except ValueError:
                value = None
            finally:
                self.specsheet.imager_inputs[imager_key] = value
                if not checkBox.isChecked():
                    checkBox.setChecked(True)
        else:
            if imager_key in self.specsheet.imager_inputs:
                del self.specsheet.imager_inputs[imager_key]
                if checkBox.isChecked():
                    checkBox.setChecked(False)
        self.parent.update_checkboxes() 
Example #16
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 #17
Source File: panel_search.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def _on_range_dblclick(self, model_index):
        item = self._ranges_model.itemFromIndex(model_index)
        if item:
            if self._ranges_model.item(model_index.row(),
                                       0).checkState() != Qt.Checked:
                self._ranges_model.item(model_index.row(),
                                        0).setCheckState(Qt.Checked)
            else:
                self._ranges_model.item(model_index.row(),
                                        0).setCheckState(Qt.Unchecked) 
Example #18
Source File: settingswindow.py    From bluesky with GNU General Public License v3.0 5 votes vote down vote up
def onitemchanged(self, item):
        if item.checkState() & Qt.Checked:
            self.curvalue.add(item.name)
        else:
            self.curvalue -= {item.name}
        self.changed_fun(list(self.curvalue)) 
Example #19
Source File: panel_search.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def _on_click_check_all(self):
        for i in range(self._ranges_model.rowCount()):
            self._ranges_model.item(i, 0).setCheckState(Qt.Checked) 
Example #20
Source File: dialog_list.py    From Dwarf with GNU General Public License v3.0 5 votes vote down vote up
def get_checked_items(self):
        ret = []
        for i in range(0, self.list.count()):
            item = self.list.item(i)
            if item.checkState() == Qt.Checked:
                ret.append(item)
        return ret 
Example #21
Source File: fuzzer.py    From pbtk with GNU General Public License v3.0 5 votes vote down vote up
def get_self_pb(self):
        if self.self_pb is None:
            self.self_pb = getattr(self.get_parent_pb(), self.ds.name)

            if self.repeated:
                self.index = len(self.self_pb)
                
                item_indices[id(self.self_pb)].append(self)
                
                if self.is_msg:
                    self.self_pb.add()
                    
            if self.is_msg:
                for i in range(self.childCount()):
                    if self.child(i).required:
                        self.child(i).parent_pb = None
                        self.child(i).self_pb = None
                        self.child(i).update(self.child(i).value)
                
                if hasattr(self.self_pb, 'SetInParent'):
                    self.self_pb.SetInParent()
                
                if not self.required:
                    self.setCheckState(0, Qt.Checked)
                    self.last_check_state = Qt.Checked
        
        # Return value is for get_parent_pb recursion
        if self.is_msg:
            if not self.repeated:
                return self.self_pb
            else:
                return self.self_pb[self.index] 
Example #22
Source File: fuzzer.py    From pbtk with GNU General Public License v3.0 5 votes vote down vote up
def unvoid(self, recur=True):
        if self.void or self.is_msg:
            if not self.required:
                self.setCheckState(0, Qt.Checked)
                self.last_check_state = Qt.Checked
            
            if recur and self.parent():
                self.parent().unvoid(True)
            
            self.void = False 
Example #23
Source File: parameter_tree.py    From Grabber with GNU General Public License v3.0 5 votes vote down vote up
def expand_options(self, item: QTreeWidgetItem):
        """Handles if the options should show, depends on checkstate."""
        if item.checkState(0) == Qt.Checked:
            item.setExpanded(True)
        else:
            item.setExpanded(False) 
Example #24
Source File: qcheckcombobox.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def checkedIndices(self):
        """
        Return a list of indices of all checked items.
        Returns
        -------
        indices : List[int]
        """
        return [i for i in range(self.count())
                if self.itemCheckState(i) == Qt.Checked] 
Example #25
Source File: view.py    From equant with GNU General Public License v2.0 5 votes vote down vote up
def _cycleCheckBoxStateChangedCallback(self, state):
        """周期触发checkbox回调"""
        if state == Qt.Checked:
            self.cycleLineEdit.setFocus()
            self.cycleLineEdit.selectAll() 
Example #26
Source File: param_panel.py    From BORIS with GNU General Public License v3.0 5 votes vote down vote up
def behaviors_button_clicked(self, command):
        for idx in range(self.lwBehaviors.count()):

            if self.lwBehaviors.item(idx).data(33) != "category":
                if command == "select all":
                    self.lwBehaviors.item(idx).setCheckState(Qt.Checked)

                if command == "unselect all":
                    self.lwBehaviors.item(idx).setCheckState(Qt.Unchecked)

                if command == "reverse selection":
                    if self.lwBehaviors.item(idx).checkState() == Qt.Checked:
                        self.lwBehaviors.item(idx).setCheckState(Qt.Unchecked)
                    else:
                        self.lwBehaviors.item(idx).setCheckState(Qt.Checked) 
Example #27
Source File: plotview.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def on_barrel_constraint_toggled(cntxt, state):
    fig, barrel_wdgt = cntxt
    diagram = fig.diagram
    checked = state == qt.Checked
    if checked:
        diagram.do_barrel_constraint = True
        barrel_wdgt.setReadOnly(False)
        barrel_wdgt.setText('{:7.4f}'.format(diagram.barrel_constraint_radius))
    else:
        diagram.do_barrel_constraint = False
        barrel_wdgt.setReadOnly(True)

    fig.refresh() 
Example #28
Source File: idealimagerdialog.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def value_change(self, fld_ape, obj_img, key):
        """ callback routine for item value widget """
        inputs = self.specsheet.etendue_inputs[fld_ape][obj_img]
        gb = self.groupboxes[fld_ape][obj_img]
        label, lineEdit, checkBox = gb.dlog_attrs[key]
        try:
            value = float(lineEdit.text())
        except ValueError:
            return
        else:
            if (key in inputs or len(inputs) < 2):
                inputs[key] = value
                if not checkBox.isChecked():
                    checkBox.setCheckState(qt.Checked)
            self.parent.update_values() 
Example #29
Source File: idealimagerdialog.py    From ray-optics with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def update_checkboxes(self, inputs, values, partition_defined=False):
        """ update the display for the etendue cell being updated

        A partition is an aperture or field pair of object/image inputs.

        If it is defined, this means that all attrs can be supplied.
        In this case, the inputs will have editable values and (checked)
        checkboxes; the remaining attrs will have uneditable values and
        (unchecked) checkboxes.

        If the partition is not defined, all values and checkboxes will be
        editable, the input attrs, if any, will be checked.
        """
        if partition_defined:
            for key in self.keys:
                label, lineEdit, checkBox = self.dlog_attrs[key]

                if key in inputs:
                    lineEdit.setEnabled(True)
                    checkBox.setEnabled(True)
                    if not checkBox.isChecked():
                        checkBox.setCheckState(qt.Checked)
                else:
                    lineEdit.setEnabled(False)
                    checkBox.setEnabled(False)
                    if checkBox.isChecked():
                        checkBox.setCheckState(qt.Unchecked)

        else:
            for key in self.keys:
                label, lineEdit, checkBox = self.dlog_attrs[key]
                lineEdit.setEnabled(True)
                checkBox.setEnabled(True)

                if key in inputs:
                    if not checkBox.isChecked():
                        checkBox.setCheckState(qt.Checked)
                else:
                    if checkBox.isChecked():
                        checkBox.setCheckState(qt.Unchecked) 
Example #30
Source File: testGraphAnalysis.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def handleChanged(self,item,column):
        count = item.childCount()
        if item.checkState(column) == Qt.Checked:
            for index in range(count):
                item.child(index).setCheckState(0,Qt.Checked)
        if item.checkState(column) == Qt.Unchecked:
            for index in range(count):
                item.child(index).setCheckState(0,Qt.Unchecked)