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


Python QStandardItem.setFlags方法代码示例

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


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

示例1: prev_track

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
 def prev_track(self):
     previous_track = self.recentTrackListModel.takeItem(0)
     if previous_track is not None or previous_track is not "":
         try:
             location = previous_track.data(1)
             try:
                 self.player.stop_item()
                 print(self.player.get_item())
                 playing_track = self.player.get_item()
                 playing_meta = self.meta_info(playing_track)
                 item = QStandardItem(playing_track)
                 item.setFlags(item.flags() & ~QtCore.Qt.ItemIsDropEnabled)  # This is necessary to drag'n'drop within QueueList
                 item.setText(playing_meta)
                 item.setData(playing_track, 1)
                 self.queueTrackListModel.insertRow(0, item)
                 print("goes back one step..")
             except FileNotFoundError:
                 print("no current track..")
             self.player.set_item(location)
             print("loaded: " + self.player.get_item())
             self.meta_info(location, active=True)
             self.recentTrackListModel.removeRow(0)
             print(previous_track.data(0) + " taken back from recent.")
             self.play_track()
         except AttributeError:
             print("nope")
     elif previous_track is None or previous_track is "":
         print("there's no track - cannot go backwards")
开发者ID:liothe,项目名称:limu,代码行数:30,代码来源:MainHandler.py

示例2: set_server_mgr

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
 def set_server_mgr(self, server_mgr):
     self.server_mgr = server_mgr
     self.nodesets = []
     self.model.clear()
     self.model.setHorizontalHeaderLabels(['Node Sets'])
     item = QStandardItem("Opc.Ua.NodeSet2.xml")
     item.setFlags(Qt.NoItemFlags)
     self.model.appendRow([item])
     self.view.expandAll()
开发者ID:FreeOpcUa,项目名称:opcua-modeler,代码行数:11,代码来源:refnodesets_widget.py

示例3: add_parent_item

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def add_parent_item(self, text):
        item = QStandardItem(text)
        item.setFlags(item.flags() & ~(Qt.ItemIsEnabled | Qt.ItemIsSelectable))
        item.setData("parent", Qt.AccessibleDescriptionRole)

        font = item.font()
        font.setBold(True)
        item.setFont(font)

        self.model().appendRow(item)
开发者ID:jopohl,项目名称:urh,代码行数:12,代码来源:SectionComboBoxDelegate.py

示例4: AddTag

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
 def AddTag( self, name ):
     newTag = QStandardItem( name )
     newTagQuantity = QItemToSortByNum( "0" )
     newTag.setFlags( Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable )
     newTag.setData( QVariant( Qt.Unchecked ), Qt.CheckStateRole )
     self.tagDict[ name ] = newTag
     currentRow = [ newTag, newTagQuantity ]
     self.tagNameToTagItemsDict[ name ] = currentRow
     self.tagModel.appendRow( currentRow )
     self.tagModel.sort( Qt.AscendingOrder )
     self.wereAnyChanges = True
开发者ID:mikhaelsk,项目名称:librarian,代码行数:13,代码来源:Tags.py

示例5: process_track

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
 def process_track(self, track):
     with lock:
         start_single = time.time()
         item = QStandardItem(track)
         item.setFlags(item.flags() & ~QtCore.Qt.ItemIsDropEnabled)  # This is necessary to drag'n'drop within QueueList
         track_info = self.meta_info(track)
         item.setText(track_info)
         item.setData(track, 1)
         self.queueTrackListModel.appendRow(item)
         stop_single = time.time() - start_single
         print("queued:", os.path.basename(item.data(0)), "(" + str(stop_single.__round__(5)) + ")" + " --- " + threading.current_thread().name)
         if self.player.status is None:
             self.get_next_track()
开发者ID:liothe,项目名称:limu,代码行数:15,代码来源:MainHandler.py

示例6: create_table

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def create_table(self, rela):
        table = custom_table.Table()
        model = QStandardItemModel()
        table.setModel(model)
        model.setHorizontalHeaderLabels(rela.header)

        for row_count, row in enumerate(rela.content):
            for col_count, data in enumerate(row):
                item = QStandardItem(data)
                item.setFlags(item.flags() & ~Qt.ItemIsEditable)
                model.setItem(row_count, col_count, item)

        return table
