【发布时间】:2019-11-11 21:29:32
【问题描述】:
我想在我的 rouded 按钮中创建一个“属性”,以便能够执行以下操作:
RoundedButton:
radius: 30
我的python代码:我在Python中有这个类:
class RoundedButton(Button):
radius = NumericProperty(30)
在我的 kv 文件中:
<RoundedButton@Button>:
background_color: 0,0,0,0 # the last zero is the critical on, make invisible
canvas.before:
Color:
rgba: (.4,.4,.4,1) if self.state=='normal' else (0,.7,.7,1) # visual feedback of press
RoundedRectangle:
pos: self.pos
size: self.size
radius: [10,]
<MenuScreen>
GridLayout:
size: root.width, root.height
GridLayout:
RoundedButton:
size: 300, 300
我想写这样的东西:
<RoundedButton@Button>:
radius: radius
background_color: 0,0,0,0 # the last zero is the critical on, make invisible
canvas.before:
Color:
rgba: (.4,.4,.4,1) if self.state=='normal' else (0,.7,.7,1) # visual feedback of press
RoundedRectangle:
pos: self.pos
size: self.size
radius: [radius,]
<MenuScreen>
GridLayout:
size: root.width, root.height
GridLayout:
RoundedButton:
size: 300, 300
radius: 10
【问题讨论】:
标签: python python-3.x kivy kivy-language