for CTk the event for comboboxes doesn't work.. I fixed this by creating this callback function and putting it in the "command=callback" of the combobox def callback(choice): food_string.set(choice) combolabel.configure(text = f"Selected value: {food_string.get()}") Just for people that are following this tutorial but are using customtkinter. Love your content tho! verry helpfull
um.. this is the first time i dont quite agree... we are not Done.... on the spinbox when you press down it prints the value it WAS, but the spinbox changes to a different value for example... it shows a 'C'.. press down The spin box changes to 'B' but it Prints 'C' it is printing the value it is changing from - you can see this on your screen example too but, because yo do it so quick it is not obvious this only seems to happen when using the events - the event is triggering, it seems, when the down is pressed - BEFORE the box chanegs value - after processing the event . THEN the spinbox make sthe change to eth variable... OUCH if i just use command=... then the function gets processed, apparently, AFTER the spin box value is changed - and so the screen and print statement align this code shows it VERY clearly - the command label always shows the same as the spinbox. But the event label is always "one behind" import tkinter as tk from tkinter import ttk window = tk.Tk() window.geometry('800x600') def sLabelUpdate(): commandLabel.configure(text=f'command triggers : {spin_string.get()}') spin_string = tk.StringVar() values = ['A', 'B', 'C', 'D', 'E'] commandLabel = ttk.Label(window, text="...") commandLabel.pack() spin = ttk.Spinbox( window, textvariable=spin_string, values=values, command = sLabelUpdate ) spin.pack() spinEventLabel = ttk.Label(window, text='...') spinEventLabel.pack() spin.bind('', lambda event: spinEventLabel.configure(text=f'event triggers : {spin_string.get()}')) spin.bind('', lambda event: spinEventLabel.configure(text=f'event triggers : {spin_string.get()}')) tk.mainloop()
for CTk the event for comboboxes doesn't work..
I fixed this by creating this callback function and putting it in the "command=callback" of the combobox
def callback(choice):
food_string.set(choice)
combolabel.configure(text = f"Selected value: {food_string.get()}")
Just for people that are following this tutorial but are using customtkinter.
Love your content tho! verry helpfull
um.. this is the first time i dont quite agree... we are not Done.... on the spinbox
when you press down it prints the value it WAS, but the spinbox changes to a different value
for example... it shows a 'C'.. press down
The spin box changes to 'B'
but it Prints 'C'
it is printing the value it is changing from - you can see this on your screen example too but, because yo do it so quick it is not obvious
this only seems to happen when using the events - the event is triggering, it seems, when the down is pressed - BEFORE the box chanegs value - after processing the event . THEN the spinbox make sthe change to eth variable... OUCH
if i just use command=... then the function gets processed, apparently, AFTER the spin box value is changed - and so the screen and print statement align
this code shows it VERY clearly - the command label always shows the same as the spinbox. But the event label is always "one behind"
import tkinter as tk
from tkinter import ttk
window = tk.Tk()
window.geometry('800x600')
def sLabelUpdate():
commandLabel.configure(text=f'command triggers : {spin_string.get()}')
spin_string = tk.StringVar()
values = ['A', 'B', 'C', 'D', 'E']
commandLabel = ttk.Label(window, text="...")
commandLabel.pack()
spin = ttk.Spinbox(
window,
textvariable=spin_string,
values=values,
command = sLabelUpdate
)
spin.pack()
spinEventLabel = ttk.Label(window, text='...')
spinEventLabel.pack()
spin.bind('', lambda event: spinEventLabel.configure(text=f'event triggers : {spin_string.get()}'))
spin.bind('', lambda event: spinEventLabel.configure(text=f'event triggers : {spin_string.get()}'))
tk.mainloop()
the code plssss🙏🙏🙏