I am rewriting a Tkinter program of mine and I want to separate the logic and UI into two different files: main.py, ui.py
In main we have a class MainApp() which handles all of the core functionality of the program.
In ui we have a class BaseApp() which is responsible for rendering the UI and doing all of those kind of things.
I have BaseApp() be a child of MainApp(), like this:
main.py
class MainApp():
def __init__(self):
#some code here
ui.py
import main
class BaseApp(main.MainApp):
def __init__(self):
main.MainApp.__init__(self)
#render UI here e.g...
mybtn = tkinter.Button(self.root, text="Hey StackOverflow", command=main.myFunction)
This all works fine. I got a long way into making this system without any issues... then I hit an issue.
I want to be able to call UI code from main. I need functions in the MainApp() class in the main module to be able to display popups and create Toplevel windows defined in classes in the ui module.
If MainApp() derives from BaseApp() then I can display the popups but the UI has access to none of the main features. If BaseApp() derives from MainApp() as above then the UI can access the logic but I cannot create any windows, e.g. ui.ProgressWindow, ui.Alert from the main module when I need to.