Python/Tkinter root window background configuration -
i'm trying create root window black background blend button backgrounds.
i have following:
class application(frame): def __init__(self, parent): frame.__init__(self, parent) self.parent = parent self.initui() ... def initui(self): self.outputbox = text(bg='black', fg='green', relief=sunken, yscrollcommand='true') self.outputbox.pack(fill='both', expand=true) self.button1 = button(self, text='button1', width=40, bg ='black', fg='green', activebackground='black', activeforeground='green') self.button1.pack(side=right, padx=5, pady=5) self.button2 = button(self, text='button2', width=20, bg='black', fg='green', activebackground='black', activeforeground='green') self.button2.pack(side=left, padx=5, pady=5) ... def main(): root = tk() root.geometry('1100x350+500+300') root.configure(background = 'black') app = application(root) root.mainloop() but root.configure(background = 'black') isn't changing root window's background color... suggestions?
this works (check how parent root referenced):
edit: edited code , figure make clear colors set:
from tkinter import * class application(frame): def __init__(self, master=none): frame.__init__(self, master) self.parent = master self.initui() def initui(self): self.outputbox = text(self.parent, bg='yellow', height= 10, fg='green', relief=sunken, yscrollcommand='true') self.outputbox.pack(fill='both', expand=true) self.button1 = button(self.parent, text='button1', width=20, bg ='blue', fg='green', activebackground='black', activeforeground='green') self.button1.pack(side=right, padx=5, pady=5) self.button2 = button(self.parent, text='button2', width=25, bg='white', fg='green', activebackground='black', activeforeground='green') self.button2.pack(side=left, padx=5, pady=5) def main(): root = tk() app = application(root) app.parent.geometry('300x200+100+100') app.parent.configure(background = 'red') app.mainloop() main()
Comments
Post a Comment