나는 사전에 항목을 더 추가하고 필요한 경우 두 번째 단추를 채우는 것을 시도하고 있습니다 !!! 모든 파란색 재생 버튼을 클릭하여 마야 스크립트 편집기에서 코드를 실행에 잘 간다하지만 난 funtest.main()왜 가져 오기로 모듈을 실행할 때 이름 오류가 발생하지만 마야의 스크립트 편집기에서 실행하지 않는 경우
창로드가 잘 funtest이 스크립트를 수입을 가져올 수 있지만, 만약 내가 중 하나를 클릭에 오류가 버튼 ... 그럼 왜 스크립트 편집기에서 코드를 실행하는 것과 다른 것을 가져 오는 것의 차이점이 무엇인지 말해주세요.
내 논리가 틀리거나 틀린가?
import maya.cmds as cmds
dic={}
print("dictionary is empty",dic)
def main():
inst=btnUI()
inst.create()
class btnUI(object):
def __init__(self, winName="winTheWindow"):
self.winTitle = "The Window"
self.winName = winName
def create(self):
if cmds.window(self.winName, exists=True):
cmds.deleteUI(self.winName)
dic['item1']='item1value'
dic['item2']='item2value'
cmds.window(self.winName, title=self.winTitle)
self.mainCol = cmds.columnLayout(adjustableColumn=True)
self.btnA = cmds.button(label='Press Me - External Func',c='outsideFunc(dic)')
self.btnb = cmds.button(label='Populate more items',c='populateDic()')
cmds.showWindow(self.winName)
cmds.window(self.winName, edit=True, widthHeight=[250,75])
def populateDic():
dic['item3']='item3value'
dic['item4']='item4value'
dic['item5']='item5value'
def outsideFunc(dicItems):
print("Outside function, called from inside a class function")
print(dicItems)
if __name__ == '__main__':
main()
왜 \ _ \ _ name \ _ \ _을 (를) 재 할당 하시겠습니까? if \ _ \ _ name \ _ \ _ == '\ _ \ _ main \ _ \ _'은 그런 식으로 결코 사실이 아닙니다. – XORcist
모듈에 이름을 지정하고 싶습니다 !! 그러나 지금은 그것을 고쳤습니다 ... –
두 개의 밑줄 표시된 속성은 특별합니다. 그들과 함께 특별한주의 (RTFM!)해야합니다. – XORcist