PDA

View Full Version : append to menuItem


spiderman3
05-10-2009, 01:01 PM
Hi i am trying to append some values to menu item to make a dynamic menu but i couldn't any append attribute, can any help me out it appending values to a menuItem

import os
import maya.cmds as cmds

class test:

def __init__(self):
temp=''
pass

def testUI(self):
if cmds.window('cWin',exists=True):
cmds.deleteUI('cWin')
cmds.window('cWin',title="Asset Manager",w=460,h=390,s=0,mb=True)
cmds.menu(l='File')
cmds.menuItem(l='Help')
cmds.menuItem(l='About')
cmds.rowColumnLayout( numberOfColumns=3,cw=[1,200])
# Project settings
cmds.optionMenu('atProjects',l=' Projects')
cmds.menuItem('abc',l='Projects')
cmds.button(l='getProjects',c=self.levelChange)
cmds.window('cWin',e=True,wh=(460,390))
cmds.showWindow('cWin')

def levelChange(self,event):
serverPath = 'f:/server'
avlProjs = os.listdir(serverPath)
projCount = len(avlProjs)
for each in avlProjs:
cmds.menuItem('abc',edit=True,l=each)

tempClass = test()
tempClass.testUI()

safakoner
05-10-2009, 01:16 PM
use parent flag to define the parent of the menuitem.

give a name to your menu (first string)

cmds.menu('MenuTestName', label='Stuff', allowOptionBoxes=True )

then parent menuItem
cmds.menuItem( label='mymenuitemtest', parent = 'MenuTestName' )

spiderman3
05-11-2009, 05:25 PM
hi
thnks a lot for the solution

CGTalk Moderation
05-11-2009, 05:25 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.