我无法格式化这些省略号,以便它们出现在屏幕中央。我已经尝试了我能想到的一切。我用 Kivy 语言编写的 Button 就像它的本意一样位于显示器的角落,但 Target 类中的所有内容都拒绝遵守我的格式,无论如何都绘制在屏幕的左下角。
class Target(Label):
def __init__(self, **kwargs):
super(Target, self).__init__(**kwargs)
with self.canvas:
Color(1,1,1)
d = 400
Ellipse(pos=((self.center_x - d / 2), (self.center_y - d / 2)), size=(d,d))
Color(0,0,0)
d = 320
Ellipse(pos=((self.center_x - d / 2), (self.center_y - d / 2)), size=(d,d))
Color(0,0,1)
d = 240
Ellipse(pos=((self.center_x - d / 2), (self.center_y - d / 2)), size=(d,d))
Color(1,0,0)
d = 160
Ellipse(pos=((self.center_x - d / 2), (self.center_y - d / 2)), size=(d,d))
Color(1,1,0)
d = 80
Ellipse(pos=((self.center_x - d / 2), (self.center_y - d / 2)), size=(d,d))
这就是与在小部件上绘制圆圈有关的所有原始 python 代码。这是处理屏幕的 Kivy 代码。
<ScoringLayout>:
FloatLayout:
Target:
center: self.parent.center
size_hint: 0.2, 0.3
Button:
text: "Return"
on_release: app.root.current = "main"
font_size: 15
size_hint: 0.3 ,0.2
pos_hint: {"right": 1, "bottom": 1}
评分布局是切换到的屏幕布局,损坏代码下方的按钮链接回应用程序的主屏幕。
我还应该说,目标是将其与我的其余代码一起打包为 Android 应用程序。