[Tutor] Self and class functions

Matthew Ngaha chigga101 at gmail.com
Sun Jun 30 12:42:34 CEST 2013


On Sun, Jun 30, 2013 at 5:10 AM, Phil <phil_lor at bigpond.com> wrote:

> I have attempted to create an instance of the DrawTest class although I had
> not tried DrawTest(parent) and in this case the error message is once again:
>
> Traceback (most recent call last):
>   File "/home/phil/Python/Qt_draw_sub/draw_test.py", line 52, in <module>
>     draw = DrawTest(parent)
> NameError: name 'parent' is not defined
>

parent is not a keyword so it needs to be defined in the correct scope
otherwise it will be undefined

> See above, "parent not defined". What should the defined parameter be?
> That's really what I was asking.
>

honestly i agree with Dave that you should read on classes in Python.
Your issue is more a Python one than Qt. Can you tell me who the
parent is? A big issue is you are trying to define and pass in a
parameter without knowing why. It should be us asking "What should the
defined parameter be?." and not you. The default argument is None, so
why not try the same code without the parent argument and see what
happens.


More information about the Tutor mailing list