J'essaie d'accéder à une entrée d'une fonction à partir d'une autre fonction. Mais ça me dit que ce n'est pas défini. J'ai fait beaucoup de recherches, mais je n'arrive pas à trouver quelque chose qui m'aide.Python: Accès à l'intérieur d'une fonction à partir d'une autre fonction
Ceci est mon code, je l'ai raccourci pour le rendre plus facile pour vous les gars. Bien que cela devrait suffire à vous donner l'idée.
from tkinter import*
class hunterClass:
def BMHunter():
hunter = Tk()
hunter.title("Beast Mastery Gear Worth Calculator")
agiString = StringVar()
agiText = Label(hunter, text = "Input points of agility:").grid(row = 3, column = 0)
agiEntry = Entry(hunter, textvariable = agiString).grid(row = 3, column = 1)
calculate = Button(hunter, text = "Calculate", command = hunterClass.calculateFun).grid(row = 12, column = 1)
def calculateFun():
agiF = float(agiEntry.get())
window = Tk()
window.title("Gear Worth Calculator")
hunterText = Label(window, text = "Hunter").grid(row = 3, column = 0)
hunterBM = Button(window, text = "Beast Mastery", width = 12, command = hunterClass.BMHunter).grid(row = 4, column = 0)
S'il vous plaît apprendre comment demander une bonne question: http://stackoverflow.com/help/how-to-ask –
Il serait cool de clarifier quelle variable n'a pas été déclarée. Mais à la fin je suis sûr que vous pouvez résoudre cette question en utilisant le mot-clé global. –
Cet exemple peut être utile: https://docs.python.org/3.5/tutorial/classes.html#scopes-and-namespaces-example –