Skip to content

Commit 796e323

Browse files
authored
set_menu
1 parent 1d6846f commit 796e323

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,17 @@ def resize_image(image: Image.Image, wanted_width: int, width_is_height: bool =
300300
PLAY_ITEMS = ttk.Frame(game_frame)
301301

302302

303+
# TODO: needs testing
304+
def set_menu(option_menu: ttk.OptionMenu, var: tk.Variable, value: Any, *values):
305+
menu = option_menu["menu"]
306+
menu.delete(0, tk.END)
307+
308+
for val in values:
309+
menu.add_command(label=str(val), command=lambda v=val: var.set(v))
310+
311+
var.set(value)
312+
313+
303314
class PrimaryButton(ttk.Button):
304315
def __init__(self, master = None, *, class_ = "", command = "", compound = "", cursor = "", default = "normal", image = "", name = ..., padding=..., state = "normal", takefocus = ..., text = "", textvariable = ..., underline = -1, width = "", **kw):
305316
kw.pop('type', None)

0 commit comments

Comments
 (0)