如何在标签 Kivy 和 Python3 中添加一段文字?
How to paragraph of text in label Kivy and Python3?
我需要用 Python3 做一个演示。我了解 Kivy 的基础知识,而且我对 Python 相当满意。我只是想知道如何在一个标签中放置大量文本,例如:一整段文本。我已经通过将文本放在标签中进行了尝试但是发生了这种情况。
THIS
整个就成了一条线window。所以我想让它出现在一个段落中。此外,如果满足我的要求所需的代码为 .kv 文件格式,将不胜感激。如果那不可能,.py 文件格式也可以。
我会在这里添加代码:
.py 文件:
#!/usr/bin/env python3
import sys
from kivy.app import App
from kivy.metrics import dp
from kivy.properties import StringProperty
from kivy.uix.widget import Widget
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.button import Button
import kivy.resources
if getattr(sys, 'frozen', False):
kivy.resources.resource_add_path(sys._MEIPASS)
class TaneMahuta(App):
pass
TaneMahuta().run()
.kv 文件:
Box:
<Box@BoxLayout>:
Label:
text: "Tāne Mahuta is one of the six kids that were born to Papatūānuku and Ranginui. Tāne is an vital character in the Māori culture because his job is to maintain the greenery and life on the earth. The forests he looks after are essential sources of food, places to live, and much more. He is the god of most natural creatures. In stories, he is very confident, persistent and resilient. He is also the one that separated Ranginui and Papatūānuku to let in light. Even the largest tree in NZ is named after him = Tāne Mahuta. The tree, Tāne Mahuta, has some of the attributes of Tāne Mahuta (atua). It is a symbol of strength and stature. "
非常感谢您!
继续编码,
马赫斯瓦尔
text_size 应该有效
.kv
Box:
<Box@BoxLayout>:
Label:
text: "Tāne Mahuta is one of the six kids that were born to Papatūānuku and Ranginui. Tāne is an vital character in the Māori culture because his job is to maintain the greenery and life on the earth. The forests he looks after are essential sources of food, places to live, and much more. He is the god of most natural creatures. In stories, he is very confident, persistent and resilient. He is also the one that separated Ranginui and Papatūānuku to let in light. Even the largest tree in NZ is named after him = Tāne Mahuta. The tree, Tāne Mahuta, has some of the attributes of Tāne Mahuta (atua). It is a symbol of strength and stature. "
text_size: 100, None
希望对您有所帮助。
我需要用 Python3 做一个演示。我了解 Kivy 的基础知识,而且我对 Python 相当满意。我只是想知道如何在一个标签中放置大量文本,例如:一整段文本。我已经通过将文本放在标签中进行了尝试但是发生了这种情况。
THIS
整个就成了一条线window。所以我想让它出现在一个段落中。此外,如果满足我的要求所需的代码为 .kv 文件格式,将不胜感激。如果那不可能,.py 文件格式也可以。
我会在这里添加代码:
.py 文件:
#!/usr/bin/env python3
import sys
from kivy.app import App
from kivy.metrics import dp
from kivy.properties import StringProperty
from kivy.uix.widget import Widget
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.button import Button
import kivy.resources
if getattr(sys, 'frozen', False):
kivy.resources.resource_add_path(sys._MEIPASS)
class TaneMahuta(App):
pass
TaneMahuta().run()
.kv 文件:
Box:
<Box@BoxLayout>:
Label:
text: "Tāne Mahuta is one of the six kids that were born to Papatūānuku and Ranginui. Tāne is an vital character in the Māori culture because his job is to maintain the greenery and life on the earth. The forests he looks after are essential sources of food, places to live, and much more. He is the god of most natural creatures. In stories, he is very confident, persistent and resilient. He is also the one that separated Ranginui and Papatūānuku to let in light. Even the largest tree in NZ is named after him = Tāne Mahuta. The tree, Tāne Mahuta, has some of the attributes of Tāne Mahuta (atua). It is a symbol of strength and stature. "
非常感谢您!
继续编码,
马赫斯瓦尔
text_size 应该有效
.kv
Box:
<Box@BoxLayout>:
Label:
text: "Tāne Mahuta is one of the six kids that were born to Papatūānuku and Ranginui. Tāne is an vital character in the Māori culture because his job is to maintain the greenery and life on the earth. The forests he looks after are essential sources of food, places to live, and much more. He is the god of most natural creatures. In stories, he is very confident, persistent and resilient. He is also the one that separated Ranginui and Papatūānuku to let in light. Even the largest tree in NZ is named after him = Tāne Mahuta. The tree, Tāne Mahuta, has some of the attributes of Tāne Mahuta (atua). It is a symbol of strength and stature. "
text_size: 100, None
希望对您有所帮助。