Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I change the background of a Frame in Tkinter?
    primarykey
    data
    text
    <p>I have been creating an <em>Email</em> program using Tkinter, in Python 3.3. On various sites I have been seeing that the Frame widget can get a different background using <code>Frame.config(background="color")</code>. However, when I use this in my Frames it gives the following error:</p> <pre><code>_tkinter.TclError: unknown option "-Background" </code></pre> <p>It does not work when doing the following:</p> <pre><code>frame = Frame(root, background="white") </code></pre> <p>Or:</p> <pre><code>frame = Frame(root) frame.config(bg="white") </code></pre> <p>I can't figure it out. I would post my whole source code but I dont want it exposed on the internet, but the frame creation goes something like this:</p> <pre><code>mail1 = Frame(self, relief=SUNKEN) mail1.pack() mail1.place(height=70, width=400, x=803, y=109) mail1.config(Background="white") </code></pre> <p>I have tried multiple options trying to modify the background. The frame is like a wrap around an email preview for an inbox.</p> <p>In case it's needed, this the way I am importing my modules:</p> <pre><code>import tkinter, time, base64, imaplib, smtplib from imaplib import * from tkinter import * from tkinter.ttk import * </code></pre> <p>The following is the full traceback:</p> <pre><code>Traceback (most recent call last): File "C:\Users\Wessel\Dropbox\Python\Main\Class Ginomail.py", line 457, in &lt;module&gt; main() File "C:\Users\Wessel\Dropbox\Python\Main\Class Ginomail.py", line 453, in main app = Application(root) #start the application with root as the parent File "C:\Users\Wessel\Dropbox\Python\Main\Class Ginomail.py", line 60, in __init__ self.initINBOX() File "C:\Users\Wessel\Dropbox\Python\Main\Class Ginomail.py", line 317, in initINBOX mail1.config(bg="white") File "C:\Python33\lib\tkinter\__init__.py", line 1263, in configure return self._configure('configure', cnf, kw) File "C:\Python33\lib\tkinter\__init__.py", line 1254, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown option "-bg" </code></pre> <p>Gives the following error with the code from the answer: </p> <pre><code> File "C:\Users\Wessel\Dropbox\Python\Main\Class Ginomail.py", line 317, in initINBOX mail1 = Frame(self, relief=SUNKEN, style='myframe') File "C:\Python33\lib\tkinter\ttk.py", line 733, in __init__ Widget.__init__(self, master, "ttk::frame", kw) File "C:\Python33\lib\tkinter\ttk.py", line 553, in __init__ tkinter.Widget.__init__(self, master, widgetname, kw=kw) File "C:\Python33\lib\tkinter\__init__.py", line 2075, in __init__ (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError: Layout myframe not found </code></pre> <hr> <p>Solved! Thanks. Its the inbox bar to the right, background needed to be white. <img src="https://i.stack.imgur.com/zIBVU.png" alt="Happy with the results, lets work on that inbox scrolling."></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload