Handle choice menu overflow
This commit is contained in:
parent
e9cadcdc89
commit
792467e25a
@ -153,23 +153,31 @@ screen choice(items):
|
|||||||
variant "pc"
|
variant "pc"
|
||||||
|
|
||||||
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
|
default has_icons = any(x is not None for x in [e.kwargs.get("icon", None) for e in items])
|
||||||
|
default columns = math.ceil(len(items) / 12)
|
||||||
|
|
||||||
vbox:
|
hbox:
|
||||||
at gui_choice_show_hide
|
at gui_choice_show_hide
|
||||||
for i, entry in enumerate(items, 1):
|
for column in range(columns):
|
||||||
|
vbox:
|
||||||
|
$ start_index = column * 12
|
||||||
|
$ end_index = start_index + 12
|
||||||
|
|
||||||
|
for i, entry in enumerate(items[start_index:end_index], 1):
|
||||||
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
|
$ scale = (1.0 * (28 / max(28, len(entry.caption))))
|
||||||
$ icon = entry.kwargs.get("icon", None)
|
$ icon = entry.kwargs.get("icon", None)
|
||||||
$ progress = entry.kwargs.get("progress", None)
|
$ progress = entry.kwargs.get("progress", None)
|
||||||
|
|
||||||
vbox:
|
|
||||||
spacing 2
|
|
||||||
|
|
||||||
button:
|
button:
|
||||||
action entry.action
|
action entry.action
|
||||||
|
|
||||||
|
# Handle columns
|
||||||
|
if columns > 1:
|
||||||
|
xmaximum (config.screen_width // columns)
|
||||||
|
|
||||||
if i < 10 and entry.action:
|
if i < 10 and entry.action:
|
||||||
keysym ("K_"+str(i), "K_KP"+str(i))
|
keysym ("K_"+str(i), "K_KP"+str(i))
|
||||||
|
|
||||||
text "[i]" style "choice_number":
|
text "[i+start_index]" style "choice_number":
|
||||||
at gui_perspective
|
at gui_perspective
|
||||||
|
|
||||||
hbox:
|
hbox:
|
||||||
@ -257,12 +265,13 @@ style choice_button is button
|
|||||||
style choice_button_text is button_text
|
style choice_button_text is button_text
|
||||||
|
|
||||||
style choice_vbox:
|
style choice_vbox:
|
||||||
xalign 0.5
|
align (0.5, 1.0)
|
||||||
yanchor 1.0
|
|
||||||
ypos 0.75
|
|
||||||
spacing 10
|
spacing 10
|
||||||
|
|
||||||
style choice_hbox:
|
style choice_hbox:
|
||||||
|
xalign 0.5
|
||||||
|
yanchor 1.0
|
||||||
|
ypos 0.75
|
||||||
spacing 2
|
spacing 2
|
||||||
|
|
||||||
style choice_button:
|
style choice_button:
|
||||||
|
Loading…
Reference in New Issue
Block a user