|
| 1 | +from Tkinter import * |
| 2 | + |
| 3 | + |
| 4 | +class App: |
| 5 | + |
| 6 | + def __init__(self, master): |
| 7 | + frame = Frame(root, width=450, height=250) |
| 8 | + frame.pack() |
| 9 | + self.quote = Label(frame, text="hel", height=10, width=30, wraplength=300, |
| 10 | + bg="#fff", padx=10, fg="#333", font=("Helvetica", 14)) |
| 11 | + self.quote.pack() |
| 12 | + self.author = Label(frame, text="-" + "author", anchor="e", |
| 13 | + justify='right', padx=20, pady=15, bg="#fff", fg="#444", font=("Helvetica", 12)) |
| 14 | + self.author.pack(side="right") |
| 15 | + self.button = Button(frame, text="QUIT", fg="red", justify="left") |
| 16 | + self.button.bind("<Button-1>", self.callback) |
| 17 | + self.button.pack() |
| 18 | + self.hi_there = Button(frame, text="Hello", |
| 19 | + command=self.say_hi, justify="left") |
| 20 | + self.hi_there.pack() |
| 21 | + |
| 22 | + def say_hi(self): |
| 23 | + print "hi there, everyone!" |
| 24 | + |
| 25 | + def callback(self, event): |
| 26 | + print "clicked at", event.x, event.y |
| 27 | +root = Tk() |
| 28 | +root.configure(background='#fff') |
| 29 | +app = App(root) |
| 30 | +root.mainloop() |
0 commit comments