当readonly为True时,是否有滚动文本的方法



我有这个.kv代码,当只读为false时,它会滚动,但当只读为true时,它不会滚动。请告诉我如何将只读设置为true滚动。感谢

enter code here <January1Window>:
name: "January1"
scroll:scroll
direction:'tb-lr'
size:(1480, 854)
ScrollView:
id:scroll
bar_color:(0, 0, 0, 0.4)
bar_inactiv_color:(0, 0, 0.7, 0.4)
bar_margin:2
bar_width:8
on_scroll_x:January1.focus = True
on_scroll_y:January1.focus = True
TextInput:
size_hint:(0.8, 0.5)
id:January1
text: root.showJanuary1()
padding:50
readonly: True
do_scroll_x:True
do_scroll_y:True
pos_hint: {'center_x': 0.4, 'center_y':0.35}
#background_color: 3,0,0.2, 0.7

我看不到readonly的值有任何影响。但是,对于要滚动的方向,需要将size_hint设置为None。例如:

TextInput:
size_hint:(0.8, None)
height: self.minimum_height
BoxLayout:
orientation: 'vertical'
Label:
text: 'Scroll TextInput'
size_hint_y: None
height: 48
ToggleButton:
size_hint_y: None
height: 48
text: 'Set Read-Only'
on_state: text_input.readonly = True if self.state else False
ScrollView:
bar_color:(0, 0, 0, 0.4)
bar_inactiv_color:(0, 0, 0.7, 0.4)
bar_margin:2
bar_width:8
do_scroll_x:True
do_scroll_y:True
TextInput:
id: text_input
size_hint: .8, None
height: self.minimum_height
text: 'This is a long long long set of words\n' * 100

感谢Elliot Garbus

最新更新