TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.36k stars 1.07k forks source link

cannot update CTkComboBox values list #1270

Open xwydq opened 1 year ago

xwydq commented 1 year ago

cannot update CTkComboBox values list. but it is ok for tkinter.ttk

import customtkinter as ctk
import random

root = ctk.CTk()
combo_value_list = ["Apple", "Banana", "Orange"]
combo = ctk.CTkComboBox(root, values=combo_value_list)
combo.pack()

# Update the combo values list
print(combo)
combo_value_list.append("Grapes")
combo['_values'] = combo_value_list

def update_list():
    random_list = [str(random.randint(0, 9)) for x in range(10)]
    combo['values'] = random_list

ctk.CTkButton(root, text="Update list", command=update_list).pack()

root.mainloop()
ElectricCandlelight commented 1 year ago

Try using .configure()

combo.confugure(values=combo_value_list)

xwydq commented 1 year ago

Try using .configure()

combo.confugure(values=combo_value_list)

tks!! but CTkComboBox is not support select multiple values. Is there a way to achieve it?

ElectricCandlelight commented 1 year ago

What you you mean?


import customtkinter
import random

root = customtkinter.CTk()
combo_value_list = ["Apple", "Banana", "Orange"]
combo = customtkinter.CTkComboBox(root, values=combo_value_list)
combo.pack()

# Update the combo values list
print(combo)
combo_value_list.append("Grapes")
combo.configure(values= combo_value_list)

def update_list():
    random_list = [str(random.randint(0, 9)) for x in range(10)]
    combo.configure(values= random_list)

customtkinter.CTkButton(root, text="Update list", command=update_list).pack()

root.mainloop()

Seems to work fine.

xwydq commented 1 year ago

I mean CTkComboBox not support multiple values be selected