具有相同功能的按钮变化不同

时间:2019-07-19 09:34:35

标签: python python-3.x macos tkinter

我试图使所有按钮都是单边的,但是尽管以后定义的按钮与稍后定义的按钮相同,但开头定义的按钮看起来却有所不同。我遇到的另一个问题是更改标题栏的颜色。

稍后,我尝试定义原始按钮“退出”,但它仍然像这样显示,而选项按钮仍然像这样显示。 [稍后显示]

def createWidgets(self):
        self.question = tk.Label(self, text="Welcome to Quiz App\nEach round we will ask you a question\nEach round you will have to\nchoose the correct answer\nGet it right and get a point\nGet it wrong and you don't.")
        self.question.grid(row=1, column=1, columnspan=2)
        self.ocontinue = tk.Button(self, width=12)
        self.ocontinue["text"] = "Continue"
        self.ocontinue["command"] = self.ogcont
        self.ocontinue.grid(column=1, row=2, columnspan=2, padx=1, pady=1)
        self.QUIT = tk.Button(self, text="Quit", width=8,fg="red", command=root.destroy)
        self.QUIT.grid(column=1, row=7, columnspan=2, padx=5, pady=5)

        self.question.config(bg="#404040", fg="white")
        self.ocontinue.config(highlightbackground="#404040")
        self.QUIT.config(highlightbackground="#404040")
        root.config(bg="#404040")
 <~ the original configs

    def darkMode(self):
        self.answercheck.config(bg="#404040", fg="white")
        self.ocontinue.config(highlightbackground="#404040")
        self.option1.config(highlightbackground="#404040", highlightthickness=2)
        self.option2.config(highlightbackground="#404040", highlightthickness=2)
        self.option3.config(highlightbackground="#404040", highlightthickness=2)
        self.option4.config(highlightbackground="#404040", highlightthickness=2)
<~ the configs applied to the option buttons.

original configs

darkmode configs

0 个答案:

没有答案