I missed the following error expected an idented block

1

I'm something new in this programming, I've seen several codes, but I do not get the point I want to get, I want to put on my hobbies, a music player and a background photo. But this jumps me the error of the title.

class App:

def __init__(self, master):
    frame = tk.Frame(master)
    frame.pack()
    self.button = tk.Button(frame, text='play', command=self.play_sound)
    self.button.pack(side=tk.LEFT)
    self.button2 = tk.Button(frame, text='stop', command=self.stop_sound)
    self.button2.pack(side=tk.LEFT)


def ayuda(self):#funcion para que aparezca la ayuda
    root=Toplevel(bg="BLUE")#crea una ventana con fondo celeste    
    root.minsize(300,0)# tamaño de ventana
    root.resizable(width=NO,height=NO)# no se hace mas pequña
    root.title("About")#titulo
    instruccion=Message(root,text="Soy Róger ")
    # lo anterior es el mensaje que se imprime 
    instruccion.place(x=0,y=0)#lugar del mensaje

def play_sound(self):
        PlaySound('Sound.wav', SND_FILENAME|SND_LOOP|SND_ASYNC)

def stop_sound(self):
        PlaySound(None, SND_FILENAME)

root = tk.Tk()
app = App(root)
root.mainloop()
    
asked by Roger Ramírez 04.11.2018 в 05:53
source

1 answer

1

Claro jumps because the def have to be indented with the class bone when we have an application in python we press "TAB" to say that one command goes inside another in the case of a function

def funcion()
>   Esto va a dentro de la funcion

class Name:
>   Esto va dentro de la clase

class Name:
    #esta funcion esta dentro de la clase
    def funcion():
        #esta linea va dentro de la funcion

pay attention to that here I pass it corrected

class App:

    def __init__(self, master):
        frame = tk.Frame(master)
        frame.pack()
        self.button = tk.Button(frame, text='play', command=self.play_sound)
        self.button.pack(side=tk.LEFT)
        self.button2 = tk.Button(frame, text='stop', command=self.stop_sound)
        self.button2.pack(side=tk.LEFT)


    def ayuda(self):#funcion para que aparezca la ayuda
        root=Toplevel(bg="BLUE")#crea una ventana con fondo celeste    
        root.minsize(300,0)# tamaño de ventana
        root.resizable(width=NO,height=NO)# no se hace mas pequña
        root.title("About")#titulo
        instruccion=Message(root,text="Soy Róger ")
        # lo anterior es el mensaje que se imprime 
        instruccion.place(x=0,y=0)#lugar del mensaje

    def play_sound(self):
        PlaySound('Sound.wav', SND_FILENAME|SND_LOOP|SND_ASYNC)

    def stop_sound(self):
        PlaySound(None, SND_FILENAME)

root = tk.Tk()
app = App(root)
root.mainloop()
    
answered by 28.12.2018 в 04:11