can not get value from CTkEntry #1744
lautnerxing
started this conversation in
General
Replies: 1 comment 1 reply
-
You are calling get_DataTransformation before set_DataTransformation and as the entries are created in set_DataTransformation they don't exist. I would recommend to create all widgets in the init method like this: class MyConfigParams_Communication(customtkinter.CTkFrame):
def __init__(self, master):
super().__init__(master, width=500, height=300, border_color="black", border_width=2)
# init_DataTransformation
self.config_dict_DTR = {
"SHORT-NAME": "SOME_IP_Default_Transformation",
"EXECUTE-DESPITE-DATA-UNAVAILABILITY": "false"}
# create labels
self.label_1 = customtkinter.CTkLabel(self, text="SHORT-NAME: ")
self.label_1.grid(row=0, column=0, padx=10, pady=(10, 0), sticky="e")
self.label_2 =customtkinter.CTkLabel(self, text="EXECUTE-DESPITE-DATA-UNAVAILABILITY: ")
self.label_2.grid(row=1, column=0, padx=10, pady=(10, 0), sticky="e")
# create entries
self.shortname_DTR = customtkinter.CTkEntry(self)
self.shortname_DTR.grid(row=0, column=1, padx=10, pady=(10, 0), sticky="e")
self.eddu_DTR = customtkinter.CTkEntry(self)
self.eddu_DTR.grid(row=1, column=1, padx=10, pady=(10, 0), sticky="e")
def set_DataTransformation(self):
# SHORT-NAME
self.shortname_DTR.insert(0, self.config_dict_DTR["SHORT-NAME"])
# EXECUTE-DESPITE-DATA-UNAVAILABILITY
self.eddu_DTR.insert(0, self.config_dict_DTR["EXECUTE-DESPITE-DATA-UNAVAILABILITY"])
def get_DataTransformation(self):
self.config_dict_DTR["SHORT-NAME"] = self.shortname_DTR.get()
self.config_dict_DTR["EXECUTE-DESPITE-DATA-UNAVAILABILITY"] = self.eddu_DTR.get()
return self.config_dict_DTR |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to get the value frome Entry, but when i call get_DataTransformation, the init will make its None, I don't want to create an Entry module during initialization, Because I want to reuse this class, what should i do?
the code is:
Beta Was this translation helpful? Give feedback.
All reactions