Integrating a tkinter GUI with previous code