Code: Select all
if i==1:
xalign 0.5 yalign 0.5
Code: Select all
if i==1:
xalign 0.5 yalign 0.5
I am looking at the latter. So I want the first button to appear in one position, the second button in another position and so on. No all of them will be used so I will need to move the spaces to make them balanced. I'm trying to see how I can achieve that.Imperf3kt wrote: ↑Tue May 26, 2020 6:18 pm I looked up the definition of 'enumerate', but I'm still confused.
Do you want a fixed number of buttons positioned in a circle, or are you trying to make buttons only appear in certain positions and not all the buttons will be used sometimes so you need them to move one space clockwise / anticlockwise when an empty space is present?
Code: Select all
screen choice(items):
style_prefix "choice"
$import math
$center_x = 960
$center_y = 540
$radius = 400
$button_idx = 0
$button_info = [("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction()),
("gui/button/choice_idle_background.png", "gui/button/choice_hover_background.png", NullAction())]
for i in items:
$angle = button_idx * math.pi * 2 / len(button_info)
$x = math.cos(angle) * radius + center_x
$y = math.sin(angle) * radius + center_y
textbutton i.caption action i.action xanchor 0.5 yanchor 0.5 xpos int(x) ypos int(y)
$button_idx += 1
add "gui/choice_circle.png" xpos 960 ypos 540
Code: Select all
textbutton i.caption action i.action xanchor 0.5 yanchor 0.5 xpos int(x) ypos int(y) xsize 150 text_align 0.5
Users browsing this forum: Google [Bot]