im making a machine for Geometric volumes but i have a problem: my problem is When the user enters a number to perform calculations, a label shows the result, but what happens if the user wants to get the volume of the cylinder? Exactly >>23
>>34
It gives two numbers, one for the previous volume and one for the current volume, and this creates a problem because the program page is limited, and if the user performs more operations than one number, it will exit the page and you have to open that window again.
Visual example:
In simple words, I want the label to show the result when the user performs the first operation, but in the second operation, the label replaces the first label and shows the result. my code:
def cube():
def jerm_1():
a = int(text.get())
b = int(text_1.get())
c = int(text_2.get())
jerm=a * b * c
Label(top,text=jerm,font=20).pack()
def ostevane():
text_2.destroy()
a = int(text.get())
b = int(text_1.get())
jerm = a * b
Label(top,text=jerm,font=20).pack()
def taghir():
mohasebe.config(command=ostevane)
def taghir_1():
mohasebe.config(command=jerm_1)
top = Toplevel()
top.maxsize(300,300)
menu_top = Menu()
menu_select = Menu(menu_top,tearoff=0)
menu_top.add_cascade(label="اشکال دیگر",menu=menu_select)
menu_select.add_command(label="استوانه",command=taghir)
menu_select.add_command(label="مکعب و مستطیل مکعب",command=taghir_1)
top.minsize(300,300)
text = Entry(top,font=20)
text.pack()
text_1 = Entry(top,font=20)
text_1.pack()
text_2 = Entry(top,font=20)
text_2.pack()
mohasebe=Button(top,text="حجم",font=20)
mohasebe.pack()
top.config(menu=menu_top)
CodePudding user response:
its fixed! step 1:first you need to create a Label then do this:
label = Label(.......)
label.pack_forget()
step 2: create a def and do what do you want then do this:
label.pack()
label.config(text = *what you have done*)
now its fixed!