I have a delete function that is supposed to remove the selected item in the Combobox and its associated dictionary value. Then it is supposed to clear the textbox that displays that dictionary value and I would like it to also clear just the text file of the combo box. Is there a way to do that?
def DeleteEntry():
if not ComboBox.get() == "" and ComboBox.get() in FriendMap:
del FriendMap[ComboBox.get()]
FriendListKeys = FriendMap.keys()
FriendListKeys.sort()
ComboBox['values']=FriendListKeys
FriendListBox.delete(1.0,2.0)
That is what I have thus far but I would like the next line to delete the text field in the Combobox.
Type something inside the textbox, and then, click the “Delete” button. It will erase the content inside the textbox.
Tkinter Text Widget is used to add the text writer in an application. It has many attributes and properties which are used to extend the functionality of a text editor. In order to delete the input content, we can use the delete("start", "end") method.
The Tkinter Combobox is one of the UI widgets in the Tkinter library and it is used for to select the values in the drop-down list column also it is one of the combinations of Entry and drop-down widgets these drop-down entries are replaceable one and the user if suppose not select the value in the box it automatically ...
textvariable. A variable linked to the current value of the combobox; when the variable is changed, the current value of the combobox will be updated, while when the user changes the combobox, the variable will be updated. values.
You can clear the selected value of a Combobox by setting its value to an empty string:
ComboBox.set('')
Set the StringVar of the combobox to empty string instead of the Widget itself.
def clear():
var.set('')
var = tk.StringVar()
values = ['one', 'two', 'three']
cb = tk.ttk.Combobox(root, state = 'readonly', textvariable = var, values = values)
cb.pack()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With