【发布时间】:2017-10-25 11:19:26
【问题描述】:
我刚刚开始使用 Python 的 Kivy 编程。我在使用 PageLayout 时遇到问题。到目前为止,这是我的 Python 代码(Python 3.6.2):
import kivy
from kivy.app import App
from kivy.uix.pagelayout import PageLayout
class PageApp(App):
def build(self):
return PageLayout()
paApp = PageApp()
paApp.run()
Kivy 文件 (PageApp.kv) 有以下内容:
<PageLayout>:
canvas:
Color:
rgb: 0, .5, .95
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
orientation: "vertical"
Button:
text: "This is a test button"
size_hint_y: .4
Label:
markup: True
text: "This is a [b]looooong[/b] text... "*100
color: 0, 0, 0, 1
outline_color: 0, 0.5, 0.5, 1
font_size: 30
BoxLayout:
orientation: "vertical"
Label:
markup: True
text: "This is an even [b]looooonger[/b] text... "*100
color: 0, 0, 0, 1
outline_color: 0, 0.5, 0.5, 1
font_size: 30
Button:
text: "This is a second test button"
size_hint_y: .2
Button:
text: "Page 3"
Button:
text: "Page 4"
结果如下所示:Page 1, Page 2 (after swiping)
从截图中可以看出,出现以下问题:
- 标签不显示。
- 背景只有部分颜色是我在画布设置中指定的颜色。
- 最重要的是:滑动后页面似乎没有重置,导致第一页的元素在滑动到第 2 页时仍保留在页面上的问题。第 3 页和第 4 页似乎工作正常,因为按钮占据了整个空间......
有人知道如何解决这些问题吗?
【问题讨论】:
标签: python-3.x kivy kivy-language page-layout