Line | |
---|
1 | #------------------------------------------------------------------------------- |
---|
2 | # Name: TkinterGuiTrial2 |
---|
3 | # Purpose: |
---|
4 | # |
---|
5 | # Author: Kelvin |
---|
6 | # |
---|
7 | # Created: 27/11/2013 |
---|
8 | # Copyright: (c) Kelvin 2013 |
---|
9 | # Licence: <your licence> |
---|
10 | #------------------------------------------------------------------------------- |
---|
11 | |
---|
12 | from Tkinter import * |
---|
13 | |
---|
14 | class App: |
---|
15 | |
---|
16 | def __init__(self, master): |
---|
17 | |
---|
18 | self.frame = Frame(master) |
---|
19 | self.frame.pack() |
---|
20 | |
---|
21 | self.button1 = Button(self.frame, text = "QUIT", fg = "red", command = self.frame.quit) |
---|
22 | self.button1.pack(side = LEFT) |
---|
23 | |
---|
24 | self.button2 = Button(self.frame, text = "Hello", command = self.introduce) |
---|
25 | self.button2.pack(side = LEFT) |
---|
26 | |
---|
27 | self.button3 = Button(self.frame, text = "Create Button!", command = self.newButton) |
---|
28 | self.button3.pack(side = LEFT) |
---|
29 | |
---|
30 | def introduce(self): |
---|
31 | print("Welcome!") |
---|
32 | |
---|
33 | def newButton(self): |
---|
34 | self.buttonNEW = Button(self.frame, text = "New Button", command = self.newButton) |
---|
35 | self.buttonNEW.pack(side = LEFT) |
---|
36 | print("New Button Created!") |
---|
37 | |
---|
38 | def main(): |
---|
39 | root = Tk() |
---|
40 | |
---|
41 | app = App(root) |
---|
42 | |
---|
43 | root.mainloop() |
---|
44 | root.destroy() |
---|
45 | |
---|
46 | if __name__ == '__main__': |
---|
47 | main() |
---|
48 | |
---|
49 | # Problem: When quit using 'x' it gives error. |
---|
Note: See
TracBrowser
for help on using the repository browser.