I am using Python 3.2.1 on Arch Linux x86_64. It really drives me crazy: I just want to have a default value, a pre-selected value for ttk.Combobox , as soon as I hide it. This is my code:
from tkinter import Tk, StringVar, ttk root = Tk() def combo(parent): value = StringVar() box = ttk.Combobox(parent, textvariable=value, state='readonly') box['values'] = ('A', 'B', 'C') box.current(0) box.grid(column=0, row=0) combo(root) root.mainloop()
What draws an empty Combobox . What is funny is that if I do not use the function, it works fine:
from tkinter import Tk, StringVar, ttk root = Tk() value = StringVar() box = ttk.Combobox(root, textvariable=value, state='readonly') box['values'] = ('A', 'B', 'C') box.current(0) box.grid(column=0, row=0) root.mainloop()
Of course, in a real program, I need to use a function, so I need a different solution.
kynikos
source share