Hi there,
First off, my apologies. My title makes it seem like I am asking a straightforward question. TBH I don't actually know what title would suit my problem. I have also tried to search for a solution on Google, consulted AI and StackOverflow, and I am none the wiser. Which is why I am here.
Just to lay the groundwork. I have 2 files a) containing the Application code, and b) a Configurations file into which I have centralised all parameters and variables used throughout the application.
file: config.py
button = {
"text": "name,
"x": #,
"y": #,
"command": "name_of_the_function"
}
file MyApp.py
def myapp():
root = tk.Tk()
new_button = tk.Button(root, text = con.button["text"], **command = con.button["command"]**) # how I currently have it writen
new_button.pack()
root.mainloop()
As you can see the command parameter draws on the respective dictionary key. The problem is that the function name I am calling is stored as a string. Additionally, I can't use an explicit reference in the config file as the function in question is not in the same file.
So far, the stringed name of the function is written such that if one were to remove the " ", the command parameter would immediately recognize the function it is being assigned to.
I am clearly not doing something right. Is there a method or a way of coding this such that I can store the function name in a dictionary as a string, which then gets set as a function when the widget gets created?
Your help is much appreciated.
Thank you