Questions tagged [pyqt]
PyQt is a set of Python v2 and v3 bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, macOS, Linux, iOS and Android
17,152
questions
157
votes
6
answers
326k
views
How to change the color of the axis, ticks and labels
I'd like to change the color of the axis, as well as ticks and value-labels for a plot I did using matplotlib and PyQt.
140
votes
7
answers
60k
views
Threading in a PyQt application: Use Qt threads or Python threads?
I'm writing a GUI application that regularly retrieves data through a web connection. Since this retrieval takes a while, this causes the UI to be unresponsive during the retrieval process (it cannot ...
121
votes
14
answers
392k
views
How to install PyQt4 on Windows using pip?
I'm using Python 3.4 on Windows. When I run a script, it complains
ImportError: No Module named 'PyQt4'
So I tried to install it, but pip install PyQt4 gives
Could not find any downloads that ...
98
votes
7
answers
194k
views
Background thread with QThread in PyQt
I have a program which interfaces with a radio I am using via a gui I wrote in PyQt. Obviously one of the main functions of the radio is to transmit data, but to do this continuously, I have to loop ...
85
votes
9
answers
52k
views
What is the correct way to make my PyQt application quit when killed from the console (Ctrl-C)?
What is the correct way to make my PyQt application quit when killed from the console (Ctrl-C)?
Currently (I have done nothing special to handle unix signals), my PyQt application ignores SIGINT (...
84
votes
12
answers
143k
views
Linking a qtDesigner .ui file to python/pyqt?
So if I go into QtDesigner and build a UI, it'll be saved as a .ui file. How can I make this as a python file or use this in python?
82
votes
1
answer
2k
views
Issues when attaching and detaching external app from QDockWidget
Consider this little piece of code:
import subprocess
import win32gui
import win32con
import time
import sys
from PyQt5.Qt import * # noqa
class Mcve(QMainWindow):
def __init__(self, path_exe):
...
78
votes
6
answers
66k
views
PyQt or PySide - which one to use [closed]
I started learning a bit of python and would now like to toy around a bit with gui-building. Qt seems to be a good choice because of its cross-platformishness.
Now there seem to be two bindings ...
76
votes
9
answers
176k
views
How to find Version of Qt?
How do I know which version of Qt I am using? When I open Qt Creator it shows "Welcome to Qt Creator 2.3". In the build setting, however, it shows Qt Version 4.7.1.
70
votes
6
answers
63k
views
PyQt4.QtCore.pyqtSignal object has no attribute 'connect'
I'm having issues with a custom signal in a class I made.
Relevant code:
self.parse_triggered = QtCore.pyqtSignal()
def parseFile(self):
self.emit(self.parse_triggered)
Both of those belong to ...
70
votes
6
answers
63k
views
Should wildcard import be avoided?
I'm using PyQt and am running into this issue. If my import statements are:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
then pylint gives hundreds of "Unused import" warnings. I'm ...
69
votes
3
answers
98k
views
how to have a directory dialog
In PyQt, how does one display a file browser that shows and selects only directories (not files)?
And how does one retrieve the name of the selected directory?
67
votes
5
answers
52k
views
How to set application's taskbar icon in Windows 7
How do I set an application's taskbar icon in PyQt4?
I have tried setWindowIcon, and it successfully sets the icon in the top-left of the main window, but it does not affect the icon shown in the ...
65
votes
14
answers
117k
views
Clear all widgets in a layout in pyqt
Is there a way to clear (delete) all the widgets in a layout?
self.plot_layout = QtGui.QGridLayout()
self.plot_layout.setGeometry(QtCore.QRect(200,200,200,200))
self.root_layout.addLayout(self....
62
votes
3
answers
37k
views
Should I use `app.exec()` or `app.exec_()` in my PyQt application?
I use Python 3 and PyQt5. Here's my test PyQt5 program, focus on the last 2 lines:
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
class window(QWidget):
def __init__(self,parent=...
58
votes
4
answers
224k
views
How do I plot only a table in Matplotlib?
Is it possible to draw only a table with matplotlib? If I uncomment the line
plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
of this example code, the plot is still visible....
58
votes
13
answers
305k
views
Convert pyQt UI to python
Is there a way to convert a ui formed with qtDesigner to a python version to use without having an extra file?
I'm using Maya for this UI, and converting this UI file to a readable python version to ...
58
votes
3
answers
76k
views
Detecting enter on a QLineEdit or QPushButton
I've built an app for a game, simple to start. It's a game in which the system randomly chooses a number and a gamer (player) tries to find out the number. Everything is almost done. The app consists ...
53
votes
2
answers
104k
views
pyqt: how to remove a widget?
I have a QGroupBox widget with children in it that I want to remove. How do I do that? I can't find any removeWidget, removeChild, removeItem, or anything similar in the docs. I can only see how to ...
53
votes
3
answers
21k
views
Is the PySide Slot Decorator Necessary?
I've seen some example code for PySide slots that uses the @QtCore.Slot decorator, and some that does not. Testing it myself, it doesn't seem to make a difference. Is there a reason I should or ...
48
votes
5
answers
20k
views
Qt programming: More productive in Python or C++?
Trying to dive into Qt big time but haven't done a large project with it yet. Currently using Python, but I've been thinking -- which is really the better language to use in terms of programmer ...
47
votes
2
answers
74k
views
PyQt on Android
I'm working on PyQt now, and I have to create the application on Android, I've seen the kivy library, but it's too crude.
Is there any way now to run an application on Android made on PyQt?
46
votes
7
answers
95k
views
Dark theme for Qt widgets?
Background
I'm building a PyQt5 application, that I'd like to have a dark theme for. Previously I've worked with Android development where there was a dark theme that I could set for a whole ...
46
votes
9
answers
51k
views
Quick and easy: trayicon with python?
I'd just need a quick example on how to easily put an icon with python on my systray. This means: I run the program, no window shows up, just a tray icon (I've got a png file) shows up in the systray ...
46
votes
4
answers
174k
views
How do you get the current text contents of a QComboBox?
Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the ...
46
votes
3
answers
62k
views
wxPython vs PyQt vs PyGTK: when and what to use?
Need advise from those who have minimum health experience to design GUI interfaces with Python.
When and what to choose depending of GUI complexity?
Which GUI builders can we use to have a better ...
44
votes
11
answers
122k
views
PySide - PyQt : How to make set QTableWidget column width as proportion of the available space?
I'm developing a computer application with PySide and I'm using the QTableWidget. Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in ...
44
votes
6
answers
69k
views
QListWidget adjust size to content
Is it possible to adjust QListWidget height and width to it's content?
sizeHint() always returns 256, 192 no matter what its content is.
QListWidgetItem's sizeHint() returns -1, -1, so I can not get ...
44
votes
3
answers
158k
views
PyQt proper use of emit() and pyqtSignal()
I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration.
Consider the following code:
import sys
from ...
43
votes
1
answer
98k
views
PyQt5 failing import of QtGui
I've just moved from PyQt4 to 5 and I'm having an issue with QtGui. I installed using the 32bit windows installer, not my own build.
when I do:
from PyQt5 import QtGui
I get
class MainWindow(...
42
votes
3
answers
73k
views
Example of the right way to use QThread in PyQt?
I'm trying to learn how to use QThreads in a PyQt Gui application. I have stuff that runs for a while, with (usually) points where I could update a Gui, but I would like to split the main work out to ...
41
votes
4
answers
78k
views
Setting the Windows taskbar icon in PyQt
I'm working on an applcation in Python's PyQt4 and cannot find how to change the taskbar icon. I made my .ui files in Qt's Designer, where I can change the windowIcon properties. But that is not what ...
40
votes
6
answers
128k
views
How to install PyQt4 in anaconda?
From the PyQt4 website their instructions for installing the package are to download the tarball and use the config file. I have two versions of Python, one is my normal system and the other is within ...
40
votes
2
answers
81k
views
PySide / PyQt detect if user trying to close window
is there a way to detect if user trying to close window?
For example, in Tkinter we can do something like this:
def exit_dialog():
#do stuff
pass
root = Tk()
root.protocol("WM_DELETE_WINDOW",...
40
votes
4
answers
60k
views
How to programmatically make a horizontal line in Qt
I'm trying to figure out how to make a horizontal line in Qt. This is easy to create in Designer but I want to create one programmatically. I've done some googleing and looked at the xml in a ui file ...
40
votes
4
answers
15k
views
What are good practices for avoiding crashes / hangs in PyQt?
I love both python and Qt, but it's pretty obvious to me that Qt was not designed with python in mind. There are numerous ways to crash a PyQt / PySide application, many of which are extraordinarily ...
40
votes
3
answers
27k
views
How do I unit testing my GUI program with Python and PyQt?
I heard Unit Testing is a great method to keep code working correctly.
The unit testing usually puts a simple input to a function, and check its simple output. But how do I test a UI?
My program is ...
39
votes
1
answer
75k
views
How to set QComboBox to item from item's text in PyQt/PySide
Is it possible to set QComboBox to an item knowing only an item's text value? I am trying to avoid looping through for i in range(myCombobox.count()) just to find an item's index so it could be used ...
38
votes
6
answers
49k
views
PyQt sending parameter to slot when connecting to a signal
I have a taskbar menu that when clicked is connected to a slot that gets the trigger event. Now the problem is that I want to know which menu item was clicked, but I don't know how to send that ...
38
votes
5
answers
62k
views
QListView/QListWidget with custom items and custom item widgets
I'm writing a PyQt application and am having some trouble creating a custom list view. I'd like the list to contain arbitrary widgets (one custom widget in particular). How would I go about this?
It ...
37
votes
1
answer
32k
views
MVC design with Qt Designer and PyQt / PySide
Python newbie coming from Java (+SWT/Windowbuilder) and am having difficulty working out how to properly code a large desktop app in Python/Qt4(QtDesigner)/PySide.
I would like to keep any view logic ...
37
votes
6
answers
4k
views
PEP8 and PyQt, how to reconcile function capitalization?
I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for ...
36
votes
8
answers
48k
views
Install PyQt5 5.14.1 on Linux
pip3 install PyQt5
Collecting PyQt5
Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Complete output ...
36
votes
4
answers
31k
views
PyQt and MVC-pattern
I am trying to design an MVC-pattern with PyQt.
I want to split all programs into 3 parts:
classes abstracted from all Qt classes (model)
classes providing data from the model to a Qt app (controller)...
36
votes
4
answers
89k
views
Proper way to quit/exit a PyQt program
I have a script which has a login screen and if the cancel button is pressed, I want to exit the application altogether. I have tried 3 ways:
sys.exit()
QApplication.quit()
QCoreApplication.instance(...
34
votes
3
answers
46k
views
PyQt: Always on top
This is on PyQt4, Linux and Python 2.5
Can I make PyQt set my window "always on top" over other applications?
For example, in GTK i use the property: Modal.
Now, in PyQt I am using a QWidget, but, ...
34
votes
2
answers
32k
views
What's the difference in Qt between setVisible, setShown and show/hide
Please excuse this potentially noobish question but when trying to hide a QWidget what is the difference between calling setVisible(False), setShown(False) and hide()?
34
votes
4
answers
66k
views
PyQt Widget connect() and disconnect()
Depending on a conditions I would like to connect/re-connect a button to a different function.
Let's say I have a button:
myButton = QtGui.QPushButton()
For this example let's say I check if there ...
34
votes
1
answer
20k
views
Redirecting stdout and stderr to a PyQt4 QTextEdit from a secondary thread
Stack overflow. Once again, I come to you in a time of dire need, teetering precariously on the brink of insanity. This question - as may be evident from the title - is an amalgamation of several ...
33
votes
6
answers
58k
views
QListWidget and Multiple Selection
I have a regular QListWidget with couple of signals and slots hookedup. Everything works as I expect. I can update, retrieve, clear etc.
But the UI wont support multiple selections.
How do I 'enable'...