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


Python QtGui.QTableWidget方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def __init__(self, parent=None):
        super(buttonEditor, self).__init__(parent)
        self.ecurequestsparser = None

        self.layout = None
        self.layouth = widgets.QHBoxLayout()
        self.buttontable = widgets.QTableWidget()
        self.layoutv = widgets.QVBoxLayout()

        self.layouth.addWidget(self.buttontable)
        self.layouth.addLayout(self.layoutv)

        self.buttondata = buttonData()
        self.layoutv.addWidget(self.buttondata)

        self.setLayout(self.layouth)

        self.buttontable.setFixedWidth(250)
        self.buttontable.setColumnCount(2)
        self.buttontable.verticalHeader().hide()
        self.buttontable.setSelectionBehavior(widgets.QAbstractItemView.SelectRows)
        self.buttontable.setSelectionMode(widgets.QAbstractItemView.SingleSelection)
        #self.buttontable.setShowGrid(False)
        self.buttontable.itemSelectionChanged.connect(self.selection_changed)
        self.enable_view(False) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:27,代碼來源:dataeditor.py

示例2: edit_modeltable

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def edit_modeltable(self):
        '''
        - Called when editing model inplace in QTableWidget
        - Set states of other components
        - Get data from the modeltable of the selected row
        - Edit name and value as per needed
        - Add the val name pair in the modeldict
        '''

        self.savebtn.setDisabled(False)
        try:
            indexitem = self.modeltable.currentItem()
            name = str(indexitem.data(0))
            rowno = indexitem.row()
            para = self.modeltable.item(rowno, 0)
            val = str(para.data(0))
            self.modeldict[val] = name
        except BaseException:
            pass 
開發者ID:FOSSEE,項目名稱:eSim,代碼行數:21,代碼來源:ModelEditor.py

示例3: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def __init__(self, parent=None):
        super(sniffer, self).__init__(parent)
        self.ecu_file = None
        self.ecurequests = None
        self.snifferthread = None
        self.currentrequest = None
        self.names = []
        self.oktostart = False
        self.ecu_filter = ""

        hlayout = widgets.QHBoxLayout()

        self.framecombo = widgets.QComboBox()

        self.startbutton = widgets.QPushButton(">>")
        self.addressinfo = widgets.QLabel("0000")

        self.startbutton.setCheckable(True)
        self.startbutton.toggled.connect(self.startmonitoring)

        self.addressinfo.setFixedWidth(90)
        self.startbutton.setFixedWidth(90)

        hlayout.addWidget(self.addressinfo)
        hlayout.addWidget(self.framecombo)
        hlayout.addWidget(self.startbutton)

        vlayout = widgets.QVBoxLayout()
        self.setLayout(vlayout)

        vlayout.addLayout(hlayout)

        self.table = widgets.QTableWidget()
        vlayout.addWidget(self.table)

        self.framecombo.activated.connect(self.change_frame) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:38,代碼來源:sniffer.py

示例4: initUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def initUi(self):
        """初始化界麵"""
        self.setWindowTitle(u'日誌')

        self.setColumnCount(2)                     
        self.setHorizontalHeaderLabels([u'時間', u'日誌'])

        self.verticalHeader().setVisible(False)                 # 關閉左邊的垂直表頭
        self.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) # 設為不可編輯狀態

        # 自動調整列寬
        self.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
        self.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.Stretch)        

    #---------------------------------------------------------------------- 
開發者ID:sunshinelover,項目名稱:chanlun,代碼行數:17,代碼來源:demoUi.py

示例5: initUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def initUi(self):
        """初始化界麵"""
        self.setWindowTitle(u'日誌')

        self.setColumnCount(2)
        self.setHorizontalHeaderLabels([u'時間', u'日誌'])

        self.verticalHeader().setVisible(False)                 # 關閉左邊的垂直表頭
        self.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) # 設為不可編輯狀態

        # 自動調整列寬
        self.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
        self.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.Stretch)

    #---------------------------------------------------------------------- 
