Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
On Sunday 03 November 2002 12:13 pm, Phil Thompson wrote:
 On Tuesday 29 October 2002 12:46 am, Kaleb Pederson wrote:
  Disconnect doesn't seem to work as expected.
 
  snip
 
  which are all very similar to the documentation examples.  SIP can't seem
  to tell which method really should be called, and None and 0 aren't
  accepted as valid wild cards so I can't really give it the parameters
  that I need.

 It just isn't supported. I've updated the TODO list and the documentation.

Thanks.  Although it isn't usually necessary, it will be nice to have.  There 
is a bug in PyQt with respect to connections being removed when the 
associated object has been deleted. But I'll try to post some example code 
within the week.

Basically, if I create a parentless object and connect signals to it.  Upon 
deletion of the object, any signals that would thereafter have gone to it 
result in a sip runtime error saying the C++ object has been deleted.

--Kaleb

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



[PyKDE] QListBoxItem

2002-11-04 Thread Rune Hansen

I'm pondering over how to set the text of a single QListBoxItem (not
every item) to bold or to a colour. Can anyone help me?

python2.2.1, pyqt.3.3x

regards

/rune


___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] QListBoxItem

2002-11-04 Thread Peter Osborne
Yup,

I've done this.

You need to reimplement the class, redifining the paintCell method. Something 
like this will atleast get you started:

class myListViewItem(QListViewItem):

def __init__(self, qlistview, parent=None):
QListViewItem.__init__(self, qlistview, None)

def setFont(self,family=Arial,size=12,bold=0):
self.font = QFont(family, size)
self.font.setBold(bold)

def paintCell(self,qpainter,cg,col,width,align):
qpainter.setFont()

QListViewItem.paintCell(self,qpainter,self.pal.active(),col,width,align)

-Pete

On November 4, 2002 10:29 am, Rune Hansen wrote:
 I'm pondering over how to set the text of a single QListBoxItem (not
 every item) to bold or to a colour. Can anyone help me?

 python2.2.1, pyqt.3.3x

 regards

 /rune


 ___
 PyKDE mailing list[EMAIL PROTECTED]
 http://mats.gmd.de/mailman/listinfo/pykde

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] Qt.Py updated

2002-11-04 Thread Jonathan Gardner
On Monday 04 November 2002 12:41 am, Marc Schmitt wrote:
 On Montag, 4. November 2002 09:58, J�r�me Martin wrote:
  I have build sip/PyQt and PyKDE for Mandrake 8.2. I can send you tthe rpm
  in order to update your download page. I have also planed to build for
  Mdk9.0

 Hi J�r�me,

 thanks for your request. The best way to do it is to place the packages
 into

 ftp://upload.sourceforge.net/incoming .

 Then mail to

 Jonathan Gardner [EMAIL PROTECTED]

 for him to grab them an move them to sourceforge/dl. After that, I can
 extract the links from sf's download-dir and place them on the homepage. So
 as soon as the Mandrake packages get visible on sf, I'll link to them.


Actually, this doesn't work too well in practice. The best way is to email me, 
then we can set something up. If we decide on a time (GMT based, of course) 
to upload, then I can be ready and you won't have to upload a second time.

Another option is to give you (the uploader) permissions to edit file 
releases.

-- 
Jonathan Gardner
[EMAIL PROTECTED]

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



[PyKDE] Python list handling for QRect, QPoint, and QSize

2002-11-04 Thread Hans-Peter Jansen
Hi Phil,

since I catched the flu this weekend, I think of contributing something
useful to PyQt. Namely the IMHO missing handling of python lists, where
QRect, QPoint, and QSize objects are expected. (QColor?)

On my first cursory look, there seem to be to ways, but I don't know
their implications:

1) implement __len__(), __getitem__() like in qstringlist.sip
2) %MappedType QxyzQInt, like in qvaluelist.sip

Q1) Why is __setitem__ missing from 1
Q2) Does method 2 provide transparent conversion from and to the correct
types, whereever they're used? (e.g. QObject)

TIA,
Hans-Peter

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] Python list handling for QRect, QPoint, and QSize

2002-11-04 Thread Phil Thompson
On Monday 04 November 2002 6:36 pm, Hans-Peter Jansen wrote:
 Hi Phil,

 since I catched the flu this weekend, I think of contributing something
 useful to PyQt. Namely the IMHO missing handling of python lists, where
 QRect, QPoint, and QSize objects are expected. (QColor?)

I'm not sure I understand. Are you saying that you want to pass a list of 
(say) x and y coordinates wherever a QPoint was expected? (Wouldn't a tuple 
be better?)

Or are you saying that you want to make QPoint behave a bit like a list?

 On my first cursory look, there seem to be to ways, but I don't know
 their implications:

 1) implement __len__(), __getitem__() like in qstringlist.sip
 2) %MappedType QxyzQInt, like in qvaluelist.sip

 Q1) Why is __setitem__ missing from 1

Because I'm lazy and nobody has complained.

 Q2) Does method 2 provide transparent conversion from and to the correct
 types, whereever they're used? (e.g. QObject)

Yes.

Phil

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] Python list handling for QRect, QPoint, and QSize

