开发者

QT push button and a python lambda function

开发者 https://www.devze.com 2023-04-09 08:02 出处:网络
I\'m just trying to create a UI for my script in maya/py using QT Designer. The problem is that I want to use a lambda expression as a command for my buttons

I'm just trying to create a UI for my script in maya/py using QT Designer.

The problem is that I want to use a lambda expression as a command for my buttons by adding a dynamic property with the type set to string, property name set to "+command" and lambda x: print('fobar!') as the value.

But running the code back in Maya using the loadUI Pyt开发者_如何学运维hon command gives me a syntax error.

It actually loads the UI but the button's function doesn't work!


How about:

button_name.clicked.connect(lambda : print('foobar'))
0

精彩评论

暂无评论...
验证码 换一张
取 消