0
`def calculate():
        actual_age = int(actual_age_entry.get())
        if actual_age > 9:
            min_age = int(min_age_entry.get())
            if min_age < actual_age:
                min_base = get_minimum_base(actual_age, min_age)
                if min_base != -1:
                    for interval, path in intervals.items():
                        start, end = interval.split("-")
                        if int(start) <= min_age <= int(end):
                           img = Image.open(path)
                           img = img.resize((80, 80))
                           img = ImageTk.PhotoImage(img)
                           result_label.config(image=img, text="Minimum base to be at least {} years old is: {}".format(min_age, min_base))
                           result_label.image = img
                           break
                       else:
                           result_label.config(text="Invalid input")
              else:
                  result_label.config(text="Invalid input")
         else:
            result_label.config(text="Invalid. Please enter age greater than 9.")

calculate_button = tk.Button(top, text="Calculate", command=calculate)
    calculate_button.pack(padx=5,pady=20,ipady = 5,ipadx = 10)
    result_label = tk.Label(top,text="")
    result_label.pack(padx=5,pady=20,ipady = 5,ipadx = 10)


`

type here

is it possible to display images along with the text? Because I need to get the image and a text ,saying that i got this value ... I tried this and I am expecting to get both image and text after I click the calculate button.is it possible in that way?pls reply with how can I write the codeyour text

  • Welcome to StackOverflow! Please add more detail about the expected and actual result to be more clear. – dimnnv Mar 06 '23 at 17:07

0 Answers0