Replies: 2 comments 1 reply
-
Instead of this lengthy stuff, could you simply explain your problem along with a sample reproducible code? import tkinter as tk
import customtkinter as ctk
opts = {"A": "1", "B": "2", "C": "3"}
def on_click(value):
opt_m2.set(opts[value])
app = ctk.CTk()
opt_m1 = ctk.CTkOptionMenu(app, values=list(opts.keys()), command=on_click)
opt_m1.place(relx=0.5, anchor="center", rely=0.4)
opt_m2 = ctk.CTkOptionMenu(app, values=list(opts.values()))
opt_m2.place(relx=0.5, anchor="center", rely=0.6)
app.mainloop() |
Beta Was this translation helpful? Give feedback.
-
@JanVasko1 import customtkinter as ctk
import tkinter as tk
Project_Type_list = ["CRQ", "INC", "INT","PROJECT"]
Activity_by_Type_dict = {
"0": {
"Project_Type": "CRQ",
"Activity": [
"Analysis",
"Bug Fixing",
"Consultancy",
"Data Migration",
"Design",
"Development (programming)",
"Parametrization",
"Project Management",
"Technical Support",
"Testing",
"User Training"
]
},
"1": {
"Project_Type": "INC",
"Activity": [
"Analysis",
"Bug Fixing",
"Consultancy",
"Data Migration",
"Design",
"Development (programming)",
"Parametrization",
"Technical Support",
"Testing",
"User Training"
]
},
"2": {
"Project_Type": "INT",
"Activity": [
"Admin",
"Analysis",
"Conference and Training Lead",
"Consultancy",
"Illness",
"Sick Leave",
"Training",
"Travel Time (Other)",
"Vacation"
]
},
"3": {
"Project_Type": "PROJECT",
"Activity": [
"Analysis",
"Bug Fixing",
"Consultancy",
"Data Migration",
"Design",
"Development (programming)",
"Parametrization",
"Project Management",
"Technical Support",
"Testing",
"Travel Time (Project)",
"User Training"
]
}
}
def on_click(value):
global Activity_list
# Find proper list based on Project_Type
for key, val in Activity_by_Type_dict.items():
Project_Type = val["Project_Type"]
if Project_Type == value:
opt_m2.configure(values= val["Activity"])
break
else:
pass
Activity_list = [""]
app = tk.Tk()
app.geometry("200x200")
opt_m1 = ctk.CTkOptionMenu(app, values=Project_Type_list, command=on_click)
opt_m1.pack()
opt_m2 = ctk.CTkOptionMenu(app, values=Activity_list)
opt_m2.pack(pady=70)
app.mainloop() Don't keep same name for function argument and loop variable, it will replace the old value of Regards. |
Beta Was this translation helpful? Give feedback.
-
Hello All,
I have question related to "values" used for "CTkOptionMenu". In my case I have 2x - CTkOptionMenu in my project and selection in one "CTkOptionMenu" has to update a list selection for values for second "CTkOptionMenu".
What to archive: Let user select value from list1 in "CTkOptionMenu1" and according to value selected the options in "CTkOptionMenu2" must be changed according to Activity_by_Type_dict where "Proejct_Type = CTkOptionMenu1.get()"
Can anyone help me? I tried to implement it somehow but never succeed, does anyone know any discussion / issue / text where this was solved?
Thank you
Jan Vaško
Beta Was this translation helpful? Give feedback.
All reactions