Python3: TkInter
Question: I've just coded this simple program but need help with Tkinter! I want to use
what the user types into the adult ticket box so i set it as global but
because the user hasn't clicked the button yet the input_adult.get() only
returns a blank string instead of the integer the user typed. Is there any way
to get around this? Thanks in advance!!

    
    
    from tkinter import *
    import sys
    
    adult_fare = 7.45
    child_fare = 5.00
    adult_tickets = 0
    
    
    def child_Gui():
        mGui = Tk()
        labelNo = Label(mGui, text = "How many child/concession tickets do you need?").pack()
        input_child = Entry(mGui)
        input_child.pack()
        input_child.focus_set()
        b = Button(mGui, text = "GO", width = 10, command = child_travel)
        b.pack()
    
    def adult_travel():
        print(adult_tickets)
    
    def adult_Gui():
        global adult_tickets
        mGui = Tk()
        labelNo = Label(mGui, text = "How many adult tickets do you need?").pack()
        input_adult = Entry(mGui)
        input_adult.pack()
        input_adult.focus_set()
        b = Button(mGui, text = "GO", width = 10, command = adult_travel)
        b.pack()
        adult_tickets = input_adult.get()
    
    
    def compare_sunday():
        sunday_answer = sundayEntry.get().lower()
        if sunday_answer == "yes":
            global child_fare
            global adult_fare
            adult_fare = 3.00
            child_fare = 3.00
            labelNo = Label(sundayGui, text = "Ok your traveling on a sunday. All prices will be $3.00!!").pack()
            okButton = Button(sundayGui, text = "Click here to continue", width = 40, command = adult_Gui).pack()
        elif sunday_answer == "no":
            labelNo = Label(sundayGui, text = "Ok your not traveling on a sunday.").pack()
            okButton = Button(sundayGui, text = "Click here to continue", width = 40, command = adult_Gui).pack()
        else:
            labelElse = Label(sundayGui, text = "Please type yes or no!!").pack()
    
    sundayGui = Tk()
    sundayGui.title("Travel Calculator")
    label_sunday = Label(sundayGui, text = "Are you traveling on a sunday?").pack()
    sundayEntry = Entry(sundayGui)
    sundayEntry.pack()
    sundayEntry.focus_set()
    sundayB = Button(sundayGui, text = "Go", width = 10, command = compare_sunday).pack()
    


Answer: You need to call the `get` method in the callback for the button. This
requires that you make the entry widget available globally:

    
    
    def adult_Gui():
        global input_adult
        ...
        input_adult = Entry()
        ...
    
    def adult_travel():
        adult_tickets = input_adult.get()
        print(adult_tickets)
    

