本文整理汇总了Python中PyQt4.QtGui.QStandardItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QStandardItem方法的具体用法?Python QtGui.QStandardItem怎么用?Python QtGui.QStandardItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QStandardItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _addChild
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def _addChild(self):
view = self._tabs.currentWidget()
lastRow = self._model.rowCount() - 1
item = self._model.item(lastRow, 0)
row = item.rowCount()
childItems = []
for i in range(0, self._model.columnCount()):
childItem = QtGui.QStandardItem(
"Child {r}, {c}".format(r=row, c=i))
childItems.append(childItem)
item.appendRow(childItems)
# -----------------------------------------------------------------------------
示例2: createGroup
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def createGroup(self):
"""
Slot to create a password group.
"""
dialog = AddGroupDialog(self.pwMap.groups)
if not dialog.exec_():
return
groupName = dialog.newGroupName()
newItem = QtGui.QStandardItem(groupName)
self.groupsModel.appendRow(newItem)
self.pwMap.addGroup(q2s(groupName))
# make new item selected to save a few clicks
itemIdx = self.groupsModel.indexFromItem(newItem)
proxyIdx = self.groupsFilter.mapFromSource(itemIdx)
self.groupsTree.selectionModel().select(proxyIdx,
QtGui.QItemSelectionModel.ClearAndSelect | QtGui.QItemSelectionModel.Rows)
self.groupsTree.sortByColumn(0, QtCore.Qt.AscendingOrder)
# Make item's passwords loaded so new key-value entries can be created
# right away - better from UX perspective.
self.loadPasswords(newItem)
self.setModified(True)
示例3: row_append
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def row_append(self, src, dst, proto, info):
self.model.appendRow((QtGui.QStandardItem(src),
QtGui.QStandardItem(dst),
QtGui.QStandardItem(proto),
QtGui.QStandardItem(info)))
示例4: _addColumn
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def _addColumn(self):
view = self._tabs.currentWidget()
col = self._model.columnCount()
items = []
for i in range(0, self._model.rowCount()):
item = QtGui.QStandardItem("Item {r}, {c}".format(r=i, c=col))
items.append(item)
self._model.appendColumn(items)
self._model.setHorizontalHeaderItem(col,
QtGui.QStandardItem("Col: " + str(col)))
# -------------------------------------------------------------------------
示例5: _addRow
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def _addRow(self):
view = self._tabs.currentWidget()
row = self._model.rowCount()
items = []
for i in range(0, self._model.columnCount()):
item = QtGui.QStandardItem("Item {r}, {c}".format(r=row, c=i))
items.append(item)
self._model.appendRow(items)
# -------------------------------------------------------------------------
示例6: update_object_extruders_cb
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def update_object_extruders_cb(self):
actual_index = self.object_extruder_c.currentIndex()
self.object_extruder_c.clear()
model = self.object_extruder_c.model()
for n, i in enumerate(['Extruder 1', 'Extruder 2', 'Extruder 3', 'Extruder 4']):
item = QStandardItem(str(i))
item.setBackground(self.controller.get_extruder_color(n+1))
model.appendRow(item)
self.object_extruder_c.setCurrentIndex(actual_index)
示例7: update_files_list
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def update_files_list(self):
self.tools = Tools()
# initialize model for inserting to table
model = QtGui.QStandardItemModel(1, 1)
model.setHorizontalHeaderLabels(['File name', 'File size', 'Mimetype', 'File ID'])
self.current_bucket_index = self.file_manager_ui.bucket_select_combo_box.currentIndex()
self.current_selected_bucket_id = self.bucket_id_list[self.current_bucket_index]
i = 0
try:
for self.file_details in self.storj_engine.storj_client.bucket_files(str(self.current_selected_bucket_id)):
item = QtGui.QStandardItem(str(self.file_details['filename'].replace('[DECRYPTED]', "")))
model.setItem(i, 0, item) # row, column, item (StandardItem)
file_size_str = self.tools.human_size(int(self.file_details["size"])) # get human readable file size
item = QtGui.QStandardItem(str(file_size_str))
model.setItem(i, 1, item) # row, column, item (QQtGui.StandardItem)
item = QtGui.QStandardItem(str(self.file_details['mimetype']))
model.setItem(i, 2, item) # row, column, item (QStandardItem)
item = QtGui.QStandardItem(str(self.file_details['id']))
model.setItem(i, 3, item) # row, column, item (QStandardItem)
i = i + 1
self.__logger.info(self.file_details)
except sjexc.StorjBridgeApiError as e:
self.__logger.error(e)
self.file_manager_ui.files_list_tableview.clearFocus()
self.file_manager_ui.files_list_tableview.setModel(model)
self.file_manager_ui.files_list_tableview.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
示例8: initialize_buckets_table
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def initialize_buckets_table(self):
self.storj_engine = StorjEngine() # Init StorjEngine
self.__logger.info('resolving buckets')
# Initialize model for inserting to table
model = QStandardItemModel(1, 1)
model.setHorizontalHeaderLabels(['Name', 'Storage', 'Transfer', 'ID'])
i = 0
try:
for bucket in self.storj_engine.storj_client.bucket_list():
item = QStandardItem(bucket.name)
model.setItem(i, 0, item) # row, column, item (QStandardItem)
item = QStandardItem(str(bucket.storage))
model.setItem(i, 1, item) # row, column, item (QStandardItem)
item = QStandardItem(str(bucket.transfer))
model.setItem(i, 2, item) # row, column, item (QStandardItem)
item = QStandardItem(bucket.id)
model.setItem(i, 3, item) # row, column, item (QStandardItem)
i = i + 1
except sjexc.StorjBridgeApiError as e:
QtGui.QMessageBox.about(
self,
'Unhandled bucket resolving exception',
'Exception: %s' % e)
# Set label of user buckets number
self.bucket_manager_ui.total_buckets_label.setText(str(i))
self.bucket_manager_ui.bucket_list_tableview.setModel(model)
self.bucket_manager_ui.bucket_list_tableview.horizontalHeader().\
setResizeMode(QtGui.QHeaderView.Stretch)
示例9: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def __init__(self, passwds, database):
"""
@param passwds: a PasswordMap instance w/ encrypted passwords
@param database: file name for saving pwMap
"""
DeOS_Vault.__init__(self, passwds, database)
self.groupsTree.setModel(self.groupsFilter)
self.groupsTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.groupsTree.customContextMenuRequested.connect(self.showGroupsContextMenu)
self.groupsTree.clicked.connect(self.loadPasswordsBySelection)
self.groupsTree.selectionModel().selectionChanged.connect(self.loadPasswordsBySelection)
self.groupsTree.setSortingEnabled(True)
self.passwordTable.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.passwordTable.customContextMenuRequested.connect(self.showPasswdContextMenu)
self.passwordTable.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self.passwordTable.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
# Shortcut
shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"), self.passwordTable, self.copyPasswordFromSelection)
shortcut.setContext(QtCore.Qt.WidgetShortcut)
# Action Triggers
self.actionQuit.triggered.connect(self.close)
self.actionBackup.triggered.connect(self.saveBackup)
self.actionSave.triggered.connect(self.saveDatabase)
self.actionSave.setShortcut(QtGui.QKeySequence("Ctrl+S"))
# Header Key/Value Items
headerKey = QtGui.QTableWidgetItem("Key");
headerValue = QtGui.QTableWidgetItem("Value");
# Password Table
self.passwordTable.setColumnCount(2)
self.passwordTable.setHorizontalHeaderItem(self.KEY_IDX, headerKey)
self.passwordTable.setHorizontalHeaderItem(self.PASSWORD_IDX, headerValue)
# Search Edit
self.searchEdit.textChanged.connect(self.filterGroups)
# Groups
groupNames = self.pwMap.groups.keys()
for groupName in groupNames:
item = QtGui.QStandardItem(s2q(groupName))
self.groupsModel.appendRow(item)
# Groups Tree
self.groupsTree.sortByColumn(0, QtCore.Qt.AscendingOrder)
示例10: apply_data_to_file_table
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QStandardItem [as 别名]
def apply_data_to_file_table(self, files_data):
model = TableModel(1, 1)
file_list_header_labels = ['File name', 'File size', 'File ID']
if DISPLAY_FILE_CREATION_DATE_IN_MAIN:
file_list_header_labels.append('Creation date')
model.setHorizontalHeaderLabels(file_list_header_labels)
i = 0
for self.file_details in files_data:
item = QtGui.QStandardItem(
str(self.file_details['filename'].replace('[DECRYPTED]', ''))
.decode('utf8'))
model.setItem(i, 0, item) # row, column, item (StandardItem)
# get human readable file size
file_size_str =\
self.tools.human_size(int(self.file_details['size']))
item = QtGui.QStandardItem(str(file_size_str))
model.setItem(i, 1, item) # row, column, item (QQtGui.StandardItem)
item = QtGui.QStandardItem(str(self.file_details['id']))
model.setItem(i, 2, item) # row, column, item (QStandardItem)
if DISPLAY_FILE_CREATION_DATE_IN_MAIN:
item = QtGui.QStandardItem(str(self.file_details[
'created']).replace('Z', '').replace('T', ' '))
model.setItem(i, 3, item) # row, column, item (QStandardItem)
i = i + 1
self.__logger.debug(self.file_details['filename'].
replace('[DECRYPTED]', '').decode('utf8'))
self.file_manager_ui.files_list_tableview.clearFocus()
self.file_manager_ui.files_list_tableview.setModel(model)
self.file_manager_ui.files_list_tableview.horizontalHeader().\
setResizeMode(QtGui.QHeaderView.Stretch)
if FILE_LIST_SORTING_MAIN_ENABLED:
self.file_manager_ui.files_list_tableview.setSortingEnabled(True)
self.file_manager_ui.files_list_tableview.horizontalHeader().sortIndicatorChanged.connect(
self.handleSortIndicatorChanged)
self.file_manager_ui.files_list_tableview.sortByColumn(
0, QtCore.Qt.AscendingOrder)
self.emit(QtCore.SIGNAL('changeLoadingGif'), False)
return True