Fisile decomposition from one field resulting from the withdrawal to another Tkinter



  • Help me get this straight. As a Tkinter programme, remove a window where a call for a number will be made and the number will be added to the previously introduced number after a call to add up. The volume in one field needs to be inserted by number (infinite number of times) and in another the amount will be removed. I don't know how to get the money out.

    from tkinter import *
    from tkinter import messagebox
    import math
    

    def calculation():
    num = int(a.get())
    num2 = int(b.get())
    num2 = num2 + num

    root = Tk()
    root.title("Додавання чисел")
    root.geometry("400x150")

    a = StringVar()
    b = StringVar()
    Label(root, text="Введіть число").place(x=20, y=20)
    Entry(root, textvariable=a).place(x=115, y=10)
    Label(root, text="Отримуємо").place(x=20, y=55)
    Entry(root, textvariable=b).place(x=115, y=55)

    but = Button(text="Додати", command=calculation).place(x=200, y=100)

    root.mainloop()



  • Call. b.set(...) in the right places.

    from tkinter import *
    from tkinter import messagebox
    import math
    

    def calculation():
    num = int(a.get())
    num2 = int(b.get())
    num2 = num2 + num
    b.set(str(num2))

    root = Tk()
    root.title("Додавання чисел")
    root.geometry("400x150")

    a = StringVar()
    b = StringVar()
    b.set("0")
    Label(root, text="Введіть число").place(x=20, y=20)
    Entry(root, textvariable=a).place(x=115, y=10)
    Label(root, text="Отримуємо").place(x=20, y=55)
    Entry(root, textvariable=b).place(x=115, y=55)

    but = Button(text="Додати", command=calculation).place(x=200, y=100)

    root.mainloop()



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2