help with python code to beginner

87 views
Skip to first unread message

CGSKOOL Professional Computer Graphics Training

unread,
Feb 19, 2017, 10:48:53 PM2/19/17
to Python Programming for Autodesk Maya
Hi friends i was try to learn python in maya and was find a code but i can't made it work, the error its in the 21 line with srt function, could some people help me with this,i don't k now what else to d, thank you.

somebody know wo it work the srt function?

import maya.cmds as cmds

class TabExample:
    
    def __init__(self):
        
        self.win = cmds.window(title="Tabble layout", wh=(300,300))
        
        self.tabs = cmds.tabLayout()
        
        firstTab = cmds.columnLayout()
        cmds.tabLayout(self.tabs, edit=True, tabLabel=[firstTab, 'simpleTab'])
        cmds.button(label ="button")
        cmds.setParent("..")
        
        newLayout = cmds.scrollLayout()
        cmds.tabLayout(self.tabs, edit=True, tabLabel=[newLayout, 'ScrollingTab'])
        cmds.columnLayout()
        
        for i in range (10):
            cmds.button(label ="button" + srt(i+1))
            
        cmds.setParent("..")
        cmds.setParent("..")
        
        cmds.showWindow(self.win)
            
TabExample()

Justin Israel

unread,
Feb 19, 2017, 11:02:59 PM2/19/17
to python_in...@googlegroups.com
On Mon, Feb 20, 2017 at 4:48 PM CGSKOOL Professional Computer Graphics Training <pablo.val...@gmail.com> wrote:
Hi friends i was try to learn python in maya and was find a code but i can't made it work, the error its in the 21 line with srt function, could some people help me with this,i don't k now what else to d, thank you.

somebody know wo it work the srt function?

In the code example you have provided, there is no definition of a srt() function, but I would assume it is some kind of function that returns a string. This is the reason you are probably seeing an error. You seem to have incomplete code.

In the future if you are having issues with code, it also helps to include an error message so that we can be sure that we are all thinking about the same problem. Are you certain this code example is complete?
 

import maya.cmds as cmds

class TabExample:
    
    def __init__(self):
        
        self.win = cmds.window(title="Tabble layout", wh=(300,300))
        
        self.tabs = cmds.tabLayout()
        
        firstTab = cmds.columnLayout()
        cmds.tabLayout(self.tabs, edit=True, tabLabel=[firstTab, 'simpleTab'])
        cmds.button(label ="button")
        cmds.setParent("..")
        
        newLayout = cmds.scrollLayout()
        cmds.tabLayout(self.tabs, edit=True, tabLabel=[newLayout, 'ScrollingTab'])
        cmds.columnLayout()
        
        for i in range (10):
            cmds.button(label ="button" + srt(i+1))
            
        cmds.setParent("..")
        cmds.setParent("..")
        
        cmds.showWindow(self.win)
            
TabExample()

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7cfbd48b-d319-4900-9d7d-63a32612eb1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

CGSKOOL Professional Computer Graphics Training

unread,
Feb 20, 2017, 6:33:47 PM2/20/17
to Python Programming for Autodesk Maya
hello Justin, thank you for your answer, sorry for my mistake in the last publication, im beginner in that jajaja, to respect to the code the console error is here:

# Error: NameError: file <maya console> line 21: global name 'srt' is not defined # 

if you delete the SRT string can you see a small interfase with two tabs and buttons, i think that problem is no have a global function in the code but i done know, thank you for your time and your help...

JP

Justin Israel

unread,
Feb 20, 2017, 8:25:12 PM2/20/17
to python_in...@googlegroups.com
Yes exactly. Your code is missing the definition for the srt() function. 
Is that your actual question? Does this answer your question?
 

JP

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

CGSKOOL Professional Computer Graphics Training

unread,
Feb 20, 2017, 10:55:30 PM2/20/17
to Python Programming for Autodesk Maya
hi Justin thank you for your answer, of course the code is bad in any place, i will try to make working, thank you for your time and if i find the solution i respond you.

have a great day and thank you again.

JP

Chad Fox

unread,
Feb 21, 2017, 1:05:06 AM2/21/17
to Python Programming for Autodesk Maya
​If we're reading your code correctly. It looks like you meant to write str( i+1 )​ not srt() to convert the result of i+1 into a string. 




-Chad


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/89b3d6cf-4888-45ba-81b8-f403c0e366cc%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages