Questions tagged [pyqt4]

PyQt is a set of Python bindings for Qt application framework and runs on all platforms supported by Qt including Windows, MacOS/X and Linux.

PyQt is developed by Riverbank Computing.

It is available on all platforms under a variety of licenses including the GNU GPL (v2 and v3) and a commercial license.

Unlike Qt, PyQt v4 is not available under the LGPL.

5631 questions
42
votes
3 answers

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 its own thread (sometimes stuff gets stuck, and…
Azendale
  • 675
  • 1
  • 7
  • 17
40
votes
2 answers

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", exit_dialog) root.mainloop() Thanks.
SaulTigh
  • 913
  • 2
  • 14
  • 27
40
votes
6 answers

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 anaconda. I'm not sure how I get this to install…
user1223862
  • 1,193
  • 2
  • 9
  • 10
40
votes
3 answers

How to make PyQt window state to maximised in pyqt

I am using PyQt4 for GUI in my application. I want to know how can make my window maximized by default. I goggled but did not found an alternate. I tried using below code, but its not for maximized instead it resizes the window to desktop screen…
Rao
  • 2,902
  • 14
  • 52
  • 70
40
votes
4 answers

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 difficult to debug, even with the proper tools. I…
Luke
  • 11,374
  • 2
  • 48
  • 61
38
votes
3 answers

How can I move file into Recycle Bin / trash on different platforms using PyQt4?

I would like to add the next feature to my cross-platform PyQt4 application: when user selects some file and select "remove" action on it that file will be moved to Recycle Bin folder instead of being permantly removed. I think I can find…
bialix
  • 20,053
  • 8
  • 46
  • 63
37
votes
6 answers

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 function names. So on the one hand, I can…
Colin
  • 10,447
  • 11
  • 46
  • 54
34
votes
2 answers

How to check if a checkbox is checked in pyqt

I'm trying to make a conditional statement based on whether a checkbox is checked or not. I've tried something like the following, but it always returns as true. self.folderactive =…
Joshua Strot
  • 2,343
  • 4
  • 26
  • 33
34
votes
6 answers

Embedding IPython Qt console in a PyQt application

I'd like to embed an IPython qt console widget in a PyQt application I am working on. The code provided below (and adapted from https://stackoverflow.com/a/9796491/1332492) Accomplishes this for IPython v0.12. However, this crashes in IPython v0.13…
ChrisB
  • 4,628
  • 7
  • 29
  • 41
32
votes
6 answers

QWidget resize signal?

I want to take an action when a widget was resized. Is there a way to catch that without installing an event filter on that widget (and, obviously, without subclassing it)? AFAIK, QWidget does not have a resized signal.
warvariuc
  • 57,116
  • 41
  • 173
  • 227
31
votes
2 answers

Getting all items of QComboBox - PyQt4 (Python)

I have A LOT of QComboBoxes, and at a certain point, I need to fetch every item of a particular QComboBox to iterate through. Although I could just have a list of items that correspond to the items in the QComboBox, I'd rather get them straight from…
Anti Earth
  • 4,671
  • 13
  • 52
  • 83
31
votes
3 answers

How to read from QTextedit in python?

I created the GUI using QTDesigner and save the file as .ui extension. Then convert the file to .py file using the following code pyuic4 -x test.ui -o test.py Now I want to integrate my project code to this test.py file. Since I am new to pyqt4,…
user3251664
  • 441
  • 2
  • 7
  • 11
30
votes
5 answers

Sending custom PyQt signals?

I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two Qthreads. Main/GUI thread. Twitter fetch thread - fetches data from Twitter every X minutes. So, every X minutes my Twitter thread downloads a new set of status…
Enfors
  • 960
  • 2
  • 14
  • 25
30
votes
5 answers

PyQt: RuntimeError: wrapped C/C++ object has been deleted

If I run this code: #!/usr/local/bin/ python3 import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Window(QMainWindow): def __init__(self): super().__init__() self.button1 = QPushButton("1") …
Brian
  • 3,453
  • 2
  • 27
  • 39
29
votes
3 answers

How can I check if a keyboard modifier is pressed (Shift, Ctrl, or Alt)?

I am building a UI with Qt Creator and I want buttons to perform different actions with different modifiers. So I thought I could call functions with dynamic string properties that would perform the action depending on the modifier. Is there a…
user1087058
  • 349
  • 1
  • 3
  • 5