开发者ID:centaurialpha,项目名称:pireal,代码行数:15,代码来源:table_widget.py

示例7: __init__

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def __init__(self, parent=None):

        self.parent = parent
        self.parent.statusbar.showMessage("Keep Columns started...")
        QWidget.__init__(self,parent)
        
        self.ui = gui.keepColumnUi()
        self.ui.setupUi(self)
        
        self.columns = []
        
        self.batch_files = filedialog.askopenfilenames(parent=root, title='Choose the file(s) you want to modify')
        
        if len(self.batch_files) == 0:
            self.close()
            return
        
        self.parent.statusbar.showMessage("Checking column validity...")

        #extract columns
        for item in self.batch_files:
            self.columns.append(helpers.extract_columns(item))
 
        #check to see if all columns are equal in all the datasets
        if not helpers.are_columns_same(self.columns):
            if not helpers.columns_not_equal_message(self):
                self.close()
                return
                
        #list of items to check from        
        
        self.model = QStandardItemModel()
        
        try:
            for col in self.columns[0]:
                item = QStandardItem(col)
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) 
                item.setData(QVariant(Qt.Unchecked), Qt.CheckStateRole) 
                self.model.appendRow(item) 
        except IndexError:
            pass

        self.list = QListView(self)
        self.list.setModel(self.model) 
        self.list.setGeometry(10, 60, 380, 430)
       
        self.ui.removeBtn.clicked.connect(self.keep)
        self.ui.closeBtn.clicked.connect(self.close)
       
        self.parent.statusbar.showMessage("Welcome back!")
        self.show()
开发者ID:micahzev,项目名称:biometric_data_manipulator,代码行数:53,代码来源:data_manipulator.py

示例8: update_table

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def update_table(self, data):
        current_table = self.current_table()
        model = current_table.model()
        # Clear content
        model.clear()
        # Add new header and content
        model.setHorizontalHeaderLabels(data.header)

        for row_count, row in enumerate(data.content):
            for col_count, data in enumerate(row):
                item = QStandardItem(data)
                item.setFlags(item.flags() & ~Qt.ItemIsEditable)
                # item.setSelectable(False)
                model.setItem(row_count, col_count, item)
开发者ID:centaurialpha,项目名称:pireal,代码行数:16,代码来源:table_widget.py

示例9: crawlBatch

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
	def crawlBatch(self):
		start_time = QElapsedTimer()
		start_time.start()
		prefix_len = len(self.root) + 1 # 1 for the /

		for path in self.crawler:
			subpath = path[prefix_len:]

			qitem = QStandardItem(subpath)
			qitem.setData(path, AbsolutePathRole)
			qitem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
			self.mdl.appendRow(qitem)

			if start_time.hasExpired(self.maxSecsPerCrawlBatch * 1000):
				self.crawlTimer.start(0)
				break
开发者ID:hydrargyrum,项目名称:eye,代码行数:18,代码来源:filechooser.py

示例10: __init__

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
	def __init__(self, db):
		super(TagChooser,self).__init__()
		self.db = db

		self.filter = u''

		self.data = QStandardItemModel()
		self.proxy = QSortFilterProxyModel()
		self.proxy.setSourceModel(self.data)
		self.setModel(self.proxy)

		self.data.itemChanged.connect(self.changed)
		for t in sorted(self.db.list_tags()):
			item = QStandardItem(t)
			item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
			item.setCheckState(Qt.Unchecked)
			self.data.appendRow(item)
开发者ID:hydrargyrum,项目名称:sit-tagger,代码行数:19,代码来源:tagwidgets.py

示例11: add_table

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def add_table(self, rela, rname):
        wtable = custom_table.Table()
        # Model
        model = QStandardItemModel()
        wtable.setModel(model)
        model.setHorizontalHeaderLabels(rela.header)

        for data in rela.content:
            nrow = model.rowCount()
            # wtable.insertRow(nrow)
            for col, text in enumerate(data):
                item = QStandardItem(text)
                item.setFlags(item.flags() & ~Qt.ItemIsEditable)
                model.setItem(nrow, col, item)

        index = self._stack_tables.addWidget(wtable)
        self._stack_tables.setCurrentIndex(index)

        self._result_list.add_item(rname, rela.count())
开发者ID:centaurialpha,项目名称:pireal,代码行数:21,代码来源:query_container.py

