对于一个项目,我需要创建一个教育计划并且我选择了一个测验。我无法让程序识别出标志已增加到 3。这是我增加标志的方式还是其他问题?。我对python(或tkinter)不太熟悉,所以请不要太苛刻。
from tkinter import *
from tkinter import ttk
root = Tk()
notebook = ttk.Notebook(root)
frame1 = ttk.Frame(notebook)
frame2 = ttk.Frame(notebook)
frame3 = ttk.Frame(notebook)
notebook.add(frame1, text="Q1")
notebook.add(frame2, text="Q2")
notebook.add(frame3, text="Q3")
def displayscore(total):
score = Tk()
score.geometry("760x450")
score.title("Score")
score.configure(background="#000138")
Label(score, text="Your score is:", fg="Black", font="Arial 36").pack()
Label(score, textvariable=total, fg="Black", font="Arial 36").pack()
def flagset():
flag.set(flag.get() + 1)
if flag == 3:
displayscore(total)
def totalset():
total.set(total.get() + 1)
def main():
#Question 1
def correct1():
clear1()
totalset()
flagset()
def clear1():
list = frame1.grid_slaves()
for l in list:
l.destroy()
Label(frame1, text="Where is the '7' in 1704?").grid(row=0)
flagset()
Label(frame1, text="Where is the '7' in 1704?").grid(row=0)
Button(frame1, text="In the Thousands", command=clear1, width=15).grid(row=1, sticky=W)
Button(frame1, text="In the Hundreds", command=correct1, width=15).grid(row=2, sticky=W)
Button(frame1, text="In the Tens", command=clear1, width=15).grid(row=3, sticky=W)
Button(frame1, text="In the Ones", command=clear1, width=15).grid(row=4, sticky=W)
#Question2
def correct2():
clear2()
totalset()
flagset()
def clear2():
list = frame2.grid_slaves()
for l in list:
l.destroy()
Label(frame2, text="What is 1704 in words?").grid(row=0)
flagset()
Label(frame2, text="What is 1704 in words?").grid(row=0)
回首忆惘然
相关分类