I have created a Window using tkinter
and config
ured the root
to have a bg
colour. I set bg="Black"
to have the whole Window Black, but when I tested the script, the space around the Window was Black but the middle of the Window was still White.
I tried searching the internet, but I could not find anything (it may be the phrasing but I don't know a better way to phrase this). I tried different ways to phrase this question like "Why does the background colour of a Window not fill the middle?" and "Why does the bg="Black" not fill the middle in Python", but it comes up with tutorials for tkinter
and picture colouring in Python.
I also tried attaching other attributes to the config
but like fg="Black"
but the code throws a Syntax Error
stating "_tkinter.TclError: unknown option "-fg" ". I don't know what is causing this or how to fix it.
Here is the segment of the code:
def mainloop_sw():
root = tk.Tk()
root.title("Adventure")
root.geometry("250x250")
root.config(bg="Black")
app = Window(root)
app.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
root.mainloop()
if __name__ == "__main__":
mainloop_sw()
As you can see the root
is config
ured to have the bg="Black"
but the middle section is left white.
Here is a picture for context:
As you can see the middle is not coloured in black, and yes, there are widgets, but all of them are coloured in black (for label
s) or grey (for button
s) there are no other widgets in the program which could cover up the background. If you need a confirmation of this you can just ask for the full code.
Why is the middle bit of the Window (shown in the image above) not coloured in Black when the root
is config
ured to have bg="Black"
and how do I fix it?