0

I'm making a unit converter, and so far it's working. I put in a number and get my answer, but it keeps all of my previous answers so they start to overlap. Is there a way to delete old answers instead of just stacking them on top of each other?example of what's going on

This is what I have and where I think the problem is

def convert():
    x1 = entry1.get()
    x2 = variable1.get()
    x3 = variable2.get()

    if x2 == 'in':
        if x3 == 'in':
            result = float(x1)

        if x3 == 'ft':
            result = float(x1)*0.0833333

    label1 = tkinter.Label(win, text=result, font='Pixeltype 30', bg='black', fg='gray')
    canvas1.create_window(300, 330, window=label1)


button1 = tkinter.Button(text='Convert', command=convert, font='Pixeltype 15', bg='black', fg='gray')
canvas1.create_window(300, 280, window=button1)

win.mainloop()
JRiggles
  • 4,847
  • 1
  • 12
  • 27
  • 3
    Don't create new labels. call `configure` on an existing label to change the text. – Bryan Oakley Nov 16 '22 at 23:07
  • 1
    You are missing pack() grid() or place(). And must add widget too tkinter.Button(win – toyota Supra Nov 17 '22 at 13:22
  • As you didn't post your whole code we can only guess. I guess you are suing textvariables in your entry and label widgetes. So just remove the creating of the widgets fromt he loop instead only update the values. – Ovski Nov 17 '22 at 17:03

0 Answers0