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

PyQt Components

PyQt4 contains the following Python modules.

  • The QtCore module contains the core non-GUI classes, including the event loop and Qt's signal and slot mechanism. It also includes platform independent abstractions for Unicode, threads, mapped files, shared memory, regular expressions, and user and application settings

  • The QtGui module contains the majority of the GUI classes. These include a number of table, tree and list classes based on the model-view-controller design pattern. Also provided is a sophisticated 2D canvas widget capable of storing thousands of items including ordinary widgets.

  • The QtHelp module contains classes for creating and viewing searchable documentation and being able to integrate online help with PyQt applications. It is based on the C++ port of the Lucene text search engine.

  • The QtNetwork module contains classes for writing UDP and TCP clients and servers. It includes classes that implement FTP and HTTP clients and support DNS lookups. Network events are integrated with the event loop making it very easy to develop networked applications. The QtOpenGL module contains classes that enable the use of OpenGL in rendering 3D graphics in PyQt applications.

  • The QtScript module contains classes that enable PyQt applications to be scripted using Qt's JavaScript interpreter.

  • The QtSql module contains classes that integrate with open-source and proprietary SQL databases. It includes editable data models for database tables that can be used with GUI classes. It also includes an implementation of SQLite.

  • The QtSvg module contains classes for displaying the contents of SVG files. It supports the static features of SVG 1.2 Tiny.

  • The QtTest module contains functions that enable unit testing of PyQt applications. PyQt does not implement the complete Qt unit test framework. Instead it assumes that the standard Python unit test framework will be used and implements those functions that simulate a user interacting with a GUI.

  • The QtWebKit module implements a web browser engine based on the WebKit open source browser engine used by Apple's Safari. It allows the methods and properties of Python objects to be published and appear as JavaScript objects to scripts embedded in HTML pages.

  • The QtXml module implements SAX and DOM interfaces to Qt's XML parser.

  • The QtXmlPatterns module implements XQuery and XPath support for XML and custom data models.

  • The phonon module implements a multimedia framework that enables the use of audio and video content in PyQt applications. On Windows DirectX is used as the backend, on MacOS/X QuickTime is used as the backend, and on Linux GStreamer is used as the backend.

  • The QtMultimedia module implements low-level multimedia functionality. Application developers would normally use the phonon module.

  • The QtAssistant module implements a simple interface for integrating Qt Assistant with PyQt applications to provide online help. Qt Assistant is itself implemented using QtHelp.

  • The QtDesigner module contains classes that allow Qt Designer to be extended using PyQt.

  • The QAxContainer module implements access to ActiveX controls and COM objects. It is only available in the commercial version of PyQt for Windows.

  • The Qt module consolidates the classes contained in all of the modules described above into a single module. This has the advantage that you don't have to worry about which underlying module contains a particular class. It has the disadvantage that it loads the whole of the Qt framework, thereby increasing the memory footprint of an application. Whether you use this consolidated module, or the individual component modules is down to personal taste.

  • The DBus support module is installed as dbus.mainloop.qt. PyQt does not support Qt's native DBus classes. Instead the module enables the Qt event loop to be used with the standard DBus Python bindings. It is only available for PyQt for X11.

  • The uic module implements support for handling the XML files created by Qt Designer that describe the whole or part of a graphical user interface. It includes classes that load an XML file and render it directly, and classes that generate Python code from an XML file for later execution.

PyQt Documentation

Current documentation is available for PyQt4 and PyQt5.

Books about PyQt

A list of tutorials

IDE for PYQT

16996 questions
23
votes
2 answers

Refreshing a QWidget

I've been having this issue a lot of times. When I modify some properties of a QWidget after the widget.show(), the widget won't update. Most of the time, a mouse click or when the mouse leaves or enters the widget, the widget will be updated.…
Olivier Giniaux
  • 870
  • 2
  • 8
  • 22
23
votes
4 answers

cx_Freeze - Preventing including unneeded packages

I have coded a tiny python program using PyQt4. Now, I want to use cx_Freeze to create a standalone application. Everything works fine - cx_Freeze includes automatically all necessary modules; the resulting exe works. The only problem is that…
Samufi
  • 2,465
  • 3
  • 19
  • 43
23
votes
1 answer

How to align QLabel text to label's right edge

