Hey all,
I'm running into an issue with my conversion into PyQt when I work with
dynamically loaded classes. I'm using a QListView to display a list of
modules, and when the user clicks on them the content pane of my layout
should update to use the selected module's UI. Here's the code that runs
on currentChanged() for the QListView:
for child in self.contentPanel.children():
child.deleteLater()
holder = self.settingsListModel.getHolder(current)
modClass = getattr(holder.module, holder.className)
modClass.UI(self.contentPanel)
holder is a simple class for the model being managed--module is a
reference to the module, and className is the class name., and
self.contentPanel is a QFrame.
Here's the relevant code from a module being called:
class NameSettings(settings.Settings):
@staticmethod
def UI(parent):
print "Loading Naming GUI"
layout = QtGui.QVBoxLayout()
topLabel = QtGui.QLabel("Naming")
layout.addWidget(topLabel)
parent.setLayout(layout)
def __init__(self):
super(NameSettings, self).__init__()
The switching itself works fine. The correct print statement runs when
I change my selection, so UI() is being called from the correct modules.
What happens when it runs is this: Whichever module loads first loads
up it's UI beatifully. All other modules clear the content pane and
leave it blank. If I reselect the first module in the list, it's UI
loads right back up. I should note that right now all of my modules
have nearly identical code (the only thing that changes is the metadata
(Module Attributes) and the class names (along with the text I'm putting
in the QLabel/print statement). Also, if I switch the load order in the
system so that my modules are in a different order, it's still always
only the first one in the list that loads its UI, whichever module that
is; but each module loads its UI correctly when alone or first loaded.
This should be fairly straightforward, I would think. This methodology
worked perfectly in the Maya UI, so I'm hoping that it's just a nuance
of Qt that I'm missing.
Any ideas?
Thanks,
Joe
--
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/525266E2.1080906%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.