|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
想进一步优化孩子的拼音抽查小软件
但是标签l2中的显示文字text2不知道如何关联刷新
求大佬赐教,代码如下
- import tkinter as tk
- import random
- window = tk.Tk()
- window.title('拼音抽查系统')
- window.geometry('400x200')
- seq = ['a','o','e','i','u',
- 'ai','ei','ui','ao','ou','iu',
- 'ie','ue','er','an','en','in','un',
- 'ang','eng','ing','ong',
- 'b','p','m','f',
- 'd','t','n','l',
- 'g','k','h','j','q','x',
- 'zh','ch','sh','r','y','w']
- num = len(seq)
- index = 0
- text2 = tk.StringVar()
- on_hit1 = False
- on_hit2 = False
- def hit(a):
- if a == False:
- a = True
- index = random.randint(0,num-1)
- value = str(seq[index])
- text2.set(value)
- else:
- a = False
-
- l1 = tk.Label(window,text = '请读出下面的拼音',width = 100,height=2)
- l2 = tk.Label(window,textvariable = text2,font = ('Arial',18),bg = 'yellow',width = 100,height=2)
- b1 = tk.Button(window,text = '下一个',width = 15,height = 2,command = hit(on_hit1))
- b2 = tk.Button(window,text = '退出',width = 15,height = 2,command = window.destroy)
- l1.pack()
- l2.pack()
- b1.pack()
- b2.pack()
- window.mainloop()
复制代码 |
|