I have two .py scripts on the same folder, and I have a function like this on one:
def combat_menu():
exec("combat.py")
Theese scripts are named dungeon.py(the one im executing from) and combat.py.
When I execute this function this error appears:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Users\hp\Documents\piton\Dungeon\dungeon_Data\dungeon.py", line 25, in combat_menu
exec("combat.py")
File "<string>", line 1, in <module>
NameError: name 'combat' is not defined
I execute this function from a tkinter button widget like this:
event_button = t.Button(root, text="Open CM", command=combat_menu)
I have tried importing the code, but this gives ImportError.