I have a script i wrote in python for maya and there are 3 buttons labeled X Y Z. Depending on which button is pressed I want a variable to pass a specific value to the function. How can I do this?? I've written in the comments for the button in regards to what I'm trying to pass. It seems to just print 'false' im not sure why.
import maya.cmds as cmds
class createMyLayoutCls(object):
def __init__(self):
pass
def show(self):
self.createMyLayout()
def createMyLayout(self):
#check to see if our window exists
if cmds.window('utility', exists = True):
cmds.deleteUI('utility')
# create our window
self.window = cmds.window('utility', widthHeight = (200, 200), title = 'Distribute', resizeToFitChildren=1, sizeable = False)
cmds.setParent(menu=True)
# create a main layout
mainLayout = cmds.gridLayout( numberOfColumns=3, cellWidthHeight=(70, 50) )
# X Y Z BUTTONS
btnAlignX = cmds.button(label = 'X', width = 40, height = 40, c = self.TakeAction) # should pass 'axis='X"
btnAlignY = cmds.button(label = 'Y', width = 40, height = 40, c = self.TakeAction) # should pass 'axis='Y"
btnAlignZ = cmds.button(label = 'Z', width = 40, height = 40, c = self.TakeAction) # should pass 'axis='Z"
# show window
cmds.showWindow(self.window)
def TakeAction(self, axis=''):
print axis
if axis == 'x':
print 'you selected x'
if axis == 'y':
print 'you selected y'
if axis == 'y':
print 'you selected z'
b_cls = createMyLayoutCls()
b_cls.show()
To substitute lambda, you can use partial :
from functools import partial
btnAlignX = cmds.button(label='X', c=partial(self.TakeAction, 'X'))
Both lambda and partial should work.
Hope it helps.
Use a lambda to give each button command its own mini-function:
btnAlignX = cmds.button(label='X', c=lambda *_:self.TakeAction('X'))
btnAlignY = cmds.button(label='Y', c=lambda *_:self.TakeAction('Y'))
btnAlignZ = cmds.button(label='Z', c=lambda *_:self.TakeAction('Z'))
Related
I've only recently dipped my toes into python (only ever coded in java and JS) and thought I would try my hand at making a simple number pad GUI. I'm still getting used to the indentation format.
I've applied proper indenting and fixed all typos and syntax errors but still receive the following error
"Traceback (most recent call last):
File "/home/pi/Desktop/Lab Work/Lab 1/Number Pad test GUI.py", line 4, in
class BaseWindow(tkinter.Tk):
File "/home/pi/Desktop/Lab Work/Lab 1/Number Pad test GUI.py", line 8, in BaseWindow
self.minsize (x,y)
NameError: name 'self' is not defined"
I have updated the code below to my latest version also
import tkinter, tkinter.ttk as ttk
import random
class BaseWindow(tkinter.Tk):
def _Change (self):
x,y = self.winfo_width(), self.winfo_height()
self.minsize (x, y); self.maxsize(x, y)
#This locks window size when called
def FgridFormatButtons (self, ButtonList, NewLineAmount = 3):
self.Row = 0
self.Col = 0
for Button in ButtonList:
Button.grid(row = self.Row, column = self.Col)
self.Col += 1
if self.Col == NewLineAmount:
self.Row += 1
self.Col = 0
continue
class Window (BaseWindow):
def __init__(self, **args):
super(Window, self).__init__()
#Main method code
self.EntryFrame = ttk.Frame(self)
self.PadFrame = ttk.Frame(self)
self.EntryFrame.pack(padx = 5, pady = 5)
self.PadFrame.pack(padx = 5, pady = 5)
self.AllButtons = []
self.CanWrite = true
self.Cod = args.get("Code") or random.randrange(9999)
self.Timer = args.get("Timer") or 2000
print ("debug %d"% self.Code)
for x in range (1,10):
self.AllButtons.append(ttk.Button(self.PadFrame, width = 4, text = x, command = lambda y = x: self.Update(x)))
self.bind(str(x), lambda CatchEvent, y = x: self.Update(y))
self.FGridFormatButtons(self.AllButtons)
self.ZeroButton = ttk.Button (self.PadFrame, width = 4, text = 0, command = lambda: self.Update(0))
self.SubmitButton = ttk.Button(self.PadFrame, width = 4, text = "Ent", command = self.CheckCode)
self.ClearButton = ttk.Button(self.PadFrame, width = 4, text = "C", command = lambda: self.Update(-1))
self.ClearButton.grid(row = self.Row, column = 0)
self.ZeroButton.grid(row = self.Row, column = 1)
self.SubmitButton.grid(row = self.Row, column = 2)
self.bind ("0", lambda CatchEvent: self.Update(0))
self.bind("<return>", lambda CatchEvent: self.CheckCode())
self.KeyEnter = ttk.Entry(self,EntryFrame, state ="disabled")
self.KeyEnter.pack
#--
self.after (5, self._Change)
#This will wait 5 miliseconds and then lock the window
#If your computer takes longer than 5 miliseconds to load then kill yourself. Or alternatively, change the last value to match how long it takes
def Update (self, x):
if self.CanWrite:
self.KeyEnter["state"] = "normal"
if x == 1:
self.KeyEnter.delete(0, tkinter.END)
else:
self.KeyEnter.insert(tkinter.END, x)
self.KeyEnter["state"] = 'disabled'
def CheckCode(self):
Key = self.KeyEnter.get()
self.Update(-1)
if Key == str(self.Code):
self.Update("Correct Code!")
self.after(self.Timer, self.destroy)
else:
self.Update("Incorrect code")
self.ChangeWritePerms()
self.after(self.Timer, self.ChangeWritePerms)
def ChangeWritePerms(self):
if self.CanWrite:
self.CanWrite = False
else:
self.CanWrite = True
self.Update(-1)
window().mainloop()
class BaseWindow(tkinter.Tk):
def _change (self):
x,y = self.winfo_width(), self.winfo_height()
self.minimize (x,y)
#This locks window size when called
def FgridFormatButtons (self, ButtonList, NewLineAmount = 3):
self.Row = 0
self.Col = 0
for Button in ButtonList:
Button.grid(row = self.Row, column = self.Col)
self.Col += 1
if self.Col == NewLineAmount:
self.Row += 1
self.Col = 0
continue
class Window (BaseWindow):
def __init__(self, **args):
super(Window, self).__init__()
#Main method code
self.EntryFrame = ttk.Frame(self)
self.PadFrame = ttk.Frame(self)
self.EntryFrame.pack(padx = 5, pady = 5)
self.PadFrame.pack(padx = 5, pady = 5)
self.AllButtons = []
self.CanWrite = true
self.Cod = args.get("Code") or random.randrange(9999)
self.Timer = args.get("Timer") or 2000
print ("debug %d"% self.Code)
for x in range (1,10):
self.AllButtons.append(ttk.Button(self.PadFrame, width = 4, text = x, command = lambda y = x: self.Update(x)))
self.bind(str(x), lambda CatchEvent, y = x: self.Update(y))
self.FGridFormatButtons(self.AllButtons)
self.ZeroButton = ttk.Button (self.PadFrame, width = 4, text = 0, command = lambda: self.Update(0))
self.SubmitButton = ttk.Button(self.PadFrame, width = 4, text = "Ent", command = self.CheckCode)
self.ClearButton = ttk.Button(self.PadFrame, width = 4, text = "C", command = lambda: self.Update(-1))
self.ClearButton.grid(row = self.Row, column = 0)
self.ZeroButton.grid(row = self.Row, column = 1)
self.SubmitButton.grid(row = self.Row, column = 2)
self.bind ("0", lambda CatchEvent: self.Update(0))
self.bind("<return>", lambda CatchEvent: self.CheckCode())
self.KeyEnter = ttk.Entry(self,EntryFrame, state ="disabled")
self.KeyEnter.pack
#--
self.after (5, self._Change)
#This will wait 5 miliseconds and then lock the window
#If your computer takes longer than 5 miliseconds to load then kill yourself. Or alternatively, change the last value to match how long it takes
def Update (self, x):
if self.CanWrite:
self.KeyEnter["state"] = "normal"
if x == 1:
self.KeyEnter.delete(0, tkinter.END)
else:
self.KeyEnter.insert(tkinter.END, x)
self.KeyEnter["state"] = 'disabled'
def CheckCode(self):
Key = self.KeyEnter.get()
self.Update(-1)
if Key == str(self.Code):
self.Update("Correct Code!")
self.after(self.Timer, self.destroy)
else:
self.Update("Incorrect code")
self.ChangeWritePerms()
self.after(self.Timer, self.ChangeWritePerms)
def ChangeWritePerms(self):
if self.CanWrite:
self.CanWrite = False
else:
self.CanWrite = True
self.Update(-1)
window().mainloop()
It seems like you change your question.
Try to change tkinter.tk into tkinter.Tk with big T.
This error shows that you forgot to put comma before lambda function.
"line 60 self.bind("" lambda CatchEvent: self.CheckCode()) ^SyntaxError: invalid syntax"
Have you tried to add comma ?
Check line 5 and 110 you forget space after def and colon at the end function argument.
Check line 86 too, you defined key as Key in line 82, so you have to call it Key with big K in line 86.
Check line 88, it shows self.;after. Please delete the semicolon to avoid syntax error too.
What is the text editor you are using ? If you use vscode, it will show the error with red underline.
include "self.minsize (x, y); self.maxsize(x, y)" inside the function
any statement inside the class must be inside a function
Ex: import tkinter, tkinter.ttk as ttk
import random
class BaseWindow(tkinter.Tk):
def _Change (self):
x,y = self.winfo_width(), self.winfo_height()
self.minsize (x, y); self.maxsize(x, y)
from tkinter import *
pencere = Tk() #Pencereyi Oluşturyor
def Ekmek(event):
print(0.6*x)
#Here i am trying to calcute the carbohydrate for diabetes
#1 gram of bread is 0.6 carbohydrate and i am trying to calculate the gram user enters
def Patates(event):
print(0.16666666666666666)
gramy = Label(text = "Yemeğin Gramını Girin:",fg = "green",bg = "black")
gram = Entry(fg = "green",bg = "black")
x = gram.get()
#In this part i want to change the "x" to a
#float value but it gives error.How can i fix it ?
ekmek = Button(text="Ekmek",fg="orange",bg = "black")
ekmek.bind("<Button-1>",Ekmek)
patates = Button(text="Patates",fg="orange",bg = "black")
patates.bind("<Button-1>",Patates)
makarna = Button(text="Makarna",fg="orange",bg = "black")
pilav = Button(text="Pilav",fg="orange",bg = "black")
gramy.grid(row=0,column=1)
gram.grid(row =0,column =2)
ekmek.grid(row =1,column = 0)
patates.grid(row =1,column = 1)
makarna.grid(row = 1,column = 2)
pilav.grid(row = 2,column = 0)
pencere.mainloop() #Pencerenin Çarpıya
Your problem code is very problematic because 'x' will always be "" (empty string) since you placed it directly under its creation not giving any time for the user to enter. And as you know, "" can not be floated.
This is your problem code:
gram = Entry(fg = "green",bg = "black")
x = gram.get()
You should place gram.get here:
def Ekmek(event):
x = gram.get()
x=float(x.split('gram')[0])
print(0.6*x)
This will retrieve x after the user pressed the button.
Another method, is that you can use a StringVar.
I'm new to python in Maya and I'm trying to build a UI which can generate shapes and transform them. The problem I think lies in the ObjectCreation function but I'm not to sure. So far this what I've got:
import maya.cmds as cmds
#check to see if window exists
if cmds.window("UserInterface", exists = True):
cmds.deleteUI("UserInterface")
#create actual window
UIwindow = cmds.window("UserInterface", title = "User Interface Test", w = 500, h = 700, mnb = False, mxb = False, sizeable = False)
mainLayout = cmds.columnLayout(w = 300, h =500)
def SceneClear(*args):
cmds.delete(all=True, c=True) #Deletes all objects in scene
cmds.button(label = "Reset", w = 300, command=SceneClear)
polygonSelectMenu = cmds.optionMenu(w = 250, label = "Polygon Selection:")
cmds.menuItem(label = " ")
cmds.menuItem(label = "Sphere")
cmds.menuItem(label = "Cube")
cmds.menuItem(label = "Cylinder")
cmds.menuItem(label = "Cone")
def ObjectCreation(*args):
if polygonSelectMenu.index == 2: #tried referring to index
ma.polySphere(name = "Sphere")
elif polygonSelectMenu == "Cube":
ma.polyCube(name = "Cube")
elif polygonSelectMenu == "Cylinder":
ma.polyCylinder(name = "Cylinder")
elif polygonSelectMenu == "Cone":
ma.polyCone(name = "Cone")
cmds.button(label = "Create", w = 200, command=ObjectCreation)
def DeleteButton(*args):
cmds.delete()
cmds.button(label = "Delete", w = 200, command=DeleteButton)#Deletes selected object
cmds.showWindow(UIwindow) #shows window
What I'm after is for the user to select one of the options from the option menu then to press the create button to generate that shape. I've tried to refer to it by name and index but I don't know what I'm missing. Like I said I'm new to python so when I tried searching for an answer myself I couldn't find anything and when I did find something similar I couldn't understand it. Plus for some reason the SceneClear function/Reset button doesn't seem to work so if there is answer to that please let me know.
polygonSelectMenu contains the path to your optionMenu UI element. In my case it is: UserInterface|columnLayout7|optionMenu4.
This is just a string and not a reference to a UI element.
To access it's current value you must use this:
currentValue = cmds.optionMenu(polygonSelectMenu, query=True, value=True)
All optionMenu's flags are listed here (Maya 2014 commands doc), queryable ones have a little green Q next to them.
As a result, here is your ObjectCreation(*args) function:
def ObjectCreation(*args):
currentValue = cmds.optionMenu(polygonSelectMenu, query=True, value=True)
if currentValue == "Sphere": #tried referring to index
cmds.polySphere(name = "Sphere")
elif currentValue == "Cube":
cmds.polyCube(name = "Cube")
elif currentValue == "Cylinder":
cmds.polyCylinder(name = "Cylinder")
elif currentValue == "Cone":
cmds.polyCone(name = "Cone")
Off-topic:
Avoid declaring functions between lines of code (in your case, the UI creation code), try instead putting the UI creation code inside a function and call this function at the end of your script.
It is readable as you have only few UI elements right now. But once you start having 20 or more buttons/labels/inputs it can be a mess quickly.
Also, I prefer giving an object name to the UI elements, just like you did with your window ("UserInterface").
To give you a concrete example:
cmds.optionMenu("UI_polygonOptionMenu", w = 250, label = "Polygon Selection:")
This optionMenu can be then accessed anywhere in you code using:
cmds.optionMenu("UI_polygonOptionMenu", query=True, value=True)
Here is the full modified script if you want:
import maya.cmds as cmds
def drawUI(): #Function that will draw the entire window
#check to see if window exists
if cmds.window("UI_MainWindow", exists = True):
cmds.deleteUI("UI_MainWindow")
#create actual window
cmds.window("UI_MainWindow", title = "User Interface Test", w = 500, h = 700, mnb = False, mxb = False, sizeable = False)
cmds.columnLayout("UI_MainLayout", w = 300, h =500)
cmds.button("UI_ResetButton", label = "Reset", w = 300, command=SceneClear)
cmds.optionMenu("UI_PolygonOptionMenu", w = 250, label = "Polygon Selection:")
cmds.menuItem(label = " ")
cmds.menuItem(label = "Sphere")
cmds.menuItem(label = "Cube")
cmds.menuItem(label = "Cylinder")
cmds.menuItem(label = "Cone")
cmds.button("UI_CreateButton", label = "Create", w = 200, command=ObjectCreation)
cmds.button("UI_DeleteButton", label = "Delete", w = 200, command=DeleteButton)#Deletes selected object
cmds.showWindow("UI_MainWindow") #shows window
def SceneClear(*args):
cmds.delete(all=True, c=True) #Deletes all objects in scene
def ObjectCreation(*args):
currentValue = cmds.optionMenu("UI_PolygonOptionMenu", query=True, value=True)
if currentValue == "Sphere":
cmds.polySphere(name = "Sphere")
elif currentValue == "Cube":
cmds.polyCube(name = "Cube")
elif currentValue == "Cylinder":
cmds.polyCylinder(name = "Cylinder")
elif currentValue == "Cone":
cmds.polyCone(name = "Cone")
def DeleteButton(*args):
cmds.delete()
drawUI() #Calling drawUI now at the end of the script
Hope this will help you.
as said above the maya.cmds works very much like mel and you have to use the command cmds.optionMenu() with the polygonSelectMenu as the first arg.
Alternatively if you use pymel instead, you could access the class attrs of polygonSelectMenu with the dot operator like:
import pymel.core as pm
if pm.window("UserInterface", exists = True):
pm.deleteUI("UserInterface")
UIwindow = pm.window("UserInterface", title = "User Interface Test", w = 500, h = 700, mnb = False, mxb = False, sizeable = False)
mainLayout = pm.columnLayout(w = 300, h =500)
polygonSelectMenu = pm.optionMenu(w = 250, label = "Polygon Selection:")
pm.menuItem(label = " ")
pm.menuItem(label = "Sphere")
pm.menuItem(label = "Cube")
pm.menuItem(label = "Cylinder")
pm.menuItem(label = "Cone")
pm.button(label = "Create", w = 200, command=ObjectCreation)
UIwindow.show()
def ObjectCreation(*args):
print polygonSelectMenu.getValue()
also you could make the program into a class with a drawUI method, which might make it easy to do things like store all the items you create in ObjectCreation inside of a class attr so that you can just delete them with your reset button (as i noticed you have cmds.delete(all=True) which i think is not supported anymore in maya), or store the UI elements in self.ui_element. That way they can be referenced later as the variable without the possible conflicts from having multiple windows open that all have buttons like "UI_CreateButton" or "okButton" etc...
import maya.cmds as cmds
class UI_Test_thingy():
windowName = 'UserInterface'
version = 'v1.1.1'
debug = True
createdThingys = []
def __init__(self):
self.drawUI()
def drawUI(self):
if UI_Test_thingy.debug: print 'DEBUG - drawUI called'
#check to see if window exists
try:
cmds.deleteUI(UI_Test_thingy.windowName)
except:
pass
#create actual window
UIwindow = cmds.window(UI_Test_thingy.windowName, title = "User Interface Test {}".format(UI_Test_thingy.version), w = 500, h = 700, mnb = False, mxb = False, sizeable = False)
mainLayout = cmds.columnLayout(w = 300, h =500)
cmds.button(label = "Reset", w = 300, command=self.SceneClear)
self.polygonSelectMenu = cmds.optionMenu(w = 250, label = "Polygon Selection:")
cmds.menuItem(label = " ")
cmds.menuItem(label = "Sphere")
cmds.menuItem(label = "Cube")
cmds.menuItem(label = "Cylinder")
cmds.menuItem(label = "Cone")
cmds.button(label = "Create", w = 200, command=self.ObjectCreation)
cmds.button(label = "Delete", w = 200, command=self.DeleteButton)#Deletes selected object
cmds.showWindow(UIwindow) #shows window
def DeleteButton(self, *args):
if UI_Test_thingy.debug: print 'DEBUG - DeleteButton called: args: {}'.format(args)
cmds.delete()
def SceneClear(self, *args):
if UI_Test_thingy.debug: print 'DEBUG - SceneClear called: args: {}'.format(args)
thingsToDel = UI_Test_thingy.createdThingys[:] # copy the list of things created by this script
UI_Test_thingy.createdThingys = [] # reset the list before deleteing the items
print 'deleteing: {}'.format(thingsToDel)
if thingsToDel:
cmds.delete( thingsToDel ) #Deletes all objects created by this script
def ObjectCreation(self, *args):
if UI_Test_thingy.debug: print 'DEBUG - ObjectCreation called: args: {}'.format(args)
menuVal = cmds.optionMenu(self.polygonSelectMenu, q=True, value=True)
if menuVal == "Sphere":
UI_Test_thingy.createdThingys += cmds.polySphere(name = "Sphere") # store the results to the class attr createdThingys
elif menuVal == "Cube":
UI_Test_thingy.createdThingys += cmds.polyCube(name = "Cube") # store the results to the class attr createdThingys
elif menuVal == "Cylinder":
UI_Test_thingy.createdThingys += cmds.polyCylinder(name = "Cylinder") # store the results to the class attr createdThingys
elif menuVal == "Cone":
UI_Test_thingy.createdThingys += cmds.polyCone(name = "Cone") # store the results to the class attr createdThingys
if __name__ == '__main__':
ui = UI_Test_thingy()
I want to be able to select a button based on what row and column it is in on a grid and the button and control its Text and Relief. I haven't been able to find anything on widgets or cells used in this manner.
Edit:
I changed where root is placed and now it says that I can't use a tuple that I recieved for 'relief' which makes sense, I need to access the widget itself. Any reccomendations
import tkinter
import functools
import random
from time import sleep
width = input('Enter the grid width. ')
height = input('Enter the grid height. ')
numb = input('Enter the number of bombs. ')
Matrix = [[0 for lp in range(int(width))] for fg in range(int(height))]
def ranintx():
return random.randint(0,int(width))
def raninty():
return random.randint(0,int(height))
def placemines():
y = ranintx()
x = raninty()
for ranintformine in range(int(numb)):
x = ranintx()
y = raninty()
Matrix[y-1][x-1] = 1
placemines()
def sunken(event, self, x, y):
button = event.widget
button['relief'] = 'sunken'
if x - 1 < 0 :
return
if x > int(width) + 1 :
return
if y - 1 < 0 :
return
if y > int(height) + 1 :
return
if Matrix[x][y] == 1 :
top = tkinter.Toplevel()
top.title("About this application...")
msg = tkinter.Message(top, text="You Lose")
msg.pack()
button = tkinter.Button(top, text="Dismiss", command=top.destroy)
button.pack()
print('Column = {}\nRow = {}'.format(x, y))
else:
n1 = x - 1
n2 = y - 1
for lp in range(3):
for lp2 in range(3):
abutton = root.grid_location(n1, n2)
abutton['relief'] = ['sunken']
# I want to be able to change and select the button here. This was one of my poor attempt
n2 =+ 1
n1 =+ 1
def push(event, self, x, y):
button = event.widget
if Matrix[x][y] == 1 :
print('Column = {}\nRow = {}'.format(x, y))
class MineSweep(tkinter.Frame):
#classmethod
def main(cls, width, height):
window = cls(root, width, height)
'''placemine()'''
root.mainloop()
def __init__(self, master, width, height):
super().__init__(master)
self.__width = width
self.__height = height
self.__build_buttons()
self.grid()
#def sunken(event):
# button = event.widget
# button['relief'] = 'sunken'
def __build_buttons(self):
self.__buttons = []
for y in range(self.__height):
row = []
for x in range(self.__width):
button = tkinter.Button(self, state='disabled')
button.grid(column=x, row=y)
button['text'] = ' '
print(grid.slaves)
self.checked = True
#button['command'] = functools.partial(self.__push, x, y)
button.bind("<Button-3>",
lambda event, arg=x, brg=y: push(event, self, arg, brg))
button['relief'] = 'raised'
button.bind("<Button-1>",
lambda event, arg=x, brg=y: sunken(event, self, arg, brg))
#button['command'] = sunken
row.append(button)
self.__buttons.append(row)
root = tkinter.Tk()
if __name__ == '__main__':
MineSweep.main(int(width), int(height))
You have a few things wrong with your program. First, sunken should be a method on the class. It's very weird to have it outside the class, and then you pass in self as some other argument. It works, but it makes the code very confusing.
That being said, you're actually very close to making this work. You're already saving a reference to each button in a list of lists, so you should be able to get the widget with self.__buttons[y][x]. However, because sunken is not part of the class, and because you named the variable with two underscores, the variable is not accessible to the sunken function.
If you change the variable to have a single underscore instead of a double, your code should work more-or-less exactly as it is (once you fix the syntax and indentation errors). The other solution is to make sunken a method on the class and fix how you call it (remove the self argument, call it as self.sunken), it will work with two underscores.
Frankly, using two underscores has zero practical benefit. Avoid the temptation to use it. At the very least, don't use it until you have your basic logic working, then you can go back and hide attributes you don't want to be exposed.
I'm trying to get the state of a checkbox in a maya UI using python. I was wondering if someone would help me. currently when the user hits the Distribute button, it calls a function which should print the true/false state of the 'x' checkbox.
import maya.cmds as cmds
class createMyLayoutCls(object):
def __init__(self, *args):
pass
def show(self):
self.createMyLayout()
def createMyLayout(self):
#check to see if our window exists
if cmds.window('utility', exists = True):
cmds.deleteUI('utility')
# create our window
self.window = cmds.window('utility', widthHeight = (200, 200), title = 'Distribute', resizeToFitChildren=1, sizeable = False)
cmds.setParent(menu=True)
# create a main layout
mainLayout = cmds.columnLayout(w = 200, h = 200, cw = 10, rs = 8, co = ['both',2])
# X Control
self.xAxis = cmds.checkBox('X')
# Distribute Button
btnDistribute = cmds.button(label = 'Distribute', width = 200, height = 40, c = self.GetSelectedNodes)
# show window
cmds.showWindow(self.window)
def GetSelectedNodes(self,*args):
cal = cmds.checkBox(self['X'],q = True, v = True)
print cal
b_cls = createMyLayoutCls()
b_cls.show()
you need to pass the checkbox's name into the call to checkBox in GetSelectedNodes:
def GetSelectedNodes(self,*args):
cal = cmds.checkBox(self.xAxis,q = True, v = True)
print cal