想用tkinter做一个从两个list里面出题的问卷
因为有12道题,都是大同小异,就想用一个loop来循环出12次。目前的问题是一下子12题同时出来了。。。有没有什么办法能让他们依次出来,一道题点了next按钮后下一道题才会出现,试了time,os.pause 都没用。。。
万分感谢!
import tkinter as tk
import random
import time
import os
Englis=['Jan','Feb','March','April','May','June','July','August','Sept','Oct','Nov','Dec']
Spalis=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']
def next():
a=0
def test():
cholis=Englis
sollis=Spalis
for i in range (0,12):
num=random.randint(0,len(cholis)-1)
EnglishWord=tk.StringVar()
EnglishWord.set('Please print out the Spanish word of '+cholis[num]+': ')
SpanishWord=tk.StringVar()
SpanishWord.set(sollis[num])
Question=tk.Label(window,textvariable=EnglishWord,font=('Arial', 25), width=15,height=3)
Question.pack()
e2 = tk.Entry(window, show=None, font=('Arial', 14))
e2.pack()
NextQButton=tk.Button(window, text="Next", command=next)
NextQButton.pack()
window=tk.Tk()
window.title('My Window')
window.geometry('1920x1080')
test()
window.mainloop()