激活tk.Frame.__init__
时需要动态更改self.darkMode()
的背景色
class Application(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master, bg="white")
self.grid()
root.title("redacted")
root.geometry("260x160")
root.resizable(0, 0)
self.createWidgets()
rows = 0
while rows < 50:
root.rowconfigure(rows, weight=1)
root.columnconfigure(rows, weight=1)
rows += 1
...
def darkMode(self):
self.question.config(bg="#404040", fg="white")
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)
self.QUIT.config(highlightbackground="#404040")
root.config(bg="#404040")
答案 0 :(得分:1)
由j_4321解决。 self.config(bg="#404040")