[PyQt] QComboBox inside the QTreeWidgetItem?
Hi, This is my first post to the list, so hello everyone! I recently started developing a small PyQT4 application with VTK 3D visualization, and I encountered a few problems, first one is described in this email. I wanted to include a combo box inside my QTreeWidgetItem, but it does no appear on the screen: self.tree_item = QTreeWidgetItem(self.widget_layers, [QString (structure_name), QString(str(sequence_length))]) combo = QComboBox() combo.addItem(QString('1st item'), Qt.DisplayRole) self.widget_layers.setItemWidget(self.tree_item, 4, combo) print type(self.widget_layers), type(self.tree_item), type(combo) print returns following values: class 'PyQt4.QtGui.QtreeWidget' class 'PyQt4.GtGui.QTreeWidgetItem' class 'PyQt4.QtGui.QComboBox' What am I doing wrong? I found similar listing in the archive: http://www.riverbankcomputing.com/pipermail/pyqt/2009-August/024067.html but author seems to have no problem with the QPushButton, which does not appear in my app, so I assume that there is some other problem than defining combo box like above? And once it's working, how can I connect to its activated SIGNAL? More general question would be: how can I get a reference to the given item in the QTreeWidgetItem? There is text() but it's now always the case... Thanks, Piotr Byzia ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] SIGNAL from checkbox embedded in the QTreeWidgetItem?
Hi, There is this email: http://www.riverbankcomputing.com/pipermail/pyqt/2009-October/024801.html Unfortunately, author did not post a follow-up post on how he got it done. I want to grab a signal from a checkbox added to the QTreeWidgetItem by the method: setCheckState(0, Qt.Checked) Could anyone help? Thanks, Piotr Byzia___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] How to read this mailing list?
Hi, I wonder how do you read this list? Separate emails is not the most convenient way as there are app. 350 messages per month. Daily Digest is messy when replying. Is there any online front-end where I can read messages, search the list, and answer to a given message? Thanks, Piotr Byzia ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Re: Global Shorcuts
On Wednesday 04 November 2009, 08:42:17 Wolfgang Rohdewald wrote: On Wednesday 04 November 2009, Manuel Enrique wrote: How can I set a global shorcut for my app? look up setShortcutContext in the docu: res = KAction(self) # should also work with QAction, I suppose res.setShortcut( Qt.CTRL + shortcut) res.setShortcutContext(Qt.ApplicationShortcut) Manuel, does this work for you? I guess you're after global desktop shortcuts, often combined with a systray app, similar to klipper and kding. I haven't checked PyQt4 yet, but for PyQt3 it indeed involved in speaking to the window manager directly, which is highly unportable, and depending on discretion of the various WMs :-(... PyKDE may be helpful here, but for my app, I needed reliable global (desktop) shortcuts _without_ depending on PyKDE, so it does depend on ctypes now. Be assured, that unlike PyQt, Xlib programming with ctypes isn't funny at all (highly understating).. Let us know about your findings, Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Konsole part doesn't emit destroyed() signal on exit
Hello! I have a program like this: #!/usr/bin/python import sys import os from PyKDE4.kdecore import * from PyKDE4.kdeui import * from PyKDE4.kparts import * from PyQt4.QtCore import * from PyQt4.QtGui import * class MainWindow (KMainWindow): def __init__ (self): KMainWindow.__init__(self) self.resize(640, 480) factory = KLibLoader.self().factory(libkonsolepart) self.part = factory.create(self, KonsolePart) self.connect(self.part, SIGNAL(destroyed()), self.readd) self.setCentralWidget(self.part.widget()) self.part.openUrl(KUrl.fromPath(os.environ['HOME'])) def readd(self): print Wow! factory = KLibLoader.self().factory(libkonsolepart) self.part = factory.create(self, KonsolePart) self.connect(self.part, SIGNAL(destroyed()), self.readd) self.setCentralWidget(self.part.widget()) self.part.openUrl(KUrl.fromPath(os.environ['HOME'])) if __name__ == '__main__': appName = Konsolepart_example catalog = programName = ki18n(Konsole Part Example) version = 1.0 description = ki18n(Example loading a Konsole Part) license = KAboutData.License_GPL copyright = ki18n((c)) text= ki18n(none) homePage= localhost bugEmail= none aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) KCmdLineArgs.init(sys.argv, aboutData) app = KApplication() mainWindow = MainWindow() mainWindow.show() app.exec_() ### When you close opened console session, the destroyed() signal doesn't emited by konsole part on system with new version of PyKDE(4.3.3)(or/and PyQt(4.6.1)). This program works absolutely fine on system with PyKDE 4.3.1 and PyQt 4.5.2. What is wrong in this code now? Sorry for my english and thanks. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Konsole part doesn't emit destroyed() signal on exit
On Wed, 4 Nov 2009 21:43:02 +0800, Shamakhov Andrey shamakho...@gmail.com wrote: Hello! I have a program like this: #!/usr/bin/python import sys import os from PyKDE4.kdecore import * from PyKDE4.kdeui import * from PyKDE4.kparts import * from PyQt4.QtCore import * from PyQt4.QtGui import * class MainWindow (KMainWindow): def __init__ (self): KMainWindow.__init__(self) self.resize(640, 480) factory = KLibLoader.self().factory(libkonsolepart) self.part = factory.create(self, KonsolePart) self.connect(self.part, SIGNAL(destroyed()), self.readd) self.setCentralWidget(self.part.widget()) self.part.openUrl(KUrl.fromPath(os.environ['HOME'])) def readd(self): print Wow! factory = KLibLoader.self().factory(libkonsolepart) self.part = factory.create(self, KonsolePart) self.connect(self.part, SIGNAL(destroyed()), self.readd) self.setCentralWidget(self.part.widget()) self.part.openUrl(KUrl.fromPath(os.environ['HOME'])) if __name__ == '__main__': appName = Konsolepart_example catalog = programName = ki18n(Konsole Part Example) version = 1.0 description = ki18n(Example loading a Konsole Part) license = KAboutData.License_GPL copyright = ki18n((c)) text= ki18n(none) homePage= localhost bugEmail= none aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail) KCmdLineArgs.init(sys.argv, aboutData) app = KApplication() mainWindow = MainWindow() mainWindow.show() app.exec_() ### When you close opened console session, the destroyed() signal doesn't emited by konsole part on system with new version of PyKDE(4.3.3)(or/and PyQt(4.6.1)). This program works absolutely fine on system with PyKDE 4.3.1 and PyQt 4.5.2. What is wrong in this code now? It's fixed in current snapshots. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] problem with QAbstractItemModel
Hi, the attached script implements a minimal tree model featuring rows deletion. It works just fine with (Qt 4.4, PyQt 4.4.4). However, with (Qt 4.5.2, PyQt 4.5.4) and (Qt 4.5.2, PyQt 4.6.1) deleting the last row raises the following error: v...@rachael:/tmp$ python tmTester.py [2] 6819 v...@rachael:/tmp$ Traceback (most recent call last): File tmTester.py, line 189, in index return self.createIndex(row, column, branch.childAtRow(row)) File tmTester.py, line 86, in childAtRow return self.children[row] IndexError: list index out of range Is it a bug in the recent versions of PyQt? Or should I fix some problem in the script? I would really appreciate your help. Vicent :: Share what you know, learn what you don't # -*- coding: utf-8 -*- #!/usr/bin/env python import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class TreeModelTester(QMainWindow): Test correctness of tree models/views def __init__(self): Initialize the application. QMainWindow.__init__(self) self.counter = 0 # Make the GUI self.setWindowTitle('TreeView tester') self.setupMenus() central_widget = QWidget(self) central_layout = QVBoxLayout(central_widget) self.setCentralWidget(central_widget) self.dbs_tree_view = QTreeView(central_widget) central_layout.addWidget(self.dbs_tree_view) # The tree of databases model/view self.dbs_tree_model = DBsTreeModel(self) self.dbs_tree_view.setModel(self.dbs_tree_model) def setupMenus(self): Set up the main window menus. remove_action = QAction('Remove', self) remove_action.setShortcut(QKeySequence.Delete) self.connect(remove_action, SIGNAL(triggered()), self.slotRemoveBranch) menu = self.menuBar().addMenu('Menu') menu.addAction(remove_action) def closeEvent(self, event): Handle close events. qApp.quit() def slotRemoveBranch(self): Delete a given branch from the tree model and its views. current = self.dbs_tree_view.currentIndex() if current is None: return # Delete the node self.dbs_tree_model.deleteNode(current) class GroupNode(object): A group node in the tree of databases model. def __init__(self, parent, name): Create a group node for the tree of databases model. self.children = [] self.parent = parent self.name = name def __len__(self): return len(self.children) def insertChild(self, child, position=0): Insert a child in a group node. self.children.insert(position, child) def childAtRow(self, row): The row-th child of this node. assert 0 = row = len(self.children) return self.children[row] def row(self): The position of this node in the parent's list of children. if self.parent: return self.parent.children.index(self) return 0 class DBsTreeModel(QAbstractItemModel): The tree of databases model. def __init__(self, parent=None): Create the model. QAbstractItemModel.__init__(self, parent) # Populate the model self.root = GroupNode(None, 'root') self.addBranch(QModelIndex(), 'First node') self.addBranch(QModelIndex(), 'Second node') self.addBranch(QModelIndex(), 'Third node') def flags(self, index): Returns the item flags for the given index. return Qt.ItemIsEnabled|Qt.ItemIsSelectable def data(self, index, role): Returns the data stored under the given role for the item referred to by the index. if not index.isValid(): return QVariant() node = self.nodeFromIndex(index) if role == Qt.DisplayRole: return QVariant(node.name) else: return QVariant() def setData(self, index, value, role=Qt.DisplayRole): Sets the role data for the item at index to value. if not index.isValid(): return False node = self.nodeFromIndex(index) if role == Qt.DisplayRole: node.name = value self.emit(SIGNAL( 'dataChanged(QModelIndex, QModelIndex)'), index, index) return True return False def headerData(self, section, orientation, role): Returns the data for the given role and section in the header with the specified orientation. if (orientation, role) == (Qt.Horizontal, \ Qt.DisplayRole): return QVariant('Sample tree') return QVariant() def columnCount(self, parent): The number of columns for the children of the given index. return 1 def rowCount(self, parent): The number of rows of the given index. if not parent.isValid(): parent_node = self.root else:
Re: [PyQt] Re: Global Shorcuts
On Wednesday 04 November 2009 04:58:27 am Hans-Peter Jansen wrote: Manuel, does this work for you? I guess you're after global desktop shortcuts, often combined with a systray app, similar to klipper and kding. I haven't checked PyQt4 yet, but for PyQt3 it indeed involved in speaking to the window manager directly, which is highly unportable, and depending on discretion of the various WMs :-(... PyKDE may be helpful here, but for my app, I needed reliable global (desktop) shortcuts _without_ depending on PyKDE, so it does depend on ctypes now. Be assured, that unlike PyQt, Xlib programming with ctypes isn't funny at all (highly understating).. Let us know about your findings, Pete Exactly Pete, thats what I'm looking for: portable Global Desktop Shorcuts. I'll post here anything I find. Manuel. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] How to read this mailing list?
I read it using http://old.nabble.com/PyQt-f23444.html -- View this message in context: http://old.nabble.com/How-to-read-this-mailing-list--tp26192857p26201163.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Drag and Drops on Mac OS X
Hey everyone, I seem to be having difficulty getting drag and drops working on a tool I am porting over from Windows to OS X. The short and skinny is that I want to be able to drag a file from a finder into a model based list view and the file name show up in the list view. I get the cursor icon to show that it will accept a drop but when I release click nothing happens. On my custom dragEnterEvent, dragMoveEvent and dropEvent methods I put simple print statements to signify in the terminal that the method is being executed, but no dice. I have a feeling that the approach to OSX must be slightly different than Windows so here's an abridged version of what I am doing and maybe someone can tell me what I might be doing wrong This simple example works fine on windows xp using PyQt 4.4.3 for python 2.5.1 but I can't seem to get it to work for PyQt 4.6 for python 2.5.4 on OS X. Any Ideas? import os, sys from PyQt4 import QtGui, uic, QtCore class myPyQt_tool(QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.rootDir = os.path.dirname(sys.argv[0]) print self.rootDir self.ui = uic.loadUi('%s/my_ui_file.ui' % self.rootDir) self.listview_model = QtGui.QStandardItemModel() self.ui.my_listview.setModel(self.listview_model) self.ui.my_listview.setAcceptDrops(True) self.ui.my_listview.setDragEnabled(True) self.current_file = '' self.ui.my_listview.__class__.dragEnterEvent = self.custom_dragEnterEvent self.ui.my_listview.__class__.dragMoveEvent = self.custom_dragEnterEvent self.ui.my_listview.__class__.dropEvent = self.custom_dropEvent def custom_dragEnterEvent(self, event): print 'drag enter event' testEvent = event.mimeData().urls()[0].toLocalFile() if testEvent: event.accept() else: event.ignore() def custom_dropEvent(self, event): print 'drop event' self.current_file = str(event.mimeData().urls()[0].toLocalFile()) if self.current_file: item_name = os.path.basename(self.current_file) list_item = QtGui.QStandardItem(item_name) self.listview_model.appendRow([list_item]) event.accept() else: event.ignore() app = QtGui.QApplication(sys.argv) dialog = myPyQt_tool() dialog.ui.show() app.exec_() and if the attachment doesn't come through here is my_ui_file.ui ?xml version=1.0 encoding=UTF-8? ui version=4.0 classDialog/class widget class=QDialog name=Dialog property name=geometry rect x0/x y0/y width310/width height435/height /rect /property property name=windowTitle stringDialog/string /property widget class=QListView name=my_listview property name=geometry rect x20/x y10/y width256/width height371/height /rect /property property name=focusPolicy enumQt::StrongFocus/enum /property property name=acceptDrops booltrue/bool /property property name=dragEnabled booltrue/bool /property property name=dragDropMode enumQAbstractItemView::NoDragDrop/enum /property property name=selectionMode enumQAbstractItemView::ExtendedSelection/enum /property /widget /widget resources/ connections/ /ui my_ui_file.ui Description: my_ui_file.ui ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] SIP default exception handler
On Tue, 03 Nov 2009 17:04:38 +0100, Sébastien Petitdemange sebastien.petitdema...@esrf.fr wrote: Hi, We have tested your snapshot code and it works as expected. In fact, we had a rather obscure problem where our exceptions were thrown in our library, but it was not seen by your specific catch route. After a lot of research, we saw that the Python (distutils) Makefile hides by default the library symbols, except the initModule function. It seems that this filtering also affect weak symbols with default values, and we believe that this avoided the try ... catch block to properly identify in run-time the good exception type id. The solution we found was to specify export_all=True in the Module Makefile. However, we have also seen a problem with dynamic parameter allocation. In the example below, the /Out/ std::string buffer parameter is created by sip. However, inside of our /Default/ exception handler or even the catch (...) handler, the object is not deleted. Do you have an idea of what could be happening? Should be fixed in tonight's snapshot. Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] googlemap api
On Wed Nov 4 19:14:47 GMT 2009, Ahmet Erdinc YILMAZ wrote: I want to use google map api in my qt application. And the way is qtWekbit module . However I encounter some problems in the web. It is said that some javascript calls may be problematic in this module. We have not started the project yet and I want to use pyqt. Is there anything you can advise? We want it as a desktop app, therefore we consider using flex too (since we can build desktop apps too), but I do not want. You may want to take a look at the C++ code for this example: http://labs.trolltech.com/blogs/2009/07/29/maps-with-a-magnifying-glass/ It might help you solve the problems with your own code. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] googlemap api
On Wed, Nov 4, 2009 at 9:14 PM, Ahmet Erdinc YILMAZ ahmeterdincyil...@gmail.com wrote: module . However I encounter some problems in the web. It is said that some javascript calls may be problematic in this module. We have not started the You can verify Qt Webkit functionality easily by testing a site functionality with the Arora browser. -- Ville M. Vainio http://tinyurl.com/vainio ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt