【发布时间】:2017-11-23 09:27:46
【问题描述】:
我已经用 Python (test.py) 和 kivy (test.kv) 编写了一些代码。
谁能告诉我如何在我的 boxLayout 中添加垂直滚动条?
我正在使用
滚动视图:
do_scroll_y: 真
do_scroll_x: 假
盒子布局:
方向:“垂直”
但我想我可能在某个地方犯了错误。
当我使用 scrollView 时,设计就会被宠坏
test.py
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
Window.clearcolor = (0.5, 0.5, 0.5, 1)
Window.size = (600, 700)
class ACgroup(Screen):
pass
class TestACgroup(App):
def build(self):
self.root = Builder.load_file('test.kv')
return self.root
if __name__ == '__main__':
TestACgroup().run()
test.kv
<CustomLabel@Label>:
text_size: self.size
#padding_x: 5
<SingleLineTextInput@TextInput>:
multiline: False
<GreenButton@Button>:
background_color: 1, 1, 1, 1
size_hint_y: None
height: self.parent.height * 0.100
ACgroup:
BoxLayout:
orientation: "vertical"
GridLayout:
cols: 2
padding : 15, 15
spacing: 20, 5
row_default_height: '20dp'
size_hint: 1, .01
pos_hint: {'x': 0, 'y':.95}
CustomLabel:
text: 'Fname'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 7
Label:
text: 'Name'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: stateName
GridLayout:
cols: 4
padding : 15, 10
spacing: 20, 5
row_default_height: '20dp'
size_hint: 1, .01
pos_hint: {'x': 0, 'y':.7}
CustomLabel:
text: 'ADDRESS :-'
CustomLabel:
CustomLabel:
CustomLabel:
CustomLabel:
text: 'City'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 4.5
Label:
text: 'Pin'
text_size: self.size
valign: 'middle'
halign: 'right'
SingleLineTextInput:
id: stateCode
CustomLabel:
text: 'Area'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 4.5
GridLayout:
cols: 6
padding: 15, 15
spacing: 5, 5
row_default_height: '20dp'
size_hint: 1, .005
pos_hint: {'x': 0, 'y':.5}
CustomLabel:
text: 'Address'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
#size_hint_y: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 3
#size_hint_y: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 3
#size_hint_y: 0
GridLayout:
cols: 2
padding : 15, 5
spacing: 10, 10
row_default_height: '20dp'
size_hint: 1, .02
pos_hint: {'x': 0, 'y':.4}
CustomLabel:
text: 'CONTACT DETAIL:-'
CustomLabel:
Label:
text: 'Phone'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
Label:
text: 'Mobile'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
Label:
text: 'E-Mail'
text_size: self.size
halign: 'left'
valign: 'middle'
size_hint_x: 2
SingleLineTextInput:
id: acGroup
size_hint_x: 6.5
#size_hint_y: 2
GreenButton:
text: 'Ok'
GreenButton:
text: 'Cancel'
on_press: app.stop()
有人可以帮助我吗?
【问题讨论】:
标签: python python-2.7 kivy kivy-language