J'ai une classe avec un bouton, il exécute la commande automatiquement lorsque le GUI est construit (ce que je ne veux pas qu'il fasse), mais ne marche pas après. Qu'est-ce que je fais mal? Les commandes intégrées telles que endcommand fonctionnent comme elles le devraient.Tkinter aide boutons
extraits pertinents (ignorer le problème tiret au début)
class GuiPart(object):
def __init__(self, master, queue, endCommand):
self.queue = queue
# Set up the GUI
#tkinter.Button(master, text='Done', command=endCommand).grid(row=6,column=6)
tkinter.Button(text='Update Variables', command=self.updateValues()).grid(row=3)
Lp_pacingState = tkinter.Label(text="p_pacingState")
Lp_pacingState.grid(row=1, column=3)
Tp_pacingState = tkinter.Label(bg="white", relief="ridge",justify="center",width=9)
Tp_pacingState.grid(row=1, column=4)
....
self.textBoxes = {"p_pacingState" : Tp_pacingState, "p_pacingMode" : Tp_pacingMode,
"p_hysteresis" : Tp_hysteresis, "p_hysteresisInterval" : Tp_hysteresisInterval,
"p_lowrateInterval" : Tp_lowrateInterval, "p_vPaceAmp" : Tp_vPaceAmp,
"p_vPaceWidth" : Tp_vPaceWidth, "p_VRP" : Tp_VRP}
#def updateValues(self,input):
def updateValues(self):
testInput = ["p_pacingState=3", "garbage=poop", "p_VRP=5"]
for updates in testInput:
print("zzzz")
var = updates.split("=")
try:
self.textBoxes[var[0]].config(text = var[1])
except:
pass
Je reçois « zzzz » imprimé 3 fois à la construction de IUG (étiquettes DonT mettre à jour leur texte bien) et le travail ne marche pas bouton après cette. Aussi, s'il existe un meilleur moyen de mettre à jour les boîtes s'il vous plaît dites-moi. Je reçois des commentaires d'un flux sans ordre particulier ni pertinence.
Merci à l'avance