找不到的修复:只接受1个参数(给定2个)

2024-04-19 11:31:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近接触了python,已经遇到了“只接受1个参数(给定2个)”的问题。在

我到处都在找它,而且大部分时间都在读《失踪》来增加自我部分。在

尽管我补充说我不能解决它,我是不是错过了女人的重点?在

import maya.cmds as cmds

class ButtonPress:

    def __init__(self):
        self.value = 0

    def buildUI(self):
        window = cmds.window(title = 'Press Button', w = 100, h = 50)
        columnL = cmds.columnLayout(w = 100, h = 50)
        cmds.button(parent = columnL, label = 'Press me', w = 100, h = 50, command = self.__increaseAndPrint)
        cmds.showWindow(window)

    def __increaseAndPrint(self):
        self.value += 1
        print self.value

谢谢你的帮助。在

编辑: 我将maya脚本编辑器中的类用于:

ButtonPress().buildUI()

我得到: 错误:\uUu increaseAndPrint()只接受1个参数(给定2个) 当按下UI按钮时。在

对不起。在


Tags: self重点参数valuedef时间windowpress
1条回答
网友
1楼 · 发布于 2024-04-19 11:31:20
import maya.cmds as cmds

class ButtonPress:

    def __init__(self):
        self.value = 0

    def buildUI(self):
        window = cmds.window(title = 'Press Button', w = 100, h = 50)
        columnL = cmds.columnLayout(w = 100, h = 50)
        cmds.button(parent = columnL, label = 'Press me', w = 100, h = 50, command = self.__increaseAndPrint)
        cmds.showWindow(window)

    def __increaseAndPrint(self, *args):
        # maya throwing through ui a default bool argument as last.
        # you need *args to catch and dismissed it
        self.value += 1
        print self.value

相关问题 更多 >