红尘初妆,山河无疆。 最初的面庞,碾碎梦魇无常,命格无双

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
   | 
  import tkinter as tk
  window = tk.Tk() window.title('My First Window') window.geometry('320x240')	
 
 
 
 
 
 
  var = tk.StringVar() 
 
  lab = tk.Label(window,textvariable = var, bg = 'green', font = ('consolas', 12), width = 25, height = 2) lab.pack() 
  on_hit = False def click_me(): 	global on_hit  	if on_hit == False: 		var.set('你点击了按钮') 		on_hit = True 	else: 		var.set('') 		on_hit = False
 
 
  butt = tk.Button(window,text = 'click me',width = 15, height = 2, command = click_me)	 butt.pack()
  window.mainloop()
 
  | 
 
完成之后的效果图