2002-11-04 Thread Phil Thompson
On Monday 04 November 2002 7:38 pm, Hans-Peter Jansen wrote:
 On Monday 04 November 2002 19:57, Phil Thompson wrote:
  On Monday 04 November 2002 6:36 pm, Hans-Peter Jansen wrote:
   Hi Phil,
  
   since I catched the flu this weekend, I think of contributing something
   useful to PyQt. Namely the IMHO missing handling of python lists, where
   QRect, QPoint, and QSize objects are expected. (QColor?)
 
  I'm not sure I understand. Are you saying that you want to pass a list of
  (say) x and y coordinates wherever a QPoint was expected? (Wouldn't a
  tuple be better?)

 Exactly. Why not support both.

 Imagine a typical situation: restore position and size of an app:
 (tuple or list doesn't matter much here)

 wh = self.cfg.mainScreenSize
 if wh:
 self.resize(wh[0], wh[1])
 xy = self.cfg.mainScreenLocation
 if xy:
 self.move(xy[0], xy[1])

 would then read:

 if self.cfg.mainScreenSize:
 self.resize(self.cfg.mainScreenSize)
 if self.cfg.mainScreenLocation:
 self.move(self.cfg.mainScreenLocation)

 Do you like this idea?

Yes and no. See item 18 of the TODO file in the sip tarball, which I haven't 
come to a conclusion about yet.

At the moment the only way to implement anything like this is to add more 
resize(), move() (etc, etc) overloads that use handwritten %MemberCode. Not 
something I'd advise doing.

Phil

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
 Thanks.  Although it isn't usually necessary, it will be nice to have. 
 There is a bug in PyQt with respect to connections being removed when the
 associated object has been deleted. But I'll try to post some example code
 within the week.

 Basically, if I create a parentless object and connect signals to it.  Upon
 deletion of the object, any signals that would thereafter have gone to it
 result in a sip runtime error saying the C++ object has been deleted.

Okay, I modified my previous example to show what is happening.  I highly 
doubt this is my fault, but if it is, I'm sure you'll correct me ;)

I ran it through gdb to see where it was dieing... the last few items in the 
backtrace gave me the following:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 12956)]
0x4141e740 in lazyMethods_QObject () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
(gdb) bt
#0  0x4141e740 in lazyMethods_QObject () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
#1  0x0202 in ?? ()
#2  0x4001f05c in parsePass2 () from 
/usr/lib/python2.2/site-packages/libsip.so
#3  0x4001e89f in sipParseArgs () from 
/usr/lib/python2.2/site-packages/libsip.so
#4  0x413ace9f in sipDo_QWidget_close () from 
/usr/lib/python2.2/site-packages/libqtcmodule.so
#5  0x080d86fd in PyCFunction_Call ()
#6  0x080b62be in PyObject_Call ()
#7  0x0807f350 in PyEval_CallObjectWithKeywords ()
...

Note. If I comment out line 64 then the program works fine and won't segfault.

To reproduce what I did, leave line 64 in and then launch the program.  Hit 
Launch as many times as you like.  Now hit Fire.  All the child 
(although parentless) objects get closed/deleted.  Now hit Fire a second 
time.  Boom!

Another way to reproduce it is to create some child objects by hitting launch.  
Now close the child objects so they get deleted appropriately.  Once all 
child objects are closed, hit Fire.

Well, please let me know what you find.  Even if there is just a work around, 
it would be nice to know.

--Kaleb

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] BUG - disconnect

2002-11-04 Thread Kaleb Pederson
On Monday 04 November 2002 05:59 am, Kaleb Pederson wrote:
 Thanks.  Although it isn't usually necessary, it will be nice to have. 
 There is a bug in PyQt with respect to connections being removed when the
 associated object has been deleted. But I'll try to post some example code
 within the week.

 Basically, if I create a parentless object and connect signals to it.  Upon
 deletion of the object, any signals that would thereafter have gone to it
 result in a sip runtime error saying the C++ object has been deleted.

I just posted a message on the list and forgot to include an attachment.  Here 
it is.

--Kaleb


#!/usr/bin/python

from qt import *
import sys

class MyDialog(QDialog):
	
	def __init__(self,id = 0,parent = None,name = MyDialog,modal=0,fl=0):
		QDialog.__init__(self,parent,name,modal,fl)

		self.id = id
		self.count = 0
		self.keep_ref = {}

		self.setCaption(Testing + str(id))

		main_layout = QVBoxLayout(self,11,6,main_layout)
		
		self.button1 = QPushButton(self,button1)
		self.button1.setText(u'Launch')
		
		main_layout.addWidget(self.button1)
		self.connect(self.button1,SIGNAL(clicked()),self.launch)

		self.button2 = QPushButton(self,button2)
		self.button2.setText(u'Fire')

		main_layout.addWidget(self.button2)
		self.connect(self.button2,SIGNAL(clicked()),self.fire)
		
		self.button3 = QPushButton(self,button3)
		self.button3.setText(u'Quit')

		main_layout.addWidget(self.button3)
		self.connect(self.button3,SIGNAL(clicked()),self,SLOT(accept()))
	
	def caught(self):
		print dlg %i caught 'fire()' signal % self.id
	
	def fire(self):
		self.emit(PYSIGNAL(fire()), () )
	
	def closeEvent(self,event):
		print dlg %i is closing % self.id
		self.emit(PYSIGNAL(closing(id)),(self.id,))
		event.accept()
	
	def accept(self):
		self.emit(PYSIGNAL(closing(id)),(self.id,))
		QDialog.accept(self)
	
	def cleanup(self,id):
		print cleaning up id %i % id
		if id in self.keep_ref.keys():
			del self.keep_ref[id]
		print references remaining:,self.keep_ref
	
	def launch(self):
		# keep a reference so it doesn't get destroyed
		dlg = MyDialog(self.count) # no parent
		self.connect(self,PYSIGNAL(fire()),dlg.caught)
		
		# it works fine unless this signal is connected
		self.connect(self,PYSIGNAL(fire()),dlg, SLOT(close()))
		
		self.connect(dlg,PYSIGNAL(closing(id)),self.cleanup)
		self.keep_ref[self.count] = dlg
		self.count += 1
		dlg.show()

qapp = QApplication(sys.argv)
mw = MyDialog()
qapp.setMainWidget(mw)
mw.show()
sys.exit(mw.exec_loop())