【问题标题】:kivy: resizing ellipse not workingkivy:调整椭圆大小不起作用
【发布时间】:2015-06-06 04:59:30
【问题描述】:

我正在尝试调整椭圆的大小。但无论我将其设置为多大,圆圈总是如下所示:

我的 Python 代码:

class TestCircle(Widget):
    def move(self, dt):
        self.x = self.x + self.velocity_x

sm = ScreenManager()
sm.add_widget(WelcomeScreen(name='welcome'))

class ShootingApp(App):
    def play_ball(self, intensity, duration):
        ball = TestCircle()
        ball.size = Vector(50, 50)
        ball.pos = Vector(0,0)
        basicscreen3.add_widget(ball)

    def build(self):
        return sm

我的 kivy 代码是这样的:

<TestCircle>:
    size: 50, 50
    canvas:
        Color: 
            rgb: (0, 1, 1)
        Ellipse:
            size: self.size
            pos: self.pos

【问题讨论】:

    标签: kivy


    【解决方案1】:

    您正在尝试设置 TestCircle 的大小?这没有任何作用,因为它的父元素 basicscreen3 可能是一个 Screen,因此是一个自动定位子元素以填充自身的 RelativeLayout。

    如果您不希望布局设置小部件的大小,则应添加 size_hint: None, None 并尝试手动设置大小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-02
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多