【问题标题】:Dynamically change frame colour tkinter动态更改帧颜色 tkinter
【发布时间】: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


【解决方案1】:

由 j_4321 在评论中解决。 self.config(bg="#404040")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-02
    • 1970-01-01
    • 2018-07-21
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 2019-09-24
    • 2014-04-05
    相关资源
    最近更新 更多