调整 Kivy 滚动视图标签的大小
Resizing Kivy Scroll View Label
我正在尝试向我的 Kivy 应用程序中的矩形添加滚动标签。我的滚动标签工作正常,但我无法调整滚动标签的大小以使其适合我的矩形。我试图弄乱高度或 size_hint,但它不会再滚动了。下面是问题的图片和代码。
问题图片
WindowManager:
MainWindow:
SettingsWindow:
HelpWindow:
<MainWindow>:
name:"main"
FloatLayout:
#Background
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Button:
size_hint: 0.06, 0.06
pos_hint: {"x":.945, "y":.945}
text: 'X'
background_color: 1,0,0,.6
on_release:
app.stop()
#Logo/Credit
Image:
source: 'Images/dtd.png'
allow_stretch: True
size_hint: 0.2, 0.2
pos_hint: {"x":0.01, "y":0.77}
Label:
text:"Job Assigner"
bold:True
italic:True
size: self.texture_size
pos_hint: {"x":-0.39, "y":0.25}
color: 1,1,1,1
Label:
text:"Created by: Anthony DeArmas"
bold:True
italic:True
size: self.texture_size
pos_hint: {"x":0.35, "y":-0.46}
color: 0,0,0,.2
#Main Menu Buttons
Image:
source: 'Images/icon_cog.png'
allow_stretch: True
size_hint: 0.04, 0.04
pos_hint: {"x":0.23, "y":0.53}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.15, "y":0.5}
text: 'Settings'
background_color: 1,1,1,.6
on_release:
app.root.current = "settings"
root.manager.transition.direction = 'left'
Image:
source: 'Images/icon_qmark.png'
allow_stretch: True
size_hint: 0.03, 0.03
pos_hint: {"x":0.7, "y":0.535}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.6, "y":0.5}
text: 'Help'
background_color: 1,1,1,.6
on_release:
app.root.current = "help"
root.manager.transition.direction = 'left'
Image:
source: 'Images/icon_notepad.png'
allow_stretch: True
size_hint: 0.035, 0.035
pos_hint: {"x":0.442, "y":0.335}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.377, "y":0.3}
text: 'Assign Jobs'
on_press: root.assign_Jobs()
background_color: 1,1,1,.6
<SettingsWindow>:
name:"settings"
FloatLayout:
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Color:
rgba: 1,1,1,.3
Rectangle:
size: 200, 500
pos: self.width/10, self.height/7
Color:
rgba: 0,0,0,.5
Rectangle:
size: 190, 350
pos: self.width/9.4, self.height/3
ScrollView:
GridLayout:
cols:1
size_hint: None, None
height: self.minimum_height
pos_hint: {"x":0.125, "y":0.1}
Label:
size_hint: None, None
size: self.texture_size
text: root.pretty_list_people * 20
Button:
text:"Back"
size_hint: 0.1, 0.1
pos_hint: {"x":0, "y":0}
background_color: 1,1,1,.6
on_release:
app.root.current = "main"
root.manager.transition.direction = 'right'
Label:
text: "People"
font_size: 30
italic: True
pos_hint: {"x":-0.275, "y":0.45}
color: 0,0,0,1
Button:
text:"Update"
size_hint: 0.25, 0.1
pos_hint: {"x":0.1, "y":0.144}
on_press: root.Pretty_Print_People(root.get_People())
Button:
text:"Add"
size_hint: 0.125, 0.09
pos_hint: {"x":0.1, "y":0.243}
#on_press: root.Pretty_Print_People(root.get_People())
Button:
text:"Remove"
size_hint: 0.125, 0.09
pos_hint: {"x":0.225, "y":0.243}
#on_press: root.Pretty_Print_People(root.get_People())
<HelpWindow>:
name:"help"
FloatLayout:
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Button:
text:"Back"
size_hint: 0.1, 0.1
pos_hint: {"x":0, "y":0}
background_color: 1,1,1,.6
on_release:
app.root.current = "main"
root.manager.transition.direction = 'right'
我正在发布我找到的解决方案。这很愚蠢,但我就是找不到 pos 提示的正确语法。这是我的滚动视图 kv 代码:
ScrollView:
size_hint: (None, None)
size: (150, 325)
pos_hint: {'center_x': .23, 'center_y': .62}
Label:
size_hint: None, None
size: self.texture_size
text: root.pretty_list_people * 20
A picture of the properties working!
我正在尝试向我的 Kivy 应用程序中的矩形添加滚动标签。我的滚动标签工作正常,但我无法调整滚动标签的大小以使其适合我的矩形。我试图弄乱高度或 size_hint,但它不会再滚动了。下面是问题的图片和代码。
问题图片
WindowManager:
MainWindow:
SettingsWindow:
HelpWindow:
<MainWindow>:
name:"main"
FloatLayout:
#Background
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Button:
size_hint: 0.06, 0.06
pos_hint: {"x":.945, "y":.945}
text: 'X'
background_color: 1,0,0,.6
on_release:
app.stop()
#Logo/Credit
Image:
source: 'Images/dtd.png'
allow_stretch: True
size_hint: 0.2, 0.2
pos_hint: {"x":0.01, "y":0.77}
Label:
text:"Job Assigner"
bold:True
italic:True
size: self.texture_size
pos_hint: {"x":-0.39, "y":0.25}
color: 1,1,1,1
Label:
text:"Created by: Anthony DeArmas"
bold:True
italic:True
size: self.texture_size
pos_hint: {"x":0.35, "y":-0.46}
color: 0,0,0,.2
#Main Menu Buttons
Image:
source: 'Images/icon_cog.png'
allow_stretch: True
size_hint: 0.04, 0.04
pos_hint: {"x":0.23, "y":0.53}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.15, "y":0.5}
text: 'Settings'
background_color: 1,1,1,.6
on_release:
app.root.current = "settings"
root.manager.transition.direction = 'left'
Image:
source: 'Images/icon_qmark.png'
allow_stretch: True
size_hint: 0.03, 0.03
pos_hint: {"x":0.7, "y":0.535}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.6, "y":0.5}
text: 'Help'
background_color: 1,1,1,.6
on_release:
app.root.current = "help"
root.manager.transition.direction = 'left'
Image:
source: 'Images/icon_notepad.png'
allow_stretch: True
size_hint: 0.035, 0.035
pos_hint: {"x":0.442, "y":0.335}
Button:
size_hint: 0.3, 0.1
pos_hint: {"x":0.377, "y":0.3}
text: 'Assign Jobs'
on_press: root.assign_Jobs()
background_color: 1,1,1,.6
<SettingsWindow>:
name:"settings"
FloatLayout:
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Color:
rgba: 1,1,1,.3
Rectangle:
size: 200, 500
pos: self.width/10, self.height/7
Color:
rgba: 0,0,0,.5
Rectangle:
size: 190, 350
pos: self.width/9.4, self.height/3
ScrollView:
GridLayout:
cols:1
size_hint: None, None
height: self.minimum_height
pos_hint: {"x":0.125, "y":0.1}
Label:
size_hint: None, None
size: self.texture_size
text: root.pretty_list_people * 20
Button:
text:"Back"
size_hint: 0.1, 0.1
pos_hint: {"x":0, "y":0}
background_color: 1,1,1,.6
on_release:
app.root.current = "main"
root.manager.transition.direction = 'right'
Label:
text: "People"
font_size: 30
italic: True
pos_hint: {"x":-0.275, "y":0.45}
color: 0,0,0,1
Button:
text:"Update"
size_hint: 0.25, 0.1
pos_hint: {"x":0.1, "y":0.144}
on_press: root.Pretty_Print_People(root.get_People())
Button:
text:"Add"
size_hint: 0.125, 0.09
pos_hint: {"x":0.1, "y":0.243}
#on_press: root.Pretty_Print_People(root.get_People())
Button:
text:"Remove"
size_hint: 0.125, 0.09
pos_hint: {"x":0.225, "y":0.243}
#on_press: root.Pretty_Print_People(root.get_People())
<HelpWindow>:
name:"help"
FloatLayout:
Widget:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "Images/logo_br.png"
Button:
text:"Back"
size_hint: 0.1, 0.1
pos_hint: {"x":0, "y":0}
background_color: 1,1,1,.6
on_release:
app.root.current = "main"
root.manager.transition.direction = 'right'
我正在发布我找到的解决方案。这很愚蠢,但我就是找不到 pos 提示的正确语法。这是我的滚动视图 kv 代码:
ScrollView:
size_hint: (None, None)
size: (150, 325)
pos_hint: {'center_x': .23, 'center_y': .62}
Label:
size_hint: None, None
size: self.texture_size
text: root.pretty_list_people * 20
A picture of the properties working!