Python PyQt5.QtWidgets.QHeaderView.Stretch() Examples
The following are 24
code examples of PyQt5.QtWidgets.QHeaderView.Stretch().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtWidgets.QHeaderView
, or try the search function
.
Example #1
Source File: mainWindow.py From openMotor with GNU General Public License v3.0 | 6 votes |
def setupGrainTable(self): self.ui.tableWidgetGrainList.clearContents() header = self.ui.tableWidgetGrainList.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setSectionResizeMode(1, QHeaderView.Stretch) self.updateGrainTable() self.ui.pushButtonMoveGrainUp.pressed.connect(lambda: self.moveGrain(-1)) self.ui.pushButtonMoveGrainDown.pressed.connect(lambda: self.moveGrain(1)) self.ui.pushButtonDeleteGrain.pressed.connect(self.deleteGrain) self.ui.pushButtonCopyGrain.pressed.connect(self.copyGrain) self.ui.tableWidgetGrainList.itemSelectionChanged.connect(self.checkGrainSelection) self.checkGrainSelection() self.ui.tableWidgetGrainList.doubleClicked.connect(self.doubleClickGrainSelector)
Example #2
Source File: mainWindowManager.py From django-pyqt with MIT License | 6 votes |
def addProduct(self): name = self.nameLinEdit.text() price = self.priceLineEdit.text() stars = self.starsLineEdit.text() try: p = Product(name=name, price=price, star=stars) p.save() except Exception as e: print(e) if self.connection: query = QSqlQuery(str(Product.objects.all().values('name', 'price', 'star').query), self.db) self.tableModel.setQuery(query) self.tableView.setModel(self.tableModel) self.tableView.hide() self.tableModel.setHeaderData(0, QtCore.Qt.Horizontal, "Name") self.tableModel.setHeaderData(1, QtCore.Qt.Horizontal, "Price") self.tableModel.setHeaderData(2, QtCore.Qt.Horizontal, "Starred") for i in range(self.tableView.horizontalHeader().count()): self.tableView.horizontalHeader().setSectionResizeMode(i, QHeaderView.Stretch) self.tableView.show()
Example #3
Source File: tabRewards.py From PIVX-SPMT with MIT License | 6 votes |
def onToggleCollateral(self): if self.ui.rewardsList.box.collateralRow is not None: if not self.ui.collateralHidden: try: # If collateral row was selected, deselect it before hiding if self.ui.rewardsList.box.item(self.ui.rewardsList.box.collateralRow, 0).isSelected(): self.ui.rewardsList.box.selectRow(self.ui.rewardsList.box.collateralRow) except Exception as e: err_msg = "Error toggling collateral" printException(getCallerName(), getFunctionName(), err_msg, e.args) self.ui.rewardsList.box.hideRow(self.ui.rewardsList.box.collateralRow) self.ui.btn_toggleCollateral.setText("Show Collateral") self.ui.collateralHidden = True self.updateSelection() else: self.ui.rewardsList.box.showRow(self.ui.rewardsList.box.collateralRow) self.ui.btn_toggleCollateral.setText("Hide Collateral") self.ui.collateralHidden = False self.updateSelection() self.ui.rewardsList.box.resizeColumnsToContents() self.ui.rewardsList.box.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch) else: myPopUp_sb(self.caller, "warn", 'No Collateral', "No collateral selected")
Example #4
Source File: ChecksumWidget.py From urh with GNU General Public License v3.0 | 6 votes |
def __init__(self, checksum_label: ChecksumLabel, message: Message, proto_view: int, parent=None): super().__init__(parent) self.ui = Ui_ChecksumOptions() self.ui.setupUi(self) self.checksum_label = checksum_label self.data_range_table_model = self.RangeTableModel(checksum_label, message, proto_view, parent=self) self.ui.tableViewDataRanges.setItemDelegateForColumn(0, SpinBoxDelegate(1, 999999, self)) self.ui.tableViewDataRanges.setItemDelegateForColumn(1, SpinBoxDelegate(1, 999999, self)) self.ui.tableViewDataRanges.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.ui.tableViewDataRanges.setModel(self.data_range_table_model) self.ui.tableViewDataRanges.setEditTriggers(QAbstractItemView.AllEditTriggers) self.display_crc_data_ranges_in_table() self.ui.comboBoxCRCFunction.addItems([crc_name for crc_name in GenericCRC.DEFAULT_POLYNOMIALS]) self.ui.comboBoxCRCFunction.addItems([special_crc_name for special_crc_name in self.SPECIAL_CRCS]) self.ui.lineEditCRCPolynomial.setValidator(QRegExpValidator(QRegExp("[0-9,a-f]*"))) self.ui.comboBoxCategory.clear() for _, member in self.checksum_label.Category.__members__.items(): self.ui.comboBoxCategory.addItem(member.value) self.set_ui_for_category() self.setFocus() self.create_connects()
Example #5
Source File: schedule_tab.py From vorta with GNU General Public License v3.0 | 6 votes |
def init_logs(self): self.logTableWidget.setAlternatingRowColors(True) header = self.logTableWidget.horizontalHeader() header.setVisible(True) [header.setSectionResizeMode(i, QHeaderView.ResizeToContents) for i in range(5)] header.setSectionResizeMode(3, QHeaderView.Stretch) self.logTableWidget.setSelectionBehavior(QTableView.SelectRows) self.logTableWidget.setEditTriggers(QTableView.NoEditTriggers) event_logs = [s for s in EventLogModel.select().order_by(EventLogModel.start_time.desc())] for row, log_line in enumerate(event_logs): self.logTableWidget.insertRow(row) formatted_time = log_line.start_time.strftime('%Y-%m-%d %H:%M') self.logTableWidget.setItem(row, 0, QTableWidgetItem(formatted_time)) self.logTableWidget.setItem(row, 1, QTableWidgetItem(log_line.category)) self.logTableWidget.setItem(row, 2, QTableWidgetItem(log_line.subcommand)) self.logTableWidget.setItem(row, 3, QTableWidgetItem(log_line.repo_url)) self.logTableWidget.setItem(row, 4, QTableWidgetItem(str(log_line.returncode))) self.logTableWidget.setRowCount(len(event_logs)) self._draw_next_scheduled_backup()
Example #6
Source File: diff_result.py From vorta with GNU General Public License v3.0 | 6 votes |
def __init__(self, fs_data, archive_newer, archive_older): super().__init__() self.setupUi(self) files_with_attributes, nested_file_list = parse_diff_lines(fs_data.split('\n')) model = DiffTree(files_with_attributes, nested_file_list) view = self.treeView view.setAlternatingRowColors(True) view.setUniformRowHeights(True) # Allows for scrolling optimizations. view.setModel(model) header = view.header() header.setStretchLastSection(False) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QHeaderView.Stretch) self.archiveNameLabel_1.setText(f'{archive_newer.name}') self.archiveNameLabel_2.setText(f'{archive_older.name}') self.okButton.clicked.connect(self.accept)
Example #7
Source File: sparrowdialogs.py From sparrow-wifi with GNU General Public License v3.0 | 6 votes |
def onAgentAnnounce(self, ipAddr, port): if not self.agentInTable(ipAddr, port): rowPosition = self.agentTable.rowCount() rowPosition -= 1 addedFirstRow = False if rowPosition < 0: addedFirstRow = True rowPosition = 0 self.agentTable.insertRow(rowPosition) # Just make sure we don't get an extra blank row if (addedFirstRow): self.agentTable.setRowCount(1) self.agentTable.setItem(rowPosition, 0, QTableWidgetItem(ipAddr)) self.agentTable.setItem(rowPosition, 1, IntTableWidgetItem(str(port))) self.agentTable.resizeColumnsToContents() self.agentTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
Example #8
Source File: telemetry.py From sparrow-wifi with GNU General Public License v3.0 | 6 votes |
def createTable(self): # Set up location table self.locationTable = QTableWidget(self) self.locationTable.setColumnCount(8) self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2) self.locationTable.setShowGrid(True) self.locationTable.setHorizontalHeaderLabels(['macAddr','SSID', 'Strength', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude']) self.locationTable.resizeColumnsToContents() self.locationTable.setRowCount(0) self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) self.ntRightClickMenu = QMenu(self) newAct = QAction('Copy', self) newAct.setStatusTip('Copy data to clipboard') newAct.triggered.connect(self.onCopy) self.ntRightClickMenu.addAction(newAct) self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu) self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu)
Example #9
Source File: archive_tab.py From restatic with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent=None): super().__init__(parent) self.setupUi(parent) self.mount_point = None header = self.archiveTable.horizontalHeader() header.setVisible(True) header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(3, QHeaderView.Stretch) header.setStretchLastSection(True) if sys.platform != "darwin": self._set_status("") # Set platform-specific hints. self.archiveTable.setSelectionBehavior(QTableView.SelectRows) self.archiveTable.setEditTriggers(QTableView.NoEditTriggers) self.archiveTable.setAlternatingRowColors(True) # Populate pruning options from database for i in self.prune_intervals: getattr(self, f"prune_{i}").setValue(getattr(self.profile(), f"prune_{i}")) getattr(self, f"prune_{i}").valueChanged.connect(self.save_prune_setting) self.mountButton.clicked.connect(self.mount_action) self.listButton.clicked.connect(self.list_action) self.pruneButton.clicked.connect(self.prune_action) self.checkButton.clicked.connect(self.check_action) self.extractButton.clicked.connect(self.extract_action) self.populate_from_profile()
Example #10
Source File: simulationAlertsDialog.py From openMotor with GNU General Public License v3.0 | 5 votes |
def __init__(self): QDialog.__init__(self) self.ui = Ui_SimAlertsDialog() self.ui.setupUi(self) header = self.ui.tableWidgetAlerts.horizontalHeader() header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(3, QHeaderView.Stretch) self.hide()
Example #11
Source File: reqlist.py From guppy-proxy with MIT License | 5 votes |
def __init__(self, *args, **kwargs): self.client = kwargs.pop("client") QTableWidget.__init__(self, *args, **kwargs) self.context = RequestContext(self.client) # Set up table self.setColumnCount(1) self.horizontalHeader().hide() self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.verticalHeader().hide() self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) #self.setSelectionMode(QAbstractItemView.NoSelection) #self.setEditTriggers(QAbstractItemView.NoEditTriggers)
Example #12
Source File: settings.py From guppy-proxy with MIT License | 5 votes |
def __init__(self, *args, **kwargs): QTableWidget.__init__(self, *args, **kwargs) self.listeners = [] # Set up table self.setColumnCount(1) self.horizontalHeader().hide() self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.verticalHeader().hide() self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.setEditTriggers(QAbstractItemView.NoEditTriggers)
Example #13
Source File: reqview.py From guppy-proxy with MIT License | 5 votes |
def __init__(self, *args, **kwargs): QTableWidget.__init__(self, *args, **kwargs) self.tags = set() # Set up table self.setColumnCount(1) self.horizontalHeader().hide() self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.verticalHeader().hide() self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.setEditTriggers(QAbstractItemView.NoEditTriggers)
Example #14
Source File: diff_dialog.py From vorta with GNU General Public License v3.0 | 5 votes |
def __init__(self, archiveTable): super().__init__() self.setupUi(self) header = self.archiveTable.horizontalHeader() header.setVisible(True) header.setSectionResizeMode(0, QHeaderView.ResizeToContents) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(3, QHeaderView.Interactive) header.setSectionResizeMode(4, QHeaderView.Stretch) header.setStretchLastSection(True) self.archiveTable.setSelectionBehavior(QTableView.SelectRows) self.archiveTable.setSelectionMode(QTableView.MultiSelection) self.archiveTable.setEditTriggers(QTableView.NoEditTriggers) self.archiveTable.setWordWrap(False) self.archiveTable.setTextElideMode(QtCore.Qt.ElideLeft) self.archiveTable.setAlternatingRowColors(True) self.archiveTable.itemSelectionChanged.connect(self.itemSelectionChanged_action) # Copy archiveTable of MainWindow self.archiveTable.setRowCount(archiveTable.rowCount()) for row in range(archiveTable.rowCount()): for column in range(archiveTable.columnCount()): try: text = archiveTable.item(row, column).text() self.archiveTable.setItem(row, column, QTableWidgetItem(text)) except AttributeError: self.archiveTable.setItem(row, column, QTableWidgetItem("")) self.diffButton.setEnabled(False) self.cancelButton.clicked.connect(self.close) self.diffButton.clicked.connect(self.diff_action) self.selected_archives = None
Example #15
Source File: extract_dialog.py From vorta with GNU General Public License v3.0 | 5 votes |
def __init__(self, fs_data, archive): super().__init__() self.setupUi(self) files_with_attributes = [] nested_file_list = nested_dict() self.selected = set() def parse_line(line): size, modified, full_path = line.split("\t") size = int(size) dir, name = os.path.split(full_path) # add to nested dict of folders to find nested dirs. d = get_dict_from_list(nested_file_list, dir.split("/")) if name not in d: d[name] = {} return size, modified, name, dir for line in fs_data.split("\n"): try: files_with_attributes.append(parse_line(line)) except ValueError: pass model = ExtractTree(files_with_attributes, nested_file_list, self.selected) view = self.treeView view.setAlternatingRowColors(True) view.setUniformRowHeights(True) # Allows for scrolling optimizations. view.setModel(model) header = view.header() header.setStretchLastSection(False) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QHeaderView.Stretch) self.archiveNameLabel.setText(f"{archive.name}, {archive.time}") self.cancelButton.clicked.connect(self.close) self.extractButton.clicked.connect(self.accept)
Example #16
Source File: cue_list_view.py From linux-show-player with GNU General Public License v3.0 | 5 votes |
def __init__(self, cue_model, parent=None): """ :type cue_model: lisp.layouts.list_layout.cue_list_model.CueListModel """ super().__init__(parent) self._model = cue_model self._model.item_added.connect(self.__cue_added, Connection.QtQueued) self._model.item_moved.connect(self.__cue_moved, Connection.QtQueued) self._model.item_removed.connect(self.__cue_removed, Connection.QtQueued) self._model.model_reset.connect(self.__model_reset) self.__item_moving = False self.setHeaderLabels( [translate('ListLayoutHeader', h) for h in CueListView.HEADER_NAMES]) self.header().setDragEnabled(False) self.header().setStretchLastSection(False) self.header().setSectionResizeMode(QHeaderView.Fixed) self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents) self.header().setSectionResizeMode(2, QHeaderView.Stretch) self.setColumnWidth(0, 40) self.setColumnWidth(len(CueListView.HEADER_NAMES) - 1, 18) self.setSelectionMode(self.SingleSelection) self.setDragDropMode(self.InternalMove) self.setAlternatingRowColors(True) self.setVerticalScrollMode(self.ScrollPerItem) self.setIndentation(0) self.currentItemChanged.connect(self.__current_changed) self.__guard = False self.verticalScrollBar().rangeChanged.connect(self.__update_range)
Example #17
Source File: sparrowdialogs.py From sparrow-wifi with GNU General Public License v3.0 | 4 votes |
def __init__(self, mainWin, agentIP, agentPort, parent = None): super(RemoteFilesDialog, self).__init__(parent) self.visibility.connect(self.onVisibilityChanged) self.mainWin = mainWin self.remoteAgentIP = agentIP self.remoteAgentPort = agentPort self.lblMsg = QLabel("Remote Files", self) self.lblMsg.move(10, 20) self.btnRefresh = QPushButton("&Refresh", self) self.btnRefresh.setShortcut('Ctrl+R') self.btnRefresh.clicked.connect(self.onRefreshFiles) # self.btnRefresh.setStyleSheet("background-color: rgba(0,128,192,255); border: none;") # self.btnRefresh.move(90, 30) self.btnCopy = QPushButton("&Copy", self) self.btnCopy.clicked.connect(self.onCopyFiles) self.btnDelete = QPushButton("&Delete", self) self.btnDelete.clicked.connect(self.onDeleteFiles) self.fileTable = QTableWidget(self) self.fileTable.setColumnCount(3) self.fileTable.setShowGrid(True) self.fileTable.setHorizontalHeaderLabels(['Filename','Size','Last Modified']) #self.fileTable.setGeometry(10, 30, 100, 30) self.fileTable.resizeColumnsToContents() self.fileTable.setRowCount(0) self.fileTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) self.fileTable.horizontalHeader().sectionClicked.connect(self.onTableHeadingClicked) self.fileTableSortOrder = Qt.DescendingOrder self.fileTableSortIndex = -1 self.ntRightClickMenu = QMenu(self) newAct = QAction('Copy', self) newAct.setStatusTip('Copy data to clipboard') newAct.triggered.connect(self.onCopy) self.ntRightClickMenu.addAction(newAct) # Attach it to the table self.fileTable.setContextMenuPolicy(Qt.CustomContextMenu) self.fileTable.customContextMenuRequested.connect(self.showNTContextMenu) self.setBlackoutColors() self.setGeometry(self.geometry().x(), self.geometry().y(), 650,400) self.setWindowTitle("Remote Files: " + self.remoteAgentIP + ':' + str(self.remoteAgentPort)) self.center() self.onRefreshFiles()
Example #18
Source File: sparrowdialogs.py From sparrow-wifi with GNU General Public License v3.0 | 4 votes |
def __init__(self, mainWin, parent = None): super(GPSCoordDialog, self).__init__(parent) self.visibility.connect(self.onVisibilityChanged) self.mainWin = mainWin # Set up GPS check timer self.gpsTimer = QTimer() self.gpsTimer.timeout.connect(self.onGPSTimer) self.gpsTimer.setSingleShot(True) self.gpsTimerTimeout = 2000 self.gpsTimer.start(self.gpsTimerTimeout) self.lastGPS = None self.firstUpdate = True self.lblMsg = QLabel("Newest coordinates are at the top", self) self.lblMsg.move(10, 20) self.historyTable = QTableWidget(self) self.historyTable.setColumnCount(6) self.historyTable.setShowGrid(True) self.historyTable.setHorizontalHeaderLabels(['Timestamp','Valid','Latitude', 'Longitude', 'Altitude', 'Speed']) self.historyTable.setGeometry(10, 30, 100, 30) self.historyTable.resizeColumnsToContents() self.historyTable.setRowCount(0) self.historyTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) # self.historyTable.horizontalHeader().sectionClicked.connect(self.onTableHeadingClicked) self.ntRightClickMenu = QMenu(self) newAct = QAction('Copy', self) newAct.setStatusTip('Copy data to clipboard') newAct.triggered.connect(self.onCopy) self.ntRightClickMenu.addAction(newAct) # Attach it to the table self.historyTable.setContextMenuPolicy(Qt.CustomContextMenu) self.historyTable.customContextMenuRequested.connect(self.showNTContextMenu) self.setBlackoutColors() self.setGeometry(self.geometry().x(), self.geometry().y(), 500,320) self.setWindowTitle("GPS Coordinate Viewer") self.center() # initial update: if self.mainWin: curGPS = self.mainWin.getCurrentGPS() self.updateTable(curGPS)
Example #19
Source File: sparrowdialogs.py From sparrow-wifi with GNU General Public License v3.0 | 4 votes |
def __init__(self, mainWin = None, parent = None): super(AgentListenerDialog, self).__init__(parent) self.parentWin = mainWin self.broadcastSocket = socket(AF_INET, SOCK_DGRAM) self.broadcastSocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.broadcastSocket.setsockopt(SOL_SOCKET, SO_BROADCAST, 1) self.agentAnnounce.connect(self.onAgentAnnounce) # Map Type droplist self.lblAgentPort = QLabel("Agent Port", self) self.lblAgentPort.setGeometry(10, 10, 100, 30) self.spinPort = QSpinBox(self) self.spinPort.setRange(1, 65535) self.spinPort.setValue(8020) self.spinPort.setGeometry(100, 10, 100, 28) self.spinPort.valueChanged.connect(self.spinChanged) # self.broadcastAddr=('255.255.255.255', int(self.spinPort.value())) self.agentListenerThread = AgentListenerThread(self, int(self.spinPort.value())) self.agentListenerThread.start() self.agentTable = QTableWidget(self) self.agentTable.setColumnCount(2) self.agentTable.setShowGrid(True) self.agentTable.setHorizontalHeaderLabels(['IP Address', 'Port']) self.agentTable.setGeometry(10, 30, 100, 30) self.agentTable.resizeColumnsToContents() self.agentTable.setRowCount(0) self.agentTable.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) self.agentTable.horizontalHeader().sectionClicked.connect(self.onTableHeadingClicked) # OK and Cancel buttons self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.buttons.move(170, 280) self.setBlackoutColors() self.setGeometry(self.geometry().x(), self.geometry().y(), 500,320) self.setWindowTitle("Remote Agent Detection") self.center()
Example #20
Source File: PLSDR.py From PLSDR with GNU General Public License v3.0 | 4 votes |
def populate_freq_list(self): self.accessible_list = [] path = self.detect_freq_file() if path == None: data = self.read_file('frequency_spreadsheet/frequency_list.ods','rb') path = "%s/frequency_list.ods" % self.config_path self.write_file(path,data,'wb') # if CSV table if re.search('(?i).*\.csv',path): table = [] with open(path) as f: content = f.read() records = re.split('\n+',content) for record in records: if len(record) > 0: record = re.sub('"','',record) fields = re.split(',',record) table.append(fields) # if ODS spreadsheet else: table = OdsConverter.OdsToArray().array_from_path(path) self.fieldNames = table[:1][0] table_data = table[1:] mults = {'ghz' : 1e9,'mhz':1e6,'khz':1e3,'hz':1} rmult = -1 # frequency multipler self.freq_field = -1 # field to which above frequency multiplier is applied self.mode_field = -1 # field from which mode is extracted for mult in mults: for n,field in enumerate(self.fieldNames): if re.search(r"(?i).*\b%s.*" % mult,field) != None: rmult = mults[mult] self.freq_field = n if re.search("(?i).*mode.*",field) != None: self.mode_field = n if self.freq_field == -1 or self.mode_field == -1: self.message_dialog("Malformed Frequency List","The present frequency-table source document (%s) is not correctly formatted -- please read the documentation." % path) else: self.model = QtGui.QStandardItemModel(parent=self) self.model.setHorizontalHeaderLabels(self.fieldNames) self.freq_table.setModel(self.model) header = self.freq_table.horizontalHeader() for n,_ in enumerate(self.fieldNames): #None # FIXME #header.setResizeMode(n, QtGui.QHeaderView.Stretch) header.setSectionResizeMode(QHeaderView.Stretch) for record in table_data: if(len(record) > 0): arecord = [] qrecord = [] for n,field in enumerate(record): item = QtGui.QStandardItem(field) item.setEditable(False) qrecord.append(item) if n == self.freq_field: # results always in Hz arecord.append(rmult * float(field)) else: arecord.append(field) self.accessible_list.append(arecord) self.model.appendRow(qrecord)
Example #21
Source File: ProtocolLabelDialog.py From urh with GNU General Public License v3.0 | 4 votes |
def __init__(self, message: Message, viewtype: int, selected_index=None, parent=None): super().__init__(parent) self.ui = Ui_DialogLabels() self.ui.setupUi(self) util.set_splitter_stylesheet(self.ui.splitter) field_types = FieldType.load_from_xml() self.model = PLabelTableModel(message, field_types) self.ui.tblViewProtoLabels.setItemDelegateForColumn(0, ComboBoxDelegate([ft.caption for ft in field_types], is_editable=True, return_index=False, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(1, SpinBoxDelegate(1, len(message), self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(2, SpinBoxDelegate(1, len(message), self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(3, ComboBoxDelegate([""] * len(settings.LABEL_COLORS), colors=settings.LABEL_COLORS, parent=self)) self.ui.tblViewProtoLabels.setItemDelegateForColumn(4, CheckBoxDelegate(self)) self.ui.tblViewProtoLabels.setModel(self.model) self.ui.tblViewProtoLabels.setEditTriggers(QAbstractItemView.AllEditTriggers) self.ui.tblViewProtoLabels.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.ui.tblViewProtoLabels.resizeColumnsToContents() self.setWindowFlags(Qt.Window) self.setWindowTitle(self.tr("Edit Protocol Labels From Message Type %s") % message.message_type.name) self.configure_special_config_tabs() self.ui.splitter.setSizes([int(self.height() / 2), int(self.height() / 2)]) self.create_connects() if selected_index is not None: self.ui.tblViewProtoLabels.setCurrentIndex(self.model.index(selected_index, 0)) self.ui.cbProtoView.setCurrentIndex(viewtype) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowFlags(Qt.Window) self.restoreGeometry(settings.read("{}/geometry".format(self.__class__.__name__), type=bytes)) for i in range(self.model.rowCount()): self.open_editors(i)
Example #22
Source File: extract_dialog.py From restatic with GNU General Public License v3.0 | 4 votes |
def __init__(self): super().__init__() self.setupUi(self) d = { "key1": "value1", "key2": ["value2", "value", "value4"], "key5": { "another key1": "another value1", "another key2": ["value2", "value", "value4"], }, } # add some nested folders for i in range(6, 200): d[f"folder-{i}"] = { "another key1": "another value1", "another key2": ["value2", "value", "value4"], } for j in range(50): d[f"folder-{i}"][f"large folder {j}"] = { "another key1": "another value1", "another key2": ["value2", "value", "value4"], } # add top-level folders to test scroll performance for f in range(1_000_000): d[f"flat folder {f}"] = "no subfolders. test" self.d = d t = self.fileTree t.setColumnCount(2) t.setHeaderLabels(["File/Foldername", "Size", "Modified"]) t.setAlternatingRowColors(True) t.setUniformRowHeights(True) # Allows for scrolling optimizations. header = t.header() header.setStretchLastSection(False) header.setSectionResizeMode(1, QHeaderView.ResizeToContents) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QHeaderView.Stretch) self.extractButton.clicked.connect(self.build_tree)
Example #23
Source File: BSSID.py From tdm with GNU General Public License v3.0 | 4 votes |
def __init__(self, *args, **kwargs): super(BSSIdDialog, self).__init__(*args, **kwargs) self.setMinimumHeight(400) self.setMinimumWidth(400) self.setWindowTitle("BSSId aliases") self.settings = QSettings("{}/TDM/tdm.cfg".format(QDir.homePath()), QSettings.IniFormat) self.settings.beginGroup("BSSId") vl = VLayout() cols = ["BSSId", "Alias"] self.tw = QTableWidget(0,2) self.tw.setHorizontalHeaderLabels(cols) self.tw.verticalHeader().hide() for c in range(2): self.tw.horizontalHeader().setSectionResizeMode(c, QHeaderView.Stretch) for k in self.settings.childKeys(): row = self.tw.rowCount() self.tw.insertRow(row) self.tw.setItem(row, 0, QTableWidgetItem(k)) self.tw.setItem(row, 1, QTableWidgetItem(self.settings.value(k))) vl.addWidget(self.tw) hl_btns = HLayout([0,3,0,3]) btnAdd = QPushButton("Add") btnDel = QPushButton("Delete") btnCancel = QPushButton("Cancel") btnSave = QPushButton("Save") hl_btns.addWidgets([btnAdd, btnDel, btnSave, btnCancel]) hl_btns.insertStretch(2) vl.addLayout(hl_btns) self.setLayout(vl) self.idx = None self.tw.clicked.connect(self.select) btnAdd.clicked.connect(self.add) btnDel.clicked.connect(self.delete) btnSave.clicked.connect(self.accept) btnCancel.clicked.connect(self.reject)
Example #24
Source File: Patterns.py From tdm with GNU General Public License v3.0 | 4 votes |
def __init__(self, *args, **kwargs): super(PatternsDialog, self).__init__(*args, **kwargs) self.setMinimumHeight(400) self.setMinimumWidth(400) self.setWindowTitle("Autodiscovery patterns") self.settings = QSettings("{}/TDM/tdm.cfg".format(QDir.homePath()), QSettings.IniFormat) self.settings.beginGroup("Patterns") vl = VLayout() cols = ["Pattern"] self.tw = QTableWidget(0, 1) self.tw.setHorizontalHeaderLabels(cols) self.tw.verticalHeader().hide() self.tw.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) for k in self.settings.childKeys(): row = self.tw.rowCount() self.tw.insertRow(row) self.tw.setItem(row, 0, QTableWidgetItem(self.settings.value(k))) vl.addWidgets([QLabel("Add your modified FullTopic patterns to enable auto-discovery of such devices\n" "Patterns MUST include %prefix%, %topic% and trailing /\n" "Default Tasmota FullTopics are built-in\n\n" "You have to reconnect to your Broker after topic changes."), self.tw]) hl_btns = HLayout([0, 3, 0, 3]) btnAdd = QPushButton("Add") btnDel = QPushButton("Delete") btnCancel = QPushButton("Cancel") btnSave = QPushButton("Save") hl_btns.addWidgets([btnAdd, btnDel, btnSave, btnCancel]) hl_btns.insertStretch(2) vl.addLayout(hl_btns) self.setLayout(vl) self.idx = None self.tw.clicked.connect(self.select) btnAdd.clicked.connect(self.add) btnDel.clicked.connect(self.delete) btnSave.clicked.connect(self.accept) btnCancel.clicked.connect(self.reject)