samedi 9 juillet 2016

Why isn't my frames background showing?

I am making an app with Tkinter (2.7) that imports a frame from another file. Unfortunately though the background colour isn't showing even though I have defined it in the imported file. The text widget on the frame shows up though. I have tried taking the mainframe = … out of the class and putting it into the body of the code between the two bottom lines but to no avail.

Main file:

import Tkinter as tk
import frames

class Window(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.title("Example Code")    
        mainframe = frames.Main(start)             

start = Window()
start.mainloop()

Frame file:

import Tkinter as tk

class Main(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)
        self.config(background="#5fe689")
        tk.Label(text="hi").pack()

Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire