On Tue, 18 Oct 2016, 5:51 AM likage <dissidia....@gmail.com> wrote:
> Hi Justin, thanks for the feedback.
> So I tried doing the following..
> ### UI File, manager_ui.py ###
> import functools
> import manager_main
> class manager_ui(QtGui.QDialog):
> def __init__(self, parent=None):
> QtGui.QDialog.__init__(self, parent)
> self.setWindowTitle('UI Manager')
> # Build the GUI
> self.resize(QtCore.QSize(600, 350))
> def init_ui(self):
> self.color_table = QtGui.QTableWidget()
> self.color_table.setHorizontalHeaderLabels(['Geos in Scene',
> self.set_color_btn = QPushButton()
> def connect_signals(self):
> manager_main.reset_color, self.color_table))
> # Function is to be called in the main file
> def reset_color(self):
> for row in xrange(self.variant_table.rowCount()):
> self.color_table.cellWidget(row, 1).setCurrentIndex(0)
> def populate_data(self):
> self.color_combobox = QtGui.QComboBox()
> self.color_table.setCellWidget(index, 1, self.color_combobox)
> And this is my main file:
> ### Main File, manager_main.py ###
> def reset_color(table):
> for row in xrange(table.rowCount()):
> table.cellWidget(row, 1).setCurrentIndex(0)
> While it seems to work, can I check with you if this is the correct
> approach to go about?
Well it's actually backwards from what I was thinking. But that might just
be the names of your modules throwing me off because I don't really know
what the full contents of manager_main will be. If you expect manager_main
to also import manager_ui then you have circular dependencies and that
would be undesirable.
My thought was that your UI would not connect up the external signals,
because it shouldn't know about the outside world that will consume it. It
can wire up its own internal signals though, to its own slots. I was
thinking manager_main would hook up the signals to its own slots when it
creates an instance of the UI.
What you can do is hide the details of your UI class by not having outside
users access the composed widgets, and just exposing signals and function
that you want users to call. An example of forwarding a signal can be
resetRequested = QtCore.Signal()
def __init__(...) :
I know in this case your main will need to access the table widgets, and
that is OK since you specifically wanted a small amount of coupling and
just a separation of the UI and business logic.
> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> 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 view this discussion on the web visit
For more options, visit https://groups.google.com/d/optout.