首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pymel文件:TypeError <maya console>

Pymel文件:TypeError <maya console>
EN

Stack Overflow用户
提问于 2015-09-09 12:52:17
回答 1查看 284关注 0票数 0

我正在尝试选择一个对象并显示行编辑

从PySide导入*从pymel导入*

代码语言:javascript
复制
 import pymel.core as pm     import maya.cmds as cmds     import maya.mel as mel     import maya.OpenMaya as OpenMaya
代码语言:javascript
复制
def select_obj(obj):
    list = pm.poly
print obj

button = QPushButton("select")
button.clicked.connect(select_obj)
button.show()

def desselect_obj(obj):
    list = OpenMaya.MSelection()
print obj

button2 = QPushButton("disconnect")
button2.clicked.connect(select_obj)
button2.show()


edit = QLineEdit(nome)
QLineEdit.show(select_obj)
label.show()

app.exec_()

# Error: line 1: TypeError: file <maya console> line 25: 'PySide.QtGui.QLineEdit' called with wrong argument types:
  PySide.QtGui.QLineEdit(function)
Supported signatures:
  PySide.QtGui.QLineEdit(PySide.QtGui.QWidget = No`enter code here`ne)
  PySide.QtGui.QLineEdit(unicode, PySide.QtGui.QWidget = None) # 
# TypeError: select_obj() takes exactly 1 argument (0 given)
EN

回答 1

Stack Overflow用户

发布于 2015-09-09 14:07:41

你的代码有很多问题。您不需要导入那么多模块(特别是那些未使用的模块)。通常,在使用PySide创建ui时,需要对继承自QWidgetQMainWindow的类进行包装。看看下面的代码,它是一个带有按钮和lineEdit的窗口的简单示例。当您按下按钮时,它会将所选对象的名称添加到lineEdit中。

代码语言:javascript
复制
from PySide import QtGui, QtCore
import maya.cmds as cmds

class Window(QtGui.QWidget):
    def __init__(self, parent = None):
        super(Window, self).__init__(parent) # Inherit from QWidget

        # Create button
        self.button = QtGui.QPushButton("select")
        self.button.clicked.connect(self.select_obj)

        # Create line edit
        self.edit = QtGui.QLineEdit()

        # Create widget's layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.button)
        mainLayout.addWidget(self.edit)
        self.setLayout(mainLayout)

        # Resize widget, and show it
        self.resize(200, 200)
        self.show()

    # Function to add selected object to QLineEdit
    def select_obj(self):
        sel = cmds.ls(sl = True) # Get selection
        if sel:
            self.edit.setText(sel[0]) # Set object's name to the lineEdit

win = Window() # Create instance of the class
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32471136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档