當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QStandardItemModel方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QStandardItemModel方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QStandardItemModel方法的具體用法?Python QtGui.QStandardItemModel怎麽用?Python QtGui.QStandardItemModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui的用法示例。


在下文中一共展示了QtGui.QStandardItemModel方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 別名]
def __init__(self, parent=None):
        QtGui.QTableView.__init__(self, parent)
        self.model = QtGui.QStandardItemModel(parent=self)
        self.model.setHorizontalHeaderLabels(['Source', 'Destination', 'Protoco', 'Info'])
        self.setModel(self.model)
        self.setColumnWidth(0, 120)
        self.setColumnWidth(1, 120)
        self.setColumnWidth(2, 100)
        self.setColumnWidth(3, 350)
        self.setAlternatingRowColors(True)
        self.setAutoScroll(True)
        self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) #整行選中
        self.setEditTriggers(QtGui.QTableView.NoEditTriggers) #不可編輯
        self.setSelectionMode(QtGui.QTableView.SingleSelection) #選擇單行
        self.show() 
開發者ID:HatBoy,項目名稱:SimpleSniffer,代碼行數:17,代碼來源:Sniffer.py

示例2: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 別名]
def __init__(self, flags):
    QtGui.QStandardItemModel.__init__(self)

    self.flags = flags
    self.header = []
    self.data = [] 
開發者ID:htm-community,項目名稱:nupic.studio,代碼行數:8,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 別名]
def __init__(self, *args, **kwargs):
		super(Outliner, self).__init__(*args, **kwargs)

		self.resize(200,500)
		self.setObjectName("CustomOutliner")

		self.layout = QtGui.QVBoxLayout(self)
		self.layout.setMargin(2)

		self.model = QtGui.QStandardItemModel()
		self.model.setItemPrototype(DagTreeItem())

		view = QtGui.QTreeView()
		view.setModel(self.model)
		view.header().setVisible(False)
		view.setEditTriggers(view.NoEditTriggers)
		view.setSelectionMode(view.ExtendedSelection)

		self.view = view
		self.layout.addWidget(self.view)

		QtCore.QTimer.singleShot(1, self.initDisplay)

		#
		# Connections
		#
		self.view.expanded.connect(self.nodeExpanded)
		self.view.selectionModel().selectionChanged.connect(self.selectionChanged) 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:30,代碼來源:outliner.py

示例4: update_files_list

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [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) 
開發者ID:lakewik,項目名稱:EasyStorj,代碼行數:42,代碼來源:file_manager.py

示例5: sort

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 別名]
def sort(self, column, order):
        if column == 0:
            self._sort_order = order
            QtGui.QStandardItemModel.sort(self, column, order) 
開發者ID:lakewik,項目名稱:EasyStorj,代碼行數:6,代碼來源:custom_qt_interfaces.py

示例6: initialize_buckets_table

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [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) 
開發者ID:lakewik,項目名稱:EasyStorj,代碼行數:38,代碼來源:bucket_manager.py

示例7: _set_groups_model

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QStandardItemModel [as 別名]
def _set_groups_model(self, header_labels):
        self.groupsModel = QtGui.QStandardItemModel()
        self.groupsModel.setHorizontalHeaderLabels(header_labels) 
開發者ID:1deos,項目名稱:deosorg,代碼行數:5,代碼來源:vault.py


注:本文中的PyQt4.QtGui.QStandardItemModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。