【发布时间】:2015-03-29 17:42:39
【问题描述】:
我正在为自己编写一个小应用程序,但遇到了一些问题。 我无法使用 ScrollView 滚动标签。标签通过读取文本文件出现。
我展示了我的代码的一部分。
.py 代码:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
class GeneralForm(TabbedPanel):
txt_show = ObjectProperty()
def SHOW_CONTENT(self):
FILE=open('data')
A=FILE.read()
self.txt_show.text=A
class TimeTable(App):
def build(self):
return GeneralForm()
if __name__ == '__main__':
TimeTable().run()
.kv 代码:
<GeneralForm>:
do_default_tab: False
txt_show:txt1
TabbedPanelItem:
text: 'Mon'
on_release: root.SHOW_CONTENT()
BoxLayout:
orientation: 'vertical'
ScrollView:
size: self.size
Label:
id:txt1
text: ''
size_hint_y: None
BoxLayout:
Button:
text: 'Edit'
Button:
text: 'Exit'
TabbedPanelItem:
text: 'Tue'
TabbedPanelItem:
text: 'Wed'
“数据”文件是一个简单的 txt 文件,其中包含很多行文本。 当该文本显示在标签中时 - 它被截断。
如何为标签中的文本添加滚动?
提前致谢。
【问题讨论】:
标签: python label scrollview kivy