, ,

Fixed button size in GridLayout

fixed_btn_gl.py
from kivy.app import App
from kivy.uix.screenmanager import Screen
 
from kivy.lang import Builder
 
gui = '''
LoginScreen:
 
    GridLayout:
        cols: 2
 
        Label:
            text: 'Subject'
 
        Label:
 
        Label:
            text: '1'
 
        SingleLineTextInput:
 
        Label:
            text: '2'
 
        SingleLineTextInput:
 
        Label:
            text: '3'
 
        SingleLineTextInput:
 
        Label:
            text: '4'
 
        SingleLineTextInput:
 
        GreenButton:
            text: 'Exit'
            on_press: app.stop()
 
        GreenButton:
            text: 'Run'
 
 
<SingleLineTextInput@TextInput>:
    multiline: False
 
 
<GreenButton@Button>:
    background_color: 0, 1, 0, 1
    size_hint_y: None
    height: self.parent.height * 0.111
'''
 
 
class LoginScreen(Screen):
    pass
 
 
class SimpleKivy(App):
 
    def build(self):
        return Builder.load_string(gui)
 
 
if __name__ == '__main__':
    SimpleKivy().run()