Python:期待一个indentend Block

时间:2016-02-06 11:44:13

标签: python functional-programming

我正在寻找几个小时,但我找不到错误:

这是我的代码:http://pastebin.com/sDBtvLqb

我收到错误:

Expect an indented Block

在大多数情况下,缺少Tabulator或类似但我无法找到它? 是否有其他错误可能导致错误? 如果我只运行MyApp类,一切都很好。只有我有新的Class" Manual_control"我收到了这个错误。

这是工作部分:

class MyApp(object):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent):
        """Constructor"""
        self.root = parent
        self.root.configure(background='blue')
        self.root.title("Kranken Trage")

        self.frame = Tk.Frame(parent,background='blue')
        self.frame.pack()

        Uebschrift= Tk.Label(self.frame,text="Kranken-Transport",font = "Verdana 30 bold",fg="red").pack()

        btnRooms = Tk.Button(self.frame,text ="Räume")
        btnRooms.config(height=3,width=15,font= "Arial 40")
        btnRooms.pack(pady=5)

        Test = Tk.Button(self.frame,text ="Test Modus")
        Test.config(height=3,width=15,font= "Arial 40")
        Test.pack(padx=10,pady=5)

        btnmanualControl = Tk.Button(self.frame,text = "Manuele Steuerung",command=openmanualControl)
        btnmanualControl.config(height=3,width=15,font= "Arial 40")
        btnmanualControl.pack(padx=10,pady=5 )

    #----------------------------------------------------------------------
    def hide(self):
        """"""
        self.root.withdraw()

    #----------------------------------------------------------------------
    def openRooms(self):
        """"""
        self.hide()
        subFrame = Rooms(self)

    #----------------------------------------------------------------------
    def openmanualControl(self):
        """"""
        self.hide()
        subFrame = Manual_Control(self)    

    #----------------------------------------------------------------------
    def show(self):
        """"""
        self.root.update()
        self.root.deiconify()

#----------------------------------------------------------------------
if __name__ == "__main__":
    root = Tk.Tk()
    root.geometry("700x700")
    app = MyApp(root)
    root.mainloop()

2 个答案:

答案 0 :(得分:0)

Manual_Control课程中,您没有缩进评论。

class Manual_Control():
"""
    GPIO.setmode(GPIO.BCM)
    # other code
"""
    mcfenster = tkinter.Tk()

应该是

class Manual_Control():
    """
    GPIO.setmode(GPIO.BCM)
    # other code
    """
    mcfenster = tkinter.Tk()

答案 1 :(得分:0)

嗯,你有很多错误。但我没有看到任何Button

但是:在声明之前调用命令openmanualControl中的函数(btnmanualControl = Tk.Button(self.frame,text = "Manuele Steuerung",command=self.openmanualControl) 的函数)。你需要写:

Manual_Control

NSString *mp3Path = [[NSBundle mainBundle] pathForResource:@"beep" ofType:@"caf"]; NSURL *mp3Url = [NSURL fileURLWithPath:mp3Path]; _player = [[AVAudioPlayer alloc] initWithContentsOfURL:mp3Url error:nil]; _player.numberOfLoops = 8; [_player play]; 缺失。