擅长:python、mysql、java
<p>你可以试试这个:-</p>
<p><strong>.py代码</strong></p>
<pre><code>class MyGoalsScreen (Screen):
def on_enter(self):
file= open("package.txt" , "r")
load_file = ""
for line in file:
load_file = load_file + line
file.close()
self.ids.mylabel.text = load_file
</code></pre>
<p><strong>.kv代码</strong></p>
<pre><code><MyGoalsScreen>:
name: "mygoals"
MDToolbar:
title: "My Goals"
pos_hint: {"top": 1}
MDCard:
orientation: "vertical"
pos_hint:{ "center_x" :0.5, "center_y": 0.5}
size_hint: 0.8, 0.7
padding: "8dp"
MDLabel:
id: mylabel
halign: "center"
font_size: (root.width**2 + root.height**2) / 13**4
size_hint: 0.8, 0.1
</code></pre>
<p>我希望这能解决你的问题</p>