[PyKDE] QCanvasItem constructor

Boudewijn Rempt bsarempt at rempt.xs4all.nl
Sun Dec 3 12:25:51 GMT 2000


I have a feeling I've found a bug in the wrapping of QCanvasItem - it
doesn't recognize a subclassed QCanvas as a canvas:

  File "kurailviewer.py", line 41, in ?
    main()
  File "kurailviewer.py", line 28, in main
    canvas=kuraCanvas()
  File "kurailviewer.py", line 14, in __init__
    self.lines.append(kuraCanvasItem(self))
  File "kurailviewer.py", line 7, in __init__
    QCanvasItem.__init__(self, canvas)
  File "/usr/local/lib/python2.0/site-packages/qt.py", line 172, in
__init__
    libqtc.sipCallCtor(191,self,args)
TypeError: Invalid argument types to QCanvasItem() 


Is what you get when you run:

import sys, string

from qt import *

class kuraCanvasItem(QCanvasItem):
  def __init__(self, canvas):
    QCanvasItem.__init__(self, canvas)
 
class kuraCanvas(QCanvas): 

  def __init__(self, parent=None):
    QCanvas.__init__(self, parent)
    self.lines=[]
    self.lines.append(kuraCanvasItem(self))

class kuralCanvasView(QCanvasView): 
  """
  The view shows a part from the text
  """
  def __init__(self, canvas, parent):
    QCanvasView.__init__(self, canvas, parent)
    self.parent=parent
    self.canvas=canvas

def main():

  qapp=QApplication(sys.argv)
  canvas=kuraCanvas()
  toplevel=kuraCanvasView(canvas, parent=None)
  toplevel.setText(Config.app.getObject("lng_text", textnr=1))
  toplevel.show()
  qapp.connect(qapp, SIGNAL('lastWindowClosed()'), qapp, SLOT('quit()'))
  qapp.exec_loop()
  
if __name__=="__main__":
  if len(sys.argv)>1:
    if sys.argv[1]=='-p':
      import profile
      profile.run('main()')
  else:
    main()





More information about the PyQt mailing list