Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] MainFrame is not defined
#1
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:

#Frontend

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.geometry("1350x750+0+0")
        self.root.config(bg="cadet blue")

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

        #=====================================Frames=====================================
        Mainframe = Frame(self.root, bg="cadet blue")
        MainFrame.grid()

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

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

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

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

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

        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")
        DataFrameRIGHT.pack(side=RIGHT)
        #========================================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)
        root.mainloop()
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.
Quote
#2
You create Mainframe with a lower case f and then refer to it as having a capitol F MainFrame
Quote
#3
WOW,that was it. Thank you so much.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)