Python Forum

Full Version: Problem of cursor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello everybody excuse me for my writing's mistakes but i am francophone
i have a problem with a little script that i have written and i will join it with my message
it is a modified combobox which permit to make automatically research in a list of values linked to the combobox
but my problem now is that when i enter a value from my keyboard i am obliged to click again in the entry part of my combobox in order to continue to enter values
you can test the code that i have join in order to understand correctly my problem
thanks you for your answers
import tkinter as tk
import tkinter.ttk as ttk
 
def _validate(s):
    nv = [ x for x in values if x.startswith(s) ]
    cb['values'] = nv
    cb.event_generate('<Down>')
    return True
 
root = tk.Tk()
values = ['dad','mom','brother','sister','daddy','mommy']
validate = (root.register(_validate), '%P')    
cb = ttk.Combobox(root, values=values, validatecommand=validate,validate='key')
cb.pack()
tk.mainloop()