I've got a pygame application (read game) I'm working on that involves building some custom gui. I've got a main.py for constructing the menu screen and a menu.py for the menu and button classes.
in the main.py I implement the specific forms of the menu and button classes that will be in the menu, then the run loop in the menu class actually manages my pygame screen.
the buttons are designed to pass a function or other piece of python code to them as part of the arguments in their __init__()
Right now I'm able to pass basic functions via string between the main and any buttons I create from the main. (so my Quit Game button works just fine!)
The problem I'm running into is in trying to pass a command for one button to initiate another entirely new menu screen (a submenu) the command passed is the menu.run() method of my menu class
since both menus (main and submenu) were constructed in the menu file, the code being executed from the button class (which resides in a separate .py) doesn't know that the submenu class object even exists.
I tried to fix this by importing the main into the button class, but then I get some kind of recursion error right at startup where the first use of a button class in main breaks down because the two files import one another.
If this is too vague I'll see what I can do to put up some pseudocode or actual snippet later.
I'm thinking the solution might be to somehow make a custom instance of the class in my main so that the execution of the command passed to the button class is done from within the main (where both menu objects reside) instead of the menu module where the generic classes reside.
Any assistance is appreciated. I apologize for wretched language but my programming jargon is worse than my actual programming ability (self-taught)