been having a problem with this program since this morning, it seems to just be placement of code rather than the code itself, I am trying to run a calculator in a new tkinter window separate from the root window and have been juggling the code around to try and get it to function to no avail, the errors that keep popping up seem to be based on "typeSpace" or "calcWindow" not being defined but they clearly are, does anybody know how to correctly place this code so it recognizes these variables correctly at run time?
from tkinter import *
import tkinter as tk
#def onButton_Plus():
# global one_Num#Declares global variable
# number_One = typeSpace.get()#Gets number typed on calculator by user
# one_Num = int(number_One)
# typeSpace.delete(0, END)
def calcClick():
calcWindow = Toplevel()##opens a new window for Calculator mode
##Creates a empty field in the calculator page for numbers to be displayed
typeSpace = Entry(calcWindow, width=35, borderwidth=5)
typeSpace.grid(row=0, column=0, columnspan=3, padx=10, pady=10)
##Names the new window
calcWindow.title("Calculator Mode")
##Defines calculator buttons and places them in grid setting on screen
button_1 = Button(calcWindow, text="1", padx=40, pady=20, command=lambda: onButton_Click(1)).grid(row=3, column=0)
button_2 = Button(calcWindow, text="2", padx=40, pady=20, command=lambda: onButton_Click(2)).grid(row=3, column=1)
button_3 = Button(calcWindow, text="3", padx=40, pady=20, command=lambda: onButton_Click(3)).grid(row=3, column=2)
button_4 = Button(calcWindow, text="4", padx=40, pady=20, command=lambda: onButton_Click(4)).grid(row=2, column=0)
button_5 = Button(calcWindow, text="5", padx=40, pady=20, command=lambda: onButton_Click(5)).grid(row=2, column=1)
button_6 = Button(calcWindow, text="6", padx=40, pady=20, command=lambda: onButton_Click(6)).grid(row=2, column=2)
button_7 = Button(calcWindow, text="7", padx=40, pady=20, command=lambda: onButton_Click(7)).grid(row=1, column=0)
button_8 = Button(calcWindow, text="8", padx=40, pady=20, command=lambda: onButton_Click(8)).grid(row=1, column=1)
button_9 = Button(calcWindow, text="9", padx=40, pady=20, command=lambda: onButton_Click(9)).grid(row=1, column=2)
button_0 = Button(calcWindow, text="0", padx=40, pady=20, command=lambda: onButton_Click(0)).grid(row=4, column=0)
button_plus = Button(calcWindow, text="+", padx=39, pady=20, command=lambda: onButton_Click()).grid(row=5, column=0)
button_equal = Button(calcWindow, text="=", padx=91, pady=20, command=lambda: onButton_Click()).grid(row=5, column=1,columnspan=2)
button_clear = Button(calcWindow, text="Clear", padx=79, pady=20, command= onButton_Clear()).grid(row=4, column=1, columnspan=2)
def tiClick():
tInputWindow = Toplevel()##opens a new window for the text input mode
tInputWindow.title("Text Input Mode")##Names the new window
def onButton_Click(number):
onNo = typeSpace.get()##gets the number pressed by the user
typeSpace.delete(0, END)##deletes previous numbers typed
typeSpace.insert(0, str(onNo) + str(number))##Inserts the number clicked into the field
def onButton_Clear():##Defines what the clear button does when clicked
typeSpace.delete(0, END)##deletes all previous numbers typed
root = Tk()#Creates root widget
root.title("Welcome Screen")#Names the welcome screen
welcomeLabel = Label (root, text="Hello user, welcome to the text input and calculator program")#Creates label widget
welcomeLabel.grid(row=0, column=0)#Casts label to screen in specified position
textInputButton = Button(root, text="Text Input Mode", command=tiClick, fg='red')#adds button
textInputButton.grid(row=1, column=10)#Positions button
calc = Button(root, text="Calculator Mode", command=calcClick, fg='red')#adds button
calc.grid(row=2, column=10)#Positions button
root.mainloop()