pyqt4

PyQt4: Databinding?

Coming from the .NET world over to Python and PyQt4. Was wondering if anyone is familiar with any functionality that would allow me to bind data to Qt widgets? For example (using sqlalchemy for data): gems = session.query(Gem).all() list = QListWidget() list.datasource = gems Is such a thing possible? ...

What will I lose or gain from switching database APIs? (from pywin32 and pysqlite to QSql)

I am writing a Python (2.5) GUI Application that does the following: Imports from Access to an Sqlite database Saves ui form settings to an Sqlite database Currently I am using pywin32 to read Access, and pysqlite2/dbapi2 to read/write Sqlite. However, certain Qt objects don't automatically cast to Python or Sqlite equivalents when...

QSortFilterProxyModel.mapToSource crashes. No info why.

I have the following code: proxy_index = self.log_list.filter_proxy_model.createIndex(index, COL_REV) model_index = self.log_list.filter_proxy_model.mapToSource(proxy_index) revno = self.log_list.model.data(model_index,QtCore.Qt.DisplayRole) self.setEditText(revno.toString()) The code crashed on the second line. There is no exception ...

How to display errors to the user while still logging it?

I'm using a PyQt4 user interface. I've redirected stderr to a log file for easy debugging and trouble-shooting, but now I need to display error messages to the user when an error occurs. My issue is that I need to catch an exception when it happens and let the user know that it happened, but still let the traceback propagate to stderr ...

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. ...

Turning ctypes data into python string as quickly as possible

I'm trying to write a video application in PyQt4 and I've used Python ctypes to hook into an old legacy video decoder library. The library gives me 32-bit ARGB data and I need to turn that into a QImage. I've got it working as follows: # Copy the rgb image data from the pointer into the buffer memmove(self.rgb_buffer, self.rgb_buffer_p...

PyQt4 Minimize to Tray

Is there a way to minimize to tray in PyQt4? I've already worked with the QSystemTrayIcon class, but now I would like to minimize or "hide" my app window, and show only the tray icon. Has anybody done this? Any direction would be appreciated. Using Python 2.5.4 and PyQt4 on Window XP Pro ...

Distinguish between designer and runtime code

I have two processes which exange messages each other. Process A is a normal (i.e non-qt) program which sends messages to process B. Process B is a QT GUI application showing received messages into a text box. I created a customized widget (called ShowMessages) which inherits from QPlainTextEdit and reads messages from a pipe when a tim...

How do I watch a serial port with QSocketNotifier (linux)?

Could someone give me an example on how to setup QSocketNotifier to fire an event if something comes on /dev/ttyS0 ? (preferably in python/pyqt4) ...

System theme icons and PyQt4

I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it matters, i'm developing t...

Segmentation fault in custom QAbstractItemModel

I've written my own QAbstractItemModel to show a tree in TreeView. It shows the top level items, but when you expand a directory, the app closes, the the following message is written to the console: "Segmentation fault" What am I doing wrong that is causing this. Here is a simplifed version of my code: #!/usr/bin/env python import sys...

PyQt4 mac drawer positioning

I am using PyQt4 for an application I only plan on using on macs. So I wanted to make it look more like a mac application. To do so I am trying to incorporate sheets and drawers instead of spawning other windows. I have got a drawer to come up but it comes up on the left side of the application. Is there any way to make the drawer ...

PyQT: QTableWidget.setItemPrototype not working?

In a QTableWidget i want to display all values only with two decimals places. For that I subclassed QTableWidgetItem. class MyCell(QTableWidgetItem): def __init__(self, *args): QTableWidgetItem.__init__(self, *args) def clone(self): return MyCell() def data(self, role): t = QTableWidgetItem(self).da...

How would you adblock using Python?

I'm slowly building a web browser in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser. How would you go about it using python/PyQt4? [edit1] Ok. I think i've setup Privoxy. I haven't setup any additional filters and it seem...

TableView Search

I write a small database project for handling payroll records. These payroll records will be put into a tableview object for viewing. How can I search a particular record in a TableView ? Any idea, please help me. ...

How can I check for a blank image in Qt or PyQt?

I have generated a collection of images. Some of them are blank as in their background is white. I have access to the QImage object of each of the images. Is there a Qt way to check for blank images? If not, can someone recommend the best way to do it in Python? ...

PyQt Automatic Repeating Forms

I'm currently attempting to migrate a legacy VBA/Microsoft Access application to Python and PyQt. I've had no problems migrating any of the logic, and most of the forms have been a snap, as well. However, I've hit a problem on the most important part of the application--the main data-entry form. The form is basically a row of text boxes...

How to call Apple Authorization API from PyQt4

I am currently working on a PyQt4 app which requires administrator privileges to access some files. I would like it to follow Apple guidelines and open the Authenticate Dialog to prompt the user to input their password in order to perform administrator tasks. I have already looked into MacPython Authorization package, but it seems a bit...

PyQt: how to handle auto-resize of widgets when their content changes

I am having some issues with the size of qt4 widgets when their content changes. I will illustrate my problems with two simple scenarios: Scenario 1: I have a QLineEdit widget. Sometimes, when I'm changing its content using QLineEdit.setText(), the one-line string doesn't fit into the widget at its current size anymore. I must select ...

Autocompletion not working with PyQT4 and PyKDE4 in most of the IDEs

I am trying to develop a plasmoid using python. I have tried eclipse with pydev, vim with pythoncomplete, PIDA and also Komodo, but none of them could give me autocmpletion for method names or members for the classes belonging to PyQT4 or PyKDE4. I added the folders in /usr/share/pyshare in the PYTHONPATH list for the IDEs. Do I need ...