示例12: create_database

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
    def create_database(self, data):
        for table in data.get('tables'):
            # Get data
            table_name = table.get('name')
            header = table.get('header')
            tuples = table.get('tuples')

            # Create relation
            rela = relation.Relation()
            rela.header = header

            # Table view widget
            table_view = custom_table.Table()
            # Model
            model = QStandardItemModel()
            model.setHorizontalHeaderLabels(header)

            # Populate table view
            row_count = 0
            for row in tuples:
                for col_count, i in enumerate(row):
                    item = QStandardItem(i)
                    # Set read only
                    item.setFlags(item.flags() & ~Qt.ItemIsEditable)
                    model.setItem(row_count, col_count, item)
                rela.insert(row)
                row_count += 1

            # Set table model
            table_view.setModel(model)
            # Add relation to relations dict
            self.table_widget.add_relation(table_name, rela)
            # Add table to stacked
            self.table_widget.stacked.addWidget(table_view)
            # Add table name to list widget
            self.lateral_widget.add_item(table_name, rela.count())
        # Select first item
        first_item = self.lateral_widget.topLevelItem(0)
        first_item.setSelected(True)
开发者ID:centaurialpha,项目名称:pireal,代码行数:41,代码来源:database_container.py

示例13: __updateSlotsModel

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
 def __updateSlotsModel(self):
     """
     Private slot to update the slots tree display.
     """
     self.filterEdit.clear()
     
     try:
         dlg = uic.loadUi(
             self.formFile, package=self.project.getProjectPath())
         objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction)
         
         signatureList = self.__signatures()
         
         self.slotsModel.clear()
         self.slotsModel.setHorizontalHeaderLabels([""])
         for obj in objects:
             name = obj.objectName()
             if not name or name.startswith("qt_"):
                 # ignore un-named or internal objects
                 continue
             
             metaObject = obj.metaObject()
             className = metaObject.className()
             itm = QStandardItem("{0} ({1})".format(name, className))
             self.slotsModel.appendRow(itm)
             for index in range(metaObject.methodCount()):
                 metaMethod = metaObject.method(index)
                 if metaMethod.methodType() == QMetaMethod.Signal:
                     if qVersion() >= "5.0.0":
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name,
                             bytes(metaMethod.methodSignature()).decode()))
                     else:
                         itm2 = QStandardItem("on_{0}_{1}".format(
                             name, metaMethod.signature()))
                     itm.appendRow(itm2)
                     if self.__module is not None:
                         if qVersion() >= "5.0.0":
                             method = "on_{0}_{1}".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             method = "on_{0}_{1}".format(
                                 name, metaMethod.signature().split("(")[0])
                         method2 = "{0}({1})".format(
                             method, ", ".join(
                                 [self.__mapType(t)
                                  for t in metaMethod.parameterTypes()]))
                         
                         if method2 in signatureList or \
                                 method in signatureList:
                             itm2.setFlags(Qt.ItemFlags(Qt.ItemIsEnabled))
                             itm2.setCheckState(Qt.Checked)
                             itm2.setForeground(QBrush(Qt.blue))
                             continue
                     
                     returnType = self.__mapType(
                         metaMethod.typeName().encode())
                     if returnType == 'void':
                         returnType = ""
                     parameterTypesList = [
                         self.__mapType(t)
                         for t in metaMethod.parameterTypes()]
                     pyqtSignature = ", ".join(parameterTypesList)
                     
                     parameterNames = metaMethod.parameterNames()
                     if parameterNames:
                         for index in range(len(parameterNames)):
                             if not parameterNames[index]:
                                 parameterNames[index] = \
                                     QByteArray("p{0:d}".format(index)
                                                .encode("utf-8"))
                     parameterNamesList = [bytes(n).decode()
                                           for n in parameterNames]
                     methNamesSig = ", ".join(parameterNamesList)
                     
                     if methNamesSig:
                         if qVersion() >= "5.0.0":
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     bytes(metaMethod.methodSignature())
                                     .decode().split("(")[0],
                                     methNamesSig)
                         else:
                             pythonSignature = \
                                 "on_{0}_{1}(self, {2})".format(
                                     name,
                                     metaMethod.signature().split("(")[0],
                                     methNamesSig)
                     else:
                         if qVersion() >= "5.0.0":
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
                                 bytes(metaMethod.methodSignature())
                                 .decode().split("(")[0])
                         else:
                             pythonSignature = "on_{0}_{1}(self)".format(
                                 name,
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:CreateDialogCodeDialog.py

示例14: _createItem

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
	def _createItem(self, name):
		item = QStandardItem(name)
		item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
		item.setCheckState(Qt.Unchecked)
		return item
开发者ID:hydrargyrum,项目名称:sit-tagger,代码行数:7,代码来源:tagwidgets.py

示例15: main

# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import setFlags [as 别名]
def main(icon_spec):
    app = QApplication(sys.argv)

    main_window = QMainWindow()

    def sigint_handler(*args):
        main_window.close()
    signal.signal(signal.SIGINT, sigint_handler)
    # the timer enables triggering the sigint_handler
    signal_timer = QTimer()
    signal_timer.start(100)
    signal_timer.timeout.connect(lambda: None)

    tool_bar = QToolBar()
    main_window.addToolBar(Qt.TopToolBarArea, tool_bar)

    table_view = QTableView()
    table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
    table_view.setSelectionMode(QAbstractItemView.SingleSelection)
    table_view.setSortingEnabled(True)
    main_window.setCentralWidget(table_view)

    proxy_model = QSortFilterProxyModel()
    proxy_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
    proxy_model.setFilterKeyColumn(1)
    table_view.setModel(proxy_model)
    proxy_model.layoutChanged.connect(table_view.resizeRowsToContents)

    item_model = QStandardItemModel()
    proxy_model.setSourceModel(item_model)

    # get all icons and their available sizes
    icons = []
    all_sizes = set([])
    for context, icon_names in icon_spec:
        for icon_name in icon_names:
            icon = QIcon.fromTheme(icon_name)
            sizes = []
            for size in icon.availableSizes():
                size = (size.width(), size.height())
                sizes.append(size)
                all_sizes.add(size)
            sizes.sort()
            icons.append({
                'context': context,
                'icon_name': icon_name,
                'icon': icon,
                'sizes': sizes,
            })
    all_sizes = list(all_sizes)
    all_sizes.sort()

    # input field for filter
    def filter_changed(value):
        proxy_model.setFilterRegExp(value)
        table_view.resizeRowsToContents()
    filter_line_edit = QLineEdit()
    filter_line_edit.setMaximumWidth(200)
    filter_line_edit.setPlaceholderText('Filter name')
    filter_line_edit.setToolTip('Filter name optionally using regular expressions (' + QKeySequence(QKeySequence.Find).toString() + ')')
    filter_line_edit.textChanged.connect(filter_changed)
    tool_bar.addWidget(filter_line_edit)

    # actions to toggle visibility of available sizes/columns 
    def action_toggled(index):
        column = 2 + index
        table_view.setColumnHidden(column, not table_view.isColumnHidden(column))
        table_view.resizeColumnsToContents()
        table_view.resizeRowsToContents()
    signal_mapper = QSignalMapper()
    for i, size in enumerate(all_sizes):
        action = QAction('%dx%d' % size, tool_bar)
        action.setCheckable(True)
        action.setChecked(True)
        tool_bar.addAction(action)
        action.toggled.connect(signal_mapper.map)
        signal_mapper.setMapping(action, i)
        # set tool tip and handle key sequence
        tool_tip = 'Toggle visibility of column'
        if i < 10:
            digit = ('%d' % (i + 1))[-1]
            tool_tip += ' (%s)' % QKeySequence('Ctrl+%s' % digit).toString()
        action.setToolTip(tool_tip)
    signal_mapper.mapped.connect(action_toggled)

    # label columns
    header_labels = ['context', 'name']
    for width, height in all_sizes:
        header_labels.append('%dx%d' % (width, height))
    item_model.setColumnCount(len(header_labels))
    item_model.setHorizontalHeaderLabels(header_labels)

    # fill rows
    item_model.setRowCount(len(icons))
    for row, icon_data in enumerate(icons):
        # context
        item = QStandardItem(icon_data['context'])
        item.setFlags(item.flags() ^ Qt.ItemIsEditable)
        item_model.setItem(row, 0, item)
        # icon name
#.........这里部分代码省略.........
开发者ID:dirk-thomas,项目名称:qt_theme_icons,代码行数:103,代码来源:icons.py


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