pyqt

how to use default icons with qt

I'm using only Qt (though PyQt) and I don't get icons when I call e.g. QMessageBox.warning(). Is there a way to use the platform's default icons? Currently I'm using the more complete QMessageBox constructor and calling setIconPixmap. ...

Why doesn't QCalendarWidget.setDateTextFormat(QDate(), ...) work?

I'm using PyQt 4.4.3. I've got this code, which should clear all formats in the QCalendarWidget: cal.setDateTextFormat(QDate(), QDateTextFormat()) According to the documentation this should work: QCalendarWidget::setDateTextFormat(QDate &date, QTextCharFormat &format) If date is null, all date formats are cleared. QDate::Q...

How do I make this progress bar close when it is done

I commonly write Python scipts to do conversion tasks for me and whenever I write one that takes a while I use this little progress bar to check on it import sys import time from PyQt4 import QtGui app = QtGui.QApplication(sys.argv) barra = QtGui.QProgressBar() barra.show() barra.setMinimum(0) barra.setMaximum(10) for a in range(10): ...

PyQt connect method bug when used in a for loop which creates widgets from a list

I have a GUI program, It auto create buttons from a name list, and connect to a function prints its name. but when I run this program, I press all the buttons, they all return the last button's name. I wonder why this thing happens. can any one help? import sys from PyQt4.QtCore import * from PyQt4.QtGui import * import logging ...

QFileDialog passing directory to python script

Hi all, Im writing a little python program that goes through an XML file and does some replacement of tags. It takes three arguments, a path from whcih it creates a directory tree, the XML file its reading and the xml file its outputting to. It works fine from the command line just passing in arguments. As its not just for me, i thought...

QTableView selected element in PyQt4

Is there some way to read which row of Qt's QTableView widget is selected by user? Does it have something to do with QModelIndex class? ...

pyQT QNetworkManager and ProgressBars

Hello, I'm trying to code something that downloads a file from a webserver and saves it, showing the download progress in a QProgressBar. Now, there are ways to do this in regular Python and it's easy. Problem is that it locks the refresh of the progressBar. Solution is to use PyQT's QNetworkManager class. I can download stuff just fine...

PyQt - Transparent background

Hello, I try to make the background of my window transparent. But under widgets which are on it i see parts of my desktop-image. Now i have this in constructor: self.setFocusPolicy(Qt.StrongFocus) self.setAttribute(Qt.WA_QuitOnClose,True) self.setBackgroundRole(QtGui.QPalette.Base) self.setAttribute(Qt.WA_NoSystemBackg...

How can I make days wrap around in a QDateEdit?

The standard behaviour is, that as soon as the day reaches 31 the step-up button stops working. I'd like it to reset to 1 and jump to the next month. ...

Qt and context menu

Hello, i need to create a context menu on right clicking at my window. But i really don't know what should i do. Are there any widgets or i must make it by my hands? Programming language: Python Graphical lib: Qt (PyQt). ...

PyQt - make window top level

Hello, i need to make my window top level when i need. Code of creating window: class Application(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, None, Qt.Tool | Qt.FramelessWindowHint) self.setFocusPolicy(Qt.StrongFocus) self.setAttribute(Qt.WA_QuitOnClose, True) And w...

Is there a way to make drawText() update a QPicture's bounding rect?

Drawing on a QPicture should update its bounding rect. Like this: >>> picture = QPicture() >>> painter = QPainter(picture) >>> picture.boundingRect() QRect(0,0,0,0) >>> painter.drawRect(20,20,50,50) >>> picture.boundingRect() QRect(20,20,50,50) But if I draw text on it, the bounding rect isn't updated: >>> picture = QPicture() >>> pa...

Drag & Drop in KListWidget (PyQt/PyKde programming)

I'm developing a little app (precisely it's a KDE4 plasmoid) in PyQt/PyKde. In my app I have a KListWidget filled with some rows, see this picture: I need to implement a drag&drop action for the list rows, for example I should be able to put any file over a row, then the app will send this file to the name on the list. The list has...

Is there a way to set the DPI of a QPicture?

Is there a way to set the DPI of a QPicture? ...

Slow selection in QTreeView, why?

I've recently hit a wall in a project I'm working on which uses PyQt. I have a QTreeView hooked up to a QAbstractItemModel which typically has thousands of nodes in it. So far, it works alright, but I realized today that selecting a lot of nodes is very slow. After some digging, it turns out that QAbstractItemModel.parent() is called way...

A ListView of checkboxes in PyQt

Hello, I want to display a QListView where each item is a checkbox with some label. The checkboxes should be visible at all times. One way I can think of is using a custom delegate and QAbstractListModel. Are there simpler ways? Can you provide the simplest snippet that does this? Thanks in advance ...

How can I find out when a PyQt-application is idle?

I'd like to know when my application is idle so that I can preload some content. Is there an event or something similar implemented in PyQt? (I could also do it with threads, but this feels like being too complicated.) ...

PyQt: splash screen while loading "heavy" libraries

My PyQt application that uses matplotlib takes several seconds to load for the first time, even on a fast machine (the second load time is much shorter as the DLLs are kept in memory by Windows). I'm wondering whether it's feasible to show a splash screen while the matplotlib library is being loaded. Where does the actual loading take p...

Enabling JPEG support for QImage in py2exe-compiled Python scripts?

Hello, I'm trying to use a JPEG image in a QImage object from a Python script, with PyQt4. The script itself works perfectly, the image loads and can be manipulated and rendered and all. However, when I try to "compile" (compyle?) this script with py2exe, everything works but the JPEG image. Replacing it with a PNG equivalent works, but...

PyQt: Show menu in a system tray application

Hello First of all, I'm an experienced C programmer but new to python. I want to create a simple application in python using pyqt. Let's imagine this application it is as simple as when it is run it has to put an icon in the system tray and it has offer an option in its menu to exit the application. This code works, it shows the menu (...