I have an interface in tkinter in which i have placed some labels, an entry and a button. So, as I input a number in the entry some metrics are calculated in background, particularly self.controller.Configurazione.IncentivoServiceProvider
in the label self.incentivo_provider
. So, as I input a number in the entry and press the button, I'd like to update the text in the said label, but I keep getting 'NoneType' object has no attribute 'config' referred to the very same label.
I tried various solutions, I even tried to define the UpdateLabel function in the scope of InputPercentaliEnergiaCondivisa function, but I keep getting always the same error.
Can anyone help me please?
Here's the code:
def SetPercentuale(self, valore):
print("premuto "+ str(valore))
self.controller.Configurazione.SetPercentualeRitenzione(100-valore)
def UpdateLabel(self, event):
print("Entro qua e percentuale ritenzione vale: "+str(self.controller.Configurazione.PercentualeRitenzione))
print("Entro qua e incentivo vale: "+str(self.controller.Configurazione.IncentivoServiceProvider))
self.incentivo_provider.config(text="L'ammontare destinato al service provider risulta: "+str(self.controller.Configurazione.IncentivoServiceProvider))
self.incentivo_provider.update()
def InputPercentualiEnergiaCondivisa(self):
self.PercentualeRitenzione = 0
tk.Label(self, text="Specificare la percentuale attribuibile agli utenti").pack()
self.percentuale_attribuibile = tk.Entry(self, textvariable=tk.IntVar())
self.percentuale_attribuibile.pack()
self.button = tk.Button(self, text="Valida")
self.button.bind("<Button-1>", lambda event: self.SetPercentuale(int(self.percentuale_attribuibile.get())))
self.button.bind("<Button-1>", self.UpdateLabel, add='+')
self.button.pack()
self.PercentualeRitenzione = 100 - int(self.percentuale_attribuibile.get())
#Istanzio la classe Configurazione che salva tutti i dati relativi alla configurazione
self.controller.Configurazione = Configurazione(len(self.controller.Proprietari_Impianti), len(self.controller.Proprietari_Superficie), len(self.controller.Consumatori_Semplici), len(self.controller.Finanziatori_Proprietari), len(self.controller.Finanziatori_Semplici), self.TotaleImmessa, self.TotalePrelevata, self.EnergiaCondivisa, self.PercentualeRitenzione)
self.incentivo_provider = tk.Label(self, text="L'ammontare destinato al service provider risulta: "+str(self.controller.Configurazione.IncentivoServiceProvider)).pack()
tk.Label(self, text="L'incentivo da ripartire agli utenti ammonta a: "+str(self.EnergiaCondivisa*(Parametri.IncentivoMise + Parametri.IncentivoArera)*int(self.percentuale_attribuibile.get()))).pack()
tk.Label(self, text="Specificare per ogni utente la percentuale dell'incentivo da attribuirgli. ").pack()