Я пытаюсь получить ярлык под названием «номер», который будет отображаться непосредственно над центром Эллипса. Я попытался установить оба в том же макете, в разных макетах, в AnchorLayouts и RelativeLayouts, и я не смог понять, как к этому.kivy якорный макет не крепление?
Вот тестовая версия моего питона показывает один и тот же вопрос:
class BugTester(FloatLayout):
def __init__(self):
super().__init__()
for i in range(1,6):
temp = GamePiece(5, "Red")
temp.pos = (i*100,i*200)
self.add_widget(temp)
class BugTestingApp(App):
def build(self):
return BugTester()
class GamePiece(ToggleButton):
def __init__(self, number, color, **kwargs):
self.number = number
self.player_color = color
self.background_normal = "5.png"
super(GamePiece, self).__init__()
if __name__ == '__main__':
BugTestingApp().run()
И мой kivy:
<BugTester>:
Button:
background_disabled_normal: "background.jpg"
disabled: True
<GamePiece>:
id: gamepiece
size_hint:(None, None)
group: self.player_color
border: (0,0,0,0)
AnchorLayout:
id: layout
center: root.center
on_size: self.size = root.size
anchor_x: "left"
anchor_y: "bottom"
canvas:
Color:
rgba: 0,0,0,1
Ellipse:
#this is the ellipse in question
id: circle
size: (root.width/2.5, root.height/3)
#pos: -15, -20
pos: root.pos
Label:
#this is the label I want centered over the ellipse
id: number
text: str(root.number)
color: (1,1,1,1)
font_size: root.height/4
bold: True
#pos: root.pos
Вот что она в настоящее время выглядит следующим образом: (один из togglebuttons нажимается для иллюстрации цели)