【发布时间】:2017-08-22 11:17:06
【问题描述】:
我一直在看一个关于创建计算器的 Kivy 和 Python 教程,但我看到了这个属性:显示小部件 id 的值。使用此值,它可以访问小部件的其他属性。 这是代码(.kv 文件):
<CalcGridLayout>:
id: calculator
display: entry #this is the display property
rows: 5
padding: 10
spacing: 10
BoxLayout:
TextInput:
id: entry #with the value of this
font_size: 32
multiline: False
BoxLayout:
spacing: 10
Button:
text: "7"
on_press: entry.text += self.text
Button:
text: "8"
on_press: entry.text += self.text
Button:
text: "9"
on_press: entry.text += self.text
Button:
text: "+"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
Button:
text: "4"
on_press: entry.text += self.text
Button:
text: "5"
on_press: entry.text += self.text
Button:
text: "6"
on_press: entry.text += self.text
Button:
text: "-"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
Button:
text: "1"
on_press: entry.text += self.text
Button:
text: "2"
on_press: entry.text += self.text
Button:
text: "3"
on_press: entry.text += self.text
Button:
text: "*"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
Button:
text: "AC"
on_press: entry.text = ""
Button:
text: "0"
on_press: entry.text += self.text
Button:
text: "="
on_press: calculator.calculate(entry.text)
Button:
text: "/"
on_press: entry.text += self.text
那个变量/属性是什么?它是干什么用的?
【问题讨论】:
标签: android python python-3.x kivy kivy-language