[PyKDE] a few issues
Gerard Vermeulen
gerard.vermeulen at grenoble.cnrs.fr
Fri Jul 29 06:16:39 BST 2005
(1) (public) member data of class Foo does not show up in dir(Foo).
This trips up tools like PyChecker and the standard library module
inspect.py
(2) documentation bug: this concerns virtual member functions which
have different C++ signatures in the inheritance tree of a class.
Since I have reinvented something along the lines of the following
hopefully self-explanatory example, I think it is good to document it:
#!/usr/bin/env python
import sys
from qt import *
class ScrollView(QScrollView):
def __init__(self):
QScrollView.__init__(self)
self.resize(200, 200)
self.resizeContents(10000, 10000)
self.enableClipper(True)
self.viewport().setBackgroundMode(QWidget.NoBackground)
self.browser = QTextBrowser(self)
self.browser.setText("""
Since the virtual C++ member function drawContents() is
overloaded in the inheritance tree of QScrollView, it may
be called as:
1. QFrame.drawContents(painter)
2. QScrollView.drawContents(painter, cx, cy, cw, ch)
Therefore, the Python reimplementation of drawContents()
must be able to handle 2 and 6 arguments.
""")
self.addChild(self.browser, 100, 100)
self.browser.resize(500, 300)
self.browser.show()
# __init__()
# Since the virtual C++ member function drawContents() is overloaded
# in the inheritance tree of QScrollView, it may be called as:
# 1. QFrame.drawContents(painter)
# 2. QScrollView.drawContents(painter, cx, cy, cw, ch)
# Therefore, the Python reimplementation of drawContents() must be
# able to handle 2 and 6 arguments.
def drawContents(self, *args):
if len(args) == 5:
painter, cx, cy, cw, ch = args
painter.fillRect(cx, cy, cw, ch, QBrush(QColor(40, 80, 0)))
self.browser.repaint()
# drawContents()
def main():
app = QApplication(sys.argv)
demo = ScrollView()
app.setMainWidget(demo)
demo.show()
app.exec_loop()
# main()
if __name__ == '__main__':
main()
# Local Variables: ***
# mode: python ***
# End: ***
Feel free to add this to the PyQt examples.
(3) If I feed SIP a class with a protected nested class containing public
data members, the code which tries to access the data members of the
protected nested class does not compile (not urgent, but I prefer to
see SIP complain instead of the compiler).
Gerard
More information about the PyQt
mailing list