|
7 | 7 |
|
8 | 8 | def on_select(event=None):
|
9 | 9 | print('----------------------------')
|
10 |
| - |
| 10 | + |
11 | 11 | if event:
|
12 | 12 | print("event.widget:", event.widget.get())
|
13 | 13 |
|
14 | 14 | for i, x in enumerate(all_comboboxes):
|
15 | 15 | print("all_comboboxes[%d]: %s" % (i, x.get()))
|
16 | 16 |
|
17 |
| - |
18 | 17 | # --- main ---
|
19 | 18 |
|
20 | 19 | root = tk.Tk()
|
21 | 20 |
|
22 | 21 | all_comboboxes = []
|
23 | 22 |
|
24 |
| -cb = ttk.Combobox(root, values=("1", "2", "3", "4", "5")) |
| 23 | +cb = ttk.Combobox(root, values=("1", "2", "3", "4", "5")) |
25 | 24 | cb.set("1")
|
26 | 25 | cb.pack()
|
27 | 26 | cb.bind('<<ComboboxSelected>>', on_select)
|
28 | 27 |
|
29 | 28 | all_comboboxes.append(cb)
|
30 | 29 |
|
31 |
| -cb = ttk.Combobox(root, values=("A", "B", "C", "D", "E")) |
| 30 | +cb = ttk.Combobox(root, values=("A", "B", "C", "D", "E")) |
32 | 31 | cb.set("A")
|
33 | 32 | cb.pack()
|
34 | 33 | cb.bind('<<ComboboxSelected>>', on_select)
|
35 | 34 |
|
36 | 35 | all_comboboxes.append(cb)
|
37 | 36 |
|
38 |
| -b = tk.Button(root, text="Show selection", command=on_select) |
| 37 | +b = tk.Button(root, text="Show all selections", command=on_select) |
39 | 38 | b.pack()
|
40 | 39 |
|
41 | 40 | root.mainloop()
|
42 |
| - |
0 commit comments