1

I have two files. One is interface.py (Tkinter code) that contains the interface of the application. Another file is logic.py. The interface contains a button. What I want is that when I click the button the logic.py file starts its execution. How can I perform this task?

Jonathon
  • 71
  • 5
  • Read about [Modules](https://docs.python.org/3/tutorial/modules.html#modules). First you have to understand [Event-driven programming](https://stackoverflow.com/a/9343402/7414759). If your logic.py is a long time running part, read [Run your own code alongside Tkinter's event loop](https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop) – stovfl Nov 11 '19 at 08:23

1 Answers1

0

The easiest way is to use main function inside the file you want to execute, and then to call it (import logic, then Button(command=logic.main).pack()) or to use __import__ or import logic inside the button command function.

rizerphe
  • 1,340
  • 1
  • 14
  • 24