[Python] How to fix the problem when the Tk window does not apply changes in the code, only...

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I did my homework from the textbook (easy currency converter), wrote everything as in the assignment, but the Tk window does not change at all, only the usual default Tk window

    from tkinter import *

    root = Tk()
    root.mainloop()
    root.geometry("250x130")
    root.title("Конвертер")

    currency = Label(root, text="Виберіть валюту")
    currency.grid(row=0, column=0, stickly='w')

    def currency_check():
    rate_value.config(text=currencVal.get())

    currencVal = IntVar()
    currencVal.set(25)

    dollar = Radiobutton(root, text="Долар", variable=currencVal, value=25, command=currency_check)
    dollar.grid(row=0, column=1)

    euro = Radiobutton(root, text="Євро", variable=currencVal, value=30, command=currency_check)
    euro.grid(row=1, column=1)

    dollar = Radiobutton(root, ___, variable=currencVal, value=25)
    euro = Radiobutton(___, text="Євро", variable=currencVal, value=25)

    rate = Label(root, text="Курс")
    rate.grid(row=2, column=0, stickly='w')
    rate_value = Label(root, text="25")
    rate_value.grid(row=2, column=1, stickly='w')

    suma = Label(root, text="Введіть суму у валюті")
    suma.grid(row=3, column=0, sticky='w')
    suma_entry = Entry(root)
    suma_entry.grid(row=3, column=1, sticky='w')
    suma_entry.insert(1,"0")

    convert = Button(root, text="Конвертувати")
    convert.grid(row=4, column=0, sticky='w')

    label = Label(root, text="")
    label.grid(row=4, column=1, sticky='w')

    def calculate(event):
    label.config(text=currencVal.get() * int(suma_entry.get()))
    convert.bind("<Button-1>", calculate)


    I tried to import differently, change the commands, but nothing changed.

    Continue reading...

Compartilhe esta Página