本文整理汇总了Python中PyQt5.QtWidgets.QTableWidget类的典型用法代码示例。如果您正苦于以下问题:Python QTableWidget类的具体用法?Python QTableWidget怎么用?Python QTableWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTableWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent = None):
QTableWidget.__init__(self, parent)
# init
# ------------------------------------------------
#FIXME: move this somewhere else maybe?
self.tmpSelectedItems = []
#FIXME: what does this do? put a comment, why 30,30?
self._sigmaList = None
self._featureGroupMapping = None # Schema: [ (groupName1, [entry, entry...]),
# (groupName2, [entry, entry...]) ]
#layout
# ------------------------------------------------
self.setCornerButtonEnabled(False)
self.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.setSelectionMode(QAbstractItemView.NoSelection)
self.setShowGrid(False)
self.viewport().installEventFilter(self)
self.setMouseTracking(1)
self.verticalHeader().setHighlightSections(False)
self.verticalHeader().setSectionsClickable(True)
self.horizontalHeader().setHighlightSections(False)
self.horizontalHeader().setSectionsClickable(True)
self.horizontalHeader().setMouseTracking(True)
self.horizontalHeader().installEventFilter(self)
self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.itemSelectionChanged.connect(self._tableItemSelectionChanged)
self.cellDoubleClicked.connect(self._featureTableItemDoubleClicked)
self.verticalHeader().sectionClicked.connect(self._expandOrCollapseVHeader)
示例2: __init__
def __init__(self, parent, configuration):
QTableWidget.__init__(self, 5, 1, parent)
self._configuration = configuration
self._manual_change = True
self.setVerticalHeaderLabels(
["Duration (cycles)", "Duration (ms)", "Cycles / ms",
'RAM access time', 'Execution Time Model'])
self.horizontalHeader().setStretchLastSection(True)
self.horizontalHeader().hide()
self.setItem(0, 0, QTableWidgetItem(str(configuration.duration)))
self.setItem(1, 0, QTableWidgetItem(str(
float(configuration.duration) / configuration.cycles_per_ms)))
self.setItem(2, 0, QTableWidgetItem(str(configuration.cycles_per_ms)))
self.setItem(
3, 0, QTableWidgetItem(str(configuration.memory_access_time)))
item = QComboBox(self)
selected = 0
for i, (etm_name, etm_code) in \
enumerate(execution_time_model_names.items()):
item.addItem(etm_name)
if etm_code == configuration.etm:
selected = i
item.setCurrentIndex(selected)
self.setCellWidget(4, 0, item)
def activation_handler(x):
configuration.etm = execution_time_model_names[str(x)]
configuration.conf_changed()
item.activated['QString'].connect(activation_handler)
# self._update_observe_window()
self.cellChanged.connect(self._cell_changed)
示例3: __init__
def __init__(self, parent=None, featureGroups=[], sigmas=[], computeIn2d=[], window_size=3.5):
"""
Args:
featureGroups: A list with schema: [ (groupName1, [entry, entry...]),
(groupName2, [entry, entry...]), ... ]
sigmas: List of sigmas (applies to all features)
computeIn2d: List of booleans to indicate which sigma column should be computed in 2d (rather than 3d)
"""
QTableWidget.__init__(self, parent)
self.setCornerButtonEnabled(False)
self.setEditTriggers(QAbstractItemView.AllEditTriggers)
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.setShowGrid(False)
self.setMouseTracking(1)
self.verticalHeader().setHighlightSections(False)
self.verticalHeader().setSectionsClickable(True)
self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.verticalHeader().sectionPressed.disconnect()
self.verticalHeader().sectionClicked.connect(self._expandOrCollapseVHeader)
self.horizontalHeader().setHighlightSections(False)
self.horizontalHeader().setSectionsClickable(False)
# self.horizontalHeader().installEventFilter(self)
self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.itemSelectionChanged.connect(self._itemSelectionChanged)
self.cellChanged.connect(self._cellChanged)
if featureGroups or sigmas or computeIn2d:
self.setup(featureGroups, sigmas, computeIn2d, window_size)
示例4: keyPressEvent
def keyPressEvent(self, event):
QTableWidget.keyPressEvent(self, event)
if event.key() == Qt.Key_Delete:
self.remove_selected_tasks()
if(event.key() == Qt.Key_C and event.modifiers() & Qt.ControlModifier):
indexes = self.selectionModel().selectedIndexes()
# TODO: mettre dans un format xml.
print("copy : ", indexes)
示例5: __init__
def __init__(self, parent, result):
QTableWidget.__init__(self, len(result.model.logs), 3, parent=parent)
self.setWindowTitle("Logs")
self.setHorizontalHeaderLabels(["Date (cycles)", "Date (ms)", "Message"])
self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
self.horizontalHeader().setStretchLastSection(True)
self.horizontalHeader().setMinimumSectionSize(60)
self.verticalHeader().hide()
self._sim = result.model
self.result = result
self.update()
示例6: __init__
def __init__(self, parent, result):
QTableWidget.__init__(
self, len(result.model.processors) + 1, 3, parent)
self.result = result
self.setHorizontalHeaderLabels(["Total load", "Payload",
"System load", "Theoric min"])
self.setVerticalHeaderLabels(
[x.name for x in result.model.processors] + ["Average"])
self.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.update()
示例7: Table
class Table(QWidget):
def __init__(self):
super().__init__()
self.lay = QHBoxLayout(self)
self.tableWidget = QTableWidget(self)
self.lay.addWidget(self.tableWidget)
for i in range(20):
self.tableWidget.insertRow(i)
self.tableWidget.insertColumn(i)
示例8: __init__
def __init__(self, parent, steps):
super(ParseStepViewer, self).__init__(parent)
self.setModal(True)
self.setWindowTitle('Parse steps view.')
self.resize(640, 480)
layout = QVBoxLayout(self)
self.table = QTableWidget()
self.table.setColumnCount(2)
self.table.setRowCount(len(steps))
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.table.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
self.table.setHorizontalHeaderLabels(['Stack', 'Input'])
for row, (right, left) in enumerate(steps):
self.table.setItem(row, 0, QTableWidgetItem('$' + ''.join(left)))
self.table.setItem(row, 1, QTableWidgetItem(''.join(right) + '$'))
self.table.resizeColumnsToContents()
ok_btn = QPushButton('&Close')
ok_btn.clicked.connect(self.close)
layout.addWidget(self.table)
layout.addWidget(ok_btn)
示例9: __init__
def __init__(self,index):
QWidget.__init__(self)
self.index=index
self.vbox=QVBoxLayout()
toolbar=QToolBar()
toolbar.setIconSize(QSize(48, 48))
self.tb_save = QAction(QIcon(os.path.join(get_image_file_path(),"add.png")), _("Add"), self)
self.tb_save.triggered.connect(self.callback_add_item)
toolbar.addAction(self.tb_save)
self.tb_save = QAction(QIcon(os.path.join(get_image_file_path(),"minus.png")), _("Minus"), self)
self.tb_save.triggered.connect(self.callback_delete_item)
toolbar.addAction(self.tb_save)
self.vbox.addWidget(toolbar)
self.tab = QTableWidget()
self.tab.resizeColumnsToContents()
self.tab.verticalHeader().setVisible(False)
self.create_model()
self.tab.cellChanged.connect(self.tab_changed)
self.vbox.addWidget(self.tab)
self.setLayout(self.vbox)
示例10: __init__
def __init__(self, settings, parent=None):
super(Form, self).__init__(parent)
icon = QtGui.QIcon(":/tcharmap.png")
self.setWindowIcon(icon)
self.settings = settings
self.results = []
self.entries = read_entries()
self.lineedit = VLineEdit()
self.lineedit.selectAll()
self.table = QTableWidget()
self.table.installEventFilter(self)
self.table.currentCellChanged[int, int, int, int].connect(self.copy_entry_slot)
layout = QVBoxLayout()
layout.addWidget(self.table)
layout.addWidget(self.lineedit)
self.setLayout(layout)
self.lineedit.textChanged[str].connect(self.update_query)
self.lineedit.setFocus()
self.setWindowTitle("tcharmap")
self.results = self.lookup("")
self.table.setColumnCount(3)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.verticalHeader().setVisible(False)
self.table.horizontalHeader().setVisible(False)
self.table.setColumnWidth(1, 150)
self.clipboard = QApplication.clipboard()
self.resize(540, 530)
self.update_ui()
示例11: __init__
def __init__(self, parent):
super(UserManagerWidget, self).__init__(parent)
self.parent = parent
self.sort_order = 'by_name'
view.notifier.observers.append(self)
self.header_label = QLabel('Users')
self.header_widget = QWidget(self)
header_layout = QBoxLayout(QBoxLayout.LeftToRight)
header_layout.addWidget(self.header_label)
self.header_widget.setLayout(header_layout)
self.sort_by_name_btn = QPushButton('Sort by Name', self)
self.sort_by_name_btn.clicked.connect(self.sort_by_name)
self.sort_by_rank_btn = QPushButton('Sort by Rank', self)
self.sort_by_rank_btn.clicked.connect(self.sort_by_rank)
self.sort_btns_widget = QWidget(self)
sort_btns_layout = QBoxLayout(QBoxLayout.LeftToRight)
sort_btns_layout.addWidget(self.sort_by_name_btn)
sort_btns_layout.addSpacing(10)
sort_btns_layout.addWidget(self.sort_by_rank_btn)
self.sort_btns_widget.setLayout(sort_btns_layout)
self.user_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 3, self)
self.user_list.setFixedHeight(300)
self.user_list.setFixedWidth(400)
self.user_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.user_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
self.user_list_widget = QWidget(self)
user_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
user_list_layout.addWidget(self.user_list)
self.user_list_widget.setLayout(user_list_layout)
self.add_player_btn = QPushButton('Add User', self)
self.add_player_btn.clicked.connect(self.parent.show_add_user_widget)
self.remove_player_btn = QPushButton('Remove User', self)
self.remove_player_btn.clicked.connect(self.parent.show_remove_user_widget)
self.player_btns_widget = QWidget(self)
player_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
player_btn_layout.addWidget(self.add_player_btn)
player_btn_layout.addSpacing(10)
player_btn_layout.addWidget(self.remove_player_btn)
self.player_btns_widget.setLayout(player_btn_layout)
self.error = None
layout = QFormLayout()
layout.addRow(self.header_widget)
layout.addRow(self.sort_btns_widget)
layout.addRow(self.user_list_widget)
layout.addRow(self.player_btns_widget)
self.setLayout(layout)
self.update()
示例12: saveZotero
def saveZotero(self):
#Write what happens to save to zotero here
rows = list(range(0, QTableWidget.rowCount(self.dlgTable.tableWidget_Zotero)))
for row in rows:
#get the itemID(zotero key) and geometry cells from the table - itemAt(x,y)
itemKey = self.dlgTable.tableWidget_Zotero.item(row, 0).text()
request_url = 'https://api.zotero.org/users/%s/items/%s' % (self.userID, itemKey)
item_request = requests.get(request_url)
QgsMessageLog.logMessage("Item Request Response: %s" % item_request.status_code, 'LiteratureMapper', Qgis.Info)
item_json = json.load(urllib.request.urlopen(request_url))
#Put the extra string back together with the new coordinates
tablegeom = self.dlgTable.tableWidget_Zotero.item(row, 4).text()
extraZotero = item_json['data']['extra']
before_geojson = extraZotero[0 : extraZotero.find("<geojson>")]
after_geojson = extraZotero[extraZotero.find("</geojson>")+10:]
extraString = '%s<geojson>%s</geojson>%s' % (before_geojson, tablegeom, after_geojson) #build the new extraString here
QgsMessageLog.logMessage("row: %s itemKey: %s extraString: %s" % (row, itemKey, extraString), 'LiteratureMapper', Qgis.Info)
####### saving Extra field
item_json['data']['extra'] = extraString
item_json=json.dumps(item_json)
put_request = requests.put(request_url, data=item_json, headers={'Authorization': 'Bearer %s' % (self.apiKey), 'Content-Type': 'application/json'})
QgsMessageLog.logMessage("Put Response: %s" % put_request.status_code, 'LiteratureMapper', Qgis.Info)
statuscode = put_request.status_code
# Message bar for result
# TODO: make it check all the results, not just the last one
if statuscode == 204:
self.iface.messageBar().pushMessage("Locations saved to Zotero.", level=4)
#QMessageBox.information(self.dlgTable(),"Info", "Locations Saved")
else:
self.iface.messageBar().pushMessage("Failed to save locations to Zotero", level=3)
示例13: __init__
def __init__(self, gui):
super(AdvSetTab, self).__init__()
self._ui = gui
self._config = self._ui.config
self._tran = self._ui.tran
self._parser = self._ui.configparser
self.setObjectName("advtab")
# main layout of this tab
self._layout = QGridLayout(self)
self._layout.setObjectName('advtab_layout')
# setup the new button
self._button_new = QPushButton(self)
self._button_new.setObjectName('advtab_button_new')
self._button_new.setText(self._tran.get_text(self._button_new.objectName()))
self._button_new.clicked.connect(self._new_setting)
# setup the delete button
self._button_del = QPushButton(self)
self._button_del.setObjectName('advtab_button_delete')
self._button_del.setText(self._tran.get_text(self._button_del.objectName()))
self._button_del.clicked.connect(self._delete_setting)
# setup the delete all
self._button_del_all = QPushButton(self)
self._button_del_all.setObjectName('advtab_button_delete_all')
self._button_del_all.setText(self._tran.get_text(self._button_del_all.objectName()))
self._button_del_all.clicked.connect(self._delete_config)
# setup the reset all button
self._button_res_all = QPushButton(self)
self._button_res_all.setObjectName('advtab_button_reset_all')
self._button_res_all.setText(self._tran.get_text(self._button_res_all.objectName()))
self._button_res_all.clicked.connect(self._reset_config)
# setup the option table
self._table = QTableWidget(0, 2)
self._table.setObjectName('advtab_table')
self._table.setHorizontalHeaderLabels([self._tran.get_text('option'), self._tran.get_text('value')])
self._table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self._table.setSelectionBehavior(QAbstractItemView.SelectRows)
self._table.setSelectionMode(QAbstractItemView.SingleSelection)
self._table.setShowGrid(False)
self._table.setGeometry(0, 0, 800, 400)
self._table.itemChanged.connect(self._changed_setting)
# add the elements to the top level layout of the tab
self._layout.addWidget(self._button_new, 0, 0, 1, 1)
self._layout.addWidget(self._button_del, 0, 1, 1, 1)
self._layout.addWidget(self._button_del_all, 0, 2, 1, 1)
self._layout.addWidget(self._button_res_all, 0, 3, 1, 1)
self._layout.addWidget(self._table, 1, 0, 4, 4)
# set the array with all elements that have tooltips
self._tooltips = [
self._button_new, self._button_del,
self._button_del_all, self._button_res_all,
]
示例14: __init__
def __init__(self):
QWidget.__init__(self)
self.win_list=windows()
self.setFixedSize(900, 600)
self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"doping.png")))
self.setWindowTitle(_("Doping profile editor (www.gpvdm.com)"))
self.win_list.set_window(self,"doping")
self.main_vbox=QVBoxLayout()
toolbar=QToolBar()
toolbar.setIconSize(QSize(48, 48))
self.save = QAction(QIcon(os.path.join(get_image_file_path(),"save.png")), _("Save"), self)
self.save.triggered.connect(self.callback_save)
toolbar.addAction(self.save)
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
toolbar.addWidget(spacer)
self.help = QAction(QIcon(os.path.join(get_image_file_path(),"help.png")), _("Help"), self)
self.help.triggered.connect(self.callback_help)
toolbar.addAction(self.help)
self.main_vbox.addWidget(toolbar)
self.fig = Figure(figsize=(5,4), dpi=100)
self.ax1=None
self.show_key=True
canvas = FigureCanvas(self.fig)
#canvas.set_background('white')
#canvas.set_facecolor('white')
canvas.figure.patch.set_facecolor('white')
canvas.show()
self.main_vbox.addWidget(canvas)
self.tab = QTableWidget()
self.tab.resizeColumnsToContents()
self.tab.verticalHeader().setVisible(False)
self.tab.clear()
self.tab.setColumnCount(4)
self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
self.load()
self.build_mesh()
self.tab.cellChanged.connect(self.tab_changed)
self.main_vbox.addWidget(self.tab)
self.draw_graph()
self.setLayout(self.main_vbox)
return
示例15: group_tasks_list
def group_tasks_list(self):
"""Define the Tasks Group arrangement."""
gb_tasks = QGroupBox(self.central_widget)
gb_tasks.setTitle(self.tr('List of Conversion Tasks'))
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(gb_tasks.sizePolicy().hasHeightForWidth())
gb_tasks.setSizePolicy(sizePolicy)
hl = QHBoxLayout(gb_tasks)
self.tb_tasks = QTableWidget(gb_tasks)
self.tb_tasks.setColumnCount(4)
self.tb_tasks.setRowCount(0)
self.tb_tasks.setSelectionMode(QAbstractItemView.SingleSelection)
self.tb_tasks.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tb_tasks.horizontalHeader().setSectionResizeMode(
0, QHeaderView.Stretch)
self.tb_tasks.setHorizontalHeaderLabels(
[self.tr('File Name'),
self.tr('Duration'),
self.tr('Target Quality'),
self.tr('Progress')])
self.tb_tasks.cellClicked.connect(self._enable_remove_file_action)
# Create a combo box for Target quality
self.tb_tasks.setItemDelegate(TargetQualityDelegate(parent=self))
hl.addWidget(self.tb_tasks)
self.vl2.addWidget(gb_tasks)
self.tb_tasks.doubleClicked.connect(self.update_edit_triggers)