-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtkinter_test.py
50 lines (39 loc) · 1.06 KB
/
tkinter_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
#Filename=tkinter_test.py
from Tkinter import *
class msgBox:
def __init__(self,parent):
parent.geometry("220x130")
self.parent=parent
self.frame1=Frame(parent)
self.frame1["height"]=200
self.frame1["width"]=200
self.frame1.pack()
#button1:
self.btn1=Button(self.frame1)
self.btn1.configure(text="exit!!!")
self.btn1.bind("<Button-1>",self.act1)
#button2:
self.btn2=Button(self.frame1)
self.btn2.configure(text='show info')
self.btn2.bind("<Button-1>",self.act2)
#labels:
self.msg=Label(self.frame1,text='Welcome to the "msgbox"!!!\nclick exit to exit :D')
self.msg2=Label(self.frame1)
self.msg.pack()
self.btn2.pack()
self.msg2.pack()
self.btn1.pack(side=BOTTOM)
def act1(self,event):
self.parent.destroy()
def act2(self,event):
if self.msg2["text"]=='':
self.msg2["text"]='this simple program is \none of my first "Tkinter" programs.'
self.btn2["text"]='Hide info'
else:
self.msg2["text"]=''
self.btn2["text"]='show info'
#main:
root=Tk()
msgBox1=msgBox(root)
root.mainloop()