Re: [PyKDE] Editable QComboBox in QTable problem ?
Le mer 19/03/2003 à 15:13, Hans-Peter Jansen a écrit : > Hi David, > > please have a look into the smalltable.py example, and you will see, > what's wrong. Also reading the docs for QTableItem will help you here. > > Pete Hello Pete, Thank you for your help. I looked smalltable.py, it's an example for Qt 3.x, with Qt 2.x, there isn't QComboTableItem(). With Qt 2.x, I haven't other solution that using setCellWidget(). True or wrong ? button, checkBox, comboBox works fine with setCellWidget() but with editable comboBox, when I'm writing, I lose my focus. any ideas ? Thanks Pete. David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] Editable QComboBox in QTable problem ?
> > I put an editable QComboBox in a cell of QTable with setCellWidget() : > > > > self.combo = QComboBox(self.table) > > self.combo.setEditable(1) > > self.table.setCellWidget(line,col,self.combo) > > > > When I'm writing in comboBox, the first character is in the comboBox, > > and after, characters are in a other cell. > > Please provide a small self contained example of your problem. Hello, Here is a little example, I'm using PyQt 3.5 and Qt 2.3 : import sys from qttable import * from qt import * class Form(QDialog): def __init__(self,parent = None,name = None,modal = 0,fl = 0): QDialog.__init__(self,parent,name,modal,fl) self.setProperty('caption',QVariant(self.tr("Form"))) self.table = QTable(self,'table') self.table.setNumRows(4) self.table.setNumCols(4) combo = QComboBox(self.table) combo.setEditable(1) combo.insertItem('a') combo.insertItem('b') combo.insertItem('c') self.table.setCellWidget(1,1,combo) if __name__ == '__main__': a = QApplication(sys.argv) QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()')) w = Form() a.setMainWidget(w) w.show() a.exec_loop() Thanks for your help. David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] Editable QComboBox in QTable problem ?
Dear all, I put an editable QComboBox in a cell of QTable with setCellWidget() : self.combo = QComboBox(self.table) self.combo.setEditable(1) self.table.setCellWidget(line,col,self.combo) When I'm writing in comboBox, the first character is in the comboBox, and after, characters are in a other cell. I don't know why, I'm using PyQt 3.5 and Qt 2.3.0 Thank you. David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] qt, pyqt license
Dear all, I don't understand the licence for qt and pyqt. On X11, it's GPL and on Microsoft Windows, it's what ? Commercial licenses and a free-as-in-free-beer for older version. That's very disorder ! I have not a good idea for the future... which choice pyqt or pygtk ? Thank you David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] Re: [C++-sig] Can boost.python and PyQt be usedtogether?
"Paul F. Kunz" <[EMAIL PROTECTED]> writes: >Me again, one final time on this topic. > >I built a Python extension module for my C++ CanvasWindow class using > SIP. Now the following works... > > [pfkeb@Kunz-pbdsl1 sip]$ python > Python 2.2.2 (#1, Oct 15 2002, 07:42:56) > [GCC 2.95.3 20010315 (release)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import sys >>>> from qt import * >>>> app = QApplication ( sys.argv) >>>> from sihippo import * >>>> cw = CanvasWindow() >>>> cw.show() >>>> app.exec_loop() > >So it appears that SIP and Boost.Python modules can not work > together if they are both interfacing to Qt. I don't think that's really the right conclusion... or at least, it masks something much deeper. I would very much appreciate it if someone could get me a simple test case I where can easily reproduce this problem (preferably, but not neccessarily on a Windows machine). Thanks, Dave -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] Re: [C++-sig] Can boost.python and PyQt be used together?
"Paul F. Kunz" <[EMAIL PROTECTED]> writes: >Its me again. This time, I've got my Python extension modules > working completely with Boost.Python wrapped alone. That is... > > [pfkeb@Kunz-pbdsl1 testsuite]$ python > Python 2.2.2 (#1, Oct 15 2002, 07:42:56) > [GCC 2.95.3 20010315 (release)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from hippo import * >>>> app = HDApp(1) >>>> cw = CanvasWindow() >>>> cw.show() >>>> app.exec_loop() > > works fine. In the above, `HDApp' is not derived from > QApplication, but delegates to a class which does. CanvasWindow > wraps a C++ class which derives from QMainWindow. > > Now I modify the dclock.py example that comes with PyQt to... Hmm, does dclock.py by any chance use threads? > a = QApplication(sys.argv) > clock = DigitalClock() > clock.resize(170,80) > a.setMainWidget(clock) > clock.show() > > cw = CanvasWindow() # added > cw.show() # added > > a.exec_loop() > > and get ... > > Starting program: /usr/local/bin/python >/home/pfkeb/hippodraw-BUILD/testsuite/dclock.py > [New Thread 1024 (LWP 5948)] > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 1024 (LWP 5948)] > PyErr_SetObject (exception=0x8108a8c, value=0x81ab208) at Python/errors.c:39 > (gdb) bt > (gdb) > >On the line of the error > > oldtype = tstate->curexc_type; > > (gdb) p tstate > $1 = (PyThreadState *) 0x0 > (gdb) Well, the thread state is NULL. I don't know what this means, but I think it's premature to conclude that SIP and Boost.Python are incompatible with one another. As far as I can tell, they should not interact in any particular way, any more than Boost.Python should interact with, say, the CPickle extension module which comes with Python's standard library. I know relatively little about Python threading, except that only one thread may be executing core Python code at any given time. That means that if your C++ code is being called from multiple threads it must acquire something called the global interpreter lock (GIL) before it touches any Python objects. If you have any virtual function dispatching back to Python going on in your C++ objects (i.e. using call_method), you could easily be running into this issue. -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] Re: [C++-sig] Can boost.python and PyQt be usedtogether?
Phil Thompson <[EMAIL PROTECTED]> writes: > Another possible conflict, perhaps more likely, is the two modules > fighting over the Qt API. Could you be a little more specific about what this might mean? Thanks, Dave -- David Abrahams [EMAIL PROTECTED] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] Changing Color in QTable entries
Hello QT folks: I have been trying to implement a GUI that uses the QTable and QTableItem methods. I have a table of entries and I want to keep track of the changes I make to the table entries. Now I want to highlight the changed cells with a different color. I sub-classed QTableItem and re-implemented the QTableItem::Paint method to change the color of the entries. However, I see a quick flicker of color change and then the old white background seems to override it. I believe before the color change is incorporated, garbage collection takes over and clears the colored objects created. If anyone has encountered such a problem, can you tell me how I could force the color of the changed items to persist? I have attached a small test snippet - The main process is coded in changeColor.py. Table.py is the code generated by Qt designer that is used by changeColor.py. One can run changeColor.py to test it. The button 'show changes' should ideally color the items. Regards, David S. from qt import * from qttable import * from table import Form1 import sys class changeColor(Form1): def __init__(self,parent=None): Form1.__init__(self,parent) self.connect(self.insertB,SIGNAL('clicked()'),self.insertData) self.connect(self.Table1,SIGNAL('valueChanged(int,int)'),self.trackChanges) self.connect(self.showB,SIGNAL('clicked()'),self.color) self.list=[] def insertData(self): for row in xrange(3): for col in xrange(3): self.Table1.setText(row,col,str(row)) self.list=[] def trackChanges(self,row,col): if [row,col] not in self.list: self.list.append([row,col]) print self.list def color(self): row=0 col=0 for cell in self.list: row=cell[0] col=cell[1] self.item=colorItem(self.Table1,QTableItem.Always,self.Table1.text(row,col)) self.Table1.setItem(row,col,self.item) class colorItem(QTableItem): def __init__(self, table, edittype, text): QTableItem.__init__(self, table, edittype, text) print "New MyTableItem" def paint(self, painter, colorgroup, rect, selected): print "paint called" cg = QColorGroup(colorgroup) cg.setColor(QColorGroup.Base, Qt.red) QTableItem.paint(self,painter, cg, rect, selected) if __name__=="__main__": app = QApplication(sys.argv) print app.desktop().width() print app.desktop().height() cc = changeColor() app.setMainWidget(cc) cc.show() app.exec_loop() # Form implementation generated from reading ui file 'table.ui' # # Created: Fri Nov 8 15:45:15 2002 # by: The PyQt User Interface Compiler (pyuic) # # WARNING! All changes made in this file will be lost! from qt import * from qttable import QTable image0_data = [ "22 22 7 1", ". c None", "# c #00", "b c #2e2e2e", "c c #5c5c5c", "d c #878787", "e c #c2c2c2", "a c #ff", "..", "##", "#aaa#b#...", "#aaa#cb#..", "#aaa#dcb#.", "#aaa#edcb#", "#aaa#aedcb#...", "#aaa###...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "#a#...", "###...", "..", ".." ] image1_data = [ "22 22 5 1", ". c None", "# c #00", "c c #848200", "a c #00", "b c #ff", "..", "..", "..", "#.", "...###.##.", "..###.", "..", "....#.", "#abab##...", "#babababababab#...", "#ababababababa#...", "#babababababab#...", "#ababab###", "#babab####", "#abab####.", &
[PyKDE] setCellWidget and signal
Dear everybody, I'm using setCellWidget() to put several buttons on cells in a table. When I capture the signal, I would like to check the button whom(row,column) the signal belongs to. Thank you for your help. David Florkin ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] Problem with German characters
> Then I get the next problem. Here is my code: > > string.split(unicode(self.widget.text.eingabe.text()),'\n') > tmp = unicode(self.widget.text.eingabe.text())+'\n' > > try: > exec tmp in user_name_space > except: > txt = str(sys.exc_info()[1]) > return > > Here I get the error message > > ASCII encoding error: ordinal not in range(128) > > -- > Janos Blazi > I'm using this : blah = textedit.text().latin1() It works fine. David Florkin ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] QButton in QTableItem
Hello all !, I'm experimenting with QTable, I would like to put a QButton in a cell. Is it possible ?, have you an example ? Thank you ! David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] #ifdef and sip
Hi Phil, hi list There is something Idon't underdtand very well with sip. How does it manage the conditional member function declaration. I mean, for exmaple, in my qpainter.h, the member function setViewXForm is declared according the the QT_NO_TRANSFORMATIONS macro. But the qpainter.sip file alaways declare this function. How is it managed when disabled in the Qt library ? Thanks. David Douard ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
pykde@mats.gmd.de
Hi list, hi Phil I am quite disappointed with the new licenses. If I understand things, the Zaurus version is no GPL'ed anymore, is it ? Cause my problem is : I would like to provide a little GPL soft I have written for the Zaurus with PyQt. But the fact is I would like to provide it, among others, as a simple ipk file, which then should contain a standalone exec file. I would like the standard user not to have to install the full python and pyqt packages. More, I need some extensions to PyQt I have written for Qtpe (namely, support for documents in Zaurus, AppLnk DocLnk, etc.). Note that I have sent a patch a month ago with thoses enhancements, but I had no answer for you, Phil, nor it has been included in PyQT. And I would like to be able to compile only the Qt Classes I do use in my soft in order to minimize code size. But it seems I cannot compile PyQt for the Zaurus, since, at least, the file qwindowdefs for the Zaurus (QtEmb) is not available. Anyone has ever developped an application for the Zaurus with PyQt ? And provided it as a standalone package ? My idea is to use Gordon McMillan's Installer to generate a standalone executable. Everything works fine on my Linux laptop (I can generate a ipk package for qvfb)... But to do the same for the zaurus is somewhat more complicated. If I succeed, one day, in this quest, I'll provide some kind of "howto" : there are so many undocumented things I had to discover... (for exmaple : how to show te little "ok" button in the toolbar) etc. Thanks for any tip (Michael Lauer maybe ?). David Douard ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] PyQt on iPAQ
On Monday 03 Jun 2002 11:58 pm, Joe Chott wrote: > I guess one of the most awesome things to me about tcl/tk was > that a code example like: > > button .b -text "Exit Program" -command exit > pack .b > > is a complete, self contained program, in two lines, which shows > how a button works in tcl/tk. > > As clean as python is (and I do like how clean the code looks), > it seems that you have more overhead to have a working PyQt app, > and that is fine. This is slightly off-topic, but the corresponding example using Tkinter would look something like: from Tkinter import * import sys b = Button(text = "Exit Program", command = sys.exit) b.pack() This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
Re: [PyKDE] Converting QStrings to Python strings
On Monday 06 May 2002 8:01 am, Janos Blazi wrote: > print int(edit.text()) > -- > > In this code I read a string from a QLineEdit and try to convert it to an > integer but this is not possible as the return value edit.text() is a > QString. (I also get a segmentation fault, who knows, why?) > > So how can I convert the QString to a Python string? I have naively used this in the past: print int(edit.text().latin1()) David This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] PyQt 3.1 qtsql build problem
I'm having difficulty building PyQt-3.1 for Qt-2.3.1 and later against Qt 2.3.2 for X11 and sip 3.1. I'm configuring using ./configure --prefix=/usr --with-qt-dir=/usr/lib/qt2 but attempting to build the bindings results in the following error when the qtsql directory is reached: Making all in qtsql make[2]: Entering directory `/usr/src/PyQt-3.1/qtsql' make[2]: *** No rule to make target `sipqtsqlProxyqtsql.h', needed by `sipqtsqlProxyqtsql.moc'. Stop. make[2]: Leaving directory `/usr/src/PyQt-3.1/qtsql' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/src/PyQt-3.1' make: *** [all] Error 2 Have I missed something obvious? -- David Boddie This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] PyQt and Qt3 in WIndows, how?
Hi, How can I get a working version of PyQt for use with qt3? The binaries in thekompany requires qt223, the source files don't compile (link error) and the pre versions don't have a Makefile for Windows (MS C++). Any idea? Thanks in advanced, David -- David Garcia TSS-Transport Simulation Systems Email: [EMAIL PROTECTED] Web: http://www.tss-bcn.com Telf: +34 93 229 62 25 Fax: +34 93 229 62 26 ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] PyQt-3.0pre6 compilation error in W2000
Hi, While compiling PyQt on a Windows 2000 computer I get the following link error (compiling in qt folder): sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QDateTimeEditBase::qt_property(int,int,class QVariant *)" (?qt_property@QDateTimeEditBase@@UAE_NHHPAVQVariant@@@Z) sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QDateTimeEditBase::qt_emit(int,struct QUObject *)" (?qt_emit@QDateTimeEditBase@@UAE_NHPAUQUObject@@@Z) sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QDateTimeEditBase::qt_invoke(int,struct QUObject *)" (?qt_invoke@QDateTimeEditBase@@UAE_NHPAUQUObject@@@Z) sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QDateTimeEditBase::qt_cast(char const *)" (?qt_cast@QDateTimeEditBase@@UAEPAXPBD@Z) sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall QDateTimeEditBase::className(void)const " (?className@QDateTimeEditBase@@UBEPBDXZ) sipqtQDateTimeEditBase.obj : error LNK2001: unresolved external symbol "public: static class QMetaObject * __cdecl QDateTimeEditBase::staticMetaObject(void)" (?staticMetaObject@QDateTimeEditBase@@SAPAVQMetaObject@@XZ) libqtc.pyd : fatal error LNK1120: 6 unresolved externals I have modified the Makefile.win32-msvc to include the defines: -DQT_DLL -DQT_THREAD_SUPPORT I'm linking it using python 2.1 and QT 3.0 final. Any idea? Thanks, David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
RE: [PyKDE] deleting the result of sipMapCppToSelf
Thanks for the answers Jim. I was playing a little bit with virtual functions in C++ when I found a curious memory leak (the origin of my question). My code is something like this: class AKLeft : public AKBase {...}; ... AKLeft * nope = new AKLeft(); ... obj = sipMapCppToSelf( nope, sipClass_AKBase ); rslt = PyObject_CallFunction( pcall, "(O)", obj ); Py_XDECREF( rslt ); Py_XDECREF( obj ); ... Rational Purify doesn't found any leak. Then if I add this code: obj = sipMapCppToSelf( nope, sipClass_AKLeft ); rslt = PyObject_CallFunction( pcall, "(O)", obj ); Py_XDECREF( rslt ); Py_XDECREF( obj ); It leaks memory on function sipNew_AKLeft, in the call to sipCreateThis. Note that I'm using two times the same object nope. Using a new object for the second sipMapCppToSelf works fine (no leaks). Using in both cases the same class in the sipMapCppToSelf call (either sipClass_AKBase or sipClass_AKLeft) produces not leaks too. Well, I suppose that is not important but is quite curious :) Best regards, David -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]En nombre de Jim Bublitz Enviado el: miercoles, 31 de octubre de 2001 17:32 Para: [EMAIL PROTECTED] Asunto: [PyKDE] deleting the result of sipMapCppToSelf On 31-Oct-01 David Garcia wrote: > I'm using sipMapCppToSelf to convert a C++ object to a > PyObject that will be a parameter in a PyObject_CallFunction > call. My question is, what I should do with the returned > PyObject when is no longer needed? Delete it? How? PyObject *obj; // Delete it Py_DECREF (obj); (or Py_XDECREF if obj might be NULL) See the "Python/C API Reference Manual" Py_DECREF is in section 3 Jim ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] deleting the result of sipMapCppToSelf
Hi, I'm using sipMapCppToSelf to convert a C++ object to a PyObject that will be a parameter in a PyObject_CallFunction call. My question is, what I should do with the returned PyObject when is no longer needed? Delete it? How? Thanks, David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] PyKDE or DCOP?
Hi I'm a newbie to KDE development - well, I haven't started yet! I am looking for a way to write a plugin for Konqueror, but as I am ignorant of C++, I'd like to start using Python or another simple language. My questions: is PyKDE suitable for scripting Konqueror? could I script Konqueror using DCOP instead? has anyone written a tutorial or some example programs using these techniques? (NB I know about the Python and Qt tutorial) best wishes -- Dave H-J ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] PyQt not compiling
I couldn't find a more appropriate place for this question. When I try to compile PyQt, I get this message: PyQt-2.4 > make make all-recursive make[1]: Entering directory `/home/rick/PyQt-2.4' Making all in qt make[2]: Entering directory `/home/rick/PyQt-2.4/qt' c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/python2.1 -I/usr/local/include/sip -I/usr/lib/qt2/include -I/usr/X11R6/include -fno-exceptions -O2 -c -o sip_helper.o `test -f sip_helper.cpp || echo './'`sip_helper.cpp In file included from /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../../../include/g++-3/iostream.h:31, from sip_helper.cpp:33: /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../../../include/g++-3/streambuf.h: In method `struct streampos streambuf::pubseekoff(long long int, ios::seek_dir, int = 3)': /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../../../include/g++-3/streambuf.h:362: conversion from `__off64_t' to non-scalar type `streampos' requested /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../../../include/g++-3/streambuf.h: In method `struct streampos streambuf::pubseekpos(_G_fpos64_t, int = 3)': /usr/lib/gcc-lib/i586-mandrake-linux/2.95.3/../../../../include/g++-3/streambuf.h:364: `struct streampos' used where a `long long int' was expected make[2]: *** [sip_helper.o] Error 1 make[2]: Leaving directory `/home/rick/PyQt-2.4/qt' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/rick/PyQt-2.4' make: *** [all-redirect] Error 2 I don't get this message with any other Qt programs I compile. Any ideas? Dave Blair ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
RE: [PyKDE] subclassing in pyqt
> On Fri, 22 Dec 2000, David Berner wrote: > > > i found a problem while subclassing pyqt-classes in python. > > > > e.g. > > > > >>> class Mylistview(QListView): > > >>> (...) > > >>> > > >>> class Mylistitem(QListViewItem): > > >>> def __init__(self, parent, name, myvar): > > >>> apply(QListViewItem.__init__,(self,parent,name) > > >>> self.MyVar = myvar > > >>> (...) > > >>> > > >>> a = Mylistview(parent) > > >>> Mylistitem(a, "first item", 5) > > > > the problem is, when i call a method of Mylistview which returns an item > > like: > > > > >>> x = a.selectedItem() > > > > since type(x) is not Mylistitem but QListViewItem, i can not > access MyVar: > > > > >>> print x.MyVar > > >>> (...) AttributeError: MyVar > > > > AFAIK there are no type-conversions in python (in C a simple > cast would do), > > so i see no way to solve this. > > > > all comments are welcome, > > David > > On Saturday, December 23 Boudewijn Rempt wrote: > This problem has been bugging me for some time, and I even have a set > of standard tests to determine whether a current version of PyQt works > or not - in the past there has been a version where it was impossible > to get at the subclass. > > However, with current versions this is not a problem. The issue > is caused by the fact that a Python subclass of a Qt class when > instatiated creates two objects: a Python object and a Qt C++ > object. > > All you have to do is to keep a reference in Python to your subclass: if > you let the Python reference to the object go out of scope, you lose your > Python class. Qt still keeps a reference to the Qt object, i.e. to the > QListViewItem, so that's what you'll get if you access it. Try the > attached two scripts and see the essential difference in output: > > boud@calcifer:~/src/python/prj/test/inherit > python inherit.py > <__main__.myListViewItem instance at 0x8242e3c> > <__main__.myListViewItem instance at 0x8242e3c> > slotHook > > boud@calcifer:~/src/python/prj/test/inherit > python inherit4.py > > Traceback (most recent call last): > File "inherit4.py", line 39, in slotOpenFile > item.slotHook() > AttributeError: slotHook > > Boudewijn Rempt Yep, this was exactly the problem. I just didn't know that. you helped me a lot, thanks. David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] subclassing in pyqt
i found a problem while subclassing pyqt-classes in python. e.g. >>> class Mylistview(QListView): >>> (...) >>> >>> class Mylistitem(QListViewItem): >>> def __init__(self, parent, name, myvar): >>> apply(QListViewItem.__init__,(self,parent,name) >>> self.MyVar = myvar >>> (...) >>> >>> a = Mylistview(parent) >>> Mylistitem(a, "first item", 5) the problem is, when i call a method of Mylistview which returns an item like: >>> x = a.selectedItem() since type(x) is not Mylistitem but QListViewItem, i can not access MyVar: >>> print x.MyVar >>> (...) AttributeError: MyVar AFAIK there are no type-conversions in python (in C a simple cast would do), so i see no way to solve this. all comments are welcome, David ___ PyKDE mailing list[EMAIL PROTECTED] http://mats.gmd.de/mailman/listinfo/pykde
[PyKDE] Problem with both parent() method and QListViewItem
>Time for a progress report I think... >I hope to release v0.11pre1 in the "next few days" - within a week >anyway (depends on how I get on painting the music room goes, and if I >can shake this cold). This will not support Qt 2. The purpose of this >release is for people to check that I haven't broken anything as far as >Qt 1 is concerned - and to include fixes for all known problems (ie. the >one described above). >v0.11pre2 will follow a "few days" afterwards with Qt 2 support. Sounds good to me! I'll assume the problems I mentioned will be fixed, and I'll just get back to working on my own list of application bugs and ToDo items while I wait. Thanks for the update... Dave Morrill
[PyKDE] Problem with both parent() method and QListViewItem
>I've started coding again today - slightly delayed by the unavailability>of public nameservers (www.valdyas.org is no longer reachable) - and I've>been trying to get around the problem. One solution would be to use>a dictionary mapping the standard objects and the extended objects, but>that's a lot of work, especially since I seem to remember that subclassing>widgets used to work in earlier versions. Yes, I agree. I thought about doing a work-around (and have for the parent problem), but I've hesitated for the QListViewItem problem, because, as you said, it used to work fine. I therefore concluded that the problem was a bug and should probably be fixed rather than worked around. If no fix is forthcoming, I'll probably go with the dictionary approach. >I guess the solution must be somewhere in siplib.ccp/*sipConvertToCpp,>judging from the comments, but I can't understand what's happening>there... I was hoping I wasn't going to have to look into that stuff myself... Dave Morrill
[PyKDE] Problem with both parent() method and QListViewItem
Hello all: I've been writing a Python program using PyKDE for the last month or so (and luvin' every minute of it...thanks Phil). I was just wrapping up some loose ends prior to releasing it to the world, when I decided to upgrade one of my other systems to Linux Mandrake 7.0 (and download Phil's latest PyQt and PyKDE RPMS) and try it out there. Guess what? It doesn't work. After slogging through the problem for a few hours, I have narrowed it down to the following details: - the foo.parent() method doesn't return the expected object in some cases (e.g. if 'foo' is a QHBoxLayout instance). - if I subclass QListViewItem and add an instance to a (subclass of) QListView, I get a QListViewItem back instead of my subclass when an event (like 'select') happens. - the versions of PyQt, PyKDE, and Qt (from the Mandrake 7.0 distro) were all newer than the versions on my development system (running Mandrake 6.1, I think). I tried uninstalling the Qt, PyQt, PyKDE RPMS and installing the versions from my working system, but it didn't make any difference (?!?). I then had the bright idea of looking for a PyKDE mailing list, and was pleasantly surprised to find a ref to one on Phil's web site. I was even more excited to find that both problems I had run into had already been reported by Gey-Hong Gweon and Boudewijn Rempt in the last week or so. Unfortunately, there has been no reported fix yet :-( UnlikeBoudewijn, I'm pretty much dead in the water as far as releasing my code (I've already got my home LAN installed, and I'm not moving any time soon :-). If anyone has any ideas, I'd be very glad to hear them. Thanks, Dave Morrill
[PyKDE] type for SIGNAL("textChanged(?)")
Hello, I am wondering what type I need for the textChanged signal of QLineEdit (or KLined). I have tried all from ['String', 'string', 'const char', 'const char*'], none working. Qt doc says it's 'const char*', but this looks certainly un-python-ish. I get a RuntimeError stating 'wrong types for slot'. That's strange, because my slot function can handle strings. Thanks! --david