def insert_joints_UI(): WINDOW = 'InsertJoints' if pm.window(WINDOW, query=True, exists=True): pm.deleteUI(WINDOW) pm.window(WINDOW, title="Insert Joints", iconName='CS', widthHeight=(200, 70)) main_col = pm.columnLayout(adjustableColumn=True) pm.separator(height=5, style='none', parent=main_col) textip_col = pm.rowColumnLayout(numberOfColumns=2, parent=main_col, columnOffset=(1, "left", 5), columnSpacing=(2, 5)) pm.separator(height=5, style='none', parent=main_col) butn_col = pm.rowColumnLayout(numberOfColumns=3, parent=main_col, columnOffset=(2, "left", 65)) pm.text(label="number of joints", parent=textip_col) textip = pm.textField(text="", parent=textip_col) pm.text(label="", parent=butn_col) pm.button(label="Create", parent=butn_col, command=lambda x: call_fun(textip.getText())) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(200, 70)) return None
def ui() : global FFU_E_SETTINGS, FFU_E_WINDOW init() WINDOW_NAME = 'w_ff_utils_export' if( pm.window( WINDOW_NAME, q=True, exists=True ) ) : pm.deleteUI( WINDOW_NAME ) FFU_E_WINDOW = pm.window( WINDOW_NAME, title='Export to Fiction Factory', sizeable=True ) vl = pm.verticalLayout() hl = pm.horizontalLayout( parent=vl ) l1 = pm.frameLayout( parent=hl, label="Scene options" ) for setting in FFU_E_SETTINGS : uiobject = __create_uiobject_from_setting( setting ) l2 = pm.frameLayout( parent=hl, label="FFEXport options" ) for setting in FFU_E_FFEXPORT_SETTINGS : uiobject = __create_uiobject_from_setting( setting ) pm.button( label='Export!', parent=vl, command=lambda *args : ui_do_export() ) FFU_E_WINDOW.setHeight(600) FFU_E_WINDOW.setWidth(200) hl.redistribute( 2.5, 1 ) vl.redistribute( 5, 1 ) FFU_E_WINDOW.show()
def setVisibilityOnAllWindows(cls, vis ): windows = pm.lsUI(typ='window') for win in windows: try: pm.window( win, edit=True, visible=vis ) except: print( traceback.format_exc() )
def setVisibilityOnAllWindows(cls, vis): windows = pm.lsUI(typ='window') for win in windows: try: pm.window(win, edit=True, visible=vis) except: print(traceback.format_exc())
def manage_shape_ui(self): WINDOW = "add_control" chk_win = pm.window(WINDOW, query=True, exists=True) if chk_win: pm.deleteUI(WINDOW) pm.window(WINDOW, title="Manage_Shapes", iconName="MS") main_col = pm.columnLayout(parent=WINDOW, adjustableColumn=True) main_split_col = pm.rowColumnLayout(parent=main_col, numberOfColumns=2, columnOffset=(2, "left", 5)) cmd_col = pm.columnLayout(parent=main_split_col) pm.separator(parent=main_col, height=10) mel_cmd_col = pm.columnLayout(parent=cmd_col, columnOffset=("left", 10)) pm.text("\t\t\t\tShape Name", parent=mel_cmd_col) nm_txt = pm.textField(text="", parent=mel_cmd_col, width=300) pm.text("\t\t\t\tShape mel command", parent=mel_cmd_col) txt = pm.scrollField("", wordWrap=True, parent=mel_cmd_col, height=130, width=300) pm.separator(parent=main_col, height=10) add_btn_col = pm.columnLayout(parent=cmd_col, columnOffset=("left", 100)) pm.button("add", parent=add_btn_col, width=100, command=lambda x: self.add_ctr(cmd=txt.getText(), nm=nm_txt.getText())) list_col = pm.columnLayout(parent=main_split_col) pm.text("\t\tExisting Shapes", parent=list_col) self.shp_lst_bx = pm.textScrollList(parent=list_col, height=165, width=170) edit_btn_col = pm.rowColumnLayout(numberOfColumns=3, parent=list_col) pm.button("Delete", parent=edit_btn_col, width=82, command=lambda x: self.delete_selection()) pm.separator(parent=edit_btn_col, horizontal=False) pm.button("rename", parent=edit_btn_col, width=82, command=lambda x: self.rename_ui()) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(500, 220)) return None
def showHelp(self): helpWindow = pm.window('Attribute Setter Help', resizeToFitChildren=True) with helpWindow: helpCol = pm.columnLayout() with helpCol: helpText = pm.text( helpString ) helpWindow.show()
def __init__(self, parentRef, selection=False, multiplier=1.0): self.parentRef = parentRef self.buttons = [] self.window = pm.window(sizeable=False, title="Light Multiplier", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: ## Using Ui on the end of Widget names self.multiplierText = pm.text(label='Multiplier:', align='left') self.multiplierUi = pm.floatField(value=1.0) self.checkBoxUi = pm.checkBox( label='Affect Selected Lights Only') self.okUi = pm.button( label='Apply', parent=self.layout, command=lambda xc: self.parentRef.applyMultiplier( multiplier=self.multiplierUi.getValue(), selection=self.checkBoxUi.getValue(), ), width=300) pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def __init__(self, parentRef=None, mmmmToolsRef=None): self.mmmmTools = mmmmToolsRef self.parentRef = parentRef self.scriptFileRunner = MmmmScriptFileRunner( parentRef=self, mmmmToolsRef=self.mmmmTools) self.scriptFileRunner.findScripts() self.win = pm.window("Script File Runner") self.ddMenuEntires = [] with self.win: self.col = pm.columnLayout() with self.col: self.textPath = pm.text("Path to scripts:") self.textFieldPath = pm.textField( text=self.scriptFileRunner.searchPath, width=400, changeCommand=lambda x: self.onTextPathChangeCommand()) self.btnRefresh = pm.button("Refresh Scripts", command=lambda x: self.buildMenu()) self.text = pm.text("Script File To Run:") self.ddMenu = pm.optionMenu(changeCommand=self.onDdMenuChange) self.buildMenu() ## self.textFieldScript = pm.textField( width=500 ) self.btnRunScript = pm.button( "Run Script", command=lambda x: self.scriptFileRunner.runScript( self.chosenScript)) self.win.show()
def run(self): self.win = pm.window( title="Mmmm Baker Tool" ) with self.win: self.col = pm.columnLayout() with self.col: self.spacers = [] self.xnormalPathTextLabel = pm.text("Path and filename of xNormal executable:") self.xnormalPathTextField = pm.textField( width = 500, text="C:/Program Files/S.Orgaz/xNormal 3.19.2/x64/xNormal.exe" ) self.spacers.append( pm.text(" ") ) self.modelsPathTextLabel = pm.text("Path where models are:") self.modelsPathTextField = pm.textField( width = 500, text="C:/Users/Public/mmmmBaker" ) self.modelsPathTextLabel2 = pm.text( "(Warning, if changed, requires custom xnormal settings xml which points to new path.)" ) self.spacers.append( pm.text(" ") ) self.highSuffixTextLabel = pm.text( 'High Suffix, on models for xnormals "high" model files, no extension' ) self.highSuffixTextField = pm.textField( width = 500, text="_hi" ) self.spacers.append( pm.text(" ") ) #self.highSuffixTextLabel = pm.text( "Suffix on files: (not extension)" ) #self.cageSuffixTextField = pm.textField( width = 500, text="_cage" ) self.xmlFilesTextLabel = pm.text( "Xml files to bake, comma separated list:" ) self.xmlFilesTextLabel2 = pm.text( "(xnormal settings files, should be in the same folder as models)" ) self.xmlFilesTextField = pm.textField( width = 500, text="xnormal_settings_for_mmmmbaker_example.xml,xnormal_settings_for_mmmmbaker_example2.xml" ) self.goButton = pm.button( label="Go! (Bake selected models) )", command=lambda x: self.go() )
def initUi(self): win = self.win = pm.window("Mmmm Mel To Python Converter") with win: col = self.col = pm.columnLayout(adjustableColumn=True) with col: labelMel = self.labelMel = pm.text("Mel:") tf01 = self.tf01 = pm.scrollField(wordWrap=True) btnRunMel = self.btnRunMel = pm.button( "Run Mel", command=lambda x: pm.mel.eval(self.tf01.getText())) labelSpacer01 = self.labelSpacer01 = pm.text("\n") labelPython = self.labelPython = pm.text("Python:") tf02 = self.tf02 = pm.scrollField(editable=False, wordWrap=True) btnRunPython = self.btnRunMel = pm.button( "Run Python", command=lambda x: self.execPython(codeStr=self.tf02. getText())) labelSpacer02 = self.labelSpacer02 = pm.text("\n") btnConvert = self.btnConvert = pm.button( "Convert Mel To Python", command=lambda x: self.tf02.setText( self.convertFunc(self.tf01.getText()))) win.show()
def test_ui(self): test_win = "log" if pm.window(test_win, query=True, exists=True): pm.deleteUI(test_win) pm.window(test_win, title="Rearrange Deformers", iconName="ReArDf") log_col = pm.columnLayout(parent=test_win, adjustableColumn=True) self.log_txt = pm.scrollField('log_list', parent=log_col, height=235, width=150, wordWrap=True) #self.reord_lst.append(self.file_ord_list) pm.showWindow(test_win) pm.window(test_win, edit=True, widthHeight=(300, 260)) return None
def initUi(self): win = self.win = pm.window("Mmmm Mel To Python Converter") with win: col = self.col = pm.columnLayout(adjustableColumn=True) with col: labelMel = self.labelMel = pm.text("Mel:") tf01 = self.tf01 = pm.scrollField( wordWrap=True ) btnRunMel = self.btnRunMel = pm.button("Run Mel", command= lambda x: pm.mel.eval( self.tf01.getText() ) ) labelSpacer01 = self.labelSpacer01 = pm.text("\n") labelPython = self.labelPython = pm.text("Python:") tf02 = self.tf02 = pm.scrollField( editable=False, wordWrap=True ) btnRunPython = self.btnRunMel = pm.button("Run Python", command= lambda x: self.execPython( codeStr=self.tf02.getText() ) ) labelSpacer02 = self.labelSpacer02 = pm.text("\n") btnConvert = self.btnConvert = pm.button("Convert Mel To Python", command= lambda x: self.tf02.setText( self.convertFunc( self.tf01.getText() ) ) )
def __init__(self, parentRef): self.parentRef = parentRef self.buttons = [] self.window = pm.window( sizeable = False, title = "Selector", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: self.labFace = pm.text( label='A Useful Tool For Making Selections.', align='left',parent = self.layout ) self.labFace = pm.text( label='Currently this tool only selects non quad faces.', align='left',parent = self.layout ) self.labFace3 = pm.text( label='More features will be added to this tool in the future.', align='left',parent = self.layout ) self.labFace4Blank = pm.text( label=' ', align='left',parent = self.layout ) self.labFace4Blank = pm.text( label=' ', align='left',parent = self.layout ) btn__find_non_quad_faces = pm.button ( label = 'Find-Quad Face Faces',parent = self.layout, command = lambda xc: self.parentRef.highlightNonQuads(),width = 300 ) self.buttons.append( btn__find_non_quad_faces ) self.labTriResult = pm.text( label='Number of Triangles Found:', align='left', parent = self.layout ) self.triFace = pm.intField(parent = self.layout, width = 40,value=0) self.labngonResult = pm.text( label='Number of n-Gons Found:', align='left', parent = self.layout ) self.ngonFace = pm.intField(parent = self.layout, width = 40,value=0) # Set the values? self.buttons.append( btn__find_non_quad_faces ) #pm.formLayout( form, edit=True,attachForm=[(self.labVtx,'top',10),(self.labVtx,'left',5),(self.layoutGrid,'top',30),(self.layoutGrid,'left',5),(self.labFace,'top',200),(self.labFace,'left',5),(btn_Face,'top',220),(btn_Face,'left',5),(self.labTriResult,'top',255),(self.labTriResult,'left',5),(self.triFace,'top',250),(self.triFace,'left',160),(self.ngonFace,'top',270),(self.ngonFace,'left',160),(self.labngonResult,'top',275),(self.labngonResult,'left',5)]) # Show Window pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def __init__(self, parentRef): self.parentRef = parentRef self.win = pm.window(title="Joint Orientation", width=250, height=180) self.col = pm.columnLayout() self.row1 = pm.rowColumnLayout(width=200, numberOfColumns=2) self.rotateXText = pm.text(label="X rotate:", parent=self.row1) self.rotateXField = pm.intField(parent=self.row1) self.rotateYText = pm.text(label="Y rotate:", parent=self.row1) self.rotateYField = pm.intField(parent=self.row1) self.rotateZText = pm.text(label="Z rotate:", parent=self.row1) self.rotateZField = pm.intField(parent=self.row1) self.button = pm.button( label="Rotate Joints", width=200, command=lambda x: parentRef.rotateJoint( self.rotateXField.getValue(), self.rotateYField.getValue(), self.rotateZField.getValue()), parent=self.col) self.button = pm.button(label="Rotate Joints Relative", width=200, command=lambda x: parentRef.rotateJoint( self.rotateXField.getValue(), self.rotateYField.getValue(), self.rotateZField.getValue(), rotateRelative=True), parent=self.col) self.win.show() self.win.setWidth(260) self.win.setHeight(210)
def makeUi( self ): self.win = pm.window(title="Mr Clean") self.win.show() with self.win: self.col = pm.columnLayout() with self.col: self.win.setWidth( 400 ) self.win.setHeight( 200 ) self.precisionText = pm.text( "Precision:\n Accuracy of face check, higher is more precise \n" + "but will allow smaller errors.\n" + "It's like the opposite of merge distance tolerance." ) self.precision = pm.intField( ) self.precision.setValue( 2 ) self.toleranceText = pm.text( "Tolerance" ) self.tolerance = pm.floatField( ) self.tolerance.setValue( 0.01 ) self.button = pm.button( "Mostly Safe Cleanup", command = lambda x: self.mrClean.mostlySafeCleanup( self.precision.getValue(), self.tolerance.getValue() ) ) self.warningText = pm.text( "Beware, backup your model first,\n" + "since this tool might delete more of\n" + "your model than you want it to. This\n" + "tool often helps with *very* broken\n" + "models, but it can potentially make\n" + "changes even where there aren't problems\n" + " on a model." )
def __init__(self, parent): self.parent = parent self.win = pm.window('Attribute Setter', resizeToFitChildren=True) with self.win: self.col = pm.columnLayout() with self.col: self.helpButton = pm.button( label="Show Help", command=lambda x: self.showHelp(), ) ## Text label that says "Attribute to change:" self.attributeLabel = pm.text( 'Attribute to change:' ) ## Text entry field, a place where the user will type in the attribute to change self.attributeField = pm.textField( width=600 ) ## Text label that says "New value for attribute:" self.valueLabel = pm.text( 'New value for attribute:' ) ## Text entry field, a place where the user will type the new value to set the attribute to self.valueField = pm.textField( width=600 ) self.go = pm.button( label="Set Attributes", command=lambda x: self.parent.setAttributes( attribute=self.attributeField.getText(), value=self.valueField.getText(), ) )
def __init__(self): if pm.window('sd_random_xform_window', query=True, exists=True): pm.deleteUI('sd_random_xform_window') ui_parent = QtWidgets.QDialog(parent=get_maya_main_window()) ui_parent.setObjectName('sd_random_xform_window') super(SDRandomXformUI, self).__init__(parent=ui_parent) self.sd = sd_utils self.interpolation_dict = self.sd.SDInterpolateTransform() # Set the title and width of the window. self.setWindowTitle('Random Xform') # Set window width. self.setMinimumWidth(250) # Specify window flags flags = QtCore.Qt.Window \ | QtCore.Qt.WindowSystemMenuHint \ | QtCore.Qt.WindowMinimizeButtonHint \ | QtCore.Qt.WindowCloseButtonHint \ | QtCore.Qt.WindowMaximizeButtonHint # Set window flags. self.setWindowFlags(flags) self.build_ui() self.show()
def create_atr_ui(self): self.ATTR_WINDOW = "Create_Attr" if pm.window(self.ATTR_WINDOW, query=True, exists=True): pm.deleteUI(self.ATTR_WINDOW) pm.window(self.ATTR_WINDOW, title="create attribute", iconName="CA", widthHeight=(250, 200)) attr_main_col = pm.columnLayout(adjustableColumn=True, parent=self.ATTR_WINDOW) attr_nm_col = pm.rowColumnLayout(parent=attr_main_col, numberOfColumns=2) pm.text(label="Enum Attribute Name : ", parent=attr_nm_col) self.attr_nm = pm.textField("", parent=attr_nm_col, width=120) pm.separator(parent=attr_main_col, style="in") attr_val_col = pm.rowColumnLayout(parent=attr_main_col, numberOfColumns=2, columnOffset=(1, "right", 5)) attr_val_ch_col = pm.rowColumnLayout(parent=attr_val_col, numberOfRows=2) attr_val_btn_ch_col = pm.rowColumnLayout(parent=attr_val_col, numberOfRows=2) pm.text(label="Enum Attribute values", parent=attr_val_ch_col) self.enum_val = pm.scrollField(parent=attr_val_ch_col, width=130, height=150) pm.text(label=" ", parent=attr_val_btn_ch_col) pm.button(label="Create Attr\non selected\ncontrol", parent=attr_val_btn_ch_col, height=150, width=100, command=lambda x: self.create_attr()) pm.showWindow(self.ATTR_WINDOW) pm.window(self.ATTR_WINDOW, edit=True, widthHeight=(250, 200)) return None
def __init__(self, parentRef): self.parentRef = parentRef self.buttons = [] self.window = pm.window(sizeable=False, title="Selector", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: self.labFace = pm.text( label='A Useful Tool For Making Selections.', align='left', parent=self.layout) self.labFace = pm.text( label='Currently this tool only selects non quad faces.', align='left', parent=self.layout) self.labFace3 = pm.text( label= 'More features will be added to this tool in the future.', align='left', parent=self.layout) self.labFace4Blank = pm.text(label=' ', align='left', parent=self.layout) self.labFace4Blank = pm.text(label=' ', align='left', parent=self.layout) btn__find_non_quad_faces = pm.button( label='Find-Quad Face Faces', parent=self.layout, command=lambda xc: self.parentRef.highlightNonQuads(), width=300) self.buttons.append(btn__find_non_quad_faces) self.labTriResult = pm.text(label='Number of Triangles Found:', align='left', parent=self.layout) self.triFace = pm.intField(parent=self.layout, width=40, value=0) self.labngonResult = pm.text(label='Number of n-Gons Found:', align='left', parent=self.layout) self.ngonFace = pm.intField(parent=self.layout, width=40, value=0) # Set the values? self.buttons.append(btn__find_non_quad_faces) #pm.formLayout( form, edit=True,attachForm=[(self.labVtx,'top',10),(self.labVtx,'left',5),(self.layoutGrid,'top',30),(self.layoutGrid,'left',5),(self.labFace,'top',200),(self.labFace,'left',5),(btn_Face,'top',220),(btn_Face,'left',5),(self.labTriResult,'top',255),(self.labTriResult,'left',5),(self.triFace,'top',250),(self.triFace,'left',160),(self.ngonFace,'top',270),(self.ngonFace,'left',160),(self.labngonResult,'top',275),(self.labngonResult,'left',5)]) # Show Window pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def createGUI(self): self.window = pm.window(menuBar=True) menu = pm.menu(label='File', tearOff=True) pm.rowColumnLayout( numberOfColumns=3 ) self.obj.createFormGUI() self.obj._createAttrGUI() self.obj._createScriptGUI() return self.window
def object_creator_ui(): """This method creates user interface to input object details User Inputs: - Object name - Object ID Returns : None """ WINDOW = 'ObjectCreator' if pm.window(WINDOW, query=True, exists=True): pm.deleteUI(WINDOW) pm.window(WINDOW, title="Object creator", iconName='OC', widthHeight=(200, 250)) column_1 = pm.columnLayout(adjustableColumn=True) pm.Text(label="Enter Object Name", parent=column_1) object_name = pm.TextField(text='Object', parent=column_1) pm.separator(height=20, style='in', parent=column_1) pm.Text(label="Enter ID to start with", parent=column_1) object_id = pm.TextField(text='01', parent=column_1) pm.separator(height=20, style='in', parent=column_1) pm.button(label='Create Joint', command=lambda x: create_joint(object_name.getText(), object_id.getText()), parent=column_1) pm.separator(height=20, style='in', parent=column_1) pm.button(label='Create Locator', command=lambda x: create_locator(object_name.getText(), object_id.getText()), parent=column_1) pm.separator(height=20, style='in', parent=column_1) pm.button(label='Create Group', command=lambda x: create_group(object_name.getText(), object_id.getText()), parent=column_1) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(200, 250)) return None
def lyr_swtch_ui(self): self.MAIN_WINDOW = "Layered_texture_switch" if pm.window(self.MAIN_WINDOW, query=True, exists=True): pm.deleteUI(self.MAIN_WINDOW) pm.window(self.MAIN_WINDOW, title="Layered Tex Switch", iconName="LTS", widthHeight=(150, 200)) main_col = pm.columnLayout(adjustableColumn=True, height=100, parent=self.MAIN_WINDOW) but_col = pm.rowColumnLayout(parent=main_col, numberOfColumns=2) self.create_attr_btn = pm.button( label="Create ENUM Attribute", parent=main_col, command=lambda x: self.create_atr_ui()) pm.separator(parent=main_col, style="in", height=10) pm.text(label="Enum Attribuite list", parent=main_col) pm.separator(parent=main_col, style="none", height=5) self.text_lst = pm.textScrollList(allowMultiSelection=False, parent=main_col, height=150) pm.separator(parent=main_col, style="none", height=5) but_col = pm.rowColumnLayout(parent=main_col, numberOfColumns=3) pm.button(label="Refresh List", parent=but_col, command=lambda x: self.populate_list()) pm.separator(parent=but_col, horizontal=False) pm.button(label="Create Switch", parent=but_col, command=lambda x: self.create_switching()) pm.showWindow(self.MAIN_WINDOW) pm.window(self.MAIN_WINDOW, edit=True, widthHeight=(150, 235)) return None
def reorder_edit_ui(self): reorder_win = "Reorder_Deformer_List" if pm.window(reorder_win, query=True, exists=True): pm.deleteUI(reorder_win) pm.window(reorder_win, title="Rearrange Deformers", iconName="ReArDf") main_col = pm.columnLayout(parent=reorder_win, adjustableColumn=True) self.reord_lst = pm.scrollField('reorder_deformer_list', parent=main_col, height=235, width=150, text=self.populate_order_edit_list()) pm.button("Save order list", parent=main_col, command=lambda x: self.save_deformer_list()) pm.showWindow(reorder_win) pm.window(reorder_win, edit=True, widthHeight=(150, 260)) return None
def ui_set_selection_enable(self, **kwargs): flag = kwargs.get("flag", None) if flag == "uniform": self.divisions.setEditable(True) self.sel_obj_chk_bx.setEditable(False) self.sel_obj_chk_bx.setValue(False) self.chk_bx_info.setEnable(False) self.chk_bx_info.setLabel("") pm.window(self.WINDOW, edit=True, widthHeight=(200, 320)) else: self.divisions.setEditable(False) self.sel_obj_chk_bx.setEditable(True) self.sel_obj_chk_bx.setValue(True) self.chk_bx_info.setEnable(True) self.chk_bx_info.setLabel( "If checked off, sample objects or\njoints \ will be placed in positions" ) pm.window(self.WINDOW, edit=True, widthHeight=(200, 335)) return None
def __init__(self, parentRef): self.parentRef = parentRef self.buttons = [] self.window = pm.window(sizeable=False, title="Retoper", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: self.lab1 = pm.Text( label='A "Retop" Tool For Creating New Topology.', align='left', parent=self.layout) self.lab2 = pm.Text( label='Please Note: This tool does not preserve', width=300, align='left', parent=self.layout) self.lab3 = pm.Text( label='construction history of edited objects.', width=300, align='left', parent=self.layout) btn__setReference = pm.Button( label='Set Reference Mesh', parent=self.layout, command=lambda xc: self.parentRef.setReference(), width=300) self.buttons.append(btn__setReference) btn__makeReferenceLive = pm.Button( label='Make Reference Live', parent=self.layout, command=lambda xc: self.parentRef.makeReferenceLive(), width=300) self.buttons.append(btn__makeReferenceLive) btn__makeReferenceNotLive = pm.Button( label='Make Reference Not Live', parent=self.layout, command=lambda xc: self.parentRef.makeReferenceNotLive(), width=300) self.buttons.append(btn__makeReferenceNotLive) btn__projectSelection = pm.Button( label='Project Selection To Surface', parent=self.layout, command=lambda xc: self.parentRef.projectSelection(), width=300) self.buttons.append(btn__projectSelection) # Show Window pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def dock(mainWindow): """ Show dockable window args mainWindow : QtGui.QMainWindow return None """ mainWindow.setObjectName('sampleWindowObject') DOCK_NAME = "dock_name" from pymel import all as pm if pm.dockControl(DOCK_NAME, q=True, ex=1): pm.deleteUI(DOCK_NAME) if pm.window('dummyWindow', q=True, ex=1): pm.deleteUI('dummyWindow') # Create dummy window object to keep the layout pm.window('dummyWindow') pm.columnLayout() floatingLayout = pm.paneLayout( configuration='single', w=300) pm.setParent('..') # Create new dock pm.dockControl( DOCK_NAME, aa=['right', 'left'], a='right', fl=False, con=floatingLayout, label="Sample Dock", w=300) # Parent QMainWindow object to the layout pm.control('sampleWindowObject', e=True, parent=floatingLayout)
def __init__(self, parentRef=None, parentWidget=None): self.parentRef = parentRef self.buttons = [] self.layoutsR = [] self.widgets = {} if parentWidget==None: parentWidget = self.widgets['parentWidget'] = pm.window( sizeable = True, title = "Mirrorer", titleBar=True, resizeToFitChildren=True, ) else: self.widgets['parentWidget'] = parentWidget with parentWidget: self.layoutC = pm.columnLayout( ) with self.layoutC: row = pm.rowLayout( numberOfColumns=3 ) self.layoutsR.append( row ) with row: self.makeStartShapeUi = pm.button ( label = 'Make Starting Shape', command = lambda xc: self.parentRef.makeStartShape(),width = 200 ) row = pm.rowLayout( numberOfColumns=3 ) self.layoutsR.append( row ) with row: self.deleteNegativeSideUi = pm.button ( label = 'Delete Negative Side', command = lambda xc: self.parentRef.deleteNegativeSide(),width = 200 ) row = pm.rowLayout( numberOfColumns=3 ) self.layoutsR.append( row ) with row: self.mirrorSelectionUi = pm.button ( label = 'Mirror As Instance', command = lambda xc: self.parentRef.mirrorSelection(),width = 200 ) row = pm.rowLayout( numberOfColumns=3 ) self.layoutsR.append( row ) with row: self.mirrorSelectionUi = pm.button ( label = 'Flatten to zero on X axis', command = lambda xc: self.parentRef.flattenToXZero(),width = 200 ) row = pm.rowLayout( numberOfColumns=3 ) self.layoutsR.append( row ) with row: self.mirrorSelectionUi = pm.button ( label = 'Mirror Geometry (Baked/Frozen)', command = lambda xc: self.parentRef.mirrorGeometry( ),width = 200 ) # Show Window if type( parentWidget ) == pm.core.windows.window: win = parentWidget pm.showWindow(win) win.setWidth(300) win.setHeight(200)
def uv_ratio_UI(self): UV_RATIO_WINDOW = "UVratio" if pm.window(UV_RATIO_WINDOW, query=True, exists=True): pm.deleteUI(UV_RATIO_WINDOW) pm.window(UV_RATIO_WINDOW, title="uv ratio", iconName="UVR") main_col = pm.columnLayout(adjustableColumn=True) self.ref_shell_btn = pm.button("set reference shell", height=40, parent=main_col, backgroundColor=(.863, 0.078, 0.235), command=lambda x: self.set_ref_shell()) pm.separator(parent=main_col, style="in", height=5) self.sel_shell_btn = pm.button("select assigned reference shell", parent=main_col, enable=False, command=lambda x: self.sel_ref_shell()) pm.separator(parent=main_col, style="in", height=10) self.assign_btn = pm.button("apply uv ratio on\n selected Shells", height=40, parent=main_col, enable=False, command=lambda x: self.rescale_uv()) #self.assign_btn.setEnable(False) pm.separator(parent=main_col, height=5, style="in") ch_bx_col = pm.rowColumnLayout(numberOfColumns=2, parent=main_col, columnOffset=(1, "left", 40)) pm.text("", parent=ch_bx_col) self.ch_bx = pm.checkBox(label="Object Selection", parent=ch_bx_col, enable=False) pm.text("Check above option to select mesh\ninstead of shell", parent=main_col) pm.showWindow(UV_RATIO_WINDOW) pm.window(UV_RATIO_WINDOW, edit=True, widthHeight=(200, 170)) return None
def __init__(self): self.simpleScripter = SimpleScripter() self.win = pm.window("Simple Scripter") with self.win: self.col = pm.columnLayout() with self.col: self.text = pm.text("Mel Script code to repeat:") self.textFieldScript = pm.textField(width=500, text=mel_command) self.btnOneToMany = pm.button( "Run as One To Many", command=lambda x: self.simpleScripter.oneToMany( self.textFieldScript.getText()))
def main_rearrange_ui(self): WIN = "rearrange_nodes" if pm.window(WIN, query=True, exists=True): pm.deleteUI(WIN) pm.window(WIN, title="Rearrange Nodes", iconName="ReArNd") main_col = pm.columnLayout(parent=WIN, adjustableColumn=True) list_ord_col = pm.rowColumnLayout(parent=main_col, numberOfColumns=3) ord_col_ch = pm.columnLayout(parent=list_ord_col, adjustableColumn=True) pm.separator(parent=list_ord_col, horizontal=False, width=10) list_col_ch = pm.columnLayout(parent=list_ord_col, adjustableColumn=True) self.ord_lst = pm.textScrollList('deformers_reorder', numberOfRows=10, parent=ord_col_ch, height=235, width=150, allowMultiSelection=False, enable=False) pm.separator(style="none", height=20, parent=list_col_ch) self.nd_typ_txt = pm.textField(parent=list_col_ch, width=150) pm.separator(style="none", height=10, parent=list_col_ch) pm.button(label="Get Selected Node Type", parent=list_col_ch, command=lambda x: self.show_type()) pm.separator(style="in", height=50, parent=list_col_ch) pm.button(label="Rearrange", height=130, parent=list_col_ch, backgroundColor=(0.561, 0.737, 0.561), command=lambda x: self.reorder_deformer_nodes()) pm.button(label="Edit Order List", parent=ord_col_ch, command=lambda x: self.reorder_edit_ui()) pm.showWindow(WIN) pm.window(WIN, edit=True, widthHeight=(320, 260)) return None
def __init__(self, parentRef): self.parentRef = parentRef self.buttons = [] self.window = pm.window(sizeable=False, title="Retoper", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: self.lab1 = pm.Text(label='A "Retop" Tool For Creating New Topology.', align="left", parent=self.layout) self.lab2 = pm.Text( label="Please Note: This tool does not preserve", width=300, align="left", parent=self.layout ) self.lab3 = pm.Text( label="construction history of edited objects.", width=300, align="left", parent=self.layout ) btn__setReference = pm.Button( label="Set Reference Mesh", parent=self.layout, command=lambda xc: self.parentRef.setReference(), width=300, ) self.buttons.append(btn__setReference) btn__makeReferenceLive = pm.Button( label="Make Reference Live", parent=self.layout, command=lambda xc: self.parentRef.makeReferenceLive(), width=300, ) self.buttons.append(btn__makeReferenceLive) btn__makeReferenceNotLive = pm.Button( label="Make Reference Not Live", parent=self.layout, command=lambda xc: self.parentRef.makeReferenceNotLive(), width=300, ) self.buttons.append(btn__makeReferenceNotLive) btn__projectSelection = pm.Button( label="Project Selection To Surface", parent=self.layout, command=lambda xc: self.parentRef.projectSelection(), width=300, ) self.buttons.append(btn__projectSelection) # Show Window pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def dock(mainWindow): """ Show dockable window args mainWindow : QtWidgets.QMainWindow return None """ mainWindow.setObjectName('sampleWindowObject') DOCK_NAME = "dock_name" from pymel import all as pm if pm.dockControl(DOCK_NAME, q=True, ex=1): pm.deleteUI(DOCK_NAME) if pm.window('dummyWindow', q=True, ex=1): pm.deleteUI('dummyWindow') # Create dummy window object to keep the layout pm.window('dummyWindow') pm.columnLayout() floatingLayout = pm.paneLayout(configuration='single', w=300) pm.setParent('..') # Create new dock pm.dockControl(DOCK_NAME, aa=['right', 'left'], a='right', fl=False, con=floatingLayout, label="Sample Dock", w=300) # Parent QMainWindow object to the layout pm.control('sampleWindowObject', e=True, parent=floatingLayout)
Utils = UtilsMod.Utils class ScripterEditorUi(object): def __init__(self,mmmmToolsRef=None,makeUi=True): widthForAll = 900 self.mmmmTools = mmmmToolsRef self.attrName = 'notes' ##'mmmmScriptStringAttr' self.activeScriptText = '' self.scriptModule = None self.node = None self.codeString = '' self.activeScriptLabelStartText = "Actice Script being Edited is: " self.win = pm.window("Scripter - Editor", width=widthForAll) initialUuid = str( uuid.uuid4() ).replace('-','_') with self.win: self.col = pm.columnLayout( width=600 ) with self.col: self.notice = pm.text( '''NOTICE: Script Objects Use Object Notes attributes, which don't exist when blank. \n You may have to add to them manually if you can't use "get from selection".''') pm.text( " ") pm.text( "Script prefix: (it is recommended this be left as the default)" ) self.scriptPrefixTextField = pm.textField( text="script__", width=widthForAll, ) pm.text( "Script name: (it is recommended that you use a unique and descriptive name)" ) self.scriptNameTextField = pm.textField( text=initialUuid, width=widthForAll, ) self.scriptGetButton = pm.button( label="Make the script, or get the script if it already exists. (Works using the above fields, prefix and name.)", command=lambda x: self.getScriptContents(), width=widthForAll, ) self.getScriptFromSelectionButton = pm.button( label="Get Script From Selection / Make new script if no script on selection \n Autofills above fields when it find a script.", command=lambda x: self.getScriptFromSelection(), width=widthForAll, ) pm.text( " " ) pm.text( " " ) ## different spaces used to keep unique names self.activeScriptText = pm.text( self.activeScriptLabelStartText ) pm.text( "Script contents: (Editing here will immediately edit the corresponding mmmmScriptStringAttr attribute on the object.)" ) self.scriptContentsScrollField = pm.scrollField( keyPressCommand = lambda x: self.setScriptContents(), changeCommand = lambda x: self.setScriptContents(), width=widthForAll, height=500,
def ui(self): WINDOW = "jointSequence" if pm.window(WINDOW, query=True, exists=True): pm.deleteUI(WINDOW) pm.window(WINDOW, title="Continue Joints along loops", iconName="JNTS") main_col = pm.columnLayout(adjustableColumn=True) guide_col = pm.columnLayout(parent=main_col) info_txt = "INFO:"+\ "\nFrom selected edges as starting point and"+\ "\ndirection guide, every next edge loop is"+\ "\nobtained till it reaches the end or the"+\ "\nstaring selection edge or the selected end point" guide_txt = "GUIDE:\nSelect 2 edges, each from adjacent loops"+\ "\nfirst edge is the starting point"+\ "\nsecond edge to guide the direction"+\ "\nif third edge is selected, acts as end point" pm.text(guide_txt, align="left", parent=guide_col) pm.separator(parent=guide_col, height=5, style="in") pm.text(info_txt, align="left", parent=guide_col) pm.separator(parent=main_col, height=10) text_col = pm.rowColumnLayout(parent=main_col, numberOfColumns=2, columnOffset=(2, "left", 25)) pm.text("number of loops to\nskip inbetween", parent=text_col) self.skip_val = pm.textField(text="0", parent=text_col, width=50) check_col = pm.rowColumnLayout(numberOfColumns=2, parent=main_col, columnOffset=(2, "left", 120)) pm.text("", parent=check_col) self.skn_chk = pm.checkBox("skin", parent=check_col) pm.separator(parent=main_col, style="none", height=5) pm.button("create", parent=main_col, command=lambda x: self.run()) pm.showWindow(WINDOW) pm.window(WINDOW, edit=True, widthHeight=(220, 230)) return None
def __init__(self): self.simpleScripter = SimpleScripter() self.win = pm.window("Simple Scripter") with self.win: self.col = pm.columnLayout() with self.col: self.text = pm.text( "Mel Script code to repeat:" ) self.textFieldScript = pm.textField( width=500, text=mel_command ) self.btnOneToMany = pm.button( "Run as One To Many", command = lambda x: self.simpleScripter.oneToMany( self.textFieldScript.getText() ) )
def createNew(self, floating=False): if self.mmmm == None: self.mmmm = MmmmToolsMod.Dynamic.GetInstance() mmmm = self.mmmm self.widgets = {} self.subs = {} ## Create Main Widgets win = self.widgets["win"] = pm.window() ## scroll = self.widgets["scroll"] = pm.scrollLayout(parent=win, horizontalScrollBarThickness=0) ## The dock must be created after the window's layout dock = self.widgets["dock"] = pm.dockControl( "MmmmTools Dock", floating=floating, area="left", content=win, allowedArea=["right", "left"] ) col = self.widgets["col"] = pm.columnLayout(parent=scroll) # self.mainFrame = MmmmMainDockableWindowSub( ) # self.mainFrame # self.mainFrame = # self.makeMainFrame( parentLayout=col ) modellerFrame = pm.frameLayout(label="Modeler", collapsable=True, parent=col, marginWidth=10) modellerCol = pm.columnLayout(parent=modellerFrame) f0 = pm.frameLayout(label="Modeler Actions", marginWidth=10, collapsable=True, parent=modellerCol) commander = self.mmmm.commander cmdEntries = commander.entries prefix = "Modeler/" for name, entry in cmdEntries.items(): if name.startswith(prefix): uiLabel = entry.get("uiLabel") if uiLabel == None: ## Trim modeler from name uiLabel = name[len(prefix) :] pm.button(label=uiLabel, parent=f0, command=commander.commandsMelNames[name]) f1 = pm.frameLayout(label="Grid Tools", marginWidth=10, collapsable=True, parent=modellerCol) mmmm.modeler.runGridTools(makeUi=True, parentWidget=f1) f2 = pm.frameLayout(label="Retopo Tools", marginWidth=10, collapsable=True, parent=modellerCol) mmmm.modeler.runRetoper(makeUi=True, parentWidget=f2) f3 = pm.frameLayout(label="Mirror Tools", marginWidth=10, collapsable=True, parent=modellerCol) mmmm.modeler.runMirrorer(makeUi=True, parentWidget=f3) pm.windowPref(win, width=500, height=500) win.setWidth(500) win.setHeight(800)
class MmmmShellThickenUi(object): def __init__(self, autorun=True ): self.shellThicken = MmmmShellThicken( ) if autorun==True: self.createUi() def createUi(self): self.win = pm.window(title="Mmmm Shell Thicken") with self.win: self.col = pm.columnLayout() with self.col: self.thicknessLabel = pm.text( "Thickness: " ) self.thicknessFloatField = pm.floatField( value=1.0, precision=9, width=200 ) self.divisionsLabel = pm.text( "Divisions: " ) self.divisionsIntField = pm.intField( value=1, width=200 ) self.mergeLabel = pm.text( "Distance (tolerance) for verts merge:" )
def __init__(self, mmmmTools=None, randomSelector=None): if randomSelector == None: self.randomSelector = RandomSelector() else: self.randomSelector = randomSelector self.win = pm.window("Random Selector") with self.win: self.col = pm.columnLayout() with self.col: self.ratioText = pm.text("Decimal number as ratio to select:") self.ratioFloat = pm.floatField() self.ratioFloat.setValue(0.5) self.selectButton = pm.button( "Select by Ratio", command=lambda x: self.randomSelector.go(self.ratioFloat.getValue()) ) self.win.show()
def hyperShadeToggle(cls): ## disabled unnecessary code only here for reference: ## we could lsUI and then check list but we don't have to ## ## try effectively does that for ussince the try effectively does that for us # listedWindows = cmds.lsUI(typ='window') showFunc, hideFunc = cls.hyperShadeShow, cls.hyperShadeHide try: isVisible = pm.window('hyperShadePanel1Window', query=True, visible=True) if isVisible: hideFunc() else: showFunc() except: showFunc()
def __init__(self, mmmmTools=None, randomSelector=None): if randomSelector == None: self.randomSelector = RandomSelector() else: self.randomSelector = randomSelector self.win = pm.window('Random Selector') with self.win: self.col = pm.columnLayout() with self.col: self.ratioText = pm.text("Decimal number as ratio to select:") self.ratioFloat = pm.floatField() self.ratioFloat.setValue(0.5) self.selectButton = pm.button( "Select by Ratio", command=lambda x: self.randomSelector.go(self.ratioFloat. getValue())) self.win.show()
def __init__(self, parentRef, selection=False, multiplier=1.0): self.parentRef = parentRef self.buttons = [] self.window = pm.window( sizeable = False, title = "Light Multiplier", titleBar=True) with self.window: self.layout = pm.columnLayout() with self.layout: ## Using Ui on the end of Widget names self.multiplierText = pm.text( label='Multiplier:', align='left' ) self.multiplierUi = pm.floatField( value=1.0 ) self.checkBoxUi = pm.checkBox( label='Affect Selected Lights Only') self.okUi = pm.button ( label = 'Apply',parent = self.layout, command = lambda xc: self.parentRef.applyMultiplier( multiplier=self.multiplierUi.getValue(), selection=self.checkBoxUi.getValue(), ), width = 300 ) pm.showWindow(self.window) self.window.setWidth(600) self.window.setHeight(400)
def run(self): self.win = pm.window(title="Mmmm Baker Tool") with self.win: self.col = pm.columnLayout() with self.col: self.spacers = [] self.xnormalPathTextLabel = pm.text( "Path and filename of xNormal executable:") self.xnormalPathTextField = pm.textField( width=500, text= "C:/Program Files/S.Orgaz/xNormal 3.19.2/x64/xNormal.exe") self.spacers.append(pm.text(" ")) self.modelsPathTextLabel = pm.text("Path where models are:") self.modelsPathTextField = pm.textField( width=500, text="C:/Users/Public/mmmmBaker") self.modelsPathTextLabel2 = pm.text( "(Warning, if changed, requires custom xnormal settings xml which points to new path.)" ) self.spacers.append(pm.text(" ")) self.highSuffixTextLabel = pm.text( 'High Suffix, on models for xnormals "high" model files, no extension' ) self.highSuffixTextField = pm.textField(width=500, text="_hi") self.spacers.append(pm.text(" ")) #self.highSuffixTextLabel = pm.text( "Suffix on files: (not extension)" ) #self.cageSuffixTextField = pm.textField( width = 500, text="_cage" ) self.xmlFilesTextLabel = pm.text( "Xml files to bake, comma separated list:") self.xmlFilesTextLabel2 = pm.text( "(xnormal settings files, should be in the same folder as models)" ) self.xmlFilesTextField = pm.textField( width=500, text= "xnormal_settings_for_mmmmbaker_example.xml,xnormal_settings_for_mmmmbaker_example2.xml" ) self.goButton = pm.button( label="Go! (Bake selected models) )", command=lambda x: self.go())
def hs_tube(self, edgering=True): """ used for correcting normals on the ends of a hard surface pipe. if edgering = True, than only one edge need be selected and it will select the ring automatically. """ if edgering: mm.eval('SelectEdgeRingSp;') oSel = pm.ls(sl=True, flatten=True) for obj in oSel: # determine weather or not the selection is a face if str(obj.split('.')[-1][0]) == 'f': # if it is, convert it to edges mm.eval('ConvertSelectionToContainedEdges;') break eSel = pm.ls(sl=True, flatten=True) # another good ol' progress bar progWind = pm.window(title='progress') pm.columnLayout() progressControl = pm.progressBar(maxValue=len(eSel), width=300) pm.showWindow(progWind) # for the selected edges run the hs_verts function for edges in eSel: pm.select(edges) mm.eval('ConvertSelectionToFaces;') angled_faces = pm.ls(sl=True, flatten=True) self.hs_verts(angled_faces[0], angled_faces[1]) ee = eSel.index(edges) pm.progressBar(progressControl, edit=True, progress=ee) pm.deleteUI(progWind) pm.selectType(edge=True)
def __init__(self, parentRef): self.parentRef = parentRef self.win = pm.window( title="Joint Orientation", width=250, height=180) self.col = pm.columnLayout() self.row1 = pm.rowColumnLayout( width = 200, numberOfColumns=2 ) self.rotateXText = pm.text( label="X rotate:", parent=self.row1 ) self.rotateXField = pm.intField( parent=self.row1 ) self.rotateYText = pm.text( label="Y rotate:", parent=self.row1 ) self.rotateYField = pm.intField( parent=self.row1 ) self.rotateZText = pm.text( label="Z rotate:", parent=self.row1 ) self.rotateZField = pm.intField( parent=self.row1 ) self.button = pm.button( label="Rotate Joints", width=200, command = lambda x: parentRef.rotateJoint( self.rotateXField.getValue() ,self.rotateYField.getValue() ,self.rotateZField.getValue() ), parent=self.col ) self.button = pm.button( label="Rotate Joints Relative", width=200, command = lambda x: parentRef.rotateJoint( self.rotateXField.getValue() ,self.rotateYField.getValue() ,self.rotateZField.getValue(), rotateRelative=True ), parent=self.col ) self.win.show() self.win.setWidth(260) self.win.setHeight(210)
def __init__(self): self.win=pm.window() with self.win: self.col = pm.columnLayout() with self.col: self.label1 = pm.text( "Attribute Group Name (To Be Added)" ) self.dropdown = pm.optionMenu( "menu", changeCommand = self.onDropDownChange ) with self.dropdown: for i,v in enumerate(addableAttrList): pm.menuItem( v ) self.attrNameField = pm.textField( ) self.addAttrButton = pm.button( "Add Attribtutes!", command = lambda x: self.addAttributeGroup( self.attrNameField.getText() ) ) self.win.show()
class ScriptFileRunnerUi(object): def __init__(self, parentRef=None, mmmmToolsRef=None): self.mmmmTools = mmmmToolsRef self.parentRef = parentRef self.scriptFileRunner = MmmmScriptFileRunner( parentRef = self, mmmmToolsRef=self.mmmmTools ) self.scriptFileRunner.findScripts() self.win = pm.window("Script File Runner") self.ddMenuEntires = [ ] with self.win: self.col = pm.columnLayout() with self.col: self.textPath = pm.text( "Path to scripts:" ) self.textFieldPath = pm.textField( text=self.scriptFileRunner.searchPath, width=400, changeCommand= lambda x : self.onTextPathChangeCommand() ) self.btnRefresh = pm.button( "Refresh Scripts", command = lambda x: self.buildMenu( )
def __init__(self, parent): self.parent = parent self.win = pm.window("Attribute Connector") self.go()
def __init__(self, parentRef=None): self.parentRef = parentRef #print( 'parent is:') #print( self.parentRef ) self.win = pm.window("UV Xform Tools") with self.win: self.lay = pm.formLayout() with self.lay: labels_x = 0 self.move_label = pm.text( "Move UVs 1 Space Over" ) x = 0 y = 0 self.lay.attachForm( self.move_label, "left",labels_x ) self.lay.attachForm( self.move_label, "top", y ) x_orig = 20 y_orig = 20 x = x_orig y = y_orig x_offset_step = 80 self.move_b1 = pm.button( label="move up", command=lambda x: self.parentRef.move_uvs(0,1) ) self.move_b2 = pm.button( label="move down", command=lambda x: self.parentRef.move_uvs(0,-1) ) self.move_b3 = pm.button( label="move left", command=lambda x: self.parentRef.move_uvs(-1,0) ) self.move_b4 = pm.button( label="move right", command=lambda x: self.parentRef.move_uvs(1,0) ) self.lay.attachForm( self.move_b1, "left",x ) self.lay.attachForm( self.move_b1, "top", y ) x=x+x_offset_step self.lay.attachForm( self.move_b2, "left",x ) self.lay.attachForm( self.move_b2, "top", y ) x=x+x_offset_step self.lay.attachForm( self.move_b3, "left",x ) self.lay.attachForm( self.move_b3, "top", y ) x=x+x_offset_step self.lay.attachForm( self.move_b4, "left",x ) self.lay.attachForm( self.move_b4, "top", y ) x_orig = 20 y_orig = 100 x = x_orig y = y_orig offset_step_y = 25 self.scale_label = pm.text( "Scale UVs" ) self.lay.attachForm( self.scale_label, "left",labels_x ) self.lay.attachForm( self.scale_label, "top", y - 20 ) self.shrink_b0 = pm.button( label="0.5", command=lambda x: self.parentRef.scale_uvs(s=0.5) ) self.shrink_b1 = pm.button( label="0.9", command=lambda x: self.parentRef.scale_uvs(s=0.9) ) self.shrink_b2 = pm.button( label="0.99", command=lambda x: self.parentRef.scale_uvs(s=0.99) ) self.shrink_b3 = pm.button( label="0.999", command=lambda x: self.parentRef.scale_uvs(s=0.999)) x_orig = 20 x = x_orig y = y_orig offset_step_y = 25 self.lay.attachForm( self.shrink_b0, "left",x ) self.lay.attachForm( self.shrink_b0, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.shrink_b1, "left", x ) self.lay.attachForm( self.shrink_b1, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.shrink_b2, "left", x ) self.lay.attachForm( self.shrink_b2, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.shrink_b3, "left", x ) self.lay.attachForm( self.shrink_b3, "top", y ) self.grow_b0 = pm.button( label="2", command=lambda x: self.parentRef.scale_uvs(s=2) ) self.grow_b1 = pm.button( label="1.1", command=lambda x: self.parentRef.scale_uvs(s=1.1) ) self.grow_b2 = pm.button( label="1.01", command=lambda x: self.parentRef.scale_uvs(s=1.01)) self.grow_b3 = pm.button( label="1.001", command=lambda x: self.parentRef.scale_uvs(s=1.001)) x_orig = 80 x = x_orig y = y_orig offset_step_y = 25 self.lay.attachForm( self.grow_b0, "left",x ) self.lay.attachForm( self.grow_b0, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.grow_b1, "left", x ) self.lay.attachForm( self.grow_b1, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.grow_b2, "left", x ) self.lay.attachForm( self.grow_b2, "top", y ) x=x+0 y=y+offset_step_y self.lay.attachForm( self.grow_b3, "left", x ) self.lay.attachForm( self.grow_b3, "top", y )
def create() : global TH_P_WIDGETS init() layerchannel.cleanup() if( pm.dockControl( TH_P_DOCK, exists=True ) ) : pm.deleteUI( TH_P_DOCK ) if( pm.window( TH_P_WIN, exists=True ) ) : pm.deleteUI( TH_P_WIN ) TH_P_WIDGETS[ 'window' ] = pm.window( TH_P_WIN ) TH_P_WIDGETS[ 'main' ] = pm.paneLayout( configuration='vertical3', staticWidthPane=1, paneSize=(3, 0, 100) ) TH_P_WIDGETS[ 'tabs' ] = pm.tabLayout( p=TH_P_WIDGETS[ 'main' ], width=274, height=100 ) TH_P_WIDGETS[ 'column1' ] = pm.verticalLayout( p=TH_P_WIDGETS[ 'main' ], width=100, height=100 ) TH_P_WIDGETS[ 'column2' ] = pm.verticalLayout( p=TH_P_WIDGETS[ 'main' ], width=10 ) # tabs ########################################################################################## # shelves TH_P_WIDGETS[ 'tab_shelves' ] = pm.verticalLayout( p=TH_P_WIDGETS['tabs'] ) TH_P_WIDGETS[ 'tabs' ].setTabLabel( ( TH_P_WIDGETS[ 'tab_shelves' ], 'Shelves' ) ) shelves.create( TH_P_WIDGETS[ 'tab_shelves' ] ) TH_P_WIDGETS[ 'tab_shelves' ].redistribute() # renaming TH_P_WIDGETS[ 'tab_renaming' ] = pm.verticalLayout( p=TH_P_WIDGETS['tabs'] ) renaming.create( TH_P_WIDGETS[ 'tab_renaming' ] ) TH_P_WIDGETS[ 'tabs' ].setTabLabel( ( TH_P_WIDGETS[ 'tab_renaming' ], 'Renaming' ) ) TH_P_WIDGETS[ 'tab_renaming' ].redistribute() # script editor TH_P_WIDGETS[ 'tab_scripteditor' ] = pm.verticalLayout( p=TH_P_WIDGETS['tabs'] ) TH_P_WIDGETS[ 'tabs' ].setTabLabel( ( TH_P_WIDGETS[ 'tab_scripteditor' ], 'Script Editor' ) ) scripteditor.create( TH_P_WIDGETS[ 'tab_scripteditor' ] ) TH_P_WIDGETS[ 'tab_scripteditor' ].redistribute() # column1 ########################################################################################## # layer editor / channel box TH_P_WIDGETS[ 'channellayer' ] = pm.verticalLayout( p=TH_P_WIDGETS[ 'column1' ] ) layerchannel.create( TH_P_WIDGETS[ 'channellayer' ] ) TH_P_WIDGETS[ 'channellayer' ].redistribute() # column2 ########################################################################################## # outliner TH_P_WIDGETS[ 'outliner' ] = pm.verticalLayout( p=TH_P_WIDGETS[ 'column2' ] ) outliner.create( TH_P_WIDGETS[ 'outliner' ] ) TH_P_WIDGETS[ 'outliner' ].redistribute() TH_P_WIDGETS[ 'tabs' ].setSelectTabIndex( 1 ) TH_P_WIDGETS[ 'column1' ].redistribute() TH_P_WIDGETS[ 'column2' ].redistribute() TH_P_WIDGETS[ 'dock_panel' ] = pm.dockControl( TH_P_DOCK, label='th_panel', area='right', allowedArea=[ 'left', 'right' ], sizeable=True, w=540, content=TH_P_WIDGETS[ 'window' ] )
def setupCmds(self): self.title = "MmmmQM" wids = self.widgets = Duck() win = wids.win = pm.window( title=self.title ) win.show() win.setWidth( 210 ) ## "with" puts the tabbed stuff in the window! with win: scr = wids.scr = pm.scrollLayout(verticalScrollBarAlwaysVisible=True) with scr: #lay = wids.lay = pm.formLayout() col = wids.col = pm.columnLayout() with col: n = {} ## we will collect all new widgets here! try: pm.text( "pop up windows" ) rowA = wids.rowA = pm.rowLayout( numberOfColumns=10 ) with rowA: self.makeAndAddButton( n, self.entries.a1 ) self.makeAndAddButton( n, self.entries.a2 ) self.makeAndAddButton( n, self.entries.a3 ) self.makeAndAddButton( n, self.entries.a4 ) except: print( traceback.format_exc() ) try: pm.text( "more..." ) rowB = wids.rowB = pm.rowLayout( numberOfColumns=10 ) with rowB: self.makeAndAddButton( n, self.entries.b1 ) self.makeAndAddButton( n, self.entries.b2 ) self.makeAndAddButton( n, self.entries.b3 ) self.makeAndAddButton( n, self.entries.b4 ) except: print( traceback.format_exc() ) try: rowC = wids.rowC = pm.rowLayout( numberOfColumns=10 ) with rowC: self.makeAndAddButton( n, self.entries.c1 ) self.makeAndAddButton( n, self.entries.c2 ) self.makeAndAddButton( n, self.entries.c3 ) self.makeAndAddButton( n, self.entries.c4 ) except: print( traceback.format_exc() ) try: rowD = wids.rowD = pm.rowLayout( numberOfColumns=10 ) with rowD: self.makeAndAddButton( n, self.entries.d1 ) self.makeAndAddButton( n, self.entries.d2 ) self.makeAndAddButton( n, self.entries.d3 ) self.makeAndAddButton( n, self.entries.d4 ) except: print( traceback.format_exc() ) for k in sorted( n.keys() ): v = n[k] k = k.lower().replace( " ", "_" ).replace(">","_") setattr( wids, k, v )