pyqt

Refresh QTextEdit in PyQt

Hi all, Im writing a PyQt app that takes some input in one widget, and then processes some text files. What ive got at the moment is when the user clicks the "process" button a seperate window with a QTextEdit in it pops up, and ouputs some logging messages. On Mac OS X this window is refreshed automatically and you cna see the proces...

oop instantiation pythonic practices

I've got the code below, and I was planning on making several classes all within the same "import". I was hoping to instantiate each class and get a return value with the widgets I'm making. This isn't really a PyQt question at all, more of a "good practices" question, as I'll have a class for each widget. Should I make functions th...

display a QMessageBox PyQT when a different combobox /list box item is selected

I have a combo box cbLayer and a function do_stuff of the following form: def do_stuff(item_selected_from_cbLayer): new_list = [] # do stuff based on item_selected_from_combobox and put the items in new_list return new_list How can I get a QMessageBox to pop up whenever a different item is selected in the following form: ...

Search Box in QToolbar

Does anybody knows how to make a good search box in Qt (actualy PyQt). It should sit in the toolbar (QToolbar) and look a little different than your normal QLineEdit (rounded corners and an icon as prefix). It should be aligned right with a blank space between the rest of the controls. All tips welcome! ...

Draw a line and rectangle using mouse events in pyqt

i want to develop an application to draw a line and rectangle as one can draw in ms paint... keeping one point fixed . can anyone help with any example... ...

Use QAction without adding to menu (or toolbar)

Hi everyone, I'm trying to develop an application with a very modular approach to commands and thought it would be nice, sind I'm using pyqt, to use QAction's to bind shortcuts to the commands. However, it seems that actions shortcuts only works when the action is visible in a menu or toolbar. Does anyone know a way to get this action t...

Custom/Owner draw control in PyQt?

I am learning PyQt and wonder if one can create custom/owner draw control like one show in the figure below: The search box has magnifier icon on its right border. Is this kind of thing possible with PyQt? Thanks! ...

Handling KeyboardInterrupt in a KDE Python application?

Hi, I'm working on a PyKDE4/PyQt4 application, Autokey, and I noticed that when I send the program a CTRL+C, the keyboard interrupt is not processed until I interact with the application, by ie. clicking on a menu item or changing a checkbox. lfaraone@stone:~$ /usr/bin/autokey ^C^C^C Traceback (most recent call last): File "/usr/lib...

Is there a possibility to automatically convert QVariants to Python objects?

PyQt 4.5.4, Python 2.6.2 Since version 4.5.2 PyQt is able to accept any Python objects where formerly only QVariants were allowed. This leads to some problems: >>> itemModel.data(index, Qt.EditRole) <Product object at 0xb7ce766c> >>> index.data(Qt.EditRole) <QVariant object at 0xb7ce768c> Is there a possibility to remove this inconsi...

replacing widget at runtime

Hi all, Here is the situation. I have a class which is derived from a QListView that adds some convenience functions, a custom widget if you like. I do not want to wrestle with the Designer to use my widget. I simply want to use a plain QlistView in the Designer (as a placeholder) and compile it with pyuic4. At runtime I want to replace...

Pyqt GroupBox parenting

In Python and Pyqt - I've got a simple class which instantiates a Label class and a GroupBox class. According to docs, passing the Groupbox to the Label upon creation should make the Groupbox the parent of Label. However, I must be missing something simple here. When I create the GroupBox it's fine, when I create the Label however - it...

How to create QString in PyQt4?

str = QtCore.QString('Hello') AttributeError: 'module' object has no attribute 'QString' QtCore.QString._init_(self) AttributeError: 'module' object has no attribute 'QString' Yes, I'm read QString Class Reference if you can, answer with code sample. Thanks ...

Custom QStyledItemDelegate: adding bold items

So here's the story: I have a QListview that uses a QSqlQueryModel to fill it up. Because some items should display in bold based on the value of a hidden column of the model, I decided to make my own custom delegate. I'm using PyQT 4.5.4 and thus inheriting from QStyledItemDelegate is the way to go according to the docs. I got it worki...

Prompt on exit in PyQt application

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

Just installed QtOpenGL but cannot import it (from Python)

I just installed it with apt-get on debian linux with apt-get install libqt4-opengl the rest of PyQt4 is available, but I cant get to this new module. from PyQt4 import QtOpenGL raises ImportError. any idea what to do? ...

How to deploy a Phonon-dependant Qt4/PyQt4/python application on Mac OS X?

I have written a crossplatform Qt4/PyQt4/python application, namely MyGreatApp, whose last version requires the Phonon module. MyGreatApp runs just fine on my own machine under Mac OS X 10.6 Snow Leopard, and more generally on any mac where Qt4.4 happens to be installed. However, innocent machines miserably fail to load Phonon: WARNING:...

Thread error in Python & PyQt

I noticed that when the function setModel is executed in parallel thread (I tried threading.Timer or threading.thread), I get this: QObject: Cannot create children for a parent that is in a different thread. (Parent is QHeaderView(0x1c93ed0), parent's thread is QThread(0xb179c0), current thread is QThread(0x23dce38) QObject::startTimer:...

Sharing widgets between PyQT and Boost.Python

Hello, I was wondering if it was possible to share widgets between PyQt and Boost.Python. I will be embedding a Python interpreter into an application of mine that uses Qt. I would like users of my application to be able to embed their own UI widgets into UI widgets programmed in C++ and exposed via Boost.Python. Is this possible and ...

Encoding problems in PyQt

My program stores file index in file packed by cPickle. There are non-english filenames. When I just do this print f [0] where f [0] is "\xc2\xe8\xf1\xee\xea\xee\xf1\xed\xfb\xe9 \xe3\xee\xe4" ("Високосный год" in normal view), it prints the string in proper way — in russian. When the program manually adds the string u'Високосный год'...

Pyqt - QMenu dynamically populated and clicked

I need to be able to know what item I've clicked in a dynamically generated menu system. I only want to know what I've clicked on, even if it's simply a string representation. def populateShotInfoMenus(self): self.menuFilms = QMenu() films = self.getList() for film in films: menuItem_Film = self.menuFilms.addAction(...