2023年12月9日發(fā)(作者:義烏婚慶)

maya的python放在哪_在Maya程序中使用Python創(chuàng)建文件夾
我正在使用操作系統(tǒng)模塊和此函數(shù):import os
def make_dir(path):
"""
input a path to check if it exists, if not, it creates all the path
:return: path string
"""
if not (path):
rs(path)
return path
因此您可以查詢:
^{pr2}$
-編輯-
您應(yīng)該編寫以下內(nèi)容,以便在按下按鈕時(shí)正確地綁定命令以調(diào)用(必須傳遞函數(shù)而不是字符串):# create a function to query your ui
text :
def MakeFolder():
path = eld(tb ,q=True, tx=True)
make_dir(path)
# U the function in command
( label='Button 1', command=MakeFolder)
如果您想在button命令中直接傳遞一些參數(shù),比如'path',那么必須使用lambda或partial(它更高級(jí)一些)。下面是一個(gè)鏈接,其中有一些解
釋:
-編輯-
這里有一個(gè)工作代碼:import as cmds
import os
def make_dir(path):
"""
input a path to check if it exists, if not, it creates all the path
:return: path string
"""
if not (path):
rs(path)
return path
def MakeFolder(*args):# always put *args to function inside ui command flag becau maya pass by default one argument TrueurInput = eld('textBox', q=1, tx=1)# you should here verify that this path is validpath = make_dir(urInput)print('{0} has been created'.format(path))()umnLayout( numberOfColumns=2, columnAttach=(1, 'right', 0), columnWidth=[(1, 100), (2, 250)] )( label='Name' )tb = eld('textBox', tx='E:/Andrew/')( label='Button 1', command=MakeFolder )ndow( )請(qǐng)記住,這段代碼避免:傳遞ui元素名稱和避免嵌套變量,通過命令傳遞參數(shù)。在
本文發(fā)布于:2023-12-09 21:28:52,感謝您對(duì)本站的認(rèn)可!
本文鏈接:http://www.newhan.cn/zhishi/a/1702128532241134.html
版權(quán)聲明:本站內(nèi)容均來自互聯(lián)網(wǎng),僅供演示用,請(qǐng)勿用于商業(yè)和其他非法用途。如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除。
本文word下載地址:maya的python放在哪_在Maya程序中使用Python創(chuàng)建文件夾.doc
本文 PDF 下載地址:maya的python放在哪_在Maya程序中使用Python創(chuàng)建文件夾.pdf
| 留言與評(píng)論(共有 0 條評(píng)論) |