[PyKDE] a few issues
Phil Thompson
phil at riverbankcomputing.co.uk
Mon Aug 8 18:50:27 BST 2005
On Friday 29 July 2005 6:16 am, Gerard Vermeulen wrote:
> (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
Works for me. Do you have an example .sip file in case I'm misunderstanding
what you mean?
> (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.
I don't see it as a documentation bug - it's a natural consequence of not
being able to overload Python functions. A Wiki entry would be useful.
> (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).
Added to the TODO list.
Phil
More information about the PyQt
mailing list