開發者ID:sunshinelover,項目名稱:chanlun,代碼行數:17,代碼來源:demoUi - 副本.py

示例6: setLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name] 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:41,代碼來源:universal_tool_template_1116.py

示例7: addparameters

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def addparameters(self):
        '''
        - Called when `Add` button clicked beside QTableWidget
        - Open up dialog box to enter parameter and value accordingly
        - Validate if parameter already in list of parameters
        - Accordingly add parameter and value in modeldict as well as table
        - text1 => parameter, text2 => value
        '''
        text1, ok = QtGui.QInputDialog.getText(
            self, 'Parameter', 'Enter Parameter')
        if ok:
            if text1 in list(self.modeldict.keys()):
                self.msg = QtGui.QErrorMessage(self)
                self.msg.setModal(True)
                self.msg.setWindowTitle("Error Message")
                self.msg.showMessage(
                    "The paramaeter " + text1 + " is already in the list")
                self.msg.exec_()
                return
            text2, ok = QtGui.QInputDialog.getText(
                self, 'Value', 'Enter Value')
            if ok:
                currentRowCount = self.modeltable.rowCount()
                self.modeltable.insertRow(currentRowCount)
                self.modeltable.setItem(
                    currentRowCount, 0, QTableWidgetItem(text1))
                self.modeltable.setItem(
                    currentRowCount, 1, QTableWidgetItem(text2))
                self.modeldict[str(text1)] = str(text2)
            else:
                pass
        else:
            pass 
開發者ID:FOSSEE,項目名稱:eSim,代碼行數:35,代碼來源:ModelEditor.py

示例8: setupUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def setupUi(self, Logs):
        Logs.setObjectName(_fromUtf8("Logs"))
        Logs.resize(930, 369)
        self.label = QtGui.QLabel(Logs)
        self.label.setGeometry(QtCore.QRect(10, 10, 911, 31))
        self.label.setObjectName(_fromUtf8("label"))
        self.line = QtGui.QFrame(Logs)
        self.line.setGeometry(QtCore.QRect(10, 40, 911, 21))
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName(_fromUtf8("line"))
        self.logs_table = QtGui.QTableWidget(Logs)
        self.logs_table.setGeometry(QtCore.QRect(10, 60, 911, 251))
        self.logs_table.setObjectName(_fromUtf8("logs_table"))
        self.logs_table.setColumnCount(0)
        self.logs_table.setRowCount(0)
        self.exit_bt = QtGui.QPushButton(Logs)
        self.exit_bt.setGeometry(QtCore.QRect(790, 330, 131, 26))
        self.exit_bt.setObjectName(_fromUtf8("exit_bt"))
        self.save_logs_as_bt = QtGui.QPushButton(Logs)
        self.save_logs_as_bt.setGeometry(QtCore.QRect(650, 330, 131, 26))
        self.save_logs_as_bt.setObjectName(_fromUtf8("save_logs_as_bt"))
        self.logs_settings_bt = QtGui.QPushButton(Logs)
        self.logs_settings_bt.setGeometry(QtCore.QRect(510, 330, 131, 26))
        self.logs_settings_bt.setObjectName(_fromUtf8("logs_settings_bt"))
        self.label_2 = QtGui.QLabel(Logs)
        self.label_2.setGeometry(QtCore.QRect(10, 320, 181, 41))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.total_log_positions = QtGui.QLabel(Logs)
        self.total_log_positions.setGeometry(QtCore.QRect(200, 320, 131, 41))
        self.total_log_positions.setObjectName(_fromUtf8("total_log_positions"))
        self.clear_logs_bt = QtGui.QPushButton(Logs)
        self.clear_logs_bt.setGeometry(QtCore.QRect(370, 330, 131, 26))
        self.clear_logs_bt.setObjectName(_fromUtf8("clear_logs_bt"))

        self.retranslateUi(Logs)
        QtCore.QMetaObject.connectSlotsByName(Logs) 
開發者ID:lakewik,項目名稱:EasyStorj,代碼行數:39,代碼來源:logs_table_ui.py

