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
28
votes
5 answers

How to change QPushButton text and background color

I am using following code to connect QMenu to QPushButton. When button is clicked a pull-down menu with multiple sub-menu's items is shown. button=QPushButton() button.setText("Press…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
28
votes
1 answer

Generally speaking, how are (Python) projects structured?

I'm a bit lost when it comes to structuring my project(s). I try to structure things in ways that make sense, but always end up restructuring the whole thing at least twice per day. Granted, my projects aren't very big, but I would love to not have…
Ruben Bakker
  • 446
  • 1
  • 5
  • 11
28
votes
2 answers

Detect if qt is running a debug build at runtime

How can I detect from within a QObject at runtime whether or not the Qt it's linked against is a debug build or release build? I know about the QT_NO_DEBUG macro, but that is resolved at build time for Qt. Example 1 of when this would be useful: I…
troy.unrau
  • 1,142
  • 2
  • 12
  • 26
27
votes
5 answers

How to embed a Python interpreter in a PyQT widget

I want to be able to bring up an interactive python terminal from my python application. Some, but not all, variables in my program needs to be exposed to the interpreter. Currently I use a sub-classed and modified QPlainTextEdit and route all…
Mathias
  • 1,446
  • 2
  • 16
  • 31
27
votes
3 answers

Preventing PyQt to silence exceptions occurring in slots

As far as I can see, if an exception occurs in a slot under PyQt, the exception is printed to screen, but not bubbled. This creates a problem in my testing strategy, because if an exception occurs in a slot, I will not see the test fail. Here is an…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
26
votes
1 answer

PyQT: how to open new window

First of all, similar questions have been answered before, yet I need some help with this one. I have a window which contains one button (Class First) and I want on pressed, a second blank window to be appeared (Class Second). I fiddled with the…
user3060854
  • 923
  • 2
  • 15
  • 25
26
votes
4 answers

How to convert a .ui file to .py file

This .ui file is made by Qt Designer. It's just a simple UI. All the commands or codes for doing this on the websites I have looked through are not for windows.
SonicFancy
  • 311
  • 1
  • 3
  • 11
26
votes
1 answer

Prompt on exit in PyQt application

Is there any way to promt user to exit the gui-program written in Python? Something like "Are you sure you want to exit the program?" I'm using PyQt.
Kirill Titov
  • 2,060
  • 5
  • 21
  • 33
26
votes
3 answers

PyQt: Prevent Resize and Maximize in QDialog?

How can I prevent a QDialog in PyQt from being resizeable or maximazable? I don't want the window's size changed.
Antoni4040
  • 2,297
  • 11
  • 44
  • 56
25
votes
3 answers

How to get the physical interface IP address from an interface

What I have done so far, using PyQt classes: all_Addresses = QNetworkInterface.allAddresses() #list-of-QHostAddress for addr in all_Addresses: print(addr.toString()) Output: 172.16.0.186 - Virtual Interface IP address 192.168.10.2 -…
Johny_M
  • 641
  • 1
  • 7
  • 16
25
votes
2 answers

Ctrl-C doesn't work with PyQt

Why doesn't Ctrl+C work to break a Python program that uses PyQt? I want to debug it and get a stack trace and for some reason, this is harder to do than with C++!
Neil G
  • 32,138
  • 39
  • 156
  • 257
25
votes
4 answers

How to set current tab of QTabWidget by name?

PyQt5's QTabWidget has a method setCurrentIndex that you can use to get a particular tab to become the active tab. I can't seem to find any way to index by tab name though (which I set in Qt Designer). Is there any way (either direct or indirect) to…
aoh
  • 1,090
  • 2
  • 13
  • 25
25
votes
1 answer

How to change the caption of a button in a QDialogButtonBox?

I have added a QDialogButtonBox button with the default Cancel and OK buttons. Is there a way to change the caption of these buttons? For example, OK should become Run.
matteo
  • 4,683
  • 9
  • 41
  • 77
25
votes
7 answers

Best way to display logs in pyqt?

I am currently working on a GUI using qt designer. I am wondering how I should go about printing strings on the GUI that acts like a logger window. I am using pyqt5.
Carlo Angelo
  • 393
  • 1
  • 6
  • 14
25
votes
3 answers

Prototyping Qt/C++ in Python

I want to write a C++ application with Qt, but build a prototype first using Python and then gradually replace the Python code with C++. Is this the right approach, and what tools (bindings, binding generators, IDE) should I use? Ideally, everything…
tstenner
  • 10,080
  • 10
  • 57
  • 92