Python GUI Program on Raspberry Pi HD

08.08.2012
This Python program uses the tkinter library to display a window with a label and a button. The button is bound to a simple event (print a message). This runs under the "wheezy" debian linux distro for the Raspberry Pi. Thanks for watching. #!/usr/bin/python3 # Create GUI # Language: Python(3) # NB the following line needs Python3 # to work on this install. from tkinter import * class MyAppClass(Frame): # NB - use two underscores together before # and after init . def __init__(self, base): super(MyAppClass, self).__init__(base) self.grid() self.create_label() self.create_button() def create_label(self): self.lattrs = Label(self) self.lattrs["text"] = "Click Him" self.lattrs.grid() def create_button(self): self.battrs = Button(self) self.battrs["text"] = "Click Me" self.battrs["command"] = self.my_event self.battrs.grid() def my_event(self): print ("Thanks for watching.") mywin = Tk() mywin.title("Rasp PI GUI") mywin.geometry("200x100") myapp = MyAppClass(mywin) mywin.mainloop()

Похожие видео

Показать еще