【问题标题】:Maya Python & Pyside: pass value returned from a method with multiple args into another methodMaya Python & Pyside:将具有多个参数的方法返回的值传递给另一个方法
【发布时间】:2016-04-06 17:18:40
【问题描述】:

我将在 Maya 2016 中使用 Pyside 开始一些 Python UI。

我正在尝试在我的 UI 类中创建一个函数来获取一些小部件的所有值。

这是我班级中涉及的函数 sn-ps:

class UI_Window_to_Rename(uiWindow_form, uiWindow_base):

    def __init__(self, parent=getMayaWindow()):

        self.create_connections()

    def create_connections(self):

        self.maxDist_spinBox.valueChanged.connect(self.get_vert_distance)
        self.setVerts_btn.clicked.connect(self.get_all_settings)

    def get_vert_distance(self, value):

        return str(value)

    def get_all_settings(self):
    # This doesn't work. How to I pass the argument from 
    #  get_vert_distance into this function?
# TypeError: get_vert_distance() takes exactly 2 arguments (1 given)


        vert_dist = self.get_vert_distance(value)

我基本上希望get_all_settings 操纵我传入的其他函数的值。但我不知道该怎么做,因为get_vert_distance 使用2 个参数。

有点类似于这个问题,但我认为这更复杂?

Calling a variable from one function to another function in Python

【问题讨论】:

    标签: python user-interface pyside maya


    【解决方案1】:

    我做错了。我应该刚刚创建了一个函数来查询maxDist_spinBox 小部件的当前值:

    def get_all_settings(self):
        print self.maxDist_spinBox.value()
    

    https://srinikom.github.io/pyside-docs/PySide/QtGui/QSpinBox.html?highlight=spinbox#PySide.QtGui.PySide.QtGui.QSpinBox.value

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 2018-08-08
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多