Skip to content

Commit e853eee

Browse files
committed
buggy UI
1 parent 796e323 commit e853eee

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

main.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,6 @@ 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-
314303
class PrimaryButton(ttk.Button):
315304
def __init__(self, master = None, *, class_ = "", command = "", compound = "", cursor = "", default = "normal", image = "", name = ..., padding=..., state = "normal", takefocus = ..., text = "", textvariable = ..., underline = -1, width = "", **kw):
316305
kw.pop('type', None)
@@ -452,19 +441,30 @@ def generate_new_round(*_, first: dict[str, Any] = None, second: dict[str, Any]
452441
PLAY_ITEMS.cur_img = resize_image(c, settings.image_width, settings.use_width_as_height, settings.image_ratio)
453442

454443

455-
def update_game_widgets(scope: str) -> int:
456-
if scope == 'game':
457-
PLAY_ITEMS.selected_episode.set(list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys())[0])
458-
PLAY_ITEMS.episode_ch.set_menu(PLAY_ITEMS.selected_episode.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys()))
459-
scope = 'episode'
460-
461-
if scope == 'episode':
462-
PLAY_ITEMS.selected_map.set(list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()][PLAY_ITEMS.selected_episode.get()].keys())[0])
463-
PLAY_ITEMS.map_ch.set_menu(PLAY_ITEMS.selected_map.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()][PLAY_ITEMS.selected_episode.get()].keys()))
444+
def update_episode_widget(value: str) -> int:
445+
print('2', value)
446+
447+
PLAY_ITEMS.selected_episode.set(value)
448+
PLAY_ITEMS.episode_ch.set_menu(PLAY_ITEMS.selected_episode.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys()))
449+
450+
PLAY_ITEMS.selected_map.set(list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()][PLAY_ITEMS.selected_episode.get()].keys())[0])
451+
PLAY_ITEMS.map_ch.set_menu(PLAY_ITEMS.selected_map.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()][PLAY_ITEMS.selected_episode.get()].keys()))
452+
453+
print(PLAY_ITEMS.selected_episode.get(), PLAY_ITEMS.selected_map.get())
464454

465455
return 0
466456

467457

458+
def update_game_widget(value: str) -> int:
459+
print('1', value)
460+
461+
PLAY_ITEMS.selected_game.set(value)
462+
463+
print(PLAY_ITEMS.selected_game.get())
464+
465+
return update_episode_widget(list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys())[0])
466+
467+
468468
def zoom_in_image():
469469
img_display = tk.Toplevel(root)
470470
img_display.geometry(f'{int(PLAY_ITEMS.cur_img.size[0] * settings.zoom_boost)}x{int(PLAY_ITEMS.cur_img.size[1] * settings.zoom_boost)}')
@@ -543,10 +543,8 @@ def setup_play_screen():
543543
PLAY_ITEMS.map_label = ttk.Label(PLAY_ITEMS.f7, text='Map', font=BOLD_TEXT)
544544
PLAY_ITEMS.secrets_label = ttk.Label(PLAY_ITEMS.f8, text='Secrets', font=BOLD_TEXT)
545545

546-
PLAY_ITEMS.game_ch = ttk.OptionMenu(PLAY_ITEMS.f5, PLAY_ITEMS.selected_game, PLAY_ITEMS.selected_game.get(), *list(CUR_DB.structure.keys()), command=lambda:
547-
update_game_widgets('game'))
548-
PLAY_ITEMS.episode_ch = ttk.OptionMenu(PLAY_ITEMS.f6, PLAY_ITEMS.selected_episode, PLAY_ITEMS.selected_episode.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys()), command=lambda:
549-
update_game_widgets('episode'))
546+
PLAY_ITEMS.game_ch = ttk.OptionMenu(PLAY_ITEMS.f5, PLAY_ITEMS.selected_game, PLAY_ITEMS.selected_game.get(), *list(CUR_DB.structure.keys()), command=update_game_widget)
547+
PLAY_ITEMS.episode_ch = ttk.OptionMenu(PLAY_ITEMS.f6, PLAY_ITEMS.selected_episode, PLAY_ITEMS.selected_episode.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()].keys()), command=update_episode_widget)
550548
PLAY_ITEMS.map_ch = ttk.OptionMenu(PLAY_ITEMS.f7, PLAY_ITEMS.selected_map, PLAY_ITEMS.selected_map.get(), *list(CUR_DB.structure[PLAY_ITEMS.selected_game.get()][PLAY_ITEMS.selected_episode.get()].keys()))
551549

552550
PLAY_ITEMS.secrets_minus = ttk.Button(PLAY_ITEMS.f9, text='-', command=lambda:

0 commit comments

Comments
 (0)