# The default button/ text to be shown will be Sphere
self.geo_btn = QtGui.QPushButton('Sphere')
self.cmd_btn = QtGui.QPushButton('Duplicate')
self.scale_x = QtGui.QCheckBox('Scale')
# If self.scale_x is checked, min_x and max_x will be used
# Else, it will be ignored
self.min_x = QtGui.QLineEdit('1.0')
self.max_x = QtGui.QLineEdit('1.0')
def which_geo(self):
# Default text is Sphere
# Switch to Cube if button is hit, and vice verse
if self.geo_btn.text() == 'Sphere':
self.geo_btn.setText('Cube')
else:
self.geo_btn.setText('Sphere')
def which_cmd(self):
if self.cmd_btn.text() == 'Duplicate':
self.cmd_btn.setText('Instance') else:
self.cmd_btn.setText('Duplicate')
def create_node(self):
# How do I write my function here?
Suppose if the push buttons are 'Cube' and 'Duplicate', and I checked scale_x withthe min value being 1.0while max value is 2.0, how should I write in `create_node()`?Should I store such variables as a dictionary or some sort so that it will be easier for me to call and usethe values?I am not sure what is the best way for me to call such values..FYI, I have quite some widgets in my ui in which I need them for my new node creations
TYPE_CUBE = "Cube"
ACTION_DUP = "Duplicate"
def which_geo(self):
if self.geo_btn.text() == TYPE_CUBE:
...
def which _cmd(self):
if self.cmd_btn.text() == ACTION_DUP:
...
TYPE_SPHERE = "Sphere"
TYPE_CUBE = "Cube"
ACTION_DUP = "Duplicate"
ACTION_INST = "Instance"
def sphere_duplicate(*args, **kwargs):
#...
action_map = {
TYPE_SPHERE: {
ACTION_DUP: sphere_duplicate,
ACTION_INST: sphere_instance,
},
TYPE_CUBE: {
ACTION_DUP: cube_duplicate,
ACTION_INST: cube_instance,
},
}
class ObjectActioner(object):
NAME=""
def callByName(self, name, *args, **kwargs):
name = name.lower()
fn = getattr(self, name)
return fn(*args, **kwargs)
def duplicate(self, *args, **kwargs):
raise NotImplementedError()
def instance(self, *args, **kwargs):
raise NotImplementedError()
class Sphere(ObjectActioner):
NAME = "Sphere"
def duplicate(self, *args, **kwargs):
#...
def instance(self, *args, **kwargs):
#...
class Cube(ObjectActioner):
NAME = "Cube"
#...
object_map = {
Sphere.NAME: Sphere,
Cube.NAME: Cube,
}
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/cf106490-d8d7-41c2-82fd-a8312e36cbb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# UI file
class UIManager(QtGui.QDialog):
def __init__(self, parent=None):
#QtGui.QDialog.__init__(self, parent)
super(UIManager, self).__init__(parent)
self.tool_title = 'UI MANAGER'
self.setWindowTitle(self.tool_title)
self.setModal(False)
self.init_ui()
self.connect_signals()
self.setFixedSize(QtCore.QSize(450, 1000))
def button_signal_action(self):
...
...
# More and coming functions for the signals or any other functions
...
...
def main():
dialog = UIManager()
dialog.show()
return dialogAt times, I will create a script called utils file if there are functions that are either used in the UI file/ shared across with other scripts foreasy maintenance1. In such cases, should the signals functions and the ui initialization be separated into 2 different files?
2. If there are several classes within a script file in which it can make debugging un-manageable, while I think it will be better to break up these classesinto separate files, is it wise to do so? If so, what are some of the procedures to take note of?
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1794b37a-6440-40db-b744-853d576c778b%40googlegroups.com.