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

Filter by
Sorted by
Tagged with
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.
Richard Durr's user avatar
  • 3,151
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 ...
balpha's user avatar
  • 50.5k
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 ...
Anna's user avatar
  • 2,755
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 ...
gwenger's user avatar
  • 1,221
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 (...
static_rtti's user avatar
  • 54.7k
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?
Chris's user avatar
  • 21.8k
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): ...
BPL's user avatar
  • 9,592
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 ...
shutefan's user avatar
  • 6,596
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.
user3472783's user avatar
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 ...
Dane Larsen's user avatar
  • 1,584
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 ...
Colin's user avatar
  • 10.6k
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?
Moayyad Yaghi's user avatar
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 ...
DamonJW's user avatar
  • 3,542
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....
Falmarri's user avatar
  • 48.2k
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=...
socket's user avatar
  • 1,193
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....
honeymoon's user avatar
  • 2,490
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 ...
Shannon Hochkins's user avatar
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 ...
arkero24's user avatar
  • 681
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 ...
Claudiu's user avatar
  • 227k
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 ...
JasonFruit's user avatar
  • 7,835
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 ...
Micah Yoder's user avatar
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?
cyberbudy's user avatar
  • 742
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 ...
sunyata's user avatar
  • 1,961
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 ...
Marco Moschettini's user avatar
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 ...
Ben's user avatar
  • 5,655
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 ...
user avatar
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 ...
AdrienW's user avatar
  • 3,262
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 ...
Qiao's user avatar
  • 16.8k
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 ...
Max's user avatar
  • 2,092
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(...
Faller's user avatar
  • 1,638
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 ...
Azendale's user avatar
  • 685
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 ...
Marko's user avatar
  • 20.5k
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 ...
user1223862's user avatar
  • 1,193
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",...
SaulTigh's user avatar
  • 913
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 ...
keegan3d's user avatar
  • 10.9k
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 ...
Luke's user avatar
  • 11.6k
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 ...
比尔盖子's user avatar
  • 3,077
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 ...
alphanumeric's user avatar
  • 18.7k
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 ...
johannix's user avatar
  • 29.4k
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 ...
Daniel Naab's user avatar
  • 22.9k
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 ...
Don Smythe's user avatar
  • 9,524
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 ...
Colin's user avatar
  • 10.6k
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 ...
ooo's user avatar
  • 522
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)...
aluuu's user avatar
  • 443
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(...
Dkellygb's user avatar
  • 896
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, ...
mRt's user avatar
  • 1,223
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()?
Jay's user avatar
  • 3,411
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 ...
alphanumeric's user avatar
  • 18.7k
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 ...
araisbec's user avatar
  • 1,233
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'...
Jeffrey Jose's user avatar
  • 2,012

1
2 3 4 5
344