Yikes. My markdown plugin seems to have made strange formatting out of that
code snippet:

On Mon, Mar 19, 2018 at 5:22 PM Justin Israel <[email protected]>
wrote:

> On Mon, Mar 19, 2018 at 4:10 PM sumant shenoy <[email protected]>
> wrote:
>
>> hey every
>> i am trying to write a ui class and the trying to querry it from the
>> instance that i created but i keep on getting error here is an example
>> please let me know if what i am trying to do is possible
>>
>>
>> save this in C:\Users\u-user\Documents\maya\2016\scripts
>>
>> ## -*-coding:UTF-8-*
>> ##Test
>> import os
>> import maya.mel as mel
>> import maya.cmds as cmds
>> UIElements={}
>> class VgsRigTools:
>>     def __init__(self,WndNme,fml,width,height):
>>         self.WndNme=WndNme
>>         self.fml=fml
>>         self.wdh=width
>>         self.hgt=height
>>         if cmds.window(self.WndNme,exists=True):
>>             cmds.deleteUI(self.WndNme)
>>
>> UIElements["windowName"]=cmds.window(self.WndNme,t=self.WndNme,mxb=False,mnb=False,sizeable=True,w=self.wdh,h=self.hgt)
>>         UIElements["Fma"]=cmds.formLayout(self.fml,w=self.wdh,h=self.hgt)
>>         cmds.showWindow(self.WndNme)
>>     def Button(self,btnName,width,height,top,left):
>>         self.btnName=btnName
>>         self.btnWdt=width
>>         self.btnHgt=height
>>         self.btnTop=top
>>         self.btnLft=left
>>
>> UIElements["btnA"]=cmds.button(l=self.btnName,w=self.btnWdt,h=self.btnHgt,p=self.fml)
>>
>> cmds.formLayout(self.fml,e=True,af=[(UIElements["btnA"],"top",self.btnTop),(UIElements["btnA"],"left",self.btnLft)])
>>     def chkBox(self,chkName,chkTop,chkLft):
>>         self.chkName=chkName
>>         self.chkTop=chkTop
>>         self.chkLft=chkLft
>>         UIElements["ChkA"]=cmds.checkBox( label=self.chkName )
>>
>> cmds.formLayout(self.fml,e=True,af=[(UIElements["ChkA"],"top",self.chkTop),(UIElements["ChkA"],"left",self.chkLft)])
>>
>> and then i tried the below script from maya  but i was not able to querry
>> the check box
>>
>>
>> from ClassTest import VgsRigTools
>> vrt=VgsRigTools
>> vrt=VgsRigTools('RigTools','RigLayout',400,100)
>> vrt.Button('ButtonA',50,20,10,0)
>> chkBx=vrt.chkBox('chktst',30,300)
>> cmds.checkBox(chkBx,q=True,v=True)
>> vrt.Button('ButtonB',50,20,50,0)
>>
>>
>> this is the error i got
>> # Error: RuntimeError: file <maya console> line 6: No object name
>> specified.
>> i know why i am getting the error but i have no idea how to fix it any
>> help would be deeply appreciated
>>
>
> I don't full understand the intent of the design, but I can tell you why
> it is failing and how to fix the specific error. Your chkBox() method does
> not return anything, but you are expecting it to return the name of the
> checkbox UI item, so that you can pass it to cmds.checkBox().
>
> This would be the simplest fix for your code:
>
> def chkBox(self,chkName,chkTop,chkLft):
>     # ... the rest of the code
>     return UIElements["ChkA"]
>
> ​
>
>
def chkBox(self,chkName,chkTop,chkLft):
    # ... the rest of the code
    return UIElements["ChkA"]



> Now your chkBox() method returns the name of the checkbox.
>
> I don't really understand the purpose of the global UIElements dictionary
> when you are already storing everything on the instance of your VgsRigTools
> class. The global is just an easy way to cause you problems down the line.
> If you were to do:
>
> vrt1 = VgsRigTools('RigTools1','RigLayout1',400,100)
> vrt2 = VgsRigTools('RigTools2','RigLayout2',400,100)
>
> ​
>
>
vrt1 = VgsRigTools('RigTools1','RigLayout1',400,100)
vrt2 = VgsRigTools('RigTools2','RigLayout2',400,100)


> The second instance would overwrite the "windowName" and "Fma" keys in
> your global dictionary, but still create two windows.
>
>
>>
>> Thank you
>> sumanth :D
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/b3c698ac-8e6d-4468-b697-233be2cecb27%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/b3c698ac-8e6d-4468-b697-233be2cecb27%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2zW1E-RoORBrgpdw6z%3D9mY6TdYeFs8dzMGwxuByDGr5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to