How can I hide the console window in a PyQt app running on Windows?
I think you should be able to run your app with pythonw.exe.
I think you should be able to run your app with pythonw.exe.
Store the file_path in a class level variable and update that value in your button click method. self.file_path = None self.Button_open.clicked.connect(self.OpenTextFile) And then, def OpenTextFile(self): dialog = QtGui.QFileDialog() dialog.setWindowTitle(“Choose a file to open”) dialog.setFileMode(QtGui.QFileDialog.ExistingFile) dialog.setNameFilter(“Text (*.txt);; All files (*.*)”) dialog.setViewMode(QtGui.QFileDialog.Detail) filename = QtCore.QStringList() if(dialog.exec_()): file_name = dialog.selectedFiles() plain_text = open(file_name[0]).read() self.Editor.setPlainText(plain_text) self.file_path = str(file_name[0]) Also … Read more
Here are Windows wheel packages built by Chris Golke – Python Windows Binary packages – PyQt In the filenames cp27 means C-python version 2.7, cp35 means python 3.5, etc. Since Qt is a more complicated system with a compiled C++ codebase underlying the python interface it provides you, it can be more complex to build … Read more
I assume that with “output from the interpreter”, you mean output written to the console or terminal window, such as output produced with print(). All console output produced by Python gets written to the program’s output streams sys.stdout (normal output) and sys.stderr (error output, such as exception tracebacks). These are file-like objects. You can replace … Read more
Qt Designer does not show all the Qt widget, and often we want to add our own widget through Qt, for that there are at least 2 solutions, the first is to create a plugin and load it to Qt Designer, and the other is simpler. promote the widget, the latter is what I will … Read more
By default, a QThread has an event loop that can process signals and slots. In your current implementation, you have unfortunately removed this behaviour by overriding QThread.run. If you restore it, you can get the behaviour you desire. So if you can’t override QThread.run(), how do you do threading in Qt? An alternative approach to … Read more
the issue is present in PyQt5 since 5.11.0 (tested 5.11.x, 5.12.x and 5.13) and PySide2 v.5.13 on MacOS (tested 10.14 and 10.12.6). The v.5.10.1 works fine. The issue does not exist under Linux and Windows Adding a call to the repaint method fix the issue. def setTextHelloWorld(self): self.label.setText(“Hello World”) self.label.repaint()
One of the main changes that PyQt6 enums use python enums so you must use the enumeration name as an intermediary, in your case MouseButtonPress belongs to the Type enum and RightButton to MouseButtons so you must change it to: def eventFilter(self, QObject, event): if event.type() == QEvent.Type.MouseButtonPress: if event.button() == Qt.MouseButtons.RightButton: print(“Right button clicked”) … Read more
Before app is loaded, and not while loading. insert: if hasattr(QtCore.Qt, ‘AA_EnableHighDpiScaling’): PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) if hasattr(QtCore.Qt, ‘AA_UseHighDpiPixmaps’): PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) like so : import PyQt5 from PyQt5 import QtCore, QtGui, uic, QtWidgets from PyQt5.QtWidgets import QWidget if hasattr(QtCore.Qt, ‘AA_EnableHighDpiScaling’): PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) if hasattr(QtCore.Qt, ‘AA_UseHighDpiPixmaps’): PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) class MyWindow(PyQt5.QtWidgets.QMainWindow): def __init__(self): super(MyWindow, self).__init__() And if that still … Read more
Firstly, +1 for realising how thread-unsafe many of the examples on stack overflow are! The solution is to use a thread-safe object (like a Python Queue.Queue) to mediate the transfer of information. I’ve attached some sample code below which redirects stdout to a Python Queue. This Queue is read by a QThread, which emits the … Read more