10/06/12 20:21
Umberto
Quando tento di eseguire questo programma
Succede così:
C:\Users\umberto>C:\Python27\python.exe C:\Users\umberto\Documents\gui.py hello
button
File "C:\Users\umberto\Documents\gui.py", line 15
b = Button(self, text="button", command=self.helloWorld)
^
IndentationError: expected an indented block
from Tkinter import * import sys class Finestra(Tk): def __init__(self): """Costruttore della classe Finestra """ iargv = 1 Tk.__init__(self) self.title(sys.argv[iargv]) self.geometry("%dx%d" % (220, 150)) iargv = iargv +1 if sys.argv[iargv] == "button": # creo il bottone b = Button(self, text="hello", command=self.helloWorld) b.place(x=15, y=15) break # registro l'evento di chiusura della finestra self.protocol('WM_DELETE_WINDOW', self.__chiudi) def mostra(self): """Visualizza la finestra """ # mando in loop l'applicazione self.mainloop() def helloWorld(self): """Stampa sullo standard output la stringa 'Hello world !' """ print 'Ciao mondo !' def __chiudi(self): """Chiude l'applicazione alla chiusura della finestra """ self.destroy() if __name__ == '__main__': f = Finestra() f.mostra()
Succede così:
C:\Users\umberto>C:\Python27\python.exe C:\Users\umberto\Documents\gui.py hello
button
File "C:\Users\umberto\Documents\gui.py", line 15
b = Button(self, text="button", command=self.helloWorld)
^
IndentationError: expected an indented block
Ultima modifica effettuata da Umberto 10/06/12 20:21
aaa