Before I start I just want to clarify that am quite new to python and programming in general. I still couldn't write a class and don't understand object orientated programming yet.
I am currently writing tools using python for maya.
The problem is I wrote a main UI for my scripts, and everything functioned just fine. However I don't want to copy/paste my script every time I update my UI so I wrote another script to call on my main UI.
import maya.cmds as mc ;
import sys ;
mp = "C:/Users/Administrator/Desktop/script/birdScript20170707" ;
if not mp in sys.path :
sys.path.append ( mp ) ;
import library.mainUI as mui ;
mui.birdMainUI () ;
This is my main UI:
import sys ;
import os ;
import maya.cmds as mc ;
mp = "C:/Users/Administrator/Desktop/script/testPackage" ;
if not mp in sys.path :
sys.path.append ( mp ) ;
import library.mayaLibrary as mlb ;
def printSelfPath( ) :
import general.printSelfPath as psp ;
reload ( psp ) ;
psp.printPath ( ) ;
###############
''' MAIN UI '''
###############
def birdMainUI ( ) :
# check if window exists
if mc.window ( 'birdMainUI' , exists = True ) :
mc.deleteUI ( 'birdMainUI' ) ;
# create window
window = mc.window ( 'birdMainUI', title = "birdMainUI v0.0", width = 200,
mnb = False , mxb = False , sizeable = True , rtf = True ) ;
general = mc.rowColumnLayout ( nc = 1 , cw = ( 1 , 200 ) ) ;
mc.button ( 'print self path' , c = 'printSelfPath( )' ) ;
mc.setParent( '..' ) ;
mc.showWindow ( window ) ;
#birdMainUI () ;
This is the function which the main UI uses:
import os ;
import sys ;
import maya.cmds as mc ;
import maya.mel as ml ;
def printPath ( *args ) :
path = ml.eval ( "file -q -sn" ) ;
print ( path ) ;
The UI appeared but when I click on my UI button this error appeared:
# Error: name 'printSelfPath' is not defined
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# NameError: name 'printSelfPath' is not defined #
I have no idea what is going on. This is my file structure:
This is the package if anyone is interested: https://drive.google.com/file/d/0B9acOuH0SmXsSk9aX0x6Nl9KbTQ/view?usp=sharing
Thank you.