Ошибка с простым скриптом интерфейса

У меня есть это сообщение об ошибке: # Ошибка: IndentationError: unindent не соответствует ни одному внешнему уровню отступа #

Я попытался удалить все отступы и заменить четыре пробела для каждого отступа, но я все еще получаю эту ошибку.

Что мне с этим делать?

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()  

1 ответ

  1. Просто заметил, что есть 5 пробелов перед def CreateCircularControllerи 4 пробела перед определением другого метода. Пожалуйста, убедитесь, что каждое определение метода имеет 4 пробела перед ним.

  2. Ошибка также может появиться из-за пустой строки сразу после def CreateCircularController(self):, Пожалуйста, удалите пустую строку и попробуйте снова.

Другие вопросы по тегам