December 2015
Beginner to intermediate
350 pages
6h 49m
English
In this recipe, we will improve our GUI by adding drop-down combo boxes that can have initial default values. While we can restrict the user to only certain choices, at the same time, we can allow the user to type in whatever they wish.
This recipe extends the previous recipes.
We are inserting another column between the Entry widget and the Button using the grid layout manager. Here is the Python code.
ttk.Label(win, text="Choose a number:").grid(column=1, row=0) # 1 number = tk.StringVar() # 2 numberChosen = ttk.Combobox(win, width=12, textvariable=number) #3 numberChosen['values'] = (1, 2, 4, 42, 100) # 4 numberChosen.grid(column=1, row=1) # 5 numberChosen.current(0) # 6
This code, when added to previous ...
Read now
Unlock full access