python error run from cmd
Question: For my coursework i am doing a booking system which uses some tree views. The
problem is that if ran from cmd when i double click on a row in the tree view
it does not populate the boxes below it, however if i run it from the idle it
does. Below is my where i have made my class and two defs which are
create_GUI(for first part of gui before double click) and double click(makes
second part of GUI)

    
    
    from tkinter import *
    import os
    import datetime
    import sqlite3
    from tkinter.ttk import Combobox,Treeview,Scrollbar
    import tkinter as tk
    import Utilities
    
    
    class Application(Frame):
        """ Binary to Decimal """ 
        def __init__(self, master):
            """ Initialize the frame. """
            super(Application, self).__init__(master)
            self.grid()
            self.create_GUI()
    
        def Quit(self):
            self.master.destroy()
    
        def create_GUI(self):
            frame1 = tk.LabelFrame(root, text="frame1", width=300, height=130, bd=5)
            frame2 = tk.LabelFrame(root, text="frame2", width=300, height=130, bd=5)
            frame1.grid(row=0, column=0, columnspan=3, padx=8)
            frame2.grid(row=1, column=0, columnspan=3, padx=8)
            self.title_lbl = Label(frame1, text = "Students")
            self.title_lbl.grid(row = 0, column = 2)
    
            self.fn_lbl = Label(frame1, text = "First Name:")
            self.fn_lbl.grid(row = 1 , column = 1)
    
            self.fn_txt = Entry(frame1)
            self.fn_txt.grid(row = 1, column = 2)
    
            self.ln_lbl =Label(frame1, text = "Last Name:")
            self.ln_lbl.grid(row = 2, column = 1)
    
            self.ln_txt = Entry(frame1)
            self.ln_txt.grid(row = 2, column = 2)
    
            self.q_btn = Button(frame1, text = "Back",padx=80,pady=10, command = lambda: self.Quit())
            self.q_btn.grid(row = 3, column = 0)
    
            self.s_btn = Button(frame1, text = "search",padx=80,pady=10, command = lambda: self.search())
            self.s_btn.grid(row = 3,column = 3)
    
            self.tree = Treeview(frame2,height = 6)
            self.tree["columns"] = ("StudentID","First Name","Last Name")#,"House Number", "Street Name", "Town Or City Name","PostCode","MobilePhoneNumber")
            self.tree.column("StudentID",width = 100)
            self.tree.column("First Name",width = 100)
            self.tree.column("Last Name", width = 100)
    ##        self.tree.column("House Number", width = 60)
    ##        self.tree.column("Street Name", width = 60)
    ##        self.tree.column("Town Or City Name", width = 60)
    ##        self.tree.column("PostCode", width = 60)
    ##        self.tree.column("MobilePhoneNumber", width = 60)
    
            self.tree.heading("StudentID",text="StudentID")
            self.tree.heading("First Name",text="First Name")
            self.tree.heading("Last Name",text="Last Name")
    ##        self.tree.heading("House Number",text="House Number")
    ##        self.tree.heading("Street Name",text="Street Name")
    ##        self.tree.heading("Town Or City Name",text="Town Or City Name")
    ##        self.tree.heading("PostCode",text="PostCode")
    ##        self.tree.heading("MobilePhoneNumber",text="MobilePhoneNumber")
    
            self.tree["show"] = "headings"
            yscrollbar = Scrollbar(frame2, orient='vertical', command=self.tree.yview)
            xscrollbar = Scrollbar(frame2, orient='horizontal', command=self.tree.xview)
            self.tree.configure(yscroll=yscrollbar.set, xscroll=xscrollbar.set)
            yscrollbar.grid(row=1, column=5, padx=2, pady=2, sticky=NS)
            self.tree.grid(row=1,column=0,columnspan =5, padx=2,pady=2,sticky =NSEW)
            self.tree.bind("<Double-1>",lambda event :self.OnDoubleClick(event))
    
        def OnDoubleClick(self, event):
            frame3 = tk.LabelFrame(root, text="frame1", width=300, height=130, bd=5)
            frame3.grid(row=2, column=0, columnspan=3, padx=8)
            self.message=StringVar()
            self.message.set("")
            self.lblupdate = Label(frame3, textvariable = self.message).grid(row=0,column=0,sticky=W)
            curItem = self.tree.focus()
            contents =(self.tree.item(curItem))
            StudentDetails = contents['values']
            print(StudentDetails)
    
            self.tStudentID=StringVar()
            self.tFirstName = StringVar()
            self.tLastName = StringVar()
            self.tHouseNumber = StringVar()
            self.tStreetName = StringVar()
            self.tTownOrCityName = StringVar()
            self.tPostCode = StringVar()
            self.tEmail = StringVar()
            self.tMobilePhoneNumber = StringVar()
    
            self.tStudentID.set(StudentDetails[0])
            self.tFirstName.set(StudentDetails[1])
            self.tLastName.set(StudentDetails[2])
            self.tHouseNumber.set(StudentDetails[3])
            self.tStreetName.set(StudentDetails[4])
            self.tTownOrCityName.set(StudentDetails[5])
            self.tPostCode.set(StudentDetails[6])
            self.tEmail.set(StudentDetails[7])
            self.tMobilePhoneNumber.set(StudentDetails[8])
    
            self.inst_lbl0 = Label(frame3, text = "Student ID").grid(row=5,column=0,sticky=W)
            self.StudentID = Label(frame3, textvariable=self.tStudentID).grid(row =5,column=1,stick=W)
            self.inst_lbl1 = Label(frame3, text = "First Name").grid(row=6,column=0,sticky=W)
            self.NFirstName = Entry(frame3, textvariable=self.tFirstName).grid(row =6,column=1,stick=W)
            self.inst_lbl2 = Label(frame3, text = "Last Name").grid(row=7,column=0,sticky=W)
            self.NLastName = Entry(frame3, textvariable=self.tLastName).grid(row =7,column=1,stick=W)
            self.inst_lbl3 = Label(frame3, text = "House Number").grid(row=8,column=0,sticky=W)
            self.HouseNumber = Entry(frame3,textvariable=self.tHouseNumber).grid(row=8,column=1,sticky=W)
            self.inst_lbl4 = Label(frame3, text = "Street Name").grid(row=9,column=0,sticky=W)
            self.StreetName =Entry(frame3,textvariable=self.tStreetName).grid(row=9,column=1,sticky=W)
            self.inst_lbl5 = Label(frame3, text = "Town or City Name").grid(row=10,column=0,sticky=W)
            self.TownOrCityName =Entry(frame3,textvariable=self.tTownOrCityName).grid(row=10,column=1,sticky=W)
            self.inst_lbl6 = Label(frame3, text = "Postcode").grid(row=11,column=0,sticky=W)
            self.PostCode = Entry(frame3,textvariable=self.tPostCode).grid(row=11,column=1,sticky=W)
            self.inst_lbl7 = Label(frame3, text = "Email").grid(row=12,column=0,sticky=W)
            self.Email =Entry(frame3,textvariable=self.tEmail).grid(row=12,column=1,sticky=W)
            self.inst_lbl8 = Label(frame3, text = "Mobile phonenumber").grid(row=13,column=0,sticky=W)
            self.MobilePhoneNumber =Entry(frame3,textvariable=self.tMobilePhoneNumber).grid(row=13,column=1,sticky=W)
    
            self.btnSaveChanges = Button(frame3, text = "save changes",padx=80,pady=10,command = lambda:self.SaveChanges()).grid(row=14,column=0,sticky=W)
            self.btnSaveChanges = Button(frame3, text = "delete record",padx=80,pady=10,command = lambda:self.DeleteRecord()).grid(row=14,column=1,sticky=W)
    
    
        def search(self):
            FirstName = self.fn_txt.get()
            LastName = self.ln_txt.get()
            with sqlite3.connect("GuitarLessons.db") as db:
                cursor = db.cursor()
                cursor.row_factory = sqlite3.Row
                sql = "select StudentID,FirstName,LastName,HouseNumber,StreetName,TownOrCityName,PostCode,Email,MobilePhoneNumber"\
                      " from tblStudents"\
                      " where FirstName like ?"\
                      " and LastName like ?"
                cursor.execute(sql,("%"+FirstName+"%","%"+LastName+"%",))
                StudentList = cursor.fetchall()
                print(StudentList)
    
            self.loadStudents(StudentList)
    
        def loadStudents(self,StudentList):
            for i in self.tree.get_children():
                self.tree.delete(i)
    
            for student in StudentList:
                self.tree.insert("" , 0,values=(student[0],student[1],student[2],student[3],student[4],student[5],student[6],student[7],student[8]))
    
        def SaveChanges(self):
            valid = True
            self.message.set("")
            NFirstName = self.tFirstName.get()
            NLastName = self.tLastName.get()
            NHouseNumber = self.tHouseNumber.get()
            NStreetName = self.tStreetName.get()
            NTownOrCityName = self.tTownOrCityName.get()
            NPostCode = self.tPostCode.get()
            NEmail = self.tEmail.get()
            NMobilePhoneNumber = self.tMobilePhoneNumber.get()
            StudentID = self.tStudentID.get()
            if NFirstName == "" or NLastName == "" or NEmail == "" or NMobilePhoneNumber == "":
                valid = False
                self.message.set('missing details,first name,last name,phone number, email are all needed')
            if not Utilities.is_phone_number(NMobilePhoneNumber ):
                valid = False
                self.message.set('invalid mobile phone number')
            if not Utilities.is_postcode(NPostCode):
                valid = False
                self.message.set('invalid postcode')
            if not Utilities.is_email(NEmail):
                valid = False
                self.message.set('invalid email')
            if NHouseNumber != "":
                if int(NHouseNumber) < 0:
                    self.message.set('invalid house number')
            if valid == True:
                with sqlite3.connect("GuitarLessons.db") as db:
                    cursor = db.cursor()
                    sql = "update tblStudents set FirstName =?,LastName=?,HouseNumber=?,StreetName=?,TownOrCityName=?,PostCode=?,Email=?,MobilePhoneNumber=? where StudentID=?"
                    cursor.execute(sql,(NFirstName,NLastName,NHouseNumber,NStreetName,NTownOrCityName,NPostCode,NEmail,NMobilePhoneNumber,StudentID))
                    db.commit()
                self.message.set("student details updated")
    
        def DeleteRecord(self):
            StudentID = self.tStudentID.get()
            #StudentID = int(StudentID)
            with sqlite3.connect("GuitarLessons.db") as db:
                cursor = db.cursor()
                sql = "delete from tblStudents where StudentID = ?"
                cursor.execute(sql,(StudentID))
                db.commit()
                self.tlabeupdate.set("student details deleted")
    
    root = Tk()
    root.title("booking system")
    root.geometry("800x800")
    root.configure(bg="white")
    app = Application(root)
    
    root.mainloop()
    

EDIT when i was copyign and pasting the rest of my code that i forgot to put
in the original post i found that it only stops working if i open it through
the student menu(separate peice of code) but it works if i dont go through the
menu


Answer: You must call `mainloop()` on the root window so that your program can process
events.

