#πŸ”’ Custom Tkinter value won't update

4 messages Β· Page 1 of 1 (latest)

steady swift
#

I've been trying to make a customtkinter value update so that it'll display the final BMI value to the user. It, however, won't update and just displays the value from the initial calculation. Here's the snippet:

class ConfigDisplay(ctk.CTkLabel):
    def __init__(display, frame, test):
        super().__init__(frame)
        frame.bmi_value = display.calc_BMI(frame)
        frame.display_bmi.set(frame.bmi_value)
        display.configure(text_color='#f0f3f2', font=('Helvetica', 110, 'bold'), textvariable=frame.display_bmi)
    # This is intended to calculate the BMI from the given values and display it. I'm having trouble actually displaying it; it displays the initial value, but doesn't update.

    def calc_BMI(display, frame):
        return round((float(frame.weight_value) / float(frame.display_height.get()) ** 2), 1)
    # Calculates BMI and returns it.

I'm not sure how to make it continually update - I've made it work with another widget but for some reason it's being very annoying rn.
The full code is here: https://paste.pythondiscord.com/PK6A

subtle vergeBOT
#

@steady swift

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

subtle vergeBOT
#

@steady swift

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.