I'm new to the Pyhton GUI and have been playing around, for some time now, with the code below. The Latin to English translator code below works by displaying three buttons with each having a Latin word on them. When pressed a English equivalent appears in the label of the GUI. I am trying get the output to show up to the right of "English translation" but then be replaced with another output if another button is pressed. Instead after pressing several buttons it displays the translation over and over causing the box area to get larger and larger. Is there a way to just swap the output in place of where the previous output was? Thank you in advance and I appreciate any help in steering me toward a solution.
import tkinter
import tkinter.messagebox
class LatConvGUI:
def __init__(self):
self.main_window = tkinter.Tk()
self.top_frame = tkinter.Frame()
self.bottom_frame = tkinter.Frame()
self.prompt_label = tkinter.Label(self.top_frame, \
text='English Translation is:')
self.prompt_label.pack(side='left')
self.sin_button = tkinter.Button(self.bottom_frame, \
text='sinister', \
command=self.convert)
self.dex_button = tkinter.Button(self.bottom_frame, \
text='dexter', \
command=self.convert2)
self.med_button = tkinter.Button(self.bottom_frame, \
text='medium', \
command=self.convert3)
self.label2 = tkinter.Label(self.bottom_frame, \
text='Latin word is:')
self.label2.pack(side='left')
self.sin_button.pack(side='left')
self.dex_button.pack(side='left')
self.med_button.pack(side='left')
self.top_frame.pack()
self.bottom_frame.pack()
tkinter.mainloop()
def convert(self):
self.label1 = tkinter.Label(self.top_frame, \
text='left')
self.label1.pack(side = 'top')
def convert2(self):
self.label3 = tkinter.Label(self.top_frame, \
text='right')
self.label3.pack(side = 'top')
def convert3(self):
self.label4 = tkinter.Label(self.top_frame, \
text='center')
self.label4.pack(side = 'top')
eng_conv = LatConvGUI()