My code generates a given nuber of name_input
entry boxes depending on user inputs. The name_input
entries have an optional vname_input
above and below them.
Each vname_input
entry has a corresponding remove_vname_tick
checkbox. The idea is that once this checkbox is selected the corresponding vname_input
is disabled or deleted.
How would I create a class which inherits from the tkinter frame object and then create a class function which deactivates or deletes the object in question?
The code in question is:
vname = []
name = []
p = 0
for i in range(10): # range taken from entry
vname_input = Entry(self, width=20)
vname_input.grid(row=6 + p + i, column=0) # p & i update position
vname.append(vname_input) # Stores entry box ID
name_input = Entry(self, width=20)
name_input.grid(row=7 + p + i, column=0)
name.append(name_input)
def remove_vname_command():
vname.grid_forget()
remove_vname_tick = Checkbutton(self, text="Remove veil",
bd=0, command=remove_vname_command) # Function for removing entries
remove_vname_tick.grid(row=6 + p + i, column=1)
p += 2
vname_input = Entry(self, width=20)
vname_input.grid(row=6 + p + i, column=0) # Places final optional vname entry
vname.append(vname_input)
Aucun commentaire:
Enregistrer un commentaire