我需要用 Python3 做一個演示。我知道 Kivy 的基礎知識,而且我對 Python 非常熟悉。我只是想知道如何在一個標簽中放置大量文本,例如:整段文本。我已經通過將文本放在標簽中進行了嘗試,但這種情況發生了。
這
它只是沿著整個視窗變成一條線。所以我想讓它出現在一個段落中。此外,如果需要以 .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. "
非常感謝您!
繼續編碼,
馬赫斯瓦爾
uj5u.com熱心網友回復:
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
希望這有幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/477041.html
標籤:python-3.x 文本 基维
