【问题标题】:How to paragraph of text in label Kivy and Python3?如何在标签 Kivy 和 Python3 中的文本段落?
【发布时间】:2022-06-27 13:53:10
【问题描述】:

我需要用 Python3 做一个演示。我知道 Kivy 的基础知识,而且我对 Python 非常熟悉。我只是想知道如何在一个标签中放置大量文本,例如:整段文本。我已经尝试通过将文本放在标签中但发生这种情况。

THIS

它只是沿着整个窗口变成一条线。所以我想让它出现在一个段落中。此外,如果需要以 .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."

【问题讨论】:

    标签: python-3.x text kivy


    【解决方案1】:

    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
    

    【讨论】:

      猜你喜欢
      • 2014-10-04
      • 1970-01-01
      • 2013-06-29
      • 1970-01-01
      • 2014-09-12
      • 2018-10-06
      • 2013-09-24
      • 1970-01-01
      • 2013-12-18
      相关资源
      最近更新 更多