I cannot send checkbox value with submit like other fields.
I have problem with sending checkbox value. I cannot do get as with other fields. I tried with var, but also doesn't work. I need to send value with submit so if license is checked, I should skip new entering of license,othereise, I should add it.
class SimpleDialog(Frame):
user_name: str = ""
password: str = ""
test_selection: str = ""
gxp_license_key: str = ""
is_license_checked: int = 0
entry_password: Entry
entry_username: Entry
entry_test_selection: Entry
entry_pxp_license_key: Entry
entry_is_license_checked: tkinter.Checkbutton
...
frame_is_license_checked = Frame(self)
frame_is_license_checked.pack(fill=X)
label_is_license_checked = Label(frame_is_license_checked, text="<License already activated", width=30)
label_is_license_checked.pack(side=RIGHT, pady=10)
# self.is_license_checked.get_toggle_state()
# self.entry_is_license_checked = tkinter.Checkbutton(frame_is_license_checked, offvalue="", textvariable=StringVar(value=self.is_license_checked))
# self.entry_is_license_checked = tkinter.Checkbutton(frame_is_license_checked, offvalue="", variable=self.is_license_checked)
self.entry_is_license_checked = tkinter.Checkbutton(frame_is_license_checked, offvalue=0, onvalue=1, variable=IntVar(value=self.is_license_checked))
self.entry_is_license_checked.pack(fill=X, expand=True, side=RIGHT)
...
def submit(self) -> None:
self.user_name = self.entry_username.get()
self.password = self.entry_password.get()
self.test_selection = self.entry_test_selection.get()
self.gxp_license_key = self.entry_pxp_license_key.get()
self.is_license_checked.var = self.entry_is_license_checked - Here I have error, Also I cannot do get()
self.quit()
Aucun commentaire:
Enregistrer un commentaire