It's a little difficult to fully understand the context of the snippets you
provided, but let me see if I understand you correctly. You are saying that
you have a uiCode.py file which creates instances of your classes, and you
import those instances and use them directly in your mainCode.py? If so, I
would say that this design is not correct.
Your uiCode.py should only provide class definitions. Your mainCore.py
should import that module, and then create instances of those classes,
which is then owns and can use directly. You should not need to be
importing a global listWidget instance from your uiCode.py. I am not clear
on what the scope actually looks like in your uiCode module so I can't be
sure where that instance is created and where it is accessible.
You mainCode should be something along the lines of:
import uiCode
def main():
app = QtGui.QApplication(...) # if not maya
win = uiCode.ListWindow()
# .. bunch of setup you want to do with win
win.show()
app.exec_() # if not maya
You can see that in this example, the main code imports the various ui
element that it needs and creates instances that it now owns. You can
connect extra signals at this point.
Justin
On Thu, Dec 10, 2015 at 7:49 AM Padraig Ó Cuínn <
[email protected]> wrote:
> Hey there again...
>
> so I have this uiCode.py with a QListWidget
>
> listWidget = QtGui.QListWidget(container)
>
>
> also in uiCode.py my Signal Class
>
> class ListWindow(QtGui.QMainWindow):
>
>
> refreshClicked = Signal(list)
>
>
> also in uiCode.py this function
>
> def refresh():
> window.refreshClicked.emit(listWidget.item())
> button.clicked.connect(refresh)
>
> In my mainCode.py
>
> def refresh():
>
> listWidget.clear()
> items = pmc.selected()
> for item in items:
> newItem = QtGui.QListWidgetItem( item.nodeName())
> listWidget.addItem(newItem)
>
>
> print 'Print statement is Working...'
>
>
> _window.refreshClicked.connect(refresh)
>
> however, it says that listWidget is not referenced even tho it is imported
> with the uiCode.
>
> Question : How do i actually get my the QListWidget and its
> QListWidgetItems referenced into the mainCode.py properly.
>
> --
> 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/33a46e73-5745-45aa-b4e4-d1810e28d152%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/33a46e73-5745-45aa-b4e4-d1810e28d152%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/CAPGFgA1VCdqk4aw%3DS9VdajXg67fQJyL%2BWB9%3Dc5%2B4VNibhgM40g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.