The label is given a fixed width via label.setFixedWidth(200). The text inside of label is shorter then label's width. As it is now the label text is being centered within a label. But I would like the text to be aligned with the label's right side…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
23
votes
3 answers

Sort dictionary of dictionaries by value

I have this dictionary: statuses = { 'pending' : {'status_for':'all', 'position':1}, 'cancelled' : {'status_for':'all','position':2}, 'approved' : {'status_for':'owner', 'position':1}, 'rejected -…
Andy
  • 49,085
  • 60
  • 166
  • 233
23
votes
4 answers

PyQt dialog - How to make it quit after pressing a button?

Well, I'm writing a small PyQt4 app, it's just a single Yes/No dialog which has to execute an external command (e.g. 'eject /dev/sr0') and quit. The app runs, it executes the command after pressing the "Yes" button, but I cannot make the dialog…
Laszlo Meller
  • 233
  • 1
  • 2
  • 4
22
votes
4 answers

Uneditable QListView

I have a QListView displaying a list of items but I don't want the items to be edited (Currently a double click on the item allows you to edit them). This is my Code: self.listView = QListView() self.model = QStringListModel([ "item1" , "item2" ,…
Jay
  • 3,373
  • 6
  • 38
  • 55
22
votes
6 answers

PyQt: How to update progress without freezing the GUI?

Questions: What is the best practice for keeping track of a thread's progress without locking the GUI ("Not Responding")? Generally, what are the best practices for threading as it applies to GUI development? Question Background: I have a PyQt…
tgray
  • 8,826
  • 5
  • 36
  • 41
22
votes
3 answers

pylint can't find QWidget and QApplication

import sys from PyQt5.QtWidgets import (QApplication, QWidget) app = QApplication(sys.argv) window = QWidget() window.setGeometry(50, 50, 500, 300) window.setWindowTitle('Hello, world') window.show() sys.exit(app.exec_()) I just started to learn…
Sergey
  • 421
  • 1
  • 5
  • 14
22
votes
5 answers

Equivalent to time.sleep for a PyQt application

I can't use time.sleep in my pyqt application because that freezes the GUI thread, so the GUI will be completely frozen during this time.I have been looking for a way to handle this. I tried to use QTimer, but it seemed like they need to be linked…
PAR
  • 624
  • 1
  • 5
  • 16
22
votes
6 answers

How can I install PyQt5 on Mac?

I am trying to install PyQt5 on my Mac but I do not know how to use it well. I have tried to install sip doing cd ~/Downloads/sip-4.17 python configure.py which worked, and then I tried cd ~/Downloads/PyQt-gpl-5.5.1 python configure.py --qmake…
user2888499
  • 369
  • 1
  • 2
  • 9
22
votes
5 answers

How to signal slots in a GUI from a different process?

Context: In Python a main thread spawns a 2nd process (using multiprocessing module) and then launches a GUI (using PyQt4). At this point the main thread blocks until the GUI is closed. The 2nd process is always processing and ideally should emit…
NovoRei
  • 261
  • 1
  • 3
  • 7
22
votes
1 answer

pyqt: receive signal when widget becomes visible/hidden

I have noticed there is no signal/event for when a QWidget becomes visible/invisible. Is there anything else I can hook to get roughly the same thing (except polling isVisible())? I want to turn of some data fetching if the widget that displays the…
Rolle
  • 2,900
  • 5
  • 36
  • 40
21
votes
3 answers

How to display a Pandas data frame with PyQt5/PySide2

I have a problem with the line below self.tableView.set??????????(df) that supposed to display the data frame in PyQt5. I put ??? there where I am missing the code I need. def btn_clk(self): path = self.lineEdit.text() df =…
Joe T. Boka
  • 6,554
  • 6
  • 29
  • 48
21
votes
2 answers

PyQt5: Create semi-transparent window with non-transparent children

I want to create a fullscreen window with semitransparent background, but fully visible children widgets (kind of overlay effect). Here's what I have so far: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets…
Enuy
  • 619
  • 1
  • 7
  • 21
21
votes
2 answers

Get a layout's widgets in PyQT

I have a QVBoxLayout that I've added a few widgets to, via addWidget(). I need to now delete those widgets, and it seems I need to use removeWidget() (which takes in a widget to be removed) to do that. I thought that calling children() or…
Xiong Chiamiov
  • 13,076
  • 9
  • 63
  • 101