示例9: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def __init__(self):
        """
            Setup widgets and select client data from the database.
        """
        super(ClientsListWidget, self).__init__()

        # Defines all layouts
        self.mainLayout = QtGui.QVBoxLayout()
        self.listLayout = QtGui.QHBoxLayout()
        self.btnsLayout = QtGui.QVBoxLayout()

        # Window config
        self.titleLabel = QtGui.QLabel(u"Clientes", self)
        self.titleLabel.setFont(titleFont)

        # Creates all buttons and add them to the btnsLayout
        self.addBtn = QtGui.QPushButton(u"Adicionar")
        self.addBtn.clicked.connect(self.add_client)
        self.editBtn = QtGui.QPushButton(u"Editar")
        self.editBtn.clicked.connect(self.update_client)
        self.removeBtn = QtGui.QPushButton(u"Remover")
        self.removeBtn.clicked.connect(self.remove_client)
        self.btnsLayout.addWidget(self.addBtn)
        self.btnsLayout.addWidget(self.editBtn)
        self.btnsLayout.addWidget(self.removeBtn)
        self.btnsLayout.addStretch()

        # Creates a table widget for showing cilents
        # and loads them
        self.clientsTable = QtGui.QTableWidget()
        self.load_table()

        # Add the btnsLayout and clientsTable to an horizontal layout
        self.listLayout.addWidget(self.clientsTable)
        self.listLayout.addLayout(self.btnsLayout)

        # A label for showing errors
        self.errorMsg = QtGui.QLabel(u"", self)
        self.errorMsg.setStyleSheet("color: red; font-weight: bold;")

        # Add all widgets to the mainLayout
        self.mainLayout.addWidget(self.titleLabel)
        self.mainLayout.addLayout(self.listLayout)
        self.mainLayout.addWidget(self.errorMsg)

        # Set the mainLayout as the visible layout
        self.setLayout(self.mainLayout) 
開發者ID:juliarizza,項目名稱:certificate_generator,代碼行數:49,代碼來源:clients.py

示例10: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QTableWidget [as 別名]
def __init__(self):
        """
            Setup widgets and select client data from the
            database.
        """
        super(EventsListWidget, self).__init__()

        # Defines all layouts
        self.mainLayout = QtGui.QVBoxLayout()
        self.listLayout = QtGui.QHBoxLayout()
        self.btnsLayout = QtGui.QVBoxLayout()

        # Window config
        self.titleLabel = QtGui.QLabel(u"Eventos", self)
        self.titleLabel.setFont(titleFont)

        # Creates all buttons and add the to the btnsLayout
        self.addBtn = QtGui.QPushButton(u"Adicionar")
        self.addBtn.clicked.connect(self.add_event)
        self.editBtn = QtGui.QPushButton(u"Editar")
        self.editBtn.clicked.connect(self.update_event)
        self.removeBtn = QtGui.QPushButton(u"Remover")
        self.removeBtn.clicked.connect(self.remove_event)
        self.btnsLayout.addWidget(self.addBtn)
        self.btnsLayout.addWidget(self.editBtn)
        self.btnsLayout.addWidget(self.removeBtn)
        self.btnsLayout.addStretch()

        # Creates a table widget for showing events
        # and loads them
        self.eventsTable = QtGui.QTableWidget()
        self.load_table()

        # Add the btnsLayout and eventsTable to an
        # horizontal layout
        self.listLayout.addWidget(self.eventsTable)
        self.listLayout.addLayout(self.btnsLayout)

        # A label for showing errors
        self.errorMsg = QtGui.QLabel(u"", self)
        self.errorMsg.setStyleSheet("color: red; font-weight: bold;")

        # Add all widgets to the mainLayout
        self.mainLayout.addWidget(self.titleLabel)
        self.mainLayout.addLayout(self.listLayout)
        self.mainLayout.addWidget(self.errorMsg)

        # Set the mainLayout as the visible layout
        self.setLayout(self.mainLayout) 
開發者ID:juliarizza,項目名稱:certificate_generator,代碼行數:51,代碼來源:events.py


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