首页 > 解决方案 > 按钮变化不同,功能相同

问题描述

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

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

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.

原始配置

暗模式配置

标签: pythonpython-3.xmacostkinter

解决方案


推荐阅读