I am a beginner at kivy, and I need to create two cols of GridLayout. I want to set the first col of a grid. And leave the last col as default. Is it possible to do that?
Where I have to set the width? in the .py file or in the .kv file?
Here is my code:
main.py
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.config import Config
from kivy.properties import ObjectProperty
from kivy.lang import Builder
Config.set('graphics', 'width', '920')
Config.set('graphics', 'height', '480')
Config.set('graphics', 'resizable', False)
from os import listdir
kv_path = '../views/mainView/'
for kv in listdir(kv_path):
Builder.load_file(kv_path+kv)
class Container(FloatLayout, object):
dispImg = ObjectProperty()
def update(self, *args):
self.dispImg = '../../images/placeholder.jpg'
class mainView(App):
def build(self):
container = Container()
return container
if __name__ == "__main__":
mainView().run()
main.kv
<Container>:
cols: 2
Image:
...
# I want to set this column width
BoxLayout:
...
# and leave this column width
What you have to do is set a fixed width in the first item and the size_hint_x
to None.
GridLayout:
cols:2
Image:
width: 200
size_hint_x: None
BoxLayout: