本文整理汇总了Python中PyQt4.QtGui.QTableWidgetItem方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QTableWidgetItem方法的具体用法?Python QtGui.QTableWidgetItem怎么用?Python QtGui.QTableWidgetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QTableWidgetItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open_FileDialog_tl
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def open_FileDialog_tl(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'File Open', './')
self.tl_label.setText(filename)
# check dimension and size
with open(filename, 'rb') as f:
global n_class
labels = pickle.load(f)
label_set = labels['train'].astype(np.int8)
max_idx = np.max(label_set) + 1 # includes '0' label
print("[INFO] #CLASSES: %d" % max_idx)
n_class = max_idx
item3 = QtGui.QTableWidgetItem(str(n_class))
self.table.setItem(self.table.rowCount()-1,2,item3)
# -----------------------------------------------------------------------
# Load PreDefined CNN
# -----------------------------------------------------------------------
示例2: addItem
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def addItem(self, row, data):
"""
This function add a item on a row
:param row: the row's number
:param data: the information
:return: None
"""
# state can be filtered, closed or open
# data[3] is state
if data[3] in ["open"]:
self.tableWidget.setVerticalHeaderItem(row, QTableWidgetItem(QIcon().fromTheme('list-add'), ''))
else:
self.tableWidget.setVerticalHeaderItem(row, QTableWidgetItem(QIcon().fromTheme('dialog-error'), ''))
for i, d in enumerate(data):
item = QTableWidgetItem(d)
item.setFlags(Qt.ItemIsEnabled)
self.tableWidget.setItem(row, i, item)
示例3: updateLog
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def updateLog(self, event):
"""更新日志"""
# 获取当前时间和日志内容
t = time.strftime('%H:%M:%S',time.localtime(time.time()))
log = event.dict_['log']
# 在表格最上方插入一行
self.insertRow(0)
# 创建单元格
cellTime = QtGui.QTableWidgetItem(t)
cellLog = QtGui.QTableWidgetItem(log)
# 将单元格插入表格
self.setItem(0, 0, cellTime)
self.setItem(0, 1, cellLog)
########################################################################
示例4: updateAccount
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def updateAccount(self, event):
""""""
data = event.dict_['data']
accountid = data['AccountID']
# 如果之前已经收到过这个账户的数据, 则直接更新
if accountid in self.dictAccount:
d = self.dictAccount[accountid]
for label, cell in d.items():
cell.setText(str(data[label]))
# 否则插入新的一行,并更新
else:
self.insertRow(0)
d = {}
for col, label in enumerate(self.dictLabels.keys()):
cell = QtGui.QTableWidgetItem(str(data[label]))
self.setItem(0, col, cell)
d[label] = cell
self.dictAccount[accountid] = d
########################################################################
示例5: updateTrade
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def updateTrade(self, event):
""""""
data = event.dict_['data']
self.insertRow(0)
for col, label in enumerate(self.dictLabels.keys()):
if label == 'Direction':
try:
value = self.dictDirection[data[label]]
except KeyError:
value = u'未知类型'
elif label == 'OffsetFlag':
try:
value = self.dictOffset[data[label]]
except KeyError:
value = u'未知类型'
else:
value = str(data[label])
cell = QtGui.QTableWidgetItem(value)
self.setItem(0, col, cell)
########################################################################
示例6: updateLog
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def updateLog(self, event):
"""更新日志"""
# 获取当前时间和日志内容
t = time.strftime('%H:%M:%S',time.localtime(time.time()))
log = event.dict_['log']
# 在表格最上方插入一行
self.insertRow(0)
# 创建单元格
cellTime = QtGui.QTableWidgetItem(t)
cellLog = QtGui.QTableWidgetItem(log)
# 将单元格插入表格
self.setItem(0, 0, cellTime)
self.setItem(0, 1, cellLog)
########################################################################
示例7: _set_table_widget_item
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def _set_table_widget_item(self, feature_attr, table_widget, row):
"""
Sets table widget items
:param feature_attr: Data from the GPX feature
:param table_widget: Table widget object
:param row: Feature count. To be used to set table row number
:return:
"""
check_box = None
for column_num, attr in enumerate(feature_attr):
if column_num == 0:
check_box = self._set_checkbox_item()
table_widget.setItem(row, column_num, check_box)
column_num += 1
if type(attr) is not basestring:
attr = unicode(attr)
table_widget.setItem(row, column_num, qg.QTableWidgetItem(attr))
return check_box
示例8: applyRegex
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def applyRegex (self):
requests=self.controller.getRequests()
if str(self.substSrcEdit.text()):
indexes=[]
n=self.tableWidget.rowCount()
for i in range(n):
if not self.tableWidget.isRowHidden(i):
indexes.append(i)
for i in indexes:
try:
requests[i].Substitute(str(self.substSrcEdit.text()),str(self.substDstEdit.text()))
self.tableWidget.setItem(i,1,QtGui.QTableWidgetItem(requests[i].urlWithoutPath))
self.tableWidget.setItem(i,2,QtGui.QTableWidgetItem(requests[i].pathWithVariables))
if requests[i]["Cookie"]:
self.tableWidget.setItem(i,3,QtGui.QTableWidgetItem(requests[i]["Cookie"]))
except Exception,a:
mb = QtGui.QMessageBox ("Error in substitution","ERROR !",QtGui.QMessageBox.Warning,QtGui.QMessageBox.Ok,0,0)
mb.exec_()
return
self.updateAllStats()
示例9: setStats
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def setStats(self, stats, selection):
# update the interface
for row in range(self.statisticsTable.rowCount()):
label = self.statisticsTable.item(row,0).text()
if label in stats:
item = QtGui.QTableWidgetItem(str(stats[label]))
self.statisticsTable.setItem(row, 1, item)
if selection:
if label in selection:
item = QtGui.QTableWidgetItem(str(selection[label]))
self.statisticsTable.setItem(row, 2, item)
else:
self.statisticsTable.setItem(row, 2, QtGui.QTableWidgetItem(""))
self.statisticsTable.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
self.statisticsTable.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.Stretch)
self.statisticsTable.horizontalHeader().setResizeMode(2, QtGui.QHeaderView.Stretch)
self.statisticsTable.resizeRowsToContents()
示例10: add_new_sync_directory
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def add_new_sync_directory(self):
self.selected_sync_sirectory = QtGui.QFileDialog.getExistingDirectory(
None,
'Select a sync directory: ',
"",
QtGui.QFileDialog.ShowDirsOnly)
if self.selected_sync_sirectory != "":
self.current_time = time.ctime()
total_files_count = self.tools.count_files_in_dir(directory=self.selected_sync_sirectory)
total_files_size = self.tools.human_size(self.tools.count_directory_size(self.selected_sync_sirectory, True))
table_row_count = self.sync_menu_ui.sync_directories_tableWidget.rowCount()
self.sync_menu_ui.sync_directories_tableWidget.setRowCount(table_row_count + 1)
self.sync_menu_ui.sync_directories_tableWidget.setItem(
table_row_count, 0, QtGui.QTableWidgetItem(str(self.selected_sync_sirectory)))
self.sync_menu_ui.sync_directories_tableWidget.setItem(
table_row_count, 1, QtGui.QTableWidgetItem(str(self.current_time)))
self.sync_menu_ui.sync_directories_tableWidget.setItem(
table_row_count, 2, QtGui.QTableWidgetItem(str(total_files_count)))
self.sync_menu_ui.sync_directories_tableWidget.setItem(
table_row_count, 3, QtGui.QTableWidgetItem(str(total_files_size)))
return True
示例11: add_row_files_queue_table
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def add_row_files_queue_table(self, row_data):
self.files_queue_progressbar_list.append(QtGui.QProgressBar())
self.files_queue_table_row_count = self.ui_single_file_upload.files_queue_table_widget.rowCount()
self.ui_single_file_upload.files_queue_table_widget.setRowCount(
self.files_queue_table_row_count + 1)
self.ui_single_file_upload.files_queue_table_widget.setItem(
self.files_queue_table_row_count, 0, QtGui.QTableWidgetItem(os.path.split(str(row_data['file_path']))[1]))
self.ui_single_file_upload.files_queue_table_widget.setItem(
self.files_queue_table_row_count, 1, QtGui.QTableWidgetItem(row_data['file_path']))
self.ui_single_file_upload.files_queue_table_widget.setItem(
self.files_queue_table_row_count, 2, QtGui.QTableWidgetItem(str(self.tools.human_size(os.path.getsize(str(row_data['file_path']))))))
self.ui_single_file_upload.files_queue_table_widget.setCellWidget(
self.files_queue_table_row_count, 3, self.files_queue_progressbar_list[self.files_queue_table_row_count])
示例12: add_key_to_database
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def add_key_to_database(self):
aircrack_log = config_dir + 'aircrack-log.txt'
# read cracked key
key = commands.getoutput("cat " + aircrack_log + " | grep 'KEY FOUND' | tr '[]' '\n' | egrep '([a-fA-F0-9]:)+' | tr -d ' \t'")
# insert a row in the database
self.table_database.insertRow(0)
item=QtGui.QTableWidgetItem()
item.setText(essid)
self.table_database.setItem(0, 0, item)
item=QtGui.QTableWidgetItem()
item.setText(self.ac)
self.table_database.setItem(0, 1, item)
item=QtGui.QTableWidgetItem()
item.setText(self.canale)
self.table_database.setItem(0, 2, item)
item=QtGui.QTableWidgetItem()
item.setText(key)
self.table_database.setItem(0, 3, item)
item=QtGui.QTableWidgetItem()
item.setText((key_to_ascii(key)))
self.table_database.setItem(0, 4, item)
#
# Database changed
#
示例13: slot_database_changed
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def slot_database_changed(self):
selrow = self.table_database.currentRow()
if selrow == -1:
return
key = str(self.table_database.item(selrow, 3))
item=QtGui.QTableWidgetItem()
item.setText((key_to_ascii(key)))
self.table_database.setItem(selrow, 4, item)
#
# Add an entry to the database table
#
示例14: change_frame
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def change_frame(self):
self.stopthread()
self.startbutton.setChecked(False)
self.names = []
framename = utf8(self.framecombo.currentText())
self.currentrequest = self.ecurequests.requests[framename]
self.ecu_filter = self.currentrequest.sentbytes
self.addressinfo.setText(self.ecu_filter)
self.names = self.currentrequest.dataitems.keys()
headernames = ";".join([n for n in self.names])
self.table.clear()
self.table.setColumnCount(1)
self.table.setRowCount(len(self.names))
headerstrings = headernames.split(";")
self.table.setVerticalHeaderLabels(headerstrings)
self.table.setHorizontalHeaderLabels([_("Values")])
for i in range(0, len(self.names)):
item = widgets.QTableWidgetItem(_("Waiting..."))
item.setFlags(item.flags() ^ core.Qt.ItemIsEditable)
self.table.setItem(i, 0, item)
self.table.resizeColumnsToContents()
self.table.resizeRowsToContents()
if not qt5:
self.table.horizontalHeader().setResizeMode(0, widgets.QHeaderView.Stretch)
else:
self.table.horizontalHeader().setSectionResizeMode(0, widgets.QHeaderView.Stretch)
示例15: init
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QTableWidgetItem [as 别名]
def init(self, ecureq):
try:
self.cellChanged.disconnect()
except:
pass
self.clear()
self.ecureq = ecureq
requestsk = self.ecureq.keys()
numrows = len(requestsk)
self.setRowCount(numrows)
self.setColumnCount(3)
self.setHorizontalHeaderLabels(str(_("Request name;Bytes;Manual")).split(";"))
count = 0
for req in requestsk:
request_inst = self.ecureq[req]
manual = checkBox(request_inst)
self.setItem(count, 0, widgets.QTableWidgetItem(req))
sbtext = request_inst.sentbytes
if len(sbtext) > 10:
sbtext = sbtext[0:10] + "..."
self.setItem(count, 1, widgets.QTableWidgetItem(sbtext))
self.setCellWidget(count, 2, manual)
count += 1
self.sortItems(0, core.Qt.AscendingOrder)
self.resizeColumnsToContents()
self.resizeRowsToContents()
self.cellChanged.connect(self.cellModified)