I'm a bit stumped with the proper way to design with Tkinter. I've read dozens of Tkinter examples but since most of them describe simple and specific cases I'm having trouble with finding the right global design for my script. I'm trying to separate as much as possible the GUI code from the data model (I'm working on a very simple card game).
My main problem is how to access Tkinter elements globally, from different functions and classes. Currently I am building the entire interface inside a large gui_build() function, right after the definitions for my data classes. This function is called from a main() function along with all the data initialisation stuff. Problem is, even if I return the Tk root object from gui_build() so that main() can pass it around, I'm having trouble accessing Tk elements when needed.
For example, I have several callback functions for different Tk buttons which are in the global scope. If one of those needs to check the state of a radio button, it's apparently impossible to find it in the Tk root hierarchy by name, and passing references to radio buttons all over the place seems very inelegant.
I can sort of make it work by declaring radio buttons globally but this defeats the purpose of keeping all the GUI code in the same place.
Wondering what could be considered as a "best practice" before trying to reinvent the wheel.
Thank you.