###### 问题遇到的现象和发生背景
本人初学者,想做一个计算器,练手,在窗口想输出计算的内容,怎么按都是空
###### 问题相关代码,请勿粘贴截图
在PY文件中:
class CalculatorScreen(Screen):
text = ""
def set_text(self,value):
self.text = self.text + value
def clear_text(self):
self.text = ""
@property
def _text(self):
return self.text
kv文件中:
<CalculatorScreen>:
name: "calculator"
BoxLayout:
orientation: "vertical"
BoxLayout:
size_hint_y: 1
Button:
text: "返回"
size_hint_x: 1
on_press: app.root.current = "main"
BackgroundLabel:
text: "计算器"
text_size: self.size
halign: "center"
size_hint_x: 9
background_color: 1, 0, 0, 1
BackgroundLabel:
id: view
size_hint_y: 3
background_color: [1, 1 , 1, 1]
text: root._text
GridLayout:
cols: 5
rows: 6
size_hint_y: 12
background_color: [1, 0, 0, 1]
Button:
text: "清除"
on_press: root.clear_text()
Button:
text: "π"
on_press: root.set_text("π")
###### 运行结果及报错内容
###### 我的解答思路和尝试过的方法
没想出是什么原因,求解答,不胜感激
###### 我想要达到的结果