本文整理汇总了Python中PySide.QtGui.QTableWidgetItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QTableWidgetItem方法的具体用法?Python QtGui.QTableWidgetItem怎么用?Python QtGui.QTableWidgetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui
的用法示例。
在下文中一共展示了QtGui.QTableWidgetItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_data_to_table
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def add_data_to_table(self, route):
self.tableWidget_path.setRowCount(len(route))
for i, row in enumerate(route):
for j, col in enumerate(row):
item = QtGui.QTableWidgetItem("{}".format(col))
self.tableWidget_path.setItem(i, j, item)
if j in [1, 2]:
self.tableWidget_path.item(i, j).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
if row[1] == "HS":
color = QtGui.QColor(223, 240, 216)
elif row[1] == "LS":
color = QtGui.QColor(252, 248, 227)
elif row[1] == "NS":
color = QtGui.QColor(242, 222, 222)
else:
color = QtGui.QColor(210, 226, 242)
if j == 3 and "wormhole" in col:
self.tableWidget_path.item(i, j).setIcon(self.icon_wormhole)
self.tableWidget_path.item(i, j).setBackground(color)
self.tableWidget_path.item(i, j).setForeground(QtGui.QColor(0, 0, 0))
示例2: OnScan
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def OnScan(self):
self.tableWidget.setRowCount(0)
self.export_btn.setDisabled(True)
self.filter_btn.setDisabled(True)
self.scan_btn.setDisabled(True)
self.scan_btn.setText("Scanning...")
self.parent.repaint()
seg = int(self.seg_combo.itemText(self.seg_combo.currentIndex()).split(' ')[0], 16)
min_refs = int(self.refcount_box.text())
refs = dxc_scan_refs(seg, min_refs)
self.tableWidget.setRowCount(len(refs))
for i, row in enumerate(refs):
addr_item = QtGui.QTableWidgetItem()
addr_item.setData(QtCore.Qt.EditRole, row[0])
addr_item.setData(QtCore.Qt.DisplayRole, str(hex(row[0])))
count_item = QtGui.QTableWidgetItem()
count_item.setData(QtCore.Qt.EditRole, row[1])
count_item.setData(QtCore.Qt.DisplayRole, str(row[1]))
self.tableWidget.setItem(i, 0, addr_item)
self.tableWidget.setItem(i, 1, count_item)
self.scan_btn.setText("Scan")
self.scan_btn.setDisabled(False)
self.filter_btn.setDisabled(False)
self.export_btn.setDisabled(False)
示例3: get_QTableWidgetItem
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def get_QTableWidgetItem():
"""QTableWidgetItem getter."""
try:
import PySide.QtGui as QtGui
return QtGui.QTableWidgetItem
except ImportError:
import PyQt5.QtWidgets as QtWidgets
return QtWidgets.QTableWidgetItem
示例4: refresh
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def refresh(self):
table = DB._get_table_info(self._source).table
labels = table.field_names
self.setColumnCount(len(labels))
self.setRowCount(len(table))
self.setVerticalHeaderLabels(['>' if record is table.current_record else ' ' for record in table])
self.setHorizontalHeaderLabels(labels)
for i, record in enumerate(table):
for j, val in enumerate(record):
self.setItem(i, j, QtGui.QTableWidgetItem(_str(val)))
示例5: newLang_action
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def newLang_action(self):
if len(self.memoData['fileList'].keys()) == 0:
print("You need have UI name structure loaded in order to create a new language.")
else:
text, ok = QtWidgets.QInputDialog.getText(self, 'New Translation Creation', 'Enter language file name (eg. lang_cn):')
if ok:
if text in self.memoData['fileList'].keys():
print("This Language already in the table.")
else:
self.uiList['dict_table'].insertColumn(self.uiList['dict_table'].columnCount())
index = self.uiList['dict_table'].columnCount() - 1
self.uiList['dict_table'].setHorizontalHeaderItem(index, QtWidgets.QTableWidgetItem(text) )
示例6: memory_to_source_ui
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def memory_to_source_ui(self):
# update ui once memory gets update
txt='\n'.join([row for row in self.memoData['fileList']])
self.uiList['source_txtEdit'].setText(txt)
# table
table = self.uiList['dict_table']
table.clear()
table.setRowCount(0)
table.setColumnCount(0)
headers = ["UI Name"]
table.insertColumn(table.columnCount())
for key in self.memoData['fileList']:
headers.append(key)
table.insertColumn(table.columnCount())
table.setHorizontalHeaderLabels(headers)
ui_name_ok = 0
translate = 1
for file in self.memoData['fileList']:
for row, ui_name in enumerate(self.memoData['fileList'][file]):
#create ui list
if ui_name_ok == 0:
ui_item = QtWidgets.QTableWidgetItem(ui_name)
table.insertRow(table.rowCount())
table.setItem(row, 0, ui_item)
translate_item = QtWidgets.QTableWidgetItem(self.memoData['fileList'][file][ui_name])
table.setItem(row, translate, translate_item)
ui_name_ok = 1
translate +=1
示例7: changeTableHeader
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def changeTableHeader(self, index):
table = self.uiList["dict_table"]
oldHeader = str(table.horizontalHeaderItem(index).text())
text, ok = QtGui.QInputDialog.getText(self, 'Change header label for column %d' % index,'Header:',QtGui.QLineEdit.Normal, oldHeader)
if ok:
if text in self.memoData['fileList'].keys():
print("This Language already in the table.")
else:
table.setHorizontalHeaderItem(index, QtGui.QTableWidgetItem(text) )
#~~~~~~~~~~~~~~
# default ui function
示例8: memory_to_source_ui
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def memory_to_source_ui(self):
# update ui once memory gets update
txt='\n'.join([row for row in self.memoData['fileList']])
self.uiList['source_txtEdit'].setText(txt)
# table
table = self.uiList['dict_table']
table.clear()
table.setRowCount(0)
table.setColumnCount(0)
headers = ["UI Name"]
table.insertColumn(table.columnCount())
for key in self.memoData['fileList']:
headers.append(key)
table.insertColumn(table.columnCount())
table.setHorizontalHeaderLabels(headers)
ui_name_ok = 0
translate = 1
for file in self.memoData['fileList']:
for row, ui_name in enumerate(self.memoData['fileList'][file]):
#create ui list
if ui_name_ok == 0:
ui_item = QtGui.QTableWidgetItem(ui_name)
table.insertRow(table.rowCount())
table.setItem(row, 0, ui_item)
translate_item = QtGui.QTableWidgetItem(self.memoData['fileList'][file][ui_name])
table.setItem(row, translate, translate_item)
ui_name_ok = 1
translate +=1
示例9: floatAsItem
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def floatAsItem(self, value):
item = QTableWidgetItem()
item.setData(Qt.EditRole, value)
return item
#Change commmand string when combo box changes
示例10: addButton_onClicked
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def addButton_onClicked(self):
if(len(self.poseName.text()) > 0):
rowPosition = self.table.rowCount()
self.table.insertRow(rowPosition)
self.table.setVerticalHeaderItem(rowPosition, QtGui.QTableWidgetItem(self.poseName.text()))
self.poseName.setText('')
self.table.setItem(rowPosition , 0, self.floatAsItem(0.5))
self._updateWidgetSize()
# Delete selected row
示例11: init_ui
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def init_ui(self):
"""
Initialized graphical elements. Literally just filling a table.
"""
# set shape (rows by cols
self.shape = (len(self.mice_weights), len(self.colnames.keys()))
self.setRowCount(self.shape[0])
self.setColumnCount(self.shape[1])
for row in range(self.shape[0]):
for j, col in enumerate(self.colnames.keys()):
try:
if col == "date":
format_date = datetime.datetime.strptime(self.mice_weights[row][col], '%y%m%d-%H%M%S')
format_date = format_date.strftime('%b %d')
item = QtGui.QTableWidgetItem(format_date)
elif col == "stop":
stop_wt = str(self.mice_weights[row][col])
minimum = float(self.mice_weights[row]['minimum_mass'])
item = QtGui.QTableWidgetItem(stop_wt)
if float(stop_wt) < minimum:
item.setBackground(QtGui.QColor(255,0,0))
else:
item = QtGui.QTableWidgetItem(str(self.mice_weights[row][col]))
except:
item = QtGui.QTableWidgetItem(str(self.mice_weights[row][col]))
self.setItem(row, j, item)
# make headers
self.setHorizontalHeaderLabels(self.colnames.values())
self.resizeColumnsToContents()
self.updateGeometry()
self.adjustSize()
self.sortItems(0)
示例12: __lt__
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def __lt__(self, other):
if isinstance(other, QCustomTableWidgetItem):
try:
selfDataValue = float(self.data(QtCore.Qt.EditRole))
otherDataValue = float(other.data(QtCore.Qt.EditRole))
return selfDataValue < otherDataValue
except ValueError:
# Can not be converted to float, so probably does not need to be (str, unicode)
selfDataValue = self.data(QtCore.Qt.EditRole)
otherDataValue = other.data(QtCore.Qt.EditRole)
return selfDataValue < otherDataValue
else:
return QtGui.QTableWidgetItem.__lt__(self, other)
示例13: PopulateForm
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def PopulateForm(self):
vboxLayout = QtGui.QVBoxLayout()
self.tableWidget.setRowCount(1)
self.tableWidget.setColumnCount(2)
self.tableWidget.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Address"))
self.tableWidget.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem("Reference Count"))
gridLayout = QtGui.QGridLayout()
self.seg_combo.addItems(dxc_get_segments())
self.seg_combo.setMaximumWidth(100)
self.seg_combo.setFixedWidth(100)
gridLayout.addWidget(QtGui.QLabel("Segment start:"), 0, 0)
gridLayout.addWidget(self.seg_combo, 0, 1)
gridLayout.addWidget(QtGui.QLabel("Minimum ref count:"), 1, 0)
self.refcount_box.setMaximumWidth(100)
self.refcount_box.setFixedWidth(100)
self.refcount_box.setText("50")
self.minfilter_box.setMaximumWidth(100)
self.minfilter_box.setFixedWidth(100)
self.maxfilter_box.setMaximumWidth(100)
self.maxfilter_box.setFixedWidth(100)
self.minfilter_box.setText("0")
self.maxfilter_box.setText("100000")
gridLayout.addWidget(self.export_btn, 0, 2)
gridLayout.addWidget(self.refcount_box, 1, 1)
gridLayout.addWidget(self.scan_btn, 1, 2)
gridLayout.addWidget(self.minfilter_box, 2, 0)
gridLayout.addWidget(self.maxfilter_box, 2, 1)
gridLayout.addWidget(self.filter_btn, 2, 2)
gridLayout.addWidget(self.tableWidget, 3, 0, 1, 5)
self.export_btn.clicked.connect(self.OnExport)
self.scan_btn.clicked.connect(self.OnScan)
self.filter_btn.clicked.connect(self.OnFilter)
self.tableWidget.cellDoubleClicked.connect(self.OnJump)
self.tableWidget.horizontalHeader().sectionClicked.connect(self.OnSectionClicked)
gridLayout.setColumnStretch(4, 1)
vboxLayout.addLayout(gridLayout)
self.parent.setLayout(vboxLayout)
示例14: setupUI
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def setupUI(self):
super(self.__class__,self).setupUI('grid')
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('box_btn;Box | sphere_btn;Sphere | ring_btn;Ring', 'my_layout;grid', 'h')
self.qui('box2_btn;Box2 | sphere2_btn;Sphere2 | ring2_btn;Ring2', 'my_layout', 'h')
self.qui('cat_btn;Cat | dog_btn;Dog | pig_btn;Pig', 'pet_layout;grid', 'v')
self.qui('cat2_btn;Cat2 | dog2_btn;Dog2 | pig2_btn;Pig2', 'pet_layout', 'v')
self.qui('name_input@Name:;John | email_input@Email:;test@test.com', 'entry_form')
self.qui('user2_btn;User2 | info2_btn;Info2', 'my_grp;vbox,Personal Data')
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('my_layout | my_table | input_split | entry_form | fileBtn_layout | pet_layout | my_grp', 'main_layout')
cur_table = self.uiList['my_table']
cur_table.setRowCount(0)
cur_table.setColumnCount(1)
cur_table.insertColumn(cur_table.columnCount())
cur_item = QtWidgets.QTableWidgetItem('ok') #QtWidgets.QPushButton('Cool') #
cur_table.insertRow(0)
cur_table.setItem(0,1, cur_item) #setCellWidget(0,0,cur_item)
cur_table.setHorizontalHeaderLabels(('a','b'))
'''
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
'''
self.memoData['settingUI']=[]
#------------- end ui creation --------------------
keep_margin_layout = ['main_layout']
keep_margin_layout_obj = []
# add tab layouts
for each in self.uiList.values():
if isinstance(each, QtWidgets.QTabWidget):
for i in range(each.count()):
keep_margin_layout_obj.append( each.widget(i).layout() )
for name, each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name not in keep_margin_layout and not name.endswith('_grp_layout') and each not in keep_margin_layout_obj:
each.setContentsMargins(0, 0, 0, 0)
self.quickInfo('Ready')
# self.statusBar().hide()
示例15: setupUI
# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QTableWidgetItem [as 别名]
def setupUI(self):
super(self.__class__,self).setupUI('grid')
#------------------------------
# user ui creation part
#------------------------------
# + template: qui version since universal tool template v7
# - no extra variable name, all text based creation and reference
self.qui('box_btn;Box | sphere_btn;Sphere | ring_btn;Ring', 'my_layout;grid', 'h')
self.qui('box2_btn;Box2 | sphere2_btn;Sphere2 | ring2_btn;Ring2', 'my_layout', 'h')
self.qui('cat_btn;Cat | dog_btn;Dog | pig_btn;Pig', 'pet_layout;grid', 'v')
self.qui('cat2_btn;Cat2 | dog2_btn;Dog2 | pig2_btn;Pig2', 'pet_layout', 'v')
self.qui('name_input@Name:;John | email_input@Email:;test@test.com', 'entry_form')
self.qui('user2_btn;User2 | info2_btn;Info2', 'my_grp;vbox,Personal Data')
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('my_layout | my_table | input_split | entry_form | fileBtn_layout | pet_layout | my_grp', 'main_layout')
cur_table = self.uiList['my_table']
cur_table.setRowCount(0)
cur_table.setColumnCount(1)
cur_table.insertColumn(cur_table.columnCount())
cur_item = QtWidgets.QTableWidgetItem('ok') #QtWidgets.QPushButton('Cool') #
cur_table.insertRow(0)
cur_table.setItem(0,1, cur_item) #setCellWidget(0,0,cur_item)
cur_table.setHorizontalHeaderLabels(('a','b'))
'''
self.qui('source_txt | process_btn;Process and Update', 'upper_vbox')
self.qui('upper_vbox | result_txt', 'input_split;v')
self.qui('filePath_input | fileLoad_btn;Load | fileExport_btn;Export', 'fileBtn_layout;hbox')
self.qui('input_split | fileBtn_layout', 'main_layout')
'''
#------------- end ui creation --------------------
keep_margin_layout = ['main_layout']
keep_margin_layout_obj = []
# add tab layouts
for each in self.uiList.values():
if isinstance(each, QtWidgets.QTabWidget):
for i in range(each.count()):
keep_margin_layout_obj.append( each.widget(i).layout() )
for name, each in self.uiList.items():
if isinstance(each, QtWidgets.QLayout) and name not in keep_margin_layout and not name.endswith('_grp_layout') and each not in keep_margin_layout_obj:
each.setContentsMargins(0, 0, 0, 0)
self.quickInfo('Ready')
# self.statusBar().hide()