pyqt

How to uncheck a checkbox to stop infinite drawing in pyqt ?

My problem is I want to keep rotating the scene if the checkbox is checked, and stop this rotation immediately once it is unchecked. However, "keep rotating" means an infinite loop... So after entering the loop, the program gets kind of freezed and no longer react to my "uncheck" signal. Is there a way to interrupt this loop? The follow...

Text under a widget added with QToolbar.addWidget()

I have a QToolbar with toolButtonStyle set to Qt::ToolButtonTextUnderIcon in which I add a QLineEdit through addWidget(). I'd like to have descriptive text under that widget like I do with other buttons, but I don't know how to do it or if it's even possible. I tried: lineEdit = QLineEdit() action = self.toolBar.addWidget(lineEdit) acti...

Invoking context menu in QTreeWidget

I would like to popup a menu, when user clicks on an object in QTreeWidgetItem. I though about catching signal contextMenuRequested from QWidget and then retrieving index from the view using itemAt. But this doesn't seem very pretty. Is there any easier way to be able to call a menu on an item inside a view? ...

PyQt4, QThread and opening big files without freezing the GUI

Hi, I would like to ask how to read a big file from disk and maintain the PyQt4 UI responsive (not blocked). I had moved the load of the file to a QThread subclass but my GUI thread get freezed. Any suggestions? I think it must be something with the GIL but I don't know how to sort it? EDIT: I am using vtkGDCMImageReader from the GDCM p...

Is PyGTK or PyQT preferred for making GTK-native Python apps?

I'm a web developer looking to get my feet wet with coding up a little desktop app for Ubuntu in Python. I've scoured the web looking for the pros and cons of PyGTK vs. PyQT and can't really find any good comparisons. What do you guys think? Do they both produce native-looking widgets on a GNOME system? Is one easier to use than the oth...

PyQt: removeChild/addChild QGroupBox

Hi Everybody, I am developing a system for a customer which is displayed in a set of tabs, and shows a table in the centralwidget with data extracted from a database. Depending on mouse events, the container (groupBox) must be removed from the centralwidget, or then added with new updated data for the table. Here is a piece of the cod...

Python PyKDE and KWindowSystem signal calling.

I'm currently slamming my head against the table trying to get a QObject.connect to work with KWindowSystem, with PyKDE, my code is as follows: from PyKDE4.kdecore import * from PyKDE4.kdeui import * from PyQt4.QtCore import * #Omitted Stupid KApplication parts. def winCheck(WId): print WId kWinSys = KWindowSystem.self() QObject....

python inheritance and __init__ functions

I came across the folloqing type of code when looking for some pyQt examples : class DisplayPage(QWizardPage): def __init__(self, *args): apply(QWizardPage.__init__, (self, ) + args) What does *args mean ? What is the purpose of using apply for this type of code ? ...

Open a second window in PyQt

I'm trying to use pyqt to show a custom QDialog window when a button on a QMainWindow is clicked. I keep getting the following error: $ python main.py DEBUG: Launch edit window Traceback (most recent call last): File "/home/james/Dropbox/Database/qt/ui_med.py", line 23, in launchEditWindow dialog = Ui_Dialog(c) File "/home/jam...

List view is not refreshed if setTabText() is called

Yes, I know this sounds crazy. But here's the situation. I composed a minimal code reproducing the bug. The code creates main window with QTabWidget, which, in turn, has one tab with QListView and a button. List view is connected to QAbstractListModel. Initially, list model contains empty list. If user clicks on a button, it is populate...

Python QtreeWidget: return tree hierarchy

Hi Everybody, I got stuck in trying to obtain the hierarchical view of a widget tree. The code works fine and generates a nice tree like that: ROOT(Animal): | | |___Not extinct: . | (red) . |_____BIRD--------------(blue) . | (green) | | ...

PyQt subclassing

The usual way to use Qt widgets from Python seems to be to subclass them. Qt widget classes have a great many methods, so inevitably I'm going to end up adding a method to the subclass, with the same name as one inherited from the Qt widget. In Python, all methods are virtual, so what I'm concerned about is that some Qt code might end u...

how to create windows 7 jump lists via python/pyqt?

i have a pyqt project which i'm interested in using to play around with the new windows 7 jump list feature. after a bunch of searching, i have not found any specific examples of anyone creating jumplists via python. has anyone here found an easy way to hook into this? does mark hammond's pywin32 module have an appropriate wrapper? t...

Remove a sublayout in qt?

In PyQt 4.5, I have a layout inside another layout. I'd like to remove the sublayout from its parent, and hide it. I can say parent_layout.removeItem(child_layout) to remove the layout from its parent, but it still shows on the widget. I can't find any way to hide it in one step, as QLayout doesn't have a hide() method like QWidget do...

How to tell QWebPage not to load images?

I'm using QWebPage to load needed site page. But QWebPage loading all additional resources: images, csses, and so on. Is there any way to present this behavior and cancel loading of images? Only idea that I have - to write custom QNetworkConnectionManager, which will return some dummy picture instead of requested. But this looks a bit o...

Catching a drag exit in Qt?

I've got a custom widget descended from QWidget that I want to be able to drop onto, and while the drag is hovering over the widget I'd like to highlight it to provide a little visual feedback to the user. Seems to me the simplest way to do this would be to highlight when dragEnterEvent is called and unhighlight when the drag exits the...

No output from QProcess

Why does the following print a blank line instead of 'Hello QProcess'? import sys from PyQt4 import QtGui, QtCore proc = QtCore.QProcess() proc.start("echo 'Hello QProcess'") proc.waitForFinished() result = proc.readAll() print result proc.close() I'm on Windows XP, btw. ...

No readyReadStandardOutput signal from QProcess

Why do I never get the readyReadStandardOutput signal when I run the following? import os, sys, textwrap from PyQt4 import QtGui, QtCore out_file = open("sleep_loop.py", 'w') out_file.write(textwrap.dedent(""" import time while True: print "sleeping..." time.sleep(1)""")) out_file.close() def started(): p...

QCheckBox: is it really not possible to differentiate between user-induced changes to state and those made programmatically? If so, should it be considered an inconsistency?

Do I miss something or there is really no (ready / built-in) way to programmatically change the state of a QCheckBox without emitting the "void stateChanged ( int state )" signal? The above-mentioned signal is emitted regardless of whether "void setCheckState ( Qt::CheckState state )" was called or the user changed the state via the ui,...

QT: Context menu (QMenu) reference from the QTableWidget.

I want to add a submenu in my context menu which is created like this: self.widget_alignment.setContextMenuPolicy(Qt.ActionsContextMenu) where widget_alignment is QTableWidget. I created a new QMenu instance: exchange_bases_menu = QMenu(self.widget_alignment) added some actions, and I found a method QAction QMenu.addMenu (self, QM...