Skip to content

Commit 9299604

Browse files
author
Mofan Zhou
committed
create tk2
1 parent 58628c5 commit 9299604

17 files changed

+28
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tkinterTUT/tk2_label_button.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import tkinter as tk
2+
3+
window = tk.Tk()
4+
window.title('my window')
5+
window.geometry('200x100')
6+
7+
var = tk.StringVar()
8+
l = tk.Label(window, textvariable=var, bg='green', font=('Arial', 12), width=15,
9+
height=2)
10+
#l = tk.Label(root, text='OMG! this is TK!', bg='green', font=('Arial', 12), width=15, height=2)
11+
l.pack()
12+
13+
on_hit = False
14+
def hit_me():
15+
global on_hit
16+
if on_hit == False:
17+
on_hit = True
18+
var.set('you hit me')
19+
else:
20+
on_hit = False
21+
var.set('')
22+
23+
b = tk.Button(window, text='hit me', width=15,
24+
height=2, command=hit_me)
25+
b.pack()
26+
27+
28+
window.mainloop()

0 commit comments

Comments
 (0)