【发布时间】:2019-07-19 12:51:18
【问题描述】:
self.darkMode()被激活时需要动态改变tk.Frame.__init__的bg
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")
【问题讨论】:
-
你试过
self.config(bg="#404040"),因为Application是继承自Frame类吗? -
@j_4321 解决了它,不敢相信没想到。谢谢你:)
标签: python python-3.x macos tkinter