【发布时间】:2015-12-06 07:44:53
【问题描述】:
我试图找出一种方法来以某种方式“获取”正在调用函数的 GUI 组件。通过这种方式,我可以进一步将我的代码整合到执行类似任务的组件的可重用部分中。我需要一种在 Maya 的 GUI 命令和 Qt 中执行此操作的方法。我想我正在寻找的是一个通用的 Python 技巧,如“init”、“file”、“main”等。如果没有通用的 python 方法,也欢迎任何 Maya/Qt 特定技巧。
这是一些任意伪代码,可以更好地解释我在寻找什么:
field1 = floatSlider(changeCommand=myFunction)
field2 = colorSlider(changeCommand=myFunction)
def myFunction(*args):
get the component that called this function
if the component is a floatSlider
get component's value
do the rest of the stuff
elif the component is a colorSlider
get component's color
do the rest of the stuff
【问题讨论】:
-
在 Qt 中,有 Signals 和 Slots,并且有一个 QObject.sender() 方法返回调用的 GUI 元素。
标签: python qt user-interface pyside maya