Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] MainFrame is not defined
I am following a YouTube Tutorial but I am getting a MainFrame error.

NameError: name 'MainFrame' is not defined

The following is the code I am using:


from tkinter import* 
import tkinter.messagebox
#import filmDatabase

class Film:

    def __init__(self,root):
        self.root =root
        self.root.title("Classic Film Collection")
        self.root.config(bg="cadet blue")

        Title = StringVar()
        Year  = StringVar()
        Genre = StringVar()
        Actors = StringVar()
        Directors = StringVar()
        Summary = StringVar()
        Rating = StringVar()
        Length = StringVar()

        Mainframe = Frame(self.root, bg="cadet blue")

        TitFrame = Frame(MainFrame, bd=2, padx=54,pady=8, bg= "Ghost White", relief=RIDGE)

        self.lblTit = Label(TitFrame, font=('arial', 47,'bold'), text="Classic Film Collection",bg="Ghost White")

        ButtonFrame =Frame(MainFrame, bd=2, width=1350, height=70, padx=18,pady=10, bg="Ghost White", relief=RIDGE)

        DataFrame =Frame(MainFrame, bd=1, width=1300, height=400, padx=20, pady=20, relief=RIDGE, bg="Cadet Blue")

        DataFrameLEFT =LabelFrame(DataFrame, bd=1, width=1000, height=600, padx=20, relief=RIDGE ,bg="Ghost White",
                                  font =('arial', 20, 'bold'), text="Title\n")

        DataFrameRIGHT =LabelFrame(DataFrame, bd=1, width=450, height=300, padx=31, pady=3, relief=RIDGE ,bg="Ghost White",
                                   font=('arial', 20, 'bold'), text="Year\n")
        #========================================Labels and Entry Widget===============================
        self.lblTitle = Label(DataFrameLEFT, font=('arial', 47,'bold'),text="Title", padx=2, pady=2, bg="Ghost White")
        self.lblTitle.grid(row=0, column=0, sticky=W)
        self.txtTitle = Entry(DataFrameLEFT, font=('arial', 47,'bold'),textvariable=Title, width=39)
        self.txtTitle.grid(row=0, column=1)

if __name__=='__main__':
        root = Tk()
        application = Film(root)
micseydel wrote Sep-26-2019, 09:27 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
You create Mainframe with a lower case f and then refer to it as having a capitol F MainFrame
WOW,that was it. Thank you so much.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)