[PyKDE] Bug khtml.Node.parentNode() ?
Mateusz Korniak
mateusz at ant.gliwice.pl
Fri Apr 18 17:46:01 BST 2003
According to http://www.riverbankcomputing.co.uk/pykde/docs/none.html
C++ NULL is converted to None
but in example below khtml.Node.parentNode() returns Node when (IMHO) should
return None. Shortly after program crashes.
Problem is always reproducable on my machine. Just run click any item on html
page.
I'm I wrong or is it bug ?
2. I'm not sure if it is right place to post such bugs ?
Program code below and in attachment:
#! /usr/bin/python
import sys
from qt import QObject,SIGNAL,SLOT
from qt import
QApplication,qApp,QFont,QLineEdit,QLabel,QPushButton,QWidget,QVBox
from kdecore import KApplication,KURL
from kdeui import KMainWindow
from khtml import KHTMLPart
def print_parents(node):
while 1:
node = node.parentNode()
print "DEBUG: checking node parent: "+repr(node)
if not node:
return
print "DEBUG: checking node: "+repr(node.nodeType())
if node.nodeType() == node.DOCUMENT_NODE:
print "This is document node. pernetNode() should be null according to
http://developer.kde.org/documentation/library/3.0-api/classref/khtml/DOM__Node.html#ref17"
print "DEBUG node.nodeName(): ",str(node.nodeName().string())
class MainWindow(KMainWindow):
def __init__(self,name):
KMainWindow.__init__(self)
self.setCaption("KDE Tutorial in Python - p4")
vbox = QVBox(self)
self.location = QLineEdit(vbox)
self.location.setText("http://www.ant.gliwice.pl")
self.browser = KHTMLPart(vbox) # Need to be memeber
self.browser.openURL(KURL("http://www.ant.gliwice.pl"))
self.connect(self.location,SIGNAL("returnPressed()"),self.changeLocation)
self.connect(self.browser,SIGNAL("selectionChanged()"),self.selectionChanged)
self.setCentralWidget(vbox )
def changeLocation(self):
self.browser.openURL(KURL(self.location.text()))
def selectionChanged(self):
print "Changed"
node = self.browser.nodeUnderMouse()
print "DEBUG: changed to node: "+repr(node)
print_parents(node)
a = KApplication(sys.argv,"p4")
window = MainWindow("Tutorial - p4")
window.resize(800,600)
a.setMainWidget(window)
window.show()
a.exec_loop()
--
Mateusz Korniak
"Black holes are where God divided by zero." - Steven Wright
-------------- next part --------------
A non-text attachment was scrubbed...
Name: domnode-bug.py
Type: text/x-python
Size: 1666 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20030418/61fab231/domnode-bug.py
More information about the PyQt
mailing list