本文整理汇总了Python中PyQt5.QtGui.QStandardItem.flags方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.flags方法的具体用法?Python QStandardItem.flags怎么用?Python QStandardItem.flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.flags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prev_track
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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")
示例2: add_parent_item
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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)
示例3: process_track
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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()
示例4: create_table
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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
示例5: update_table
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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)
示例6: add_table
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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())
示例7: create_database
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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)
示例8: main
# 需要导入模块: from PyQt5.QtGui import QStandardItem [as 别名]
# 或者: from PyQt5.QtGui.QStandardItem import flags [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
#.........这里部分代码省略.........