I want to add some UI elements when user press the button like shape editor in maya


I want to add some UI elements when the user presses the button, something like a shape editor in Maya, this code just add a number, for now, I don’t know how to receive variable from this function after pressing a button so I use a global variable, this code is working fine, but it’s nice to do it without using a global variable, is there a way? image

import maya.cmds as cmds
a =10

def defaultButtonPush():
global a
print a

cmds.window( width=150 )
cmds.columnLayout( adjustableColumn=True )
cmds.button( label=‘Button 1’, command=“defaultButtonPush()”)