Generally I would say it is a questionable design if you have child classes
that make assumptions about the members of the parent. It means that your
child class can only be used with that specific parent class that will have
the expected attributes. If your child class needs to trigger behavior in
the parent, a better design would be to have your child class emit signals.
This should give you a cleaner separation between the two widgets. It then
becomes the responsibility of your parent window to connect to the signals
of interest, and perform the required actions as it is notified.


On Thu, Mar 5, 2015 at 10:27 PM Benjam901 <[email protected]> wrote:

> Hello again Marcus,
>
> I was wondering why intellisense does not pick up on the internal
> variables and buttons etc. do I need to add another handle?
>
> Cheers,
>
> Ben
>
> On Thursday, 5 March 2015 09:29:23 UTC+1, Marcus Ottosson wrote:
>
>> self.modelTree = self.uiMainWindow.uiModelTree # This is where I get the 
>> error
>>
>> self is referring to your instance of ModelWindow, but you store
>> uiMainWindow in the instance of MainWindowSetup.
>>
>> If you want to access that, you’ll need to pass a handle to it. It’s
>> typically done using a parent, but you aren’t including the parent in your
>> __init__ method.
>>
>> Try something like this.
>>
>> class MainWindowSetup(QtGui.QMainWindow):
>>     def __init__(self):
>>         QtGui.QMainWindow.__init__(self)
>>
>>         self.uiMainWindow = Ui_MainWindow()
>>         self.uiMainWindow.setupUi(self)
>>         self.uiModelWindow = ModelWindow(self)
>> class ModelWindow(QtGui.QTreeWidget):
>>     def __init__(self, parent):
>>         print "!! Initialised model window"
>>         QtGui.QTreeWidget.__init__(self, parent)
>>
>>         self.modelTree = parent.uiMainWindow.uiModelTree # This is where I 
>> get the error
>>
>> ​
>> ​
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/065722da-82df-4108-92d5-6c76844d0696%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/065722da-82df-4108-92d5-6c76844d0696%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1-jUn_1oWmzDFk8ZVPP0rCprXi2JJY15Gd9V2fkdj1iQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to