0

I'm creating a program where I have two entries for receiving some values from the user. With that values, I want to make some calculations and display the result in a label. I don´t want to use any kind of button or widgets to refresh the value of the label. I've tried using bind events for that, but I haven't found any event that works when the entry value changes. I hope that my question is understood. Thankyou.


    self.Capacity_Entry=Entry(self.Window,borderwidth=3,textvariable=self.Capacity)

    self.Capacity_Entry.grid(row=3,column=0)

    self.Capacity_Entry.bind('<Enter>',self.calculate_unknown_variable)

    self.Voltage_Entry=Entry(self.Window,borderwidth=3,textvariable=self.Voltage)

    self.Voltage_Entry.grid(row=3,column=2)

    self.Voltage_Entry.bind('<Enter>',self.calculate_unknown_variable)

    self.Energy_label=Label(self.Window)

    self.Energy_label.grid(row=1,column=4,)


    def calculate_unknown_variable(self,*args):

        self.V=float(self.Voltage.get())

        self.C=float(self.Capacity.get())

        self.E=0.5*self.C*self.V*self.V

        self.Result_Label.config(text=self.E)

dejanualex
  • 3,872
  • 6
  • 22
  • 37
  • Hi, you can handle this using entry's change event, check this it might be helpful - https://stackoverflow.com/questions/47581333/kivy-how-to-trigger-event-by-text-change/47581657 – Divyesh Nov 18 '20 at 09:40

1 Answers1

0

You can use "<KeyRelease>" event to do so.

Everytime you release a key on keyboard, on releasing the key the method associated will be triggered.

self.Capacity_Entry.bind("<KeyRelease>",self.calculate_unknown_variable))

Mayank
  • 1,595
  • 1
  • 11
  • 26