Hi all,
I have a module called ‘module_test’ shown below:
import maya.cmds as cmds
def method_test(string_test, *args):
print string_test
The script below imports ‘method_test’ from this module, then creates a UI containing a button and a text field.
I want the button to print out whatever is in the text field.
from functools import partial
import maya.cmds as cmds
from module_test import method_test
# create UI
def create_ui():
if cmds.window('my_window', exists=True):
cmds.deleteUI('my_window')
cmds.window('my_window')
cmds.columnLayout()
text_field = cmds.textField('my_text_field')
button_test = cmds.button(label='test_button', command = partial(method_test, cmds.textField(text_field, query=True, text=True)))
cmds.showWindow()
create_ui()
I’ve tried to get the button to call the ‘method_test’ method, and pass into it a query of the text field, however nothings gets printed.
Please can anyone tell me how this should be done?
Thanks a lot.