Home > OS >  How to increase the height of a cell in Kivy
How to increase the height of a cell in Kivy

Time:11-21

I'm trying to make a GUI for my ai and am attempting to make a template for it. But my 'TESTER-MAN' button does not fill the white space below it, leaving a. gap and what would be shrinking my image that will go there. I would like to get some help on attempting to increase the height of the cell to fill the white space.

python3:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout

class BoxLayoutE(BoxLayout):
    pass

class guiApp(App):
    pass


guiApp().run()

.kv

 BoxLayoutE:



<BoxLayoutE>:

orientation: "vertical"
Button:
    text: "TESTER-MAN"

BoxLayout:
    orientation: "horizontal"
    Button:
        text: "1"
        color: 0, 0, 1, 1
        size_hint: .5, None
    Button:
        text: "2"
        color: 0, 0, 1, 1
        size_hint: .5, None
    Button:
        text: "3"
        color: 0, 0, 1, 1
        size_hint: .5, None
Button:
    text: "A"
    color: 0, 0, 1, 1
Button:
    text: "B"
    color: 0, 0, 1, 1
Button:
    text: "C"
    color: 0, 0, 1, 1

Picture of the GUI and where the picture of gui

CodePudding user response:

The problem is that in your horizontal BoxLayout, you have assigned size_hint to (.5, None) for each of the Buttons, so that those Buttons do not fill the BoxLayout vertically. Try changing that part of the kv to:

BoxLayout:
    orientation: "horizontal"
    Button:
        text: "1"
        color: 0, 0, 1, 1
        size_hint: .5, 1
    Button:
        text: "2"
        color: 0, 0, 1, 1
        size_hint: .5, 1
    Button:
        text: "3"
        color: 0, 0, 1, 1
        size_hint: .5, 1

Note that the size_hints are now .5, 1, so the Buttons fill the space vertically.

  • Related