PDA

View Full Version : Menu Item's menu not found


DEVILSAN
11-10-2012, 11:07 AM
Hello I feel like I have shot myself on the foot, I usually keep my GUI in one class and logic in different class, so now in the the class
Logic(object):
def __init__(self):
self.favItems={}
if os.path.isdir(self.minimeDir):
if os.path.isfile(self.favFile):
print "Favorite file exists"
try:
read_fav_file=open(self.favFile,"r")
self.favItems=eval(read_fav_file.read())
self.loadMenuItems()
except Exception as err:
print err
finally:
read_fav_file.close()
else:
print "Creating " + self.favFile
try:
output_fav_file=open(self.favFile,"w")
output_fav_file.write(str(self.favItems))
except Exception as er:
print er
finally:
output_fav_file.close()
else:
print "Creating " + self.minimeDir
os.mkdir(self.minimeDir)
def addFavBtn(self,*args):
"""
add favorite project
"""
nam=(cmds.textField('location',q=True,tx=True)).split("\\")[-1]

if nam not in self.favItems:
self.favItems.update({nam:cmds.textField('location',q=True,tx=True)})
cmds.menuItem(label=nam,parent='favMenu')
else:
print "Item already in favorites"

def loadMenuItems(self,*args):
"""
loads all favorite items to menu
"""
print self.favItems," in loadMenuItems"
for eachitem in self.favItems.iterkeys():
cmds.menuItem(label=eachitem, parent='favMenu')

now when I call the loadMenuItem from the costructor of the Logic() i do have the value in self.favItems of dictionary but executing the for loop leads to error saying "Menu Item's menu not found." but in case of the addFavBtn() method I do not get error coz it is called by the button press event from the GUI class and the object gets passed..

the obvious thing is something I need to know that I am not doing it right....

CGTalk Moderation
11-10-2012, 11:07 AM
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.