[PyQt] QTableView cell deselected after soting
Hello, I have found a strange behavior with a combo of QTableView, QSortFilterProxyView and disabled items. If you select a row in the table from the example below then sort by a column, the cell in the last column will be deselected after sorting. This happens only for cells with ItemIsSelectable as it's only item flag. Is there something I can do about this? Example: from PyQt4.QtCore import * from PyQt4.QtGui import * import sys my_array = [['00', '01', '02'], ['10', '11', '12'], ['20', '21', '22']] def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) class MyWindow(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) sorttablemodel = QSortFilterProxyModel(self) tablemodel = MyTableModel(my_array, self) sorttablemodel.setSourceModel(tablemodel) tableview = QTableView() tableview.setModel(sorttablemodel) tableview.setSelectionBehavior(QAbstractItemView.SelectRows) tableview.setSortingEnabled(True) layout = QVBoxLayout(self) layout.addWidget(tableview) self.setLayout(layout) class MyTableModel(QAbstractTableModel): def __init__(self, datain, parent=None, *args): QAbstractTableModel.__init__(self, parent, *args) self.arraydata = datain def rowCount(self, parent): return len(self.arraydata) def columnCount(self, parent): return len(self.arraydata[0]) def data(self, index, role): if not index.isValid(): return QVariant() elif role != Qt.DisplayRole: return QVariant() return QVariant(self.arraydata[index.row()][index.column()]) def flags(self, index): if index.column() == 2: return Qt.ItemIsSelectable return QAbstractTableModel.flags(self, index) if __name__ == "__main__": main() Cheers Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] pyqtMethodProxy
Hello, I was trying to connect the dataChanged signal of a QTableView instance the "new style way" via its string name and __getattr__ like so: treeview.__getattr__("dataChanged").connect(someSlot) Instead of getting a bound signal (like I do with a ComboBox for example), I am getting a pyqtMethodProxy, which does not have a connect attribute. I can't find anything on the internet about this. Is there a way to get the actual signal? Cheers Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] possible regression
Thank you I understand your point. I was just wondering why it worked in previous versions and thought this might be a bug. On 07/09/2012 06:20 PM, Phil Thompson wrote: On Mon, 09 Jul 2012 17:28:31 +0200, Sebastian Elsner wrote: Hello, I am updating some code to use PyQt-Py2.6-x86-gpl-4.9.4-1.exe. I have previously used PyQt-Py2.6-x86-gpl-4.8.6-1.exe. With the code attached I get a runtime error in 4.9.4 I did not get in the 4.8.6. Please execute the attached py file and click the open button in the window appearing. This opens a dialog. Close the dialog and click the signal button. Here I am getting an error: Traceback (most recent call last): File "pyqt_runtimeerror.py", line 50, in check print "test checked", self.isChecked() File "pyqt_runtimeerror.py", line 28, in isChecked return self.checkBox.isChecked() RuntimeError: wrapped C/C++ object of %S has been deleted The %S is obviously a (sip) bug, but it doesn't affect anything. To get rid of the problem I can comment line 8 (self.dialog = parent). Is this something I should fix in my app and was the 4.8.6 behaviour unintened or is this a bug? The current behaviour seems perfectly reasonable to me. The C++ dialog and its contents are destroyed when the dialog is closed. The corresponding Python objects are still alive because you have an explicit reference. If you remove that explicit reference (by commenting out line 8) then the Python objects get garbage collected. You don't get an exception in that case because the connection was broken when the slot object was garbage collected. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] possible regression
Hello, I am updating some code to use PyQt-Py2.6-x86-gpl-4.9.4-1.exe. I have previously used PyQt-Py2.6-x86-gpl-4.8.6-1.exe. With the code attached I get a runtime error in 4.9.4 I did not get in the 4.8.6. Please execute the attached py file and click the open button in the window appearing. This opens a dialog. Close the dialog and click the signal button. Here I am getting an error: Traceback (most recent call last): File "pyqt_runtimeerror.py", line 50, in check print "test checked", self.isChecked() File "pyqt_runtimeerror.py", line 28, in isChecked return self.checkBox.isChecked() RuntimeError: wrapped C/C++ object of %S has been deleted To get rid of the problem I can comment line 8 (self.dialog = parent). Is this something I should fix in my app and was the 4.8.6 behaviour unintened or is this a bug? Cheers Sebastian from PyQt4.QtGui import QMainWindow, QApplication, QCheckBox, QPushButton, QDialog, QVBoxLayout, QWidget, QHBoxLayout from PyQt4.QtCore import Qt, QAbstractItemModel, pyqtSignal class MyTreeModel(QAbstractItemModel): def __init__(self, parent): QAbstractItemModel.__init__(self, parent) self.dialog = parent def columnCount(self, parent): return 0 def rowCount(self, parent): return 0 class BaseDialog(QDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.checkBox = None def addCheckbox(self): self.checkBox = QCheckBox("checkbox") self.layout().insertWidget(self.layout().count() - 1, self.checkBox) def isChecked(self): if self.checkBox: return self.checkBox.isChecked() else: return False class Dialog(BaseDialog): def __init__(self, parent): """Dialog to add or edit notes""" BaseDialog.__init__(self, parent) self.setAttribute(Qt.WA_DeleteOnClose) self.mainWindow = parent self.treeModel = MyTreeModel(self) self.mainWindow.mySignal.connect(self.check) hBoxLayout = QVBoxLayout() self.setLayout(hBoxLayout) self.addCheckbox() def check(self): print "test checked", self.isChecked() class MainWindow(QMainWindow): mySignal = pyqtSignal() def __init__(self): QMainWindow.__init__(self) centralWidget = QWidget() hBoxLayout = QHBoxLayout() centralWidget.setLayout(hBoxLayout) self.setCentralWidget(centralWidget) self.openButton = QPushButton("open") self.openButton.clicked.connect(self.openDialog) hBoxLayout.addWidget(self.openButton) self.signalButton = QPushButton("signal") self.signalButton.clicked.connect(self.mySignal) hBoxLayout.addWidget(self.signalButton) def openDialog(self): dlg = Dialog(self) dlg.show() app = QApplication([]) mainWindow = MainWindow() mainWindow.show() app.exec_() ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] pyuic resources import
Hello, my folder structure for an application I want to restructure is like this: src lib ui __init__.py MainWindow __init__.py MainWindow.ui MainWindow.py ui_MainWindow.py resources.qrc resources_rc.py main.py The MainWindow.ui uses icons from the resources.qrc (which I would also like to use for all other dialogs as well) and this works perfectly. pyuic translates the .ui file to ui_MainWindow.py and adds an "import resources_rc" This is where it stops working because in the MainWindow folder is no resources_rc file and thus the import fails. Ways to avoid this, which I thought about: * tell pyuic not to import resources_rc and import it manually in main.py * split the resources.qrc for icons only used in MainWindow.ui and put icons used in other dialogs in another qrc -> only what about icons used in MainWindow and another dialog and thus defined two qrcs. does the system use double the memory? * make pyuic aware of absolute imports like import lib.ui.resources_rc What is the recommended way of doing this? Cheers Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] negative index "setWidget" not working as expected
Hallo, inserting widgets with a negative index does not work as expected. I was expecting -1 to add a widget to the end and -2 to insert it right before the last widget in the layout. Is my assumption wrong? Demo code: from PyQt4.QtGui import QLineEdit, QCheckBox, QPushButton, QDialog, QFormLayout, \ QVBoxLayout, QApplication class Gui(QDialog): def __init__(self): QDialog.__init__(self) editLayout = QFormLayout() editLayout.addRow("enter something:", QLineEdit()) editLayout.addRow("enter another something:", QLineEdit()) button = QPushButton("press me") layout = QVBoxLayout() layout.addLayout(editLayout) layout.addWidget(button) self.setLayout(layout) self.layout().insertWidget(-2, QCheckBox("check me!")) app = QApplication([]) g = Gui() g.show() app.exec_() cheers Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] phonon videoplayer stopped working going from pyqt 4.7 to 4.8
Nokia fixed this with their 4.7.2 update, which was released March 1st. Now we just have to wait for a PyQt update. Am 03.03.2011 00:53, schrieb mw: > Any ideas why this could be? > > > I have the same issue here with a 4.8.1 install. > Sample app attached. > > Whether using the VideoPlayer or building my own media graph for video > the picture never showed and python keeps throwing the same error: > WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no > objectName ) to Phonon::VideoWidget ( no objectName ). > > Using an audio only graph or the audio player worked as expected. > > > > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Phonon error in 4.8.1
Here is s small example which worked in PyQt 4.7.x import sys from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.phonon import Phonon class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.verticalLayout = QtGui.QVBoxLayout() self.videoPlayer = Phonon.VideoPlayer(Phonon.VideoCategory) self.connect(self.videoPlayer, QtCore.SIGNAL("finished()"), self.videoPlayer, QtCore.SLOT("deleteLater()")); self.verticalLayout.addWidget(self.videoPlayer) self.videoPlayer.play(Phonon.MediaSource("grattgratt.mpg")) if __name__ == '__main__': app = QtGui.QApplication(sys.argv) app.setApplicationName("Phonvideo") window = MainWindow() window.show() sys.exit(app.exec_()) Seems to be a windows issue. I get: WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::VideoWidget ( no objectName ). Could be this bug: http://bugreports.qt.nokia.com/browse/QTBUG-13062 Can somebody confirm? Did somebody experience similar problems? Regards Sebastian On 11/25/2010 09:04 PM, Hans-Peter Jansen wrote: On Thursday 25 November 2010, 14:17:55 Sebastian Elsner wrote: Hello, switching to 4.8.1 gave me this error: WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::VideoWidget ( no objectName ). The VideoPlayer worked well in previous versions without any errors? i tried to track it down, but had no luck. Could it be a bug introduced on Qt 4.7? The usual "please provide a minimum runnable example" applies here too.. Pete ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Phonon error in 4.8.1
Hello, switching to 4.8.1 gave me this error: WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::VideoWidget ( no objectName ). The VideoPlayer worked well in previous versions without any errors? i tried to track it down, but had no luck. Could it be a bug introduced on Qt 4.7? Regards Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] pyuic4 vs uic.loadUI
Hmm interesting topic, I recently had to switch back from ui files to py files because I couldnt get py2exe to package the ui files correctly (Any help appreciated though) Secondly using ui files I loose the comfort of auto-completion with pydev and Eclipse, because pydev wouldnt know how to deal with the ui xml data. If there is anybody out there having advice on that, I'd gladly take it :) Am 28.09.2010 21:46, schrieb fpp: On Tue, Sep 28, 2010 at 6:19 PM, pard wrote: Hi I have found that some people use pyuic4 to compile their ui files and some load them dynamically using loadUI. Does anyone have the pro's and con's of each of these methods? What is the recommended PyQT way of doing this? Thanks for starting the discussion, I've often wondered myself. I have no opinion one way or another, but since most seem to favour loadUI, I'll play the devil's advocate for pyuic4 :-) I can think of several reasons to prefer compiled ui files : 1) if you're using eric4 as an IDE, it does everything for you, so why not ? 2) on a reasonably recent PC, and for common UIs, the additional launch time, CPU& memory usage due to loadUI are probably not even measurable, compared to the Python, Qt and PyQt startup load. For extremely complex and widget-heavy UIs this might be less evident : parsing XML is not the most efficient thing in the world after all. And if we're running on mobile platforms with more limited power/CPU/RAM and slow Flash I/O, like Nokia's Symbian or Maemo smartphones, it could become quite perceptible. 3) during the early design phases, it's sometimes handy to be able to manually modify a generated Python UI file, just to check out the effect of some minor change, without having to do it in Designer (especially if it involves sizers :-) 4) if for some reason you wish or need to distribute only binaries, as sometimes happens, you can exclude the .ui source files and ship only the UI .pyc/pyo files. Dumb, yes, but not entirely impossible :-) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] PyQt, uic and cx_freeze
I've had the exact same issue with py2exe today. I just deleted the port_v3 folder and it worked. Am 22.09.2010 20:42, schrieb Phil Thompson: On Thu, 23 Sep 2010 06:37:43 +1200, Matthew Huck wrote: Hi, I'm in the process of trying cx_freeze an PyQt app I've written and have discovered the following bug: In PyQt/uic/port_v3/proxy_base.py, on line 4, if it reads "class ProxyBase(metaclass):" the code can be interpreted by python 2.6, and 3.1, however with it in it's default state of "class ProxyBase(metaclass=ProxyType):" only 3.1 can interpret it. ...and pyuic4 guarantees that it will only be called by Python3. It's a cx_freeze bug/feature. Phil ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] timers from mainwindow
Of course thats it, thanks :) On 09/14/2010 08:01 PM, Doug Bell wrote: Sebastian Elsner wrote: I would like to start a QTimer from a mainwindow's menu, creating a new instance of a custom class. See the example below. All works except the timer's callback is never called. Asking if the timer is active returns True. I ran out of ideas. Maybe I misunderstand how timers work?! Any help appreciated. def doit(self): Timers() You're not keeping a reference to your Timers instance. It's getting garbage collected before the timer fires. Doug ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] timers from mainwindow
Hello, I would like to start a QTimer from a mainwindow's menu, creating a new instance of a custom class. See the example below. All works except the timer's callback is never called. Asking if the timer is active returns True. I ran out of ideas. Maybe I misunderstand how timers work?! Any help appreciated. from PyQt4 import QtCore, QtGui from PyQt4 import uic import sys class Timers(QtCore.QObject): def __init__(self, parent=None): QtCore.QObject.__init__(self) print "Timers instance created" self.timer = QtCore.QTimer() self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.callback) self.timer.start(1000) print self.timer.isActive() def callback(self): print "timer called" class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.menubar = QtGui.QMenuBar(self) self.menuMenu = QtGui.QMenu(self.menubar) self.setMenuBar(self.menubar) self.actionDOIT = QtGui.QAction(self) self.menuMenu.addAction(self.actionDOIT) self.menubar.addAction(self.menuMenu.menuAction()) self.menuMenu.setTitle("menu") self.actionDOIT.setText("DO IT") self.connect(self.actionDOIT, QtCore.SIGNAL("triggered()"), self.doit) def doit(self): Timers() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) mainWindow = MainWindow() mainWindow.show() sys.exit(app.exec_()) Thank you Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Newbie question - Quicktime
H I have tried it on my win box. I only get avis to play (divx, wmv, asf, motion jpg...), no mov. Its not a problem of the code, it's just the backend. I have heard that the linux backend works best, because its based on gstreamer, so it can essentially play everything. Have you had a look at the capabilities example. Also please have a look a the phonon docs, they list all the backends and options. On 07/07/2010 12:14 PM, Hugo Léveillé wrote: Hey there I tried it under windows XP and Mac osx 10.5. At least under OSX, i get an error message that might help WARNING: Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface I've added that line to my script, no more error but still a black square with no video :( On Wed, 07 Jul 2010 09:52 +0200, "Sebastian Elsner" wrote: Hey Hugo, it's not working here either. But this might be because the backend is not able to play it. Which OS are you on? I am on windows XP and I think QT is not supported there for phonon. Start the capabilities app, which comes with the pyqt phonon examples. There you can find what is supported on you system. Cheers Sebastian Am 07.07.2010 01:38, schrieb David Boddie: On Wed Jul 7 00:13:43 BST 2010, Hugo Léveillé wrote: Id like to have some pointer on how, if possible, to add a quicktime movie in pyqt. I guess I have to add it to a label ? How to you add it ( QtGui.QMovie ? ) QMovie is an ancient class that basically plays animated GIF files and some MNG files. To play video streams and files, you need to look at the classes in the Phonon module. PyQt doesn't appear to have any Phonon examples written in Python and, from memory, I think the only one supplied with Qt is actually a demo. This code came from an example I wrote for PyCon Italia last year: class Player(QWidget): def __init__(self, parent = None): QWidget.__init__(self, parent) self.player = Phonon.VideoPlayer(Phonon.VideoCategory) urlLabel = QLabel(self.tr("&Location:")) self.urlEdit = QLineEdit() urlLabel.setBuddy(self.urlEdit) self.playButton = QPushButton(self.tr("&Play/Stop")) self.connect(self.urlEdit, SIGNAL("returnPressed()"), self.playButton, SLOT("animateClick()")) self.connect(self.playButton, SIGNAL("clicked()"), self.play) layout = QGridLayout(self) layout.addWidget(self.player, 0, 0, 2, 3) layout.addWidget(urlLabel, 2, 0) layout.addWidget(self.urlEdit, 2, 1) layout.addWidget(self.playButton, 2, 2) def play(self): if self.player.isPlaying(): self.player.stop() else: url = QUrl(self.urlEdit.text()) self.player.play(Phonon.MediaSource(url)) I hope you find it useful. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Newbie question - Quicktime
Hey Hugo, it's not working here either. But this might be because the backend is not able to play it. Which OS are you on? I am on windows XP and I think QT is not supported there for phonon. Start the capabilities app, which comes with the pyqt phonon examples. There you can find what is supported on you system. Cheers Sebastian Am 07.07.2010 01:38, schrieb David Boddie: On Wed Jul 7 00:13:43 BST 2010, Hugo Léveillé wrote: Id like to have some pointer on how, if possible, to add a quicktime movie in pyqt. I guess I have to add it to a label ? How to you add it ( QtGui.QMovie ? ) QMovie is an ancient class that basically plays animated GIF files and some MNG files. To play video streams and files, you need to look at the classes in the Phonon module. PyQt doesn't appear to have any Phonon examples written in Python and, from memory, I think the only one supplied with Qt is actually a demo. This code came from an example I wrote for PyCon Italia last year: class Player(QWidget): def __init__(self, parent = None): QWidget.__init__(self, parent) self.player = Phonon.VideoPlayer(Phonon.VideoCategory) urlLabel = QLabel(self.tr("&Location:")) self.urlEdit = QLineEdit() urlLabel.setBuddy(self.urlEdit) self.playButton = QPushButton(self.tr("&Play/Stop")) self.connect(self.urlEdit, SIGNAL("returnPressed()"), self.playButton, SLOT("animateClick()")) self.connect(self.playButton, SIGNAL("clicked()"), self.play) layout = QGridLayout(self) layout.addWidget(self.player, 0, 0, 2, 3) layout.addWidget(urlLabel, 2, 0) layout.addWidget(self.urlEdit, 2, 1) layout.addWidget(self.playButton, 2, 2) def play(self): if self.player.isPlaying(): self.player.stop() else: url = QUrl(self.urlEdit.text()) self.player.play(Phonon.MediaSource(url)) I hope you find it useful. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QLineEdit drop event
Ah, thanks Sybren, this works. Regards, Sebastian On Wed, 28 Apr 2010 16:31:05 +0200, Sybren A. Stüvel wrote: On 28-4-2010 16:23, Sebastian Elsner wrote: Ah, thanks Sybren, this works. Great! Perhaps you could forward your reply to the list too? It may be useful for others to read that it works too ;-) Cheers, -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QLineEdit drop event
Hello, I designed a GUI with Qt Designer. The GUI has several QLineEdits. I'd like to be able to drop files from the windows explorer to this line edits and display the path of the files. Documentation suggests that I subclass the line edit and reimplement the dropEvent. Would not be a problem, but my Line edit widget already exists on the dialog, so how to subclass without creating a completely new instance? Or is there another way I don't see? Thank you for any suggestions Regards Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSystemTrayIcon not working with py2exe
Hey, Ok here is the solution: If I use a png with pyrcc it works, whereas it does not when using an ico file wit pyrcc. Using an ico works when not using pyrcc and but copying the pyqtdir/plugins/imageformats to the py2exe distribution folder. This is weird. Any explanation? On Tue, 27 Apr 2010 15:50:16 +0200, Sebastian Elsner wrote: Hello Nick, my setup.py is autogenerated by GUI2exe. Find the contents below. As you can see, I included the icon as data and icon file (even if I did not have to when I was using ressources). both ways work when not compiled with py2exe. I also tried several combinations with optimize, compressed and bundle. also the QtCore and QtGui pyds and dlls get copied correctly... I searched the web and the py2exe homepage, but it seems they do not have a mailing list. I'd appreciate all suggestions. Sebastian from distutils.core import setup import shutil class Target(object): """ A simple class that holds information on our executable file. """ def __init__(self, **kw): """ Default class constructor. Update as you need. """ self.__dict__.update(kw) data_files = [('', ['X:\\hermes\\src\\icon.ico'])] includes = ['sip'] excludes = [] packages = [] dll_excludes = [] icon_resources = [(1, 'X:\\hermes\\src\\icon.ico')] bitmap_resources = [] other_resources = [] GUI2Exe_Target_1 = Target( script = "HermesServerSysTray.py", icon_resources = icon_resources, bitmap_resources = bitmap_resources, other_resources = other_resources, dest_base = "HermesServerSysTray", version = "0.1", company_name = "No Company", copyright = "No Copyrights", name = "Py2Exe Sample File", ) setup( data_files = data_files, options = {"py2exe": {"compressed": 0, "optimize": 0, "includes": includes, "excludes": excludes, "packages": packages, "dll_excludes": dll_excludes, "bundle_files": 3, "dist_dir": "dist", "xref": False, "skip_archive": False, "ascii": False, "custom_boot_script": '', } }, zipfile = None, console = [], windows = [GUI2Exe_Target_1], service = [], com_server = [], ctypes_com_server = [] ) On Tue, 27 Apr 2010 15:05:31 +0200, Nick Gaens wrote: Without insight to your setup.py, it's a lot of guessing ;-). You might have forgotten to add the icon itself as a resource to setup.py? On Tue, Apr 27, 2010 at 1:33 PM, Sebastian Elsner < sebastianels...@freenet.de> wrote: Hello, My application has a system tray icon, which gets its data from a ressource compiled via pyrcc. When started via double click on the .py script the icon shows up as expected. But when I compile with py2exe It does not. I also tried not using pyrcc, same result. Is this a known problem? Any ideas why this would happen? Thanks Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QSystemTrayIcon not working with py2exe
Hello Nick, my setup.py is autogenerated by GUI2exe. Find the contents below. As you can see, I included the icon as data and icon file (even if I did not have to when I was using ressources). both ways work when not compiled with py2exe. I also tried several combinations with optimize, compressed and bundle. also the QtCore and QtGui pyds and dlls get copied correctly... I searched the web and the py2exe homepage, but it seems they do not have a mailing list. I'd appreciate all suggestions. Sebastian from distutils.core import setup import shutil class Target(object): """ A simple class that holds information on our executable file. """ def __init__(self, **kw): """ Default class constructor. Update as you need. """ self.__dict__.update(kw) data_files = [('', ['X:\\hermes\\src\\icon.ico'])] includes = ['sip'] excludes = [] packages = [] dll_excludes = [] icon_resources = [(1, 'X:\\hermes\\src\\icon.ico')] bitmap_resources = [] other_resources = [] GUI2Exe_Target_1 = Target( script = "HermesServerSysTray.py", icon_resources = icon_resources, bitmap_resources = bitmap_resources, other_resources = other_resources, dest_base = "HermesServerSysTray", version = "0.1", company_name = "No Company", copyright = "No Copyrights", name = "Py2Exe Sample File", ) setup( data_files = data_files, options = {"py2exe": {"compressed": 0, "optimize": 0, "includes": includes, "excludes": excludes, "packages": packages, "dll_excludes": dll_excludes, "bundle_files": 3, "dist_dir": "dist", "xref": False, "skip_archive": False, "ascii": False, "custom_boot_script": '', } }, zipfile = None, console = [], windows = [GUI2Exe_Target_1], service = [], com_server = [], ctypes_com_server = [] ) On Tue, 27 Apr 2010 15:05:31 +0200, Nick Gaens wrote: Without insight to your setup.py, it's a lot of guessing ;-). You might have forgotten to add the icon itself as a resource to setup.py? On Tue, Apr 27, 2010 at 1:33 PM, Sebastian Elsner < sebastianels...@freenet.de> wrote: Hello, My application has a system tray icon, which gets its data from a ressource compiled via pyrcc. When started via double click on the .py script the icon shows up as expected. But when I compile with py2exe It does not. I also tried not using pyrcc, same result. Is this a known problem? Any ideas why this would happen? Thanks Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QSystemTrayIcon not working with py2exe
Hello, My application has a system tray icon, which gets its data from a ressource compiled via pyrcc. When started via double click on the .py script the icon shows up as expected. But when I compile with py2exe It does not. I also tried not using pyrcc, same result. Is this a known problem? Any ideas why this would happen? Thanks Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QStandardItemModel best practice
Try using QAbstractItemModel instead. ANd have a look at the table examples coming with PyQt. They helped me a lot. TheyAm 18.04.2010, 19:43 Uhr, schrieb Dom : Hi- I'm looking to create a table with checkable items based off a dictionary using the QStandardItemModel class, what is the best practice to do this? I've looked at using the class directly and it seemed cumbersome to add the data to the table and I couldn't get data to display at all when I subclassed. class MyTableModel(QStandardItemModel): def __init__(self, datain, headerdata, parent=None, *args): """ datain: a list of lists headerdata: a list of strings """ QStandardItemModel.__init__(self, 5, 6) self.arraydata = datain self.headerdata = headerdata def rowCount(self, parent): return len(self.arraydata) def columnCount(self, parent): return len(self.arraydata[0]) def data(self, index, role): if not index.isValid(): return QVariant() elif role != Qt.DisplayRole: return QVariant() return QVariant(self.arraydata[index.row()][index.column()]) def headerData(self, col, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return QVariant(self.headerdata[col]) return QVariant() thanks -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] properly exiting application while still in init
Hello, In the __init__ method of a standard QDialog I check for some requirements to be fulfilled before the gui is shown (I communicate with a server over a QTcpSocket for that matter) If the conditions fail I want to exit the Application. How would I properly do that? Currently I tried: socket.close() #first close the socket self.close() #close the window, does not do anything in the init because the window is not actually shown yet sys.exit() works but gives me an error (QWaitCondition: Destroyed while threads are still waiting) What could I try next? Regards Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QAbstractItemModel causes segfault
*bump* No ideas on this one? On Wed, 07 Apr 2010 18:14:28 +0200, Sebastian Elsner wrote: One additional question: You wrote, that internalPointer() is not meant to be used outside of the model. But how would I get the associated object from a QModelIndex? I am using selectedIndex() on the view to get the indexes, but how to proceed from there on? is On Tue, 06 Apr 2010 17:40:09 +0200, Phil Thompson wrote: On Tue, 06 Apr 2010 16:23:30 +0200, "Sebastian Elsner" wrote: Hello, I finally was able to compile an example case, which is not too complex, please find it attached. Run the python script, expand one LevelOne item and select a LevelTwo item and in the menu choose add/edit levelthree. If you do this you should see an error or the interpreter will crash (try adding more items und expand them!). As said this error can be prevented by adding strong references for all items in the tree (which is something the createIndex obviously does not). Uncomment line 210 and 211 to see that adding all items to a list helps. The root item is owned by the model, so this should work, right?! The root item is owned by the model, but does the root item own all of its children, grandchildren etc.? I can see that it owns its children because you explicitly call its appendChild() method, but I'm not clear where the children's equivalent methods are called. Have you tried printing out the tree of items starting with the root item at various point to make sure the tree contains what you think it should? QAbstractItemModel won't maintain your model for you. As the documentation says, it "provides the abstract interface for item model classes" - the key word being "interface". It is not the container of the model data - that's the responsibility of a sub-class. Phil -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] connect every widget to one slot
Hello, i created a dialog with some widgets. Now I'd like to connect every widget to a slot, so when the user changes values (for lets say a spinbox) a "dirty" flag for the dialog is set. Is there a way to accomplish this without connecting every widget explicitly? regards Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] QAbstractItemModel causes segfault
Hello, I am using a QTreeView to display data coming from a sqlalchemy query. All is fine for displaying, but when I add rows, which also adds records to the database the "internal pointers", the QAbstractItemModel so heavily depends on, suddenly point to nowhere, because they don't keep strong references (crashing the interpreter). I am using the reference implementation of the editable tree example, with the small adjustment that instead of TreeItem my sqlalchemy class is used. So, at first it seemed like the error was produced by sqlalchemy, but with the help of the people on the other list I could verify, that its a problem of PyQt. To quote Conor from the sqlalchemy list: I believe the real problem is that these "internal pointers" are not doing proper incref/decref on the python objects they point to, so your python objects are getting garbage collected prematurely. The expire-on-commit readily exposes this issue, but disabling it will not really fix the underlying problem. A newer version of pyQT may do the incref/decref for you. If not, your QAbstractItemModel-derived object should keep strong references to everything that was pointed to by an "internal pointer" in a private list or set. This should prevent them from being garbage collected. I followed conors suggestion with the string reference list and it worked. The objects are not garbage collected, the tree builds and extends properly. Is there any pyqt developer, who can share his thoughts on this and maybe help. I don't want to scream: BUG! but to Michael Bayer, the creator of sqlalchemy this is one: if QT is maintaining a "reference" to something using its "memory address", but is not actually recording a strong reference to the object within the python interpreter, that sure sounds like a bug to me. It would imply that to use that library, every object you generate in Python must have a strong reference maintained, or QT now references invalid ids. Thank you very much for helping Sebastian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] simpletreemodel throwing error
Hello, the simple tree model example seems to work fine at first, but when closed the terminal prints: QObject::startTimer: QTimter can only be used with threads started with QThread I run the example unchanged from within Eclipse with Pydev using the latest PyQt 4.7 on Windows XP 64bit SP2. What is wrong here? Can it be ignored? Sebastian -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Palette on QInputDialog
Hello, seems like palettes are not working on QInputDialogs. Please see the script attached. Setting a palette on an QErrorMessage works fine, but not on a InputDialog. Using PyQt 4.6.2 on Windows XP 64bit SP2 with python 2.6.4 32bit. from PyQt4 import QtCore from PyQt4 import QtGui class MyDlg (QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.resize(100,100) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) self.setPalette(palette) self.button=QtGui.QPushButton("push me!") self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.addWidget(self.button) self.connect(self.button,QtCore.SIGNAL("clicked()"),self.pressed) self.inputDialog=QtGui.QInputDialog(self) self.inputDialog.setPalette(self.palette()) self.errorMessage=QtGui.QErrorMessage(self) self.errorMessage.setPalette(self.palette()) def pressed(self): self.inputDialog.getText(self,"bug?","background should be yellow") self.errorMessage.showMessage("Works here!") if __name__=="__main__": import sys app=QtGui.QApplication(sys.argv) app.setStyle("plastique") dlg=MyDlg() dlg.show() sys.exit(app.exec_()) -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt