0

我有这个错误信息:# Error: IndentationError: unindent does not match any external indentation level #

我试图删除所有缩进并替换每个缩进有四个空格,但我仍然收到此错误。

我该怎么办?

import pymel.core as pm
class UI():
    def __init__(self):
        print 'init'


    def renameselection (self):
        sel=pm.ls(sl=True)
        dialog = pm.promptDialog(title='Rename Object',message='Enter Name:', button=['OK', 'Add','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel')

        if dialog == 'OK':
            name = pm.promptDialog(query=True, text=True)
            for e in sel :
                e.rename(name)

        if dialog == 'Add':
            name = pm.promptDialog(query=True, text=True)
            for e in sel:
                e.rename(e+name)

     def CreateCircularController(self):

        dialog = pm.promptDialog(title='Name',message='Name CTL:', button=['OK','_CTL','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel')
        selectedJoint=pm.ls(sl=True)
        name = pm.promptDialog(query=True, text=True)
        for e in selectedJoint:
            if dialog=='OK':
                Controller=pm.circle(nr=(0,1,0),n=name)
                ControllerGrp=pm.group(Controller,n=name)
            if dialog=='_CTL':
                Controller=pm.circle(nr=(0,1,0),n=name+'CTL')
                ControllerGrp=pm.group(Controller,n=name+'CTL')
            pm.parent(ControllerGrp,selectedJoint,r=1)
            pm.parent(ControllerGrp,w=1)



    def buttonfunction(self,*args):    
        print ('Rename')
        renameselection()  

    def secondButtonfunction(self,*args):
        print ('Create Controller')
        CreateCircularController()   

    ####### Layout
    def uipopup(self):
        mrwindow = pm.window( title="Bjorn_rigging_wizzard", iconName='BWZ', widthHeight=(200, 400) )        

        # if set to true adjustable column will automatically update the UI layout if the user rezizes the window.
        pm.columnLayout( adjustableColumn=True )

        # text in the menu
        pm.text(label='Select function doctor...')
        # layout of the menu, collums are downward and rows are horizontally made side by side   
        pm.columnLayout (columnAttach=('both', 5), rowSpacing=10, columnWidth=(100))
        # buttons are made into variables so that they can be called upon later with the setCommand - which enables functionallity
        buttonOne = pm.button(label='Rename', width=100, command=self.buttonfunction)
        buttonTwo = pm.button(label='Controller on selection', width=100)
        buttonTwo.setCommand(self.secondButtonfunction)

        # the setParent with '..' goes one back in hierachey, you will see the following text being outside of the "div" of the buttons.
        pm.setParent('..')
        pm.text(' ')
        pm.text('Blaabjergb.com')



        # once everything is build we can show the window
        pm.showWindow( mrwindow )

UI1=UI() 
UI1.uipopup()  
4

1 回答 1

0
  1. 刚刚注意到在另一个方法定义之前有 5 个空格def CreateCircularController,而在另一个方法定义之前有 4 个空格。请确保每个方法定义前面有 4 个空格。

  2. 由于紧随其后的空行,也可能会出现错误def CreateCircularController(self):。请删除空行并重试。

于 2014-01-25T17:24:23.313 回答