Change alignment of headers in QTableWidget
header = table.horizontalHeader() header.setDefaultAlignment(Qt.AlignRight|Qt.AlignVCenter)
References
https://stackoverflow.com/questions/37222081/pyqt-qtableview-set-horizontal-vertical-header-labels
header = table.horizontalHeader() header.setDefaultAlignment(Qt.AlignRight|Qt.AlignVCenter)
References
https://stackoverflow.com/questions/37222081/pyqt-qtableview-set-horizontal-vertical-header-labels
header = self.table.horizontalHeader() header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
item = QTableWidgetItem(scraped_age) # create the item item.setTextAlignment(Qt.AlignHCenter) # change the alignment
self.progress.canceled.connect(self.process.terminate)
mydialog.setFixedSize(width, height)
to set it to always be the current size
self.setFixedSize(self.size())
References
https://stackoverflow.com/questions/13775351/pyqt-prevent-resize-and-maximize-in-qdialog
from win32gui import SetWindowPos import win32con SetWindowPos(window.winId(), win32con.HWND_TOPMOST, # = always on top. only reliable way to bring it to the front on windows 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_SHOWWINDOW) SetWindowPos(window.winId(), win32con.HWND_NOTOPMOST, # disable the always on top, but leave window at its top position 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_SHOWWINDOW) window.raise_() window.show() window.activateWindow()
References
https://stackoverflow.com/questions/12118939/how-to-make-a-pyqt4-window-jump-to-the-front
... output = bytearray(self.process.readAllStandardOutput()) output = output.decode(self.GetCMD_Encoding()) print (output) def GetCMD_Encoding(self): CMD = QProcess(self) CMD.setProcessChannelMode(QProcess.MergedChannels) CMD.start("C:\Windows\System32\chcp.com") CMD.waitForReadyRead() output = bytearray(CMD.readAllStandardOutput()) output = output.decode("ascii") output = output[18:] return "cp" + output
References
https://stackoverflow.com/questions/41761132/pyqt-qprocess-readallstandardoutput-encoding
https://stackoverflow.com/questions/57663191/how-to-convert-a-qbytearray-to-a-python-string-in-pyside2
import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import QProcess if __name__ == '__main__': app = QtGui.QApplication(sys.argv) command = "./testCommand.py" args = [""] #"regular" startDetached : give two arguments, get a boolean process=QProcess() re=process.startDetached("ls",["."]) print(re) print(type(re)) #"overload" startDetached : give three arguments, get a tuple(boolean,PID) process2=QProcess() re,pid=process2.startDetached("ls",["."],".") print(re,pid) print(type(re),type(pid))
if self.mosquitto_process is None: self.mosquitto_process = QProcess() self.mosquitto_process.start("mosquitto.cmd")
self.port = utils.pick_free_port() _logger().debug('starting server process: %s', ' '.join([self._interpreter, server.__file__, str(self.port)])) self._process = QtCore.QProcess() self._process.readyRead.connect(self._on_ready_read) self._process.setProcessChannelMode(self._process.MergedChannels) self._process.finished.connect(self._on_finished) self._process.stateChanged.connect(self._on_state_changed) self._process.start( self._interpreter, (server.__file__, str(self.port)))
proc = QProcess() proc.start(*py_proc('print("Hello World")')) dev = qtutils.PyQIODevice(proc) assert not dev.closed with pytest.raises(OSError) as excinfo: dev.seek(0) assert str(excinfo.value) == 'Random access not allowed!' with pytest.raises(OSError) as excinfo: dev.tell() assert str(excinfo.value) == 'Random access not allowed!' proc.waitForFinished(1000) proc.kill() assert bytes(dev.read()).rstrip() == b'Hello World'
References
https://programtalk.com/python-examples/PyQt5.QtCore.QProcess/
start_datetime.setSecsSinceEpoch(1234567890) start_datetime.toSecsSinceEpoch()
References
https://stackoverflow.com/questions/2935041/how-to-convert-from-timestamp-to-date-in-qt