Error - 'None Type' has no attribute 'config'

30 views Asked by At

Error Code

Whenever I run this , it either shows 'None Type' has no attribute 'config' or 'None Type' has no attribute 'get'. How to solve this?

def trip1():
   global trip
   trip=trip*2
   print(trip)

def trip2():
   global trip
   trip=trip*3
   print(trip)
   
def Book():
   Booknow=Toplevel(root)
   Booknow.geometry("1000x1000")

   def grab():
      Booklable=Label(Booknow,bd=1,bg="white",height=45,width=150,relief='solid')
      Booklable.place(x=240,y=75)
      Confirmed=Message(Booknow, text="TICKET CONFIRMED",font="500",fg="BLACK",width=200,bd=6,relief="solid").place(x=690,y=120)
      Adults=Label(Booknow, text="Adults",fg="BLACK",width=5,bd=6,relief="solid").place(x=690,y=150)
      Adult1=Label(Booknow,text="",fg="BLACK",width=5,bd=6,relief="solid").place(x=750,y=250)
      Adult1.config(text=adlt.get())

   Showticket=Button(Booknow,text="SHOW TICKET",command=grab,width=58,height=2,relief='solid').place(x=40,y=450)      

   
   
   
   
   
   

#USER INTERFACE



labelhead=Label(root,text='FLY HIGH ! BOOK YOUR HAPPINESS !',bd=10,relief=RIDGE,fg='#CDCDC8' ,bg='#2F2F4F',font=("algerian",30))
labelhead.place(x=425, y=20)

labelcentre=Label(root,bd=1,bg="#363664",height=27,width=77,relief='solid')
labelcentre.place(x=500,y=200)

labelleft=Label(root,bd=1,bg="#363664",height=38,width=60,relief='solid')
labelleft.place(x=37,y=200)

labelright=Label(root,bd=1,bg="#363664",height=38,width=60,relief='solid')
labelright.place(x=1079,y=200)

labelbottom=Label(root,bd=1,bg="#363664",height=9,width=77,relief='solid')
labelbottom.place(x=500,y=635)

arrivallable=Label(root,text='DEPARTURE',bd=1,bg="#BCBCEE",relief='solid',width=10,height=2)
arrivallable.place(x=511,y=296)
departurelable=Label(root,text='ARRIVAL',bd=1,bg="#BCBCEE",relief='solid',width=10,height=2)
departurelable.place(x=780,y=296)

labelframe1 = LabelFrame(root,bg="#363664" ,height=70,width=200,font=('algerian',1),fg='gold',bd=2,relief=RIDGE)
labelframe1.place(x=0,y=110,relwidth=10)

oneway = Button(root, text = "One Way",width=103,height=2,bg='#CDCDB5',relief='solid',command=trip1).place(x=25,y=125)
roundtrip = Button(root, text = "Round Trip",width=103,height=2,bg='#CDCDB5',relief='solid',command=trip2).place(x=780,y=125)


labelfrom = Label(root, text = "From",width=34,bg='#BCBCEE',relief='solid',bd=1).place(x = 512,y = 210)  
labelto = Label(root, text = "To",width=35,bg='#BCBCEE',relief='solid',bd=1).place(x = 780, y = 210)    
entry1 = Entry(root,width=40,relief='solid',bd=1).place(x = 512, y = 245)  
entry2 = Entry(root,width=41,relief='solid',bd=1).place(x = 780, y = 245)

from tkcalendar import *

#Create an instance of tkinter frame or window
from datetime import date
dt1=date(2024,3,1) 
dt2=date(2026,12,30)
dt3=date(2026,1,1)

cal1= Calendar(root, selectmode="day",mindate=dt1,maxdate=dt2)
cal1.place(x = 508,y =350)

#Function to select the date
def get_date():
   buttonlabel1.config(text=cal1.get_date())

button1= Button(root, text= "Select the Date", command= get_date,relief='solid',bd=1)
button1.place(x = 512,y =550)

buttonlabel1= Label(root, text="",relief='solid')
buttonlabel1.place(x = 512,y =580)

#Calendar for arrival
cal2= Calendar(root, selectmode="day",mindate=dt1,maxdate=dt3)
cal2.place(x = 780,y =350)

#Function to select the date
def get_date():
   buttonlabel2.config(text=cal2.get_date())

button2= Button(root, text= "Select the Date", command= get_date,relief='solid',bd=1)
button2.place(x = 780,y =550)

buttonlabel2= Label(root, text="",relief='solid')
buttonlabel2.place(x = 780,y =580)

classlabel=Label(root,text='Choose Class',bd=1,bg='#BCBCEE',width=58,height=2,relief='solid').place(x=40,y=450)

v=0
rb1=Radiobutton(root,text='Economy',variable=v,value=1,height=4,width=20,relief='solid').place(x=165,y=510)
rb2=Radiobutton(root,text='Premium Economy',variable=v,value=2,height=4,width=20,relief='solid').place(x=165,y=590)
rb3=Radiobutton(root,text='Business Class',variable=v,value=3,height=4,width=20,relief='solid').place(x=165,y=670)

classlabel=Label(root,text='Select Number of People',bd=1,bg='#BCBCEE',width=58,height=2,relief='solid').place(x=1086,y=450)

inflable=Label(root,text='Infants',bd=1,relief='solid',width=27,height=3).place(x=1086,y=526)
inf= Spinbox(root, from_=0, to=10,width=25).place(x=1296,y=540)

childlable=Label(root,text='Children',bd=1,relief='solid',width=27,height=3).place(x=1086,y=606)
child= Spinbox(root, from_=0, to=10,width=25).place(x=1296,y=620)

adultlable=Label(root,text='Adults',bd=1,relief='solid',width=27,height=3).place(x=1086,y=686)
adlt= Spinbox(root, from_=0, to=10,width=25).place(x=1296,y=700)

flights2=LabelFrame(root,text='Available Flights To',bd=1,bg='white',relief='solid',height=200,width=350,labelanchor=N).place(x=1113,y=223)
labelflights2= Label(root, text="London Dubai Kolkata Delhi Mumbai Chennai",wraplength=90,font=(20),anchor=N) .place(x=1250,y=250)

flights1=LabelFrame(root,text='Available Flights From',bd=1,bg='white',relief='solid',height=200,width=350,labelanchor=N).place(x=78,y=223)
labelflights1= Label(root, text="Jaipur Hyderabad Kolkata Delhi Mumbai Chennai",wraplength=90,font=(20),anchor=N) .place(x=195,y=250)

bookbutton=Button(root, text= "Book The Flight",width=60,height=5, command=Book ,relief='solid',bd=1)
bookbutton.place(x = 555,y =660)
















root.mainloop() 

I tried multiple options , making a nested function , a new button to pull it off so I could display a spinbox number inside a toplevel window which is triggered using another button.

0

There are 0 answers