简体   繁体   中英

Resizing Kivy Scroll View Label

I am trying to add a scroll label to a rectangle in my Kivy application. My scroll label is working perfectly, but I cannot resize the scroll label so it fits inside my rectangle. I tried to mess with the height or the size_hint, but then it won't scroll anymore. Below is a picture of the problem along with the code.

A picture of the problem 问题图

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'

I am posting the solution I found. It is pretty silly, but I just couldn't find the right syntax for pos hint. Here is my scroll view kv code:

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM