Python 名称错误:名称';ChildFirstBox3';未定义-尝试#1-7时出现相同错误,但对8正常工作

Python 名称错误:名称';ChildFirstBox3';未定义-尝试#1-7时出现相同错误,但对8正常工作,python,tkinter,pycharm,Python,Tkinter,Pycharm,我试图弄明白为什么我的代码在这里运行时会出错 def Scroll(): global ChildScroll global text_area TESTSCROLL() # Title Label ChildScroll = Label(AppWindow, text="Review Info", font=("Times New Roman", 15),background='green',

我试图弄明白为什么我的代码在这里运行时会出错

    def Scroll():
global ChildScroll
global text_area
TESTSCROLL()
# Title Label
ChildScroll = Label(AppWindow, text="Review Info",
                    font=("Times New Roman", 15),background='green',
                    foreground="white")
ChildScroll.place(relx=0.5, rely=0.03)

# Creating scrolled text area
# widget with Read only by
# disabling the state
text_area = st.ScrolledText(AppWindow, width=15,height=8,
                            font=("Ariel",10))

text_area.place(relx=0.5, rely=0.1, relheight=.4, relwidth=.3)
# Inserting Text which is read only
# IF statement + Batman functions
text_area.insert(tk.INSERT, TextForReview)

# Making the text read only
text_area.configure(state='disabled')
#ForScrollText()

    def TESTSCROLL():
global a
a = ChildFirstBox1.get() + ", " + DOBBox1.get() + ", " + GenBox1.get() + ", " + AgeBox1.get() \
    + "\nShirt Size: " + ShirtBox1.get() \
    + "\nPants Size: " + PantsBox1.get() \
    + "\nShoes Size: " + ShoeBox1.get() \
    + "\nWish 1: " + WishBox1.get() \
    + "\nWish 2: " + WishBox2.get() \
    + "\nNeed: " + WishBox3.get()

global b
b = ChildFirstBox2.get() + ", " + DOBBox2.get() + ", " + GenBox2.get() + ", " + AgeBox2.get() \
    + "\nShirt Size: " + ShirtBox2.get() \
    + "\nPants Size: " + PantsBox2.get() \
    + "\nShoes Size: " + ShoeBox2.get() \
    + "\nWish 1: " + WishBox1_2.get() \
    + "\nWish 2: " + WishBox2_2.get() \
    + "\nNeed: " + WishBox3_2.get()

global c
c = ChildFirstBox3.get() + ", " + DOBBox3.get() + ", " + GenBox3.get() + ", " + AgeBox3.get() \
    + "\nShirt Size: " + ShirtBox3.get() \
    + "\nPants Size: " + PantsBox3.get() \
    + "\nShoes Size: " + ShoeBox3.get() \
    + "\nWish 1: " + WishBox1_3.get() \
    + "\nWish 2: " + WishBox2_3.get() \
    + "\nNeed: " + WishBox3_3.get()


global d
d = ChildFirstBox4.get() + ", " + DOBBox4.get() + ", " + GenBox4.get() + ", " + AgeBox4.get() \
    + "\nShirt Size: " + ShirtBox4.get() \
    + "\nPants Size: " + PantsBox4.get() \
    + "\nShoes Size: " + ShoeBox4.get() \
    + "\nWish 1: " + WishBox1_4.get() \
    + "\nWish 2: " + WishBox2_4.get() \
    + "\nNeed: " + WishBox3_4.get() \


global e
e = ChildFirstBox5.get() + ", " + DOBBox5.get() + ", " + GenBox5.get() + ", " + AgeBox5.get() \
    + "\nShirt Size: " + ShirtBox5.get() \
    + "\nPants Size: " + PantsBox5.get() \
    + "\nShoes Size: " + ShoeBox5.get() \
    + "\nWish 1: " + WishBox1_5.get() \
    + "\nWish 2: " + WishBox2_5.get() \
    + "\nNeed: " + WishBox3_5.get() \

global f
f = ChildFirstBox6.get() + ", " + DOBBox6.get() + ", " + GenBox6.get() + ", " + AgeBox6.get() \
    + "\nShirt Size: " + ShirtBox6.get() \
    + "\nPants Size: " + PantsBox6.get() \
    + "\nShoes Size: " + ShoeBox6.get() \
    + "\nWish 1: " + WishBox1_6.get() \
    + "\nWish 2: " + WishBox2_6.get() \
    + "\nNeed: " + WishBox3_6.get() \

global g
g = ChildFirstBox7.get() + ", " + DOBBox7.get() + ", " + GenBox7.get() + ", " + AgeBox7.get() \
    + "\nShirt Size: " + ShirtBox7.get() \
    + "\nPants Size: " + PantsBox7.get() \
    + "\nShoes Size: " + ShoeBox7.get() \
    + "\nWish 1: " + WishBox1_7.get() \
    + "\nWish 2: " + WishBox2_7.get() \
    + "\nNeed: " + WishBox3_7.get()

global h
h = ChildFirstBox8.get() + ", " + DOBBox8.get() + ", " + GenBox8.get() + ", " + AgeBox8.get() \
    + "\nShirt Size: " + ShirtBox8.get() \
    + "\nPants Size: " + PantsBox8.get() \
    + "\nShoes Size: " + ShoeBox8.get() \
    + "\nWish 1: " + WishBox1_8.get() \
    + "\nWish 2: " + WishBox2_8.get() \
    + "\nNeed: " + WishBox3_8.get()

global TextForReview
TextForReview = ""
if NumKids.get() == "1":
    TextForReview = "  " + a

elif NumKids.get() == "2":
    TextForReview = "  " + a + "\n\n" + b

elif NumKids.get() == "3":
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c

elif NumKids.get() == "4":
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c \
                    + "\n\n" + d

elif NumKids.get() == "5":
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c \
                    + "\n\n" + d + "\n\n" + e

elif NumKids.get() == "6":
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c \
                    + "\n\n" + d + "\n\n" + e + "\n\n" + f

elif NumKids.get() == "7":
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c \
                    + "\n\n" + d + "\n\n" + e + "\n\n" + f \
                    + "\n\n" + g

else:
    TextForReview = "  " + a + "\n\n" + b + "\n\n" + c \
                    + "\n\n" + d + "\n\n" + e + "\n\n" + f \
                    + "\n\n" + g + "\n\n" + h
在我的程序开始时,要求用户填写他们的信息并键入他们的子女数量(1-8),然后我的代码只填充输入框以填写有关他们子女的信息。完成此操作后,他们单击一个名为review的按钮,它将显示用户键入的信息。我正在用尽屏幕空间,试图将所有信息放入页面中,因此我查看了如何添加滚动小部件以提供帮助。当输入#8时,用户键入的所有信息都会完美地显示在该查看页面中,并且滚动条工作正常,但是如果用户尝试输入除8以外的任何数字(因此为1-7),我会在标题中列出错误。我做错什么了吗