[PyQt] pyuic4 addItem issue
Hi Phil, attached is a ui file, generated with designer of Qt 4.5.1, that throws this exception: > pyuic4 -dp configdialogbase.ui PyQt4.uic.uiparser: UI version is 4.0 PyQt4.uic.uiparser: uiname is ConfigDialogBase PyQt4.uic.uiparser: toplevel widget is QDialog PyQt4.uic.properties: setting property geometry PyQt4.uic.properties: setting property windowTitle PyQt4.uic.uiparser: push QDialog ConfigDialogBase PyQt4.uic.uiparser: push QGridLayout gridLayout_3 PyQt4.uic.uiparser: push QHBoxLayout horizontalLayout PyQt4.uic.properties: setting property sizePolicy PyQt4.uic.properties: setting property minimumSize PyQt4.uic.properties: setting property maximumSize PyQt4.uic.properties: setting property baseSize PyQt4.uic.properties: setting property tabKeyNavigation PyQt4.uic.properties: setting property movement PyQt4.uic.properties: Static PyQt4.uic.properties: setting property flow PyQt4.uic.properties: TopToBottom PyQt4.uic.properties: setting property viewMode PyQt4.uic.properties: IconMode PyQt4.uic.uiparser: push QListWidget lwConfig PyQt4.uic.uiparser: pop widget QListWidget lwConfig PyQt4.uic.uiparser: new topwidget PyQt4.uic.properties: setting property sizePolicy PyQt4.uic.properties: setting property currentIndex PyQt4.uic.uiparser: push QTabWidget twConfig PyQt4.uic.uiparser: push QWidget generalTab PyQt4.uic.uiparser: push QGridLayout gridLayout_2 PyQt4.uic.properties: setting property title PyQt4.uic.uiparser: push QGroupBox groupBox PyQt4.uic.uiparser: push QFormLayout formLayout PyQt4.uic.properties: setting property text PyQt4.uic.properties: setting property buddy PyQt4.uic.uiparser: push QLabel lbName PyQt4.uic.uiparser: pop widget QLabel lbName PyQt4.uic.uiparser: new topwidget PyQt4.uic.uiparser: push QLineEdit leName PyQt4.uic.uiparser: pop widget QLineEdit leName PyQt4.uic.uiparser: new topwidget PyQt4.uic.properties: setting property text PyQt4.uic.properties: setting property buddy PyQt4.uic.uiparser: push QLabel lbEmail PyQt4.uic.uiparser: pop widget QLabel lbEmail PyQt4.uic.uiparser: new topwidget PyQt4.uic.uiparser: push QLineEdit leEmail PyQt4.uic.uiparser: pop widget QLineEdit leEmail PyQt4.uic.uiparser: new topwidget PyQt4.uic.properties: setting property text PyQt4.uic.properties: setting property buddy PyQt4.uic.uiparser: push QLabel lbMailServer PyQt4.uic.uiparser: pop widget QLabel lbMailServer PyQt4.uic.uiparser: new topwidget PyQt4.uic.uiparser: push QLineEdit leMailServer PyQt4.uic.uiparser: pop widget QLineEdit leMailServer PyQt4.uic.uiparser: new topwidget Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/PyQt4/uic/port_v2/invoke.py", line 12, in invoke exit_status = driver.invoke() File "/usr/lib/python2.6/site-packages/PyQt4/uic/driver.py", line 35, in invoke return self._preview() File "/usr/lib/python2.6/site-packages/PyQt4/uic/driver.py", line 49, in _preview widget = loadUi(self._ui_file) File "/usr/lib/python2.6/site-packages/PyQt4/uic/__init__.py", line 112, in loadUi return DynamicUILoader().loadUi(uifile, baseinstance) File "/usr/lib/python2.6/site-packages/PyQt4/uic/Loader/loader.py", line 21, in loadUi return self.parse(filename) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 700, in parse actor(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 548, in createUserInterface self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 329, in createLayout self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 349, in handleItem self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 329, in createLayout self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 349, in handleItem self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 168, in createWidget self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526, in traverseWidgetTree handler(self, child) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 168, in createWidget self.traverseWidgetTree(elem) File "/usr/lib/python2.6/site-packages/PyQt4/uic/uiparser.py", line 526
Re: [PyQt] What about qtbrowserplugin?
Well, making a binding for QtNPBindable and QtNPFactory isn't the problem... as compiling it against the qtbrowserplugin which doesn't install anywhere on the system -_- even adding the qtbrowserplugin.o qtbrowserplugin_x11.o to OFILES i Makefile still makes broken binary: /usr/lib64/python2.6/site-packages/QtBrowserPlugin.so: undefined symbol: _Z16qtns_instantiatev (undefined symbol: _ZTI11QtNPFactory when compiled without those two *.o files). Any ideas? :) I'm not good at compiling C/C++ with libraries in chaos ;) W dniu 20 czerwca 2009 02:57 użytkownik piotr maliński napisał: > It's something interesting - making browser plugins with Qt, but I didn't > found any examples/success stories of this add-on so I'm asking :) > > 2009/6/20 David Boddie > > On Thu Jun 18 14:12:48 BST 2009, piotr malinski wrote: >> >> > QtSoftware has in the add-ons catalog qtbrowserplugin package. I wonder >> if >> > this framework could get Python API and the possibility to write the >> > plugins in Python? >> > >> > >> http://www.qtsoftware.com/products/appdev/add-on-products/catalog/4/Utiliti >> >es/qtbrowserplugin >> >> I haven't looked at it closely, but have you though about wrapping the >> QtNPBindable class and creating a generic plugin like the one for Qt >> Designer >> that is supplied with PyQt? >> >> I know you've made bindings for other C++ widgets before: >> >> http://www.rkblog.rk.edu.pl/w/p/making-pyqt4-widgets-sip/ >> >> :-) >> >> 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] What about qtbrowserplugin?
On Sat Jun 20 15:21:28 BST 2009, piotr malinski wrote: > Well, making a binding for QtNPBindable and QtNPFactory isn't the > problem... as compiling it against the qtbrowserplugin which doesn't > install anywhere on the system -_- even adding the qtbrowserplugin.o > qtbrowserplugin_x11.o to OFILES i Makefile still makes broken binary: > > /usr/lib64/python2.6/site-packages/QtBrowserPlugin.so: undefined symbol: > _Z16qtns_instantiatev Yes, the qtns_instantiate() function is usually provided by the specific plugin implementation, via the QTNPFACTORY_END() macro. > (undefined symbol: _ZTI11QtNPFactory when compiled without those two *.o > files). Any ideas? :) I'm not good at compiling C/C++ with libraries in > chaos ;) I would implement qtns_instantiate() to return an instance of a QtNPFactory subclass written in Python. This subclass would do what the QtNPClassList implementation would do in a C++ plugin - this subclass is made using the QTNPFACTORY_BEGIN() macro in C++. The qtns_instantiate() function will also need to initialize the Python interpreter. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Exposing complex Qt objects as javascript objects
On 05/01/2009 05:33 PM, Phil Thompson wrote: On Thu, 23 Apr 2009 02:31:39 +0200, Henning Schröder wrote: On Tue, Apr 21, 2009 at 2:15 AM, Ori Avtalion wrote: Hi, I'm trying to create a Qt object that will be exposed to javascript. I want that javascript object to be complex: It has nested objects inside it, and has arrays with other objects in them. I'm not sure how to define the properties for the top object that I expose. pyqtProperty doesn't accept "QVariant". (It returns the error "TypeError: type 'QVariant' is not supported as a property type") Dynamic properties via setProperty use variants but I think it does not work correctly for objects and widgets. It seems that the type is not set to QMetaType::QObjectStar or QMetaType::QWidgetStar in the constructor. At least QtScript does not recognize the variant as a object or widget (see app property in attached example - the C++ equivalent would work this way). I think this is fixed in tonight's snapshot. If there is anything else that you don't think works properly then please let me know. Actually, with version 4.5.1-snapshot-20090614 and sip 4.8.1 perhaps there's a regression. This method, when called from javascript, will return an empty string instead of a javascript object. It used to return a javascript object in 4.4.4 @pyqtSignature("fun()", result="QVariant") def fun(self): return QVariant({"one":1, "arr":[1,2,{"three":3}], "obj":{"foo":"bar"} }) -Ori ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] wchar_t type mapping
Hi, I want to wrap a method with the following signature: virtual irr::gui::IGUIStaticText* addStaticText(const wchar_t* text, const irr::core::rect& rectangle, bool border=false, bool wordWrap=true, irr::gui::IGUIElement* parent=0, irr::s32 id=-1, bool fillBackground = false) = 0; All types are mapped or declared, and compilation succeeds. However, on calling the function, Python barks with Traceback (most recent call last): File "hello_world.py", line 64, in main() File "hello_world.py", line 45, in main True); TypeError: argument 1 of IGUIEnvironment.addStaticText() has an invalid type So I tried to map the wchar_t from and to PyUnicode-objects. But this gives me an error that says mac-dir:IrrSinn-1.5 deets$ python2.6 setup.py install running install running build running build_ext building 'irrlicht' extension /Library/Frameworks/Python.framework/Versions/2.6/bin/sip -c build/temp.macosx-10.3-i386-2.6 -b build/temp.macosx-10.3-i386-2.6/irr.sbf irr.sip sip: types.sip:613: Invalid type for %MappedType error: command '/Library/Frameworks/Python.framework/Versions/2.6/bin/sip' failed with exit status 1 The mapping looks like this: %MappedType wchar_t* { %TypeHeaderCode #include %End %ConvertFromTypeCode if (!sipCpp) return Py_None; wchar_t *s = (wchar_t*)sipCpp; return PyUnicode_FromWideChar(s, wcslen(s)); %End %ConvertToTypeCode if (sipIsErr == NULL) { return PyUnicode_Check(sipPy); } if (sipPy == Py_None) { *sipCppPtr = NULL; return 0; } Py_ssize_t len = PyUnicode_GET_SIZE(sipPy); wchar_t *w = malloc(sizeof(wchar_t) * len + 1); w[len] = 0; PyUnicode_AsWideChar(PyUnicodeObject *unicode, wchar_t *w, Py_ssize_t size); PyUnicode_AsWideChar(sipPy, w, len); *sipCppPtr = w; return 1; %End }; Any suggestions? Of course if anything else fails, I could manually wrap the methods in question - but I'd rather spare myself that effort. Diez ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Pressing enter in QLineEdit clicks QPushButton?
Hello, I've got a dialog with a QLineEdit and a QPushButton. The QLineEdit is connected to a method which takes its text and appends it to a QTextBrowser (that's taken from the first GUI example in the PyQt book by M. Summerfield). The "clicked()" signal of the QPushButton is connected to a method that just prints a message. The problem: this method, which should only be called by clicking the button, is called every time Enter is pressed in the QLineEdit. This happens even if the edit control isn't connected to any method. The button is next to the line edit in the form and in the tab order. With "setAutoDefault(false)" for this button and for the exit button which follows in tab order I can prevent this behavior, but that isn't really very comfortable. And it shouldn't be necessary, should it? All this on openSUSE with Python 2.6, PyQt 4.4.4. Thank you for help, Sibylle -- Sibylle Koczian ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] What about qtbrowserplugin?
On Sat, 20 Jun 2009 18:07:40 +0200, David Boddie wrote: > I would implement qtns_instantiate() to return an instance of a QtNPFactory > subclass written in Python. This subclass would do what the QtNPClassList > implementation would do in a C++ plugin - this subclass is made using the > QTNPFACTORY_BEGIN() macro in C++. > > The qtns_instantiate() function will also need to initialize the Python > interpreter. Just to follow up on this, I put together a set of bindings and a plugin based on the Qt Designer plugin supplied with PyQt. I've put my additions in a Mercurial repository: http://bitbucket.org/dboddie/pyqt-browser-plugin/ You will need to obtain the original Open Source version of the Browser Plugin Qt Solution and copy the directories from the repository into it. Then it should be possible to enter the python directory and run the configure.py script to build a plugin and bindings. At the moment it's hard-wired for Mozilla-based browsers on Unix/Linux, so you will need to copy the libpyqtbrowserplugin.so and the plugins from the examples/python directory into your $HOME/.mozilla/plugins directory. You also need to make sure that the QtBrowserPlugin.so library is on your Python path when you run Firefox. Good luck! David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Snow Leopard/ Python 2.6 bug
Anyone able to get PyQt 4.4.1 or higher running on Snow Leopard? I used mac ports to install 4.4.1 and got the following error when running scripts that worked on Leopard: % python numbers.pyw Qt: qcolorFromCGColor: cannot convert from colorspace model: 0 I noticed a mention of this checkin for C++: http://qt.gitorious.org/~gberg/qt/qt-gberg/commit/e773b0486a4784994a900c03a2620baf2775ac9d?diffmode=sidebyside ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt