I'm new to Python and trying to create an app to perform Psychrometric calculations. I have created a UI using customTkInter and want to retrieve the contents of an entry widget to perform some calculations. I have created a get method from within the class but when I try to call it the interpreter crashes saying there is no reference. From everything I have searched I appear to be doing it right but there must be something amiss. All help appreciated. Error is AttributeError: '_tkinter.tkapp' object has no attribute 'get_db'
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("500x300")
self.title("Psychrometrics")
customtkinter.set_appearance_mode("system")
customtkinter.set_default_color_theme("green")
label_title = customtkinter.CTkLabel(self, text="Saturation Pressure")
label_title.grid(row=0, column=0, pady=DPadY, padx=DPadX)
entry_db = customtkinter.CTkEntry(self, placeholder_text="Dry Bulb")
entry_db.grid(row=1, column=0, pady=DPadY, padx=DPadX)
label_dbsp = customtkinter.CTkEntry(self, width=300, placeholder_text="Dry Bulb Saturation Pressure")
label_dbsp.grid(row=1, column=1, pady=DPadY, padx=DPadX)
entry_wb = customtkinter.CTkEntry(self, placeholder_text="Wet Bulb")
entry_wb.grid(row=2, column=0, pady=DPadY, padx=DPadX)
label_wbsp = customtkinter.CTkEntry(self, width=300, placeholder_text="Wet Bulb Saturation Pressure")
label_wbsp.grid(row=2, column=1, pady=DPadY, padx=DPadX)
button = customtkinter.CTkButton(self, text="Calculate", command=login)
button.grid(row=3, column=0, pady=DPadY, padx=DPadX)
def get_db(self):
_Db = self.entry_db.get()
return _Db
def login():
Cdb = app.get_db()
print(Cdb)
app = App()
app.mainloop()
Tried multiple ways of getting the value and simlply want to print to output the contents.