def aiHyperShadeCreateMenu_BuildMenu(): """ Function: aiHyperShadeCreateMenu_BuildMenu() Purpose: Builds menu items for creating arnold nodes, organized into submenus by category. Notes: When this function is invoked, it is inside of the Create menu. This function mimics the buildCreateSubmenu() function in hyperShadePanel.mel, and in fact calls that function with a slightly different set of arguments than the other Maya node types. For arnold nodes, the menu items are set up to call back to the aiCreateCustomNode() function for node creation. """ # build a submenu for each node category # for (staticClass, runtimeClass, nodePath, nodeTypes) in getTypeInfo(): # skip unclassified if staticClass == 'rendernode/arnold' or staticClass == 'rendernode/arnold/shader': continue pm.menuItem(label = nodePath.replace('/', ' '), tearOff = True, subMenu = True) # call buildCreateSubMenu() to create the menu entries. The specified # creation command is aiCreateCustomNode runtimeClassification. The # buildCreateSubMenu will append to that argument list the name of the # node type, thereby completing the correct argument list for the # creation routine. # pm.mel.buildCreateSubMenu(staticClass, '%s %s ""' % (_createNodeCallbackProc, runtimeClass) ) pm.setParent('..', menu=True)
def ui_reload_tools(self, *uiargs, **kwargs): ''' Source toolbox base path for tools scripts/folders ''' if self.verbose: print '\t...Reloading tools' # TO-DO: # Add additional registration for tools which # will provide more information to the UI. # - Help Info (button) # - Neat name for button # : This will likely require a secondary # utility script to perform file parsing # possibly using the ast module for literal_eval # or using a JSON/XML format. # - Folder support ## SIMPLE VERSION ## # As the simple version, only take script files at face value and execute. # Check paths if self.ui_path.getText(): source_path = self.ui_path.getText() else: source_path = self.ui_path.getPlaceholderText() source_path = os.path.normpath(source_path) if not os.path.exists(source_path): pm.warning('The toolbox path you are trying to source does not exist.') return # Add to sys.path if source_path not in sys.path: if self.verbose: print 'Adding source path to the sys.path...' sys.path.append(source_path) if self.verbose: print 'Sourcing from: ', source_path # Find contents of folder and identify scripts. tool_dir = os.walk(source_path) tool_file_list = [x for x in tool_dir.next()[2] if not '__init__' in x] if self.verbose: print 'tool_file_list: ', tool_file_list if not tool_file_list: pm.warning('Could not find any valid tool files to add.') return # Kill old toolbox lists (archives) if self.toolbox_archive: pm.deleteUI(self.toolbox_archive) # Add UI elements which represent the files on disk. pm.setParent(self.ui_toolbox_layout) with pm.scrollLayout() as self.toolbox_archive: for tool in tool_file_list: exec_path = os.path.join(source_path, tool) if self.verbose: print exec_path pm.button( label= tool.partition('.')[0], command= pm.Callback(execfile, exec_path) )
def populate_selection_layout(self): pm.setParent(self.widgets['selectionSet_vertical']) self.widgets['selectionSet_vertical'].clear() treeViewSelected = pm.treeView (self.widgets["directory_treeView"], q=True, selectItem=True) if not treeViewSelected: return pm.scrollLayout(cr=True) path = os.path.abspath(treeViewSelected[0]) set_paths = [] for dir in os.listdir(path): if dir.find(self.library_objects_suffix[2]) != -1: #.set set_paths.append(os.path.abspath(os.path.join(path, dir))) for set_path in set_paths: print "create button" set_obj = Set(set_path) infos = set_obj.get_info() label = infos['name'].split('.')[0] pm.iconTextButton(style='textOnly',label=label, c=pm.Callback(self.selection_set_button_load, set_obj)) pm.popupMenu() pm.menuItem(label='Save Pose', c=pm.Callback(self.selection_set_button_save, set_obj)) pm.menuItem(label='Load Pose', c=pm.Callback(self.selection_set_button_load, set_obj)) self.widgets["selectionSet_vertical"].redistribute()
def __init__(self): ''' # class to sort and give info on shaders ''' self.layout = pm.rowColumnLayout(numberOfColumns= 3, columnWidth=([1, 150], [2, 150], [3, 250])) pm.columnLayout() pm.text(label= 'Shaders') self.shader_list = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.update_connections_list)) pm.button(label= 'Refresh', width= 150, command= pm.Callback(self.update_shader_list)) pm.setParent(self.layout) pm.columnLayout() pm.text(label='Connections') self.connections_list = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(self.write_info)) self.check_box = pm.checkBox(label= 'Select Node') pm.setParent(self.layout) pm.columnLayout() pm.text(label='Node Info') self.info_field = pm.scrollField(wordWrap= True, width= 250, height= 200) self.attr_check_box = pm.checkBox(label= 'Show All') self.update_shader_list()
def create_ui(* args): ''' # this creates the ui for the selected light from the scrollField ''' # dictionary for class # the script get the light type each type is a key # and based on that it will pick which class to instance light_classes = {'spotLight': lights.Light_spot, 'directionalLight': lights.Light_directional, 'ambientLight': lights.Light_ambient, 'areaLight': lights.Light_area, 'pointLight': lights.Light_point, 'volumeLight': lights.Light_volume} selected = scroll_list.getSelectItem() global lights_dict global obj_ui_list # deleteting existing ui objects for obj in obj_ui_list: try: obj.delete() except: pass for sel in selected: pm.setParent(ui_row) # getting the node type obj_type = pm.nodeType('%s' % (lights_dict[u'%s' %(str(sel))])) # using the ^^ dictionarry to instance the appropritate class light = light_classes[obj_type](light= '%s' % (sel)).create() # appending that object to the global objects list obj_ui_list.append(light)
def __init__(self): self.parti_nodes = [] self.scene_lights = [] self.parti_lights = [] self.parti_dict = {} self.parti_lights_dict = {} self.scene_lights_dict = {} pm.columnLayout(adjustableColumn= True) main = pm.rowColumnLayout(numberOfColumns= 3, columnWidth= ([1,180], [2, 180], [3,180])) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Parti Volumes') self.parti_scroll = pm.textScrollList(width= 180, height= 125, selectCommand = pm.Callback(self.get_input_lights)) pm.button(label= 'Refresh', command= pm.Callback(self.refresh_nodes)) pm.setParent('..') pm.columnLayout(adjustableColumn= True) pm.text(label= 'Parti Lights') self.parti_light_scroll = pm.textScrollList(width= 180, height= 125) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 90], [2, 90])) pm.button(label= '+', command= pm.Callback(self.add_light)) pm.button(label= '-', command= pm.Callback(self.remove_light)) pm.setParent(main) pm.columnLayout(adjustableColumn= True) pm.text(label= 'Scene Lights') self.light_scroll = pm.textScrollList(width= 180, height= 125) pm.button(label= 'Refresh', command= pm.Callback(self.refresh_lights)) self.refresh_lights() self.refresh_nodes()
def create(self): self.main_layout = pm.columnLayout(adjustableColumn= True, width= 400) main_frame = pm.frameLayout( label='%s' % (self.obj), collapsable= True) pm.columnLayout(adjustableColumn= False, width= 400) self.mapping_menu = pm.optionMenu( label='Mapping', width= 150, changeCommand= pm.Callback(self.mapping_type, self.obj)) pm.menuItem( label='Spherical') pm.menuItem( label='Angular') pm.setParent(main_frame) self.type_menu = pm.optionMenu( label='Type', width= 150, changeCommand= pm.Callback(self.file_type, self.obj)) pm.menuItem( label='Image File') pm.menuItem( label='Texture') self.image_field = pm.textFieldButtonGrp(label= 'Image Name', editable= False, columnWidth3= [100,200,100], buttonLabel= '<<<', buttonCommand= pm.Callback(self.load_image, self.obj)) self.list_field = pm.textScrollList(allowMultiSelection= False , width= 100, height= 100) pm.attrColorSliderGrp( at='%s.color' % (self.obj), columnWidth4= [100, 75, 175, 50]) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 200], [2, 200])) pm.button(label= 'List Ramps', command= pm.Callback(self.list_textures)) pm.button(label= 'Link Ramps', command= pm.Callback(self.link_texture, self.obj)) pm.button(label= 'Edit Ramps', command= pm.Callback(self.edit_ramp)) pm.button(label= 'Create Ramps', command= pm.Callback(self.create_ramp))
def createRadioBtnObj( self ): """ creates a RadioButton Element """ if mel.scrollLayout(self._scrollField, ex=True): mel.setParent( self._ActionCol) mel.separator(h=10,style="none") ObjUIpath = mel.frameLayout(mw=10,l="Radio Buttons") mel.columnLayout('sampleCol') mel.separator(h=10,style="none") mel.radioButtonGrp('rbg',nrb=3, l="Big Options", select=self.gSampleState['rbg'], la3=("Option 1", "Option 2", "Option 3")) mel.radioButtonGrp('rbg2',nrb=3, l="Little Options", select=self.gSampleState['rbg'], la3=("Option 4", "Option 5", "Option 6")) mel.separator(h=10,style="none") return ObjUIpath
def build_options_menu( self ): pmc.setParent( menu = True ) menu = pmc.menu( label = 'Options', allowOptionBoxes = True ) pmc.menuItem( label = 'Set xNormal Location', command = self.set_xn_location ) pmc.menuItem( divider = True ) enable = utils.get_bake_normals( ) if enable == None: utils.set_bake_normals( True ) enable = True pmc.menuItem( label = 'Bake Normal Map', cb = enable, command = pmc.CallbackWithArgs( self.map_cbx_callback, 'normal' ) ) enable = utils.get_bake_ao( ) if enable == None: utils.set_bake_ao( False ) enable = False pmc.menuItem( optionBox = True ) pmc.menuItem( label = 'Bake Ambient Occlusion Map', cb = enable, command = pmc.CallbackWithArgs( self.map_cbx_callback, 'ao' ) ) pmc.menuItem( optionBox = True )
def create(self): self.main_layout = pm.columnLayout(adjustableColumn= True, width= 400) main_frame = pm.frameLayout( label='%s' % (self.light), collapsable= True) pm.frameLayout( label='Light Attributes', collapsable= True) pm.attrColorSliderGrp( at='%s.color' % (self.light), columnWidth4= [100, 75, 175, 50]) pm.attrFieldSliderGrp( at='%s.intensity' % (self.light), columnWidth4= [100, 75, 175, 50]) pm.attrFieldSliderGrp(at='%s.ambientShade' % (self.light), columnWidth4= [100, 75, 175, 50]) pm.setParent(main_frame) pm.frameLayout(label= 'Shadows', collapsable= True) pm.attrColorSliderGrp( at='%s.shadowColor' % (self.light), columnWidth4= [100, 75, 175, 50]) self.check_box = pm.checkBox(label= 'Use Ray Trace Shadows', changeCommand= pm.Callback(self.shadows)) self.shadow_radius = pm.attrFieldSliderGrp( at='%s.shadowRadius' %(self.light), enable= False, columnWidth4= [100, 75, 175, 50]) self.shadow_rays = pm.attrFieldSliderGrp( at='%s.shadowRays' % (self.light), enable= False, columnWidth4= [100, 75, 175, 50]) self.ray_depth = pm.attrFieldSliderGrp( at='%s.rayDepthLimit' % (self.light), enable= False, columnWidth4= [100, 75, 175, 50]) pm.setParent(main_frame) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= [200, 200]) pm.button(label= 'Select Light', width= 200, command= pm.Callback(self.select)) pm.button(label= 'Delete UI', width= 200, command= pm.Callback(self.delete)) pm.button(label= 'Hide', command= pm.Callback(self.hide)) pm.button(label= 'Show', command= pm.Callback(self.show)) return self.main_layout
def __init__(self, questions_file): self.file = open(questions_file, 'r') self.questions = self.file.readlines() self.file.close() self.main_layout = pm.columnLayout() self.name_field = pm.textFieldGrp(label= 'Quiz Name') self.layout = pm.rowColumnLayout(numberOfColumns= 2, columnWidth= ([1, 75], [2, 475])) pm.columnLayout() pm.text(label= 'Questions') self.question_scroll_list = pm.textScrollList(width= 60, height= 400, selectCommand= pm.Callback(self.read_questions), allowMultiSelection= True) pm.setParent(self.layout) pm.columnLayout() pm.text(label= 'Questions Info') self.question_scroll_field = pm.scrollField(wordWrap= True, height= 400, width= 475) pm.setParent(self.main_layout) pm.button(label= 'Create Quiz', command= pm.Callback(self.create_quiz), width= 550, height= 50) self.list_questions()
def _categoryUpdated(self, add=None, rename=None, delete=None): _pmCore.setParent(self._uiWidget[_UiWidgetEnum.categoryTabLayout]) if add: # Add a tab in main asset view. childLayout = _pmCore.scrollLayout(width=300, height=200, childResizable=True) self._uiWidget[add] = _pmCore.gridLayout(numberOfColumns=3, cellHeight = self._iconSize, cellWidth=self._iconSize) _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], tabLabel=((childLayout, add),), edit=True) # Add a menu item in category list. From example in Maya doc optionMenuGrp. newMenuItem = _pmCore.menuItem(label=add, parent=self._uiWidget[_UiWidgetEnum.categoryCombox]+'|OptionMenu') self._uiWidget[_UiWidgetEnum.categoryMenuList].append(newMenuItem) if rename: tabNameList = _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], query=True, tabLabel=True) childLayoutList = _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], query=True, childArray=True) _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], edit=True, tabLabel=((childLayoutList[tabNameList.index(rename[0])], rename[1]))) for item in self._uiWidget[_UiWidgetEnum.categoryMenuList]: if _pmCore.menuItem(item, query=True, label=True) != rename[0]: continue _pmCore.menuItem(item, edit=True, label=rename[1]) break if delete: tabNameList = _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], query=True, tabLabel=True) childLayoutList = _pmCore.tabLayout(self._uiWidget[_UiWidgetEnum.categoryTabLayout], query=True, childArray=True) _pmCore.deleteUI(childLayoutList[tabNameList.index(delete)]) for item in self._uiWidget[_UiWidgetEnum.categoryMenuList]: if _pmCore.menuItem(item, query=True, label=True) != delete: continue _pmCore.deleteUI(item) break
def _gatherEvents(self, instance): """event collector called once after the first Idle Event""" message = "Gathered events by '%s':\n" % instance # get the Id for the key inverseID=dict(zip(self.eventID.values(),self.eventID.keys())) # prompt Result for Id in self.eventRecord: token = str(" ID %4d Event: %s \n" % (Id, inverseID.get(Id,0))) message = message + token # --------------create new UI entry--------------- objUI = self._UIobject.createTextfieldObj(message, "eventID: %s" % inverseID.get(self.eventRecord[0],0),True) mel.setParent(objUI) mel.frameLayout(mw=self._optionMarginWidth,l = 'Command Inspect', collapse = True, collapsable = True) mel.columnLayout('subCol',adj=True) mel.separator(h=self._optionMarginWidth,style="none") mel.scrollField(numberOfLines=3, editable=False, wordWrap=False, h = self._optionInspectHeight, w = self._optionInspectWidth, text = "place Holder" ) mel.separator(h=self._optionMarginWidth,style="none") # reset Event Collection self.eventRecord = [] self.eventID["idle"] = 0
def loadDriven(self, *args): """ Load object name for driven object in text field """ sel = pm.ls(sl=True, fl=True) pm.textFieldButtonGrp(self.drivenField, edit=True, text=sel[0]) # Clear the menu items so list doesn't grow items = pm.optionMenu(self.drivenAttField, q=True, ill=True) if(items): pm.setParent(self.drivenAttField, menu=True) for each in items: pm.deleteUI(each) # Check if blendshape if 'BlendShape' in str(type(sel[0])): bs = sel[0] temp = pm.aliasAttr(bs, q=1) temp.sort() targets = [] for each in temp: if each.startswith('weight'): continue targets.append(each) for tgt in targets: try: pm.menuItem(parent=self.drivenAttField, label=tgt) except Exception, e: print e pm.warning('%s failed to create / connect' % tgt)
def show(self): self.window = pm.window(self.name, wh=(self.w, self.h), title=self.name) self.fl = pm.formLayout(nd=100) #create the main form layout of the window self.frame_layout = pm.frameLayout(bgc=(.3,.1,.25), li=self.w/4, la='center', fn='boldLabelFont', label='AW Binary Proxy Tools', borderStyle='in', mh=self.h/12,h=self.h-40) self.cl = pm.columnLayout(adj=True, cal='left', cat=['both',0], rs=5) pm.text(label='mip_renderProxy Creation', al='center') pm.button (label='Create Render Proxies', bgc=(.4,.5,.2), command= lambda *args: self._createRenderProxy( pm.ls(sl=True) )) pm.separator(st='doubleDash', h=25) pm.text(label='mip_renderProxy Assignment', al='center') self.fileInput = TextFieldBrowserInput( width=300, name='Proxy Input', option_name='Proxy Browse Type', options=['from file', 'from folder'], button_name='Browse', parent=self.cl ) pm.button (label='Assign Render Proxies', bgc=(.4,.5,.2), command= lambda *args: self._attachRenderProxy( pm.ls(sl=True) )) pm.button (label='DELETE ALL BINARY PROXIES', bgc=(.4, .2, .2), command=self._removeAllBipx) pm.setParent('..') pm.setParent('..') #add the close window button self.close_btn = pm.button (w=self.bw, label='Close', bgc = (.4, .2, .2), command=self.close_UI) #finalize form layout pm.formLayout(self.fl, edit=True, attachForm = [(self.frame_layout, 'top', 0), (self.frame_layout, 'left', 0), (self.frame_layout, 'right', 0), (self.close_btn, 'bottom', 10), (self.close_btn, 'right', 10)]) pm.showWindow(self.window)
def refresh(self): ''' Delete and rebuild the AOV control rows ''' self.waitingToRefresh = False pm.setParent(self.aovCol) pm.cmds.columnLayout(self.aovCol, edit=True, visible=False) numDeleted = len(self.optionMenus) for ctrl in self.aovControls: ctrl.delete() self.aovControls = [] self.optionMenus = [] self.aovRows = {} # add all control rows if self.renderOptions.node.exists(): self.addRows() self.browser.updateActiveAOVs() pm.cmds.columnLayout(self.aovCol, edit=True, visible=True) # a maya bug causes menus to ignore their specified width #print "refresh", numDeleted, len(self.optionMenus) if numDeleted != len(self.optionMenus): #print "creating script job" callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus)
def create_ui(*args): ''' creates uis for the selected node from the text scroll list ''' selected = scroll_list.getSelectItem() print selected global obj_list print obj_list for obj in obj_list: # try except in case ui was already deleted or could not be found try: # deleting the uis obj.delete_ui() obj.delete_obj() except: continue # clearign the list obj_list = [] for sel in selected: # setting parent to the appropriate layout pm.setParent(dyn_uis) my_ui = Node_UI(node='%s' %(sel)) # creating instance my_ui.create() # invoking create my_ui.toggle_vis() # toggling visibilty obj_list.append(my_ui) # appending to global list
def leftInfo_area(): rightInfo_layout = pm.rowColumnLayout(nr=1) # ral=[[1, 'right'], [2, 'right']] global refresh_btn refresh_btn = pm.button(l='Refresh', al='center', w=150, h=45, bgc=primary_componentColor, c=refreshWindow, ann='Refresh the interface when lights are deleted or not showing up') # NOT CONNECTED pm.setParent(info_layout)
def gui(): ''' # gui for the script ''' win = 'rigid_body_win' if pm.window(win, exists= True): pm.deleteUI(win) if pm.windowPref(win, exists= True): pm.windowPref(win, remove= True) global obj_scroll_list, name_field, tab_layout my_win = pm.window(win, title= 'BAKE', toolbox= True, width= 300) tab_layout = pm.tabLayout() ui_creator = pm.columnLayout(adjustableColumn= False) name_field = pm.textFieldGrp(label = 'System Name', text= 'Name', columnWidth2= [145, 150]) obj_scroll_list = pm.textScrollList(width= 300, height= 200, allowMultiSelection= True) pm.rowColumnLayout(nc=3, columnWidth= ([1,100], [2,100], [1,100])) pm.button(label= 'Load', command= pm.Callback(load_objects), width= 100) pm.button(label= '+', command= pm.Callback(add_objects), width= 100) pm.button(label= '-', command= pm.Callback(remove_objects), width= 100) pm.setParent('..') pm.button(label= 'Create Baking System', height= 50, width= 300, command= pm.Callback(create_baking_system)) pm.tabLayout( tab_layout, edit=True, tabLabel=((ui_creator, 'Setup'))) my_win.show()
def create(self): self.checkBox = pm.checkBox(label = 'Modify Weighting', onCommand = pm.Callback(self.editFields), offCommand = pm.Callback(self.editFields) ) self.antiField = pm.intFieldGrp( numberOfFields=2, label='Antialias/Noise Quality', extraLabel = 'Weight %' , value2 = 45 , enable1 = False , enable2 = False, changeCommand=pm.Callback(self.updateTotal)) self.compField = pm.intFieldGrp( numberOfFields=2, label='Composition/Focal Length', extraLabel = 'Weight %' , value2 = 45 , enable1 = False , enable2 = False ,changeCommand=pm.Callback(self.updateTotal)) self.proField = pm.intFieldGrp( numberOfFields=2, label='Professionalism', extraLabel = 'Weight %' ,value2 = 10 ,enable1 = False , enable2 = False, changeCommand=pm.Callback(self.updateTotal)) self.lateField = pm.intFieldGrp( numberOfFields=1, label='Late Deduction' , changeCommand=pm.Callback(self.updateTotal)) self.totalField = pm.intFieldGrp( numberOfFields=1, label='Total Grade',enable1 = False, changeCommand=pm.Callback(self.updateTotal)) # attaching the controls pm.formLayout( self.layout, edit=1, attachForm=[[self.checkBox, "left", 140], [self.checkBox, "top", 5]]) pm.formLayout( self.layout, edit=1, attachOppositeControl=[[self.antiField ,"top", 40, self.checkBox], [self.antiField, "right", 10, self.checkBox]]) pm.formLayout( self.layout, edit=1, attachOppositeControl=[[self.compField ,"top", 40, self.antiField], [self.compField, "right", 10, self.antiField]]) pm.formLayout( self.layout, edit=1, attachOppositeControl=[[self.proField ,"top", 40, self.compField], [self.proField, "right", 10, self.compField]]) pm.formLayout( self.layout, edit=1, attachOppositeControl=[[self.lateField ,"top", 40, self.proField], [self.lateField, "left", 0, self.proField]]) pm.formLayout( self.layout, edit=1, attachOppositeControl=[[self.totalField ,"top", 40, self.lateField], [self.totalField, "left", 0, self.lateField]]) pm.setParent(self.columnLayout) pm.text(label = '') self.warning = pm.text(label='') pm.text(label = '') #pm.button( label = 'Output Grade and Comment' , width = 480) return None
def show( reset=False ): if pm.about(batch=True): print 'menu not available in batch mode.' return else: # -- get things ready for building the menu menu_name = "Impress Example" pm.setParent( MAYA_WINDOW ) if pm.menu( menu_name, exists=True ): if reset: pm.deleteUI( menu_name ) else: main_menu = pm.menu( menu_name, edit=True ) return main_menu if not pm.menu( menu_name, exists=True ): main_menu = pm.menu( menu_name, tearOff=True ) # -- build the menu with main_menu: with pm.subMenuItem( 'Display', aob=True, tearOff=True ): ui.commandMenuItem( performExample )
def __init__(self, template): self.template = template self.win = "arnold_filter_list_win" if pm.window(self.win, exists=True): pm.deleteUI(self.win) pm.window(self.win, title="Add Light Filter", sizeable=False, resizeToFitChildren=True) #pm.windowPref(removeAll=True) pm.columnLayout(adjustableColumn=True, columnOffset=("both", 10), #columnAttach=('both',1), rowSpacing=10) self.scrollList = pm.textScrollList('alf_filter_list', nr=4, ams=False) pm.textScrollList(self.scrollList, e=True, doubleClickCommand=Callback(self.addFilterAndHide)) for label, nodeType in self.filters(): pm.textScrollList(self.scrollList, edit=True, append=label) pm.rowLayout(numberOfColumns=2, columnAlign2=("center", "center")) pm.button(width=100, label="Add", command=Callback(self.addFilterAndHide)) pm.button(width=100, label="Cancel", command=Callback(pm.deleteUI, self.win, window=True)) pm.setParent('..') pm.setParent('..') pm.showWindow(self.win)
def createUI(): global m2uwin if m2uwin is not None: pm.deleteUI(m2uwin, window=True) v = m2u.getVersion() m2uwin = pm.window( title="m2u "+v+" (maya)", iconName='m2u', widthHeight=(150, 300) ) pm.columnLayout() pm.rowLayout(numberOfColumns = 2) pm.button( label='Connect', c=cbConnect ) pm.button( label='Setup Cameras', c=cbSetupCamera ) pm.setParent('..') pm.checkBox( label='Sync Camera', onc = cbSyncCamera, ofc = cbSyncCameraOff, v = False) pm.checkBox( label='Sync Objects', onc = cbSyncObjects, ofc = cbSyncObjectsOff, v = False) pm.checkBox( label='Sync Visibility', onc = cbSyncVisibility, ofc = cbSyncVisibilityOff, v = False) pm.separator() pm.button( label='Fetch Selected', c = cbFetchSelected) pm.button( label='Send Selected To Editor', c = cbSendSelectedToEd) #pm.button( label='Import Content Test', c = cbUDKImportContent) pm.setParent( '..' ) pm.showWindow( m2uwin )
def initialiseLayout(self): #======================================================================= # Define Top Level Layout #======================================================================= self.widgets['top_level_layout'] = pm.verticalLayout(ratios=[2,1]) #======================================================================= # Define Reorder Buttons Layout #======================================================================= pm.setParent(self.widgets['top_level_layout']) self.widgets['reorder_buttons_layout'] = pm.horizontalLayout() self.widgets['button_top'] = pm.button(label='TOP' ,command=self.attr_top_cmd) self.widgets['button_up'] = pm.button(label='UP' ,command=self.attr_up_cmd) self.widgets['button_dn'] = pm.button(label='DN' ,command=self.attr_dn_cmd) self.widgets['button_bot'] = pm.button(label='BOT' ,command=self.attr_bot_cmd) #======================================================================= # Define Reorder Buttons Layout #======================================================================= pm.setParent(self.widgets['top_level_layout']) self.widgets['separator_layout'] = pm.horizontalLayout(ratios=[1,2,1]) self.widgets['separator_text'] = pm.text('Separator :') self.widgets['separator_name'] = pm.textField() self.widgets['button_separator'] = pm.button(label = "Add", command=self.add_separator_cmd) #======================================================================= # Redistribute #======================================================================= self.widgets['reorder_buttons_layout'].redistribute() self.widgets['separator_layout'].redistribute() self.widgets['top_level_layout'].redistribute()
def _buildWidgets( self, parent ): for field in self.optionmodel.fields: pm.setParent( parent ) if hasattr( field, 'updateWidget'): field.buildWidget( changeCommand=lambda * args: ( self._updateOptions(), self._updateWidgets() ) ) elif hasattr( field, 'buildWidget'): field.buildWidget()
def UI_custom(self): numJoints = len(self.jointInfo) pm.rowLayout(numberOfColumns = 2, columnWidth = [1, 100], adjustableColumn = 2) pm.text(label = "Number of Joints: ") self.numberOfJointsField = pm.intField(value = numJoints, minValue = 2, changeCommand = self.ChangeNumberOfJoints) pm.setParent('..') joints = self.GetJoints() self.CreateRotationOrderUIControl(joints[0]) pm.separator(style = 'in') pm.text(label = "Orientation: ", align = "left") pm.rowLayout(numberOfColumns = 3) pm.attrEnumOptionMenu(attribute = "%s:module_grp.sao_local" %self.moduleNamespace, label = "Local: ") pm.text(label = " will be oriented to ") pm.attrEnumOptionMenu(attribute = "%s:module_grp.sao_world" %self.moduleNamespace, label = "World: ") pm.setParent('..') pm.separator(style = 'in') interpolating = False if pm.objExists("%s:interpolation_container" %self.moduleNamespace): interpolating = True pm.rowLayout(numberOfColumns = 2, columnWidth = [1, 80], adjustableColumn = 2) pm.text(label = "Interpolate: ") pm.checkBox(label = "", value = interpolating, onCommand = partial(self.SetupInterpolation, True), offCommand = self.DeleteInterpolation)
def gui(): ''' creates the gui for the tool ''' win = 'uvtools' if(pm.window(win, ex = True)): pm.deleteUI(win) if(pm.windowPref(win, ex = True)): pm.windowPref(win, remove = True) global scroll_list, dyn_uis myWin = pm.window(win, title='Anim UV Tool' , sizeable = True, mnb = True, width = 500, height = 400, backgroundColor= [.68,.68,.68]) pm.scrollLayout(width= 500) pm.button(label= 'Creates Nodes', command= create_nodes, width= 500) row_layout = pm.rowColumnLayout(numberOfColumns= 3, columnWidth= [[1, 150], [2, 10], [3, 340]]) pm.columnLayout(adjustableColumn= False, width=150) scroll_list = pm.textScrollList(width= 150, height= 200, selectCommand= pm.Callback(create_ui)) pm.button(label= 'List Nodes', command= list_nodes, width= 148) pm.setParent(row_layout) pm.text(label= '') dyn_uis = pm.columnLayout(adjustableColumn= False, width= 340) # listing the nodes at start up list_nodes() myWin.show()
def createSliderObj( self ): """ creates a Slider Element """ # control=str(mel.scriptedPanel(self.__name__, # q=1,control=1)) # mel.setParent(control) # mel.setParent(self.panelUIpath) if mel.scrollLayout(self._scrollField, ex=True): # mel.setParent(control+'|'+self._scrollField+'|'+self._rowColumn) mel.setParent( self._ActionCol) mel.separator(h=10,style="none") ObjUIpath = mel.frameLayout(mw=10,l="Sliders") mel.columnLayout('sampleCol',adj=True) mel.separator(h=10,style="none") mel.floatSliderGrp('fsg1',v=self.gSampleState['fsg1'], l="Property A",f=True) mel.floatSliderGrp('fsg2',v=self.gSampleState['fsg2'], l="Property B",f=True) mel.floatSliderGrp('fsg3',v=self.gSampleState['fsg3'], l="Property C",f=True) mel.separator(h=10,style="none") # mel.setParent('..') # mel.setParent('..') return ObjUIpath
def populate_namespace_horizontal(self): pm.setParent(self.widgets["namespace_horizontal"]) pm.text(label='Namespace : ') self.widgets["nameSpace_textField"] = pm.textField() pm.button(label='Select', c=pm.Callback(self.load_selected_object)) self.widgets["namespace_horizontal"].redistribute()
def SetParentMenuLayout(parentMenuLayout): """ Sets the given menu layout instance to be the parent of any subsequently created menu items. :param parentMenuLayout: PyMel menu reference. """ if(not IsCurrentMenuParent(parentMenuLayout)): pm.setParent(parentMenuLayout, menu=True)
def show(): UI_Name = "Path_Tracker_Win" if pm.window(UI_Name, ex=1): pm.deleteUI(UI_Name) window = pm.window(UI_Name, title=u"特效轨迹导出工具") pm.columnLayout(adjustableColumn=True) pm.button(label=u'生成跟随面片', command=generateFollowPlane) pm.button(label=u'导出', command=exportPlane) pm.setParent('..') pm.showWindow(window)
def zFileSwitchRefreshNew(attr): # Is there a less dumb way to align the button sensibly? pm.rowLayout(nc=5, cl5=("center", "center", "center", "center", "center")) pm.text(label='') pm.button('refreshFileSwitch', label='Refresh') pm.text(label='') pm.text(label='') pm.text(label='') pm.setParent('..') zFileSwitchRefreshReplace(attr)
def buildFromSelection(self, *args): logWin = pm.window(title="Shifter Build Log", iconName='Shifter Log') pm.columnLayout(adjustableColumn=True) pm.cmdScrollFieldReporter(width=800, height=500, clr=True) pm.button(label='Close', command=('import pymel.core as pm\npm.deleteUI(\"' + logWin +'\", window=True)')) pm.setParent('..') pm.showWindow(logWin) rigging.beam.logInfos() rg = shifter.Rig() rg.buildFromSelection()
def loadMenu_recursive(menuXml, menuName): if menuXml.nodeType == 1: nodename = menuXml.nodeName nodetype = menuXml.attributes["type"].value if nodetype == 'subMenu': name = menuXml.attributes["name"].value pm.menuItem(parent=menuName, subMenu=True, tearOff=True, label=name) for child in menuXml.childNodes: loadMenu_recursive(child, menuName) pm.setParent('..') if nodetype == 'command': name = menuXml.attributes["name"].value comment = menuXml.attributes["comment"].value commandExe = menuXml.attributes["cmd"].value mode = menuXml.attributes["mode"].value option = menuXml.attributes["option"].value if option == 'False': option = False else: option = True cmd_option = menuXml.attributes["cmd_option"].value cmd = commandExe.encode('latin-1', 'replace') if mode == 'mel': commandExe = ('pm.mel.eval(\'' + cmd + '\')') pm.menuItem(label=name, command=commandExe, annotation=commandExe) if option: pm.menuItem(label=name, command=commandExe, annotation=commandExe, optionBox=option) if mode == 'python': pm.menuItem(label=name, command=commandExe, annotation=commandExe) if option: pm.menuItem(label=name, command=cmd_option, annotation=commandExe, optionBox=option) if nodetype == 'separator': pm.menuItem(divider=True)
def create(self, parent): layout = OpenMayaUI.MQtUtil.fullName(long(ui_wrapper.unwrapinstance(parent))) pm.setParent(layout) self.panel = pm.windows.modelPanel( self.set_name(20), label='IndividualModelPanel', parent=layout ) self.set_model_panel_options() self.hide_bar_layout() self.hide_menu_bar() camera = self.get_camera() self.set_camera(self.panel, camera)
def list_ibls(*args): ''' # this list all the ibl's in the scene # and creates the ui for each ibl # most likely there will only be one ''' pm.setParent(ibl_layout) ibls = pm.ls(exactType='mentalrayIblShape') for ibl in ibls: ibl_ui = lights.IBL_UI(ibl).create()
def create_window(): window_name = 'PerforceDialog' if pm.window(window_name, exists=True): pm.deleteUI(window_name) window = pm.window(window_name, t=window_name, widthHeight=(400, 100)) pm.columnLayout(adjustableColumn=True) pm.text("Command") pm.textField("Command") pm.button("Enter P4 Command", command=perform_p4_command) pm.setParent('..') pm.showWindow(window)
def _build_program_settings_frame(parent_layout): program_settings_frame = pm.frameLayout(label="Program Settings", collapsable=True) # Create Form Layout with embedded Tab Layout program_settings_form = pm.formLayout() program_settings_tab_layout = pm.tabLayout('program_settings_tab_layout') pm.formLayout(program_settings_form, edit=True, attachForm=[(program_settings_tab_layout, "top", 3), (program_settings_tab_layout, "bottom", 3), (program_settings_tab_layout, "left", 3), (program_settings_tab_layout, "right", 3)]) general_settings_tab_layout = _build_general_settings_tab(program_settings_tab_layout) proc_options_tab_layout = _build_proc_options_tab(program_settings_frame) tabs = [[general_settings_tab_layout, 'General'], [proc_options_tab_layout, 'Advanced']] assign_tabs(tabs, program_settings_tab_layout) program_settings_col = pm.columnLayout(adj=True, columnAttach=['both', 3]) # Output options pm.checkBox('cb_overwriteFile', label="Overwrite existing file", value=postproc_config.OPTS_OVERWRITE_EXISTING_FILE, annotation='If checked, an existing file with the input ' \ 'output name will be overwritten') pm.checkBox('cb_ignoreWarnings', label="Ignore warnings", value=postproc_config.OPTS_IGNORE_WARNINGS, annotation='If checked, all warnings will be ignored and ' \ 'a program will be written') pm.separator(height=3, style='none') pm.separator(height=3, style='none') pm.button('Check Program', command=mimic_program.check_program, height=25, annotation='Evalutes if program violates any physical ' \ 'robot parameters like speed limits') pm.button('Save Program', command=mimic_program.save_program, height=25, annotation='Saves robot control program with input parameters') pm.separator(height=3, style='none') export_progress_bar = pm.progressBar('pb_exportProgress', maxValue=100, visible=0) pm.setParent(parent_layout)
def mantraMainMenu(): log.debug("Creating mantra main menu") menuName = "Mantra" if pm.menu(menuName, query=True, exists=True): pm.deleteUI(menuName) gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow') mantraMenu = pm.menu(menuName, label = menuName, parent = gMainWindow, tearOff = True ) pm.menuItem( label = 'AttributeManager', command = Callback(menuCallback, "AttributeManager") ) pm.menuItem( label = 'DummyMenu' , command = Callback(menuCallback, "Dummy") ) pm.menuItem( label = '', divider = True ) pm.menuItem( label = 'DummyMenuA' , command = Callback(menuCallback, "DummyA") ) pm.setParent("..", menu = True)
def lightLst(self, *args): butLayout = pm.rowColumnLayout(numberOfColumns=1, columnWidth=[(10,120)], columnOffset=[10,"right",5]) totalLgt = 0 lis = pm.ls(type='light') pm.button('buttonMain',label="UPDATE", e= True ,command = lambda * args: self.update(totalLgt,lis, butLayout )) #list all lights in scene for lgt in lis: totalLgt += 1 nameLgt = lgt.longName() name = nameLgt.split("|")[1] self.updateList(name, lgt, totalLgt) pm.setParent('..')
def install(): """Install Skinning submenu """ pm.setParent(mgear.menu_id, menu=True) pm.menuItem(divider=True) commands = ( ("Anim Picker", str_open_picker_mode), ("-----", None), ("Edit Anim Picker", str_open_edit_mode) ) mgear.menu.install("Anim Picker", commands)
def asset_widget(self, current_parent, asset_name): ''' Single asset widget. ''' self.main = pm.frameLayout(labelVisible=False, parent=current_parent) self.form = pm.formLayout() # Creating Components self.asset_image = pm.button(width=48, height=48) self.asset_text = pm.text(height=48, width=125, align='left', label=asset_name) self.asset_low = pm.button(height=26, width=75, label='Low', command=pm.Callback(self.reference_asset, 'low')) self.asset_med = pm.button(height=26, width=75, label='Medium', command=pm.Callback(self.reference_asset, 'medium')) self.asset_high = pm.button(height=26, width=75, label='High', command=pm.Callback( self.reference_asset, 'high')) # Positioning Components. # Symbol Button self.form.attachForm(self.asset_image, 'top', 5) self.form.attachForm(self.asset_image, 'left', 5) # asset text self.form.attachForm(self.asset_text, 'top', 5) self.form.attachForm(self.asset_low, 'top', 15) self.form.attachForm(self.asset_med, 'top', 15) self.form.attachForm(self.asset_high, 'top', 15) self.form.attachControl(self.asset_text, 'left', 15, self.asset_image) # form.attachControl(asset_text, 'right', 5, asset_low) self.form.attachControl(self.asset_low, 'left', 5, self.asset_text) self.form.attachControl(self.asset_med, 'left', 5, self.asset_low) self.form.attachControl(self.asset_high, 'left', 5, self.asset_med) self.form.attachForm(self.asset_high, 'right', 5) self.form.attachForm(self.asset_image, 'bottom', 5) # res buttons # Return parent to orginal layout pm.setParent(current_parent)
def add_ldt_menus(): """Add Look dev Tools menus to dccs.""" from ldt import context dcc = context.dcc() if dcc == 'Maya': import pymel.core as pm if pm.menu('LookDevTools', l=u'LookDevTools', ex=True): logger.info('menu already exists.') else: pm.menu('LookDevTools', l=u'LookDevTools', to=True) pm.menuItem(l=u'Open', c='import ldt;reload(ldt)') pm.setParent("..")
def displayDialog(self, txet=None): ''' @text : str , This is the text is error result ''' window = pm.window(t="outcome display", widthHeight=(200, 70)) pm.columnLayout(adjustableColumn=True) cmds.text('') txetList = txet.split(' ') for s in txetList: cmds.text(label=s, align='center') pm.setParent('..') pm.showWindow(window)
def update_shelf_top_menu(menu): """ Populate the shelves menu with one menu item per shelf tab. """ # Clear the menu so it can be repopulated. pm.setParent(menu, menu=True) pm.menu(menu, e=True, deleteAllItems=True) shelves = Shelf.get_shelves() for shelf in shelves: create_shelf_button_menu(shelf, menu)
def bug_report_window(self): ''' ''' windowName = 'bugWindow' w = 400 h = 330 if pm.control(windowName, exists=True): pm.deleteUI(windowName) bug_window = pm.window(windowName, t="Bug Report / Contact", widthHeight=[w, h], rtf=False, mnb=False, mxb=False, s=False, toolbox=True) pm.columnLayout(w=w, cw=w, cal='center') wM = (w - 30) pm.rowColumnLayout(nc=3, cw=([1, 15], [2, wM], [3, 15])) pm.text(l='', w=15) pm.columnLayout(w=wM, cw=wM, cal='center') pm.text(l='Message or Bug:', w=wM, h=30, al='left', font='boldLabelFont') message_text = pm.scrollField(w=wM, wordWrap=True) pm.text(l='Email Address (Optional, if you want a reply):', w=wM, h=30, al='left', font='boldLabelFont') email_address = pm.textField(w=wM) pm.setParent('..') pm.text(l='', w=15) pm.setParent('..') pm.separator(style='none', h=12, w=wM) cwA = 10 cwB = (w / 2) - (1.5 * cwA) pm.rowColumnLayout(nc=5, cw=([1, cwA], [2, cwB], [3, cwA], [4, cwB], [5, cwA])) pm.text(l='', w=cwA) pm.button('bug_send', l='Send', w=cwB, h=25, command=lambda *args: self.bug_report_send(windowName, pm.textField( email_address, query=True, text=True), pm.scrollField( message_text, query=True, text=True))) pm.text(l='', w=cwA) pm.button('bug_cancel', l='Cancel', w=cwB, h=25, command=lambda *args: pm.deleteUI(windowName)) pm.text(l='', w=cwA) bug_window.show() pm.window(bug_window, edit=True, h=h, w=(w + 2))
def createArnoldAOVTab(): parentForm = cmds.setParent(query=True) aovNode = aovs.AOVInterface() pm.columnLayout('enableAOVs', adjustableColumn=True) pm.setUITemplate('attributeEditorTemplate', pushTemplate=True) pm.attrControlGrp(attribute=aovNode.node.aovMode, label='Mode') # the tab gets recreated from scratch each time rather than updated and each # time the AOVOptionMenuGrp adds itself to the AOVChanged callback list. # we must remove it or we'll leave behind invalid copies global _aovDisplayCtrl if _aovDisplayCtrl is not None: aovs.removeAOVChangedCallback(_aovDisplayCtrl.update) _aovDisplayCtrl = shaderTemplate.AOVOptionMenuGrp('aiOptions', 'displayAOV', label='Render View AOV', allowCreation=False, includeBeauty=True, allowEmpty=False, allowDisable=False) _aovDisplayCtrl._setToChildMode() _aovDisplayCtrl._doSetup(aovNode.node.name() + '.displayAOV') pm.setParent(parentForm) cmds.scrollLayout('arnoldAOVsScrollLayout', horizontalScrollBarThickness=0) cmds.columnLayout('arnoldTabColumn', adjustableColumn=True) ed = ArnoldAOVEditor(aovNode) cmds.formLayout(parentForm, edit=True, af=[('enableAOVs', "top", 5), ('enableAOVs', "left", 0), ('enableAOVs', "right", 0), ('arnoldAOVsScrollLayout', "bottom", 0), ('arnoldAOVsScrollLayout', "left", 0), ('arnoldAOVsScrollLayout', "right", 0)], an=[('enableAOVs', "bottom")], ac=[('arnoldAOVsScrollLayout', "top", 5, 'enableAOVs')]) pm.setUITemplate('attributeEditorTemplate', popTemplate=True) cmds.setParent(parentForm) pm.evalDeferred(ed.fixOptionMenus) ed.setEnabledState() pm.scriptJob(attributeChange=(aovNode.node.aovMode, ed.setEnabledState), parent=ed.mainCol)
def build_prefs_tab(parent_layout): # Create preferences tab Layout prefs_tab_layout = pm.columnLayout('prefs_tab_layout', height=525, adj=True, width=200) # Hotkeys frame _build_hotkeys_frame(prefs_tab_layout) # UI frame _build_ui_prefs_frame(prefs_tab_layout) pm.setParent(parent_layout) return prefs_tab_layout
def mantraMainMenu(): log.debug("Creating mantra main menu") menuName = "Mantra" if pm.menu(menuName, query=True, exists=True): pm.deleteUI(menuName) gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow') mantraMenu = pm.menu(menuName, label=menuName, parent=gMainWindow, tearOff=True) pm.menuItem(label='Create Geo Standin', command=pm.Callback(menuCallback, "GeoStandin")) pm.setParent("..", menu=True)
def _set_parent_layout(): """ Run a with block with our layout set as the UI parent. If the UI parent doesn't exist, the block won't be executed. """ if not pm.window(pm.mel.globals['gPreferenceWindow'], exists=True): return if pm.columnLayout(_layout_name, q=True, numberOfChildren=True) == 0: return pm.setParent(_layout_name) yield
def create_window(self): window = "ARExporter" if pm.window(window, ex=True): pm.deleteUI(window) pm.window(window, t=u"ARExporter %s" % manager_version, mb=True, cc=lambda *args: self._closed_window_cmd()) pm.formLayout("ExportUIMainLayout") pm.setParent("ExportUIMainLayout") pm.showWindow(window) return window
def SJ_furDisplaySwitchwdUI(): if pm.window('furdisplay',ex=True): pm.deleteUI('furdisplay',wnd=True) pm.window('furdisplay',t='furDisplayToolV2.1') pm.columnLayout(adj=True) pm.text(l='毛发显隐V2.1',fn='fixedWidthFont',h=50,annotation="更新说明V2.1:增加hair和yeti混合情况的显隐切换",w=80) pm.flowLayout( columnSpacing=0) pm.checkBox("allsw" ,label='切换所有yeti毛发显隐',ann="",h=50,w=140) pm.checkBox("all" ,label='强制所有毛发显示 \n(最终提交渲染模式)',ann="",h=50,w=130) pm.setParent( '..' ) pm.button(l='yeti毛发显隐切换',c=yetidisplays,h=50,w=80,ann="默认操作为切换选中目标显隐(无需选毛发节点,框选到控制器即可)!!") pm.showWindow()
def create_buttons(self): ''' # this initatializes a Lambert_object_button object for each object with a default lambert ''' for obj in self.lambert_objs: pm.setParent(self.buttons_layout) button = Lambert_object_button(obj) pm.setParent(self.layout) pm.button(label='Select All', command=pm.Callback(self.select_all), height=50)
def source_attr_list_column(self): pm.columnLayout(adj=1, rs=5) pm.text(label=u"Source Object:", al="left") pm.textField("sourceObjectField", w=250) pm.textScrollList("sourceObjectAttrScrollList", sc=lambda *args: self.print_selected_item( widget="sourceObjectAttrScrollList")) pm.button("loadSourceBtn", label=u"Load Object", c=lambda *args: self.load_controller( widget="sourceObjectField", extra_widget="sourceObjectAttrScrollList")) pm.setParent("..")
def getLayerDisplayType(): """ get current layer type in layer editor :return: `string` layer type ("Display", "Render", "Anim") """ gCurrentLayerEditor = pm.melGlobals["gCurrentLayerEditor"] pm.setParent(gCurrentLayerEditor) type = mel.eval("tabLayout -query -selectTab DisplayLayerUITabLayout") return { "DisplayLayerTab": "Display", "RenderLayerTab": "Render", "AnimLayerTab": "Anim" }[type]
def addRows(self): for aovName, aovList in self.renderOptions.getAOVs(group=True): frame = pm.frameLayout(collapsable=False, labelVisible=False) col = pm.columnLayout(adj=True) rows = [] for aov in aovList: row = AOVItem(self, aov) rows.append(row) self.optionMenus.extend(row.getMenus()) self.aovRows[aov.name] = rows self.aovControls.append(frame) pm.setParent('..') pm.setParent('..')
def randomizer_createUserInterface(): """-------------------------------------------------------------------------- Create User Interface Procedure --------------------------------------------------------------------------""" pm.window('randomizer_window', s=0, rtf=0, t="randomizer", wh=(300, 700)) # Create UI elements pm.columnLayout('mainColumnLayout', h=900, w=248, columnAlign="center", adjustableColumn=1) pm.separator('selectedTransformObjectsSeparator', h=10, w=240, st="none") pm.text('selectedTransformObjectsText', fn="boldLabelFont", h=24, l="selected transform Objects", w=240, al="center") pm.textScrollList('selectedTransformObjectsTextScrollList', h=80, w=240) pm.button('loadObjectsButton', h=28, c=lambda *args: randomizer_loadSelection(0), l="load transform Objects", w=240) pm.separator('selectedMaterialsSeparator', h=10, w=240, st="none") pm.text('selectedMaterialsText', fn="boldLabelFont", h=24, l="selected Materials", w=240, al="center") pm.textScrollList('selectedMaterialsTextScrollList', h=80, w=240) pm.button('loadMaterialsButton', h=28, c=lambda *args: randomizer_loadSelection(1), l="load Materials", w=240) pm.separator('transformAttributesSeparator', h=10, w=240, st="none") pm.text('randomizeAttributesText', fn="boldLabelFont", h=24, l="randomize Attributes", w=240, al="center") pm.checkBoxGrp('randomizeAttributesCheckBoxGrp', h=24, l4="Material", l2="Rotate", l3="Scale", w=240, l1="Translate", ncb=4, cw=[(1, 67), (2, 57), (3, 50), (4, 57)]) pm.separator('translateAttributesSeparator', h=10, w=240, st="none") pm.text('translateText', fn="boldLabelFont", h=24, l="Translate", w=240, al="center") pm.floatFieldGrp('minMaxXtranslateFloatFieldGrp', pre=3, el="max X", bgc=(0.25, 0, 0), h=24, l="min X", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxYtranslateFloatFieldGrp', pre=3, el="max Y", bgc=(0, 0.25, 0), h=24, l="min Y", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxZtranslateFloatFieldGrp', pre=3, el="max Z", bgc=(0, 0, 0.25), h=24, l="min Z", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.separator('rotateAttributesSeparator', h=10, w=240, st="none") pm.text('rotateText', fn="boldLabelFont", h=24, l="Rotate", w=240, al="center") pm.floatFieldGrp('minMaxXrotateFloatFieldGrp', pre=3, el="max X", bgc=(0.25, 0, 0), h=24, l="min X", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxYrotateFloatFieldGrp', pre=3, el="max Y", bgc=(0, 0.25, 0), h=24, l="min Y", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxZrotateFloatFieldGrp', pre=3, el="max Z", bgc=(0, 0, 0.25), h=24, l="min Z", nf=2, v1=0, v2=0, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.separator('scaleAttributesSeparator', h=10, w=240, st="none") pm.text('scaleText', fn="boldLabelFont", h=24, l="Scale", w=240, al="center") pm.floatFieldGrp('minMaxXscaleFloatFieldGrp', pre=3, el="max X", bgc=(0.25, 0, 0), h=24, l="min X", nf=2, v1=1, v2=1, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxYscaleFloatFieldGrp', pre=3, el="max Y", bgc=(0, 0.25, 0), h=24, l="min Y", nf=2, v1=1, v2=1, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.floatFieldGrp('minMaxZscaleFloatFieldGrp', pre=3, el="max Z", bgc=(0, 0, 0.25), h=24, l="min Z", nf=2, v1=1, v2=1, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.separator('randomizeSelectionSeparator', h=10, w=240, st="none") pm.button('randomizeAbsoluteButton', h=28, c=lambda *args: randomizer_randomizeSelection(), l="randomize Abolute", w=240) pm.button('randomizeRelativeButton', h=28, c=lambda *args: randomizer_randomizeSelection(relative=True), l="randomize Relative", w=240) pm.separator('timeAttributesSeparator', h=10, w=240, st="none") pm.text('timeText', fn="boldLabelFont", h=24, l="Time", w=240, al="center") pm.intFieldGrp('minMaxTimeIntFieldGrp', el="max", bgc=(0, 0, 0), h=24, l="min", nf=2, v1=-1, v2=1, w=240, cw=[(1, 60), (2, 60), (3, 60), (4, 60)]) pm.button('setUniformKeyframe', h=28, c=lambda *args: rand_Keyframe(objects=None, attribute="all", axis=["X", "Y", "Z"], uniform=True, min=-10, max=10, step=1), l="Set Keyframes uniform", w=240) pm.button('setRandomKeyframe', h=28, c=lambda *args: rand_Keyframe(objects=None, attribute="all", axis=["X", "Y", "Z"], uniform=False, min=-10, max=10, step=1), l="Set Keyframes random", w=240) pm.separator('undoSeparator', h=10, w=240, st="none") pm.button('undoButton', h=28, c=lambda *args: pm.undo(), l="undo", w=240) pm.iconTextButton('staschiIconTextButton', h=28, c=lambda *args: randomizer_loadHelpWebsite(), l="www.staschi.com", w=240, st="textOnly") pm.setParent('..') pm.setParent('..') # Display UI pm.showWindow('randomizer_window')
def build_mimic_ui(): """ Builds main mimic UI and defines relationships between UI buttons/features and back-end functions :return: """ mimic_win = create_mimic_window('mimic_win') # Create Main UI column pm.columnLayout(width=244, adj=True) # Add UI Header Image. robotImage = pm.image(image='mimic_logo.png', width=244, height=60) mimic_tab_layout = create_mimic_tabs() animate_tab_layout = build_animate_tab(mimic_tab_layout) program_tab_layout = build_program_tab(mimic_tab_layout) setup_tab_layout = build_setup_tab(mimic_tab_layout) external_tab_layout = build_external_tab(mimic_tab_layout) prefs_tab_layout = build_prefs_tab(mimic_win) tabs = [(animate_tab_layout, "Animate"), (program_tab_layout, "Program"), (setup_tab_layout, "Setup"), (external_tab_layout, "External"), (prefs_tab_layout, "Prefs")] assign_tabs(tabs, mimic_tab_layout) # Create output column outputColumn = pm.columnLayout('outputColumn', width=7, adj=True) outputForm = pm.formLayout() outputScrollField = pm.scrollField('programOutputScrollField', width=3, height=610) pm.formLayout(outputForm, edit=True, attachForm=[(outputScrollField, "top", 3), (outputScrollField, "bottom", 3), (outputScrollField, "left", 3), (outputScrollField, "right", 3)]) pm.setParent(mimic_win) pm.columnLayout('outputBarColumn', width=7) pm.separator(height=1, style='none') bullets = '\n'.join([unichr(0x2022) for _ in range(3)]) pm.text(bullets, align='left', annotation='Drag edge to view Output Window!') # Launch UI window pm.window('mimic_win', height=560, width=245, edit=True) mimic_win.show()
def make_shelf_icon(name, icon_path, command_str, source_type="python", annotation=None): """ make an icon on the current shelf Args: name (str): the string name for this shelf item icon_path (str): the path to the image to use for the shelf item command_str (str): the command to run when pressing this shelf item source_type (str): the type of command, mel or python annotation (str): the tool-tip annotation to display on hovering over this shelf item Returns: returns the button just created """ # type: (str, str, str, str, str) -> pm.uitypes.ShelfButton icon_path = os.path.normpath(icon_path) # Maya requires all paths to be forward slash for internal use if platform.system().startswith("Win"): icon_path = icon_path.replace("\\", "/") try: current_shelf = pm.uitypes.ShelfLayout( pm.mel.eval('tabLayout -q -st $gShelfTopLevel;')) for item in [ x for x in current_shelf.getChildren() if isinstance(x, pm.uitypes.ShelfButton) ]: if name == item.getLabel(): item.delete() # you must set the active parent before creating shelf buttons or they will be parented under maya's main window pm.setParent(current_shelf) shelf_button = pm.shelfButton(label=name) shelf_button.setSourceType(source_type) shelf_button.setCommand(command_str) shelf_button.setImage(icon_path) if annotation: shelf_button.setAnnotation(annotation) return shelf_button except Exception as e: pm.warning( "Something went wrong making the shelf item: {}\n Exception Msg: {}" .format(name, e.message))
def createMethodInstance(self, i ): #setUITemplate('attributeEditorTemplate', pushTemplate=1) rowSpacing = [30, 20, 400] defs = [] #try: argUtil = factories.ApiArgUtil( self.apiClassName, self.apiMethodName, i ) proto = argUtil.getPrototype( className=False, outputs=True, defaults=False ) enable = argUtil.canBeWrapped() if argUtil.isDeprecated(): pm.text(l='DEPRECATED') # main info row row = pm.rowLayout( '%s_rowMain%s' % (self.methodName,i), nc=3, cw3=rowSpacing, enable=enable ) self.rows.append(row) pm.text(label='') if self.overloadPrecedenceColl is not None: # toggle for overloaded methods pm.radioButton(label='', collection=self.overloadPrecedenceColl, enable = enable, onCommand=pm.Callback( MethodRow.overloadPrecedenceCB, self, i )) pm.text( l='', #l=proto, annotation = self.methodInfoList[i]['doc'], enable = enable) pm.setParent('..') try: argList = factories.apiClassOverrides[self.apiClassName]['methods'][self.apiMethodName][i]['args'] except (KeyError, IndexError): argList = self.methodInfoList[i]['args'] returnType = self.methodInfoList[i]['returnType'] types = self.methodInfoList[i]['types'] args = [] for arg , type, direction in argList: type = str(types[arg]) assert arg != 'return' self._makeArgRow( i, type, arg, direction, self.methodInfoList[i]['argInfo'][arg]['doc'] ) if returnType: self._makeArgRow( i, returnType, 'return', 'return', self.methodInfoList[i]['returnInfo']['doc'] ) pm.separator(w=800, h=14) return enable