first_page
is a local variable of main()
, but you try to use it as a global variable in change_to_secondwindow()
. Instead of this function, a common Python idiom is to put this code inside an if
block where you check if the module is the main program:
# remove the call to main()
if __name__ == '__main__':
root=Tkinter.Tk()
root.title("Control")
first_page = FirstWindow(root)
root.mainloop()