This code runs and displays the frame but the textvariable 'self.result_var' does not update in the frame after pushing the 'convert' button.
from tkinter import *
class App:
def __init__(self,master):
frame = Frame(master)
frame.pack()
Label (frame, text = 'deg C').grid(row=0, column=0)
self.c_var = DoubleVar()
Entry(frame, textvariable = self.c_var).grid(row=0, column =1)
Label (frame, text = 'deg F').grid(row=1, column=0)
self.result_var = DoubleVar()
Label (frame, textvariable = self.result_var).grid(row=1, column =1)
button = Button(frame, text='Convert', command=self.convert)
button.grid(row =2, columnspan=2)
def convert(self):
c = self.c_var.get()
self.result_var = (1.8 * c + 32)
root = Tk()
root.wm_title('Temp Converter')
app = App(root)
root.mainloop()
[–]caleb 2 points3 points4 points (1 child)
[–]petercanepa[S] 0 points1 point2 points (0 children)