Change the Label everytime the button is pressed

1

I'm doing a PYTHON table using FOR, in TKINTER, and I would like every time a new number is placed in ENTRY, the label changes to the new table. For example, a number will be placed in the ENTRY and the person will click the TAB button, when it is clicked, the table will appear, but if the person wants another number, and again, the new table will go down from the previous one. My solution was to create a button that erases the previous table, but when the button is pressed, only the last multiplication is deleted. I would like to know how I click the tabuada button, and the previous one erases the new one without using another button .Get the code and a photo below, Thanks. Note: First photo shows reset button working, but it just erase the last multiplication, second photo shows the whole multiplication.

from tkinter import *
import tkinter as tk

win=tk.Tk()
win.title('Table')
lb=Label(win,text='Type a number:',font='Helvetica 12 bold')
lb.pack()
e=Entry(win)
e.pack()

def click():
   global c
   c=e.get()
   print('requested number ',c)

    for b in (range(0, 11)):
       global lb2
       lb2=Label(text='{} x {} = {} '.format(c, b, int(b)*int(c)))
       lb2.pack()

def reset():
   lb2['text'] = ' '

bt1=Button(win,text='GO',bg='lightblue',command=click)
bt1.pack()
bt2=Button(win,text='RESET',bg='lightblue',command=reset)
bt2.pack()
win.mainloop()

    
asked by anonymous 14.09.2017 / 00:58

0 answers