【发布时间】:2018-09-03 11:44:15
【问题描述】:
我不确定我应该如何将其创建为“多项选择”问答游戏。
我不知道如何继续。我不确定如何在这种情况下使用类。如果我能得到第一个问题的答案,我相信我会从那里继续,但我需要帮助。
这是我当前的代码:
from tkinter import *
from tkinter import ttk
#User Interface Code
root = Tk() # Creates the window
root.title("Quiz Game")
def new_window():
newWindow = Toplevel()
message = Label(newWindow, text="What is the capital of France?", font =
("Arial", "24"), pady=30)
display = Label(newWindow, width=150, height=40)
class letsQuiz:
def __init__(self, questions, answers):
self.questions = questions
self.answers = answers
self.label = Label(newWindow, text="What is the capital of France?")
self.label.pack()
self.answer1button = Button(newWindow, text="Madrid")
self.answer2button = Button(newWindow, text="Paris")
self.answer3button = button(newWindow, text="London")
self.answer1button.pack()
self.answer2button.pack()
self.answer3button.pack()
message.pack()
display.pack()
message_label1 = Label(text="Let's quiz some of your knowledge :)", font = (
"Arial", "25"), padx=40, pady=20)
message_label2 = Label(root, text="Click 'Continue' to begin.",
wraplength=250)
button1 = Button(root, text ="Continue", command=new_window, width=16,
bg="red")
display2 = Label(root, width=100, height=30)
message_label1.pack()
message_label2.pack()
button1.pack()
display2.pack()
root.mainloop() # Runs the main window loop
【问题讨论】:
-
看起来您已将“问题一”固定在窗口底部。并且不接受它作为答案xD
-
哦,对不起,我是新来的。不知道事情是如何运作的。对不起,我的坏人。我会接受你的回答!
-
我将处理一个示例并在几分钟内发布解决方案。
-
好。但为了记录:“请帮助我”不是这个社区范围内的请求。为了更符合这个社区的政策,你应该先尝试自己解决这个问题。然后,当您遇到具体问题时,您应该提出一个问题。放下需求和一些代码,然后:现在告诉我如何将这两件事结合在一起......正如所说:不是一个好主意。
-
可以理解。我会更符合社区规则和准则。这个问题一直困扰着我一段时间,我尝试自己解决但失败了,所以我将尝试在这里提问,