Can you automatically load user information in kivy - python

I am making an app where there is a profile screen in which you can enter generic profile information (name, height, weight, ect..) using textinput boxes. I know there is a way to put a button next to each textinput box to save the information and another button to load the information. I am wondering if there is a way to automatically load this information when the user opens the app rather than manually loading the information by hitting a button.
<Phone>:
result: _result
h: _h
w: _w
AnchorLayout:
anchor_x: 'center'
anchor_y: 'top'
ScreenManager:
size_hint: 1, .9
id: _screen_manager
Screen:
name: 'home'
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "/home/aaron/Desktop/main.png"
Label:
markup: True
text: '[size=100][color=ff3333]Welcome to [color=ff3333]Diabetes Manager[/color][/size]'
Screen:
name: 'menu'
GridLayout:
cols: 2
padding: 50
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "/home/aaron/Desktop/main.png"
Button:
text: 'My Profile'
on_press: _screen_manager.current = 'profile'
Button:
text: 'History'
on_press: _screen_manager.current = 'history'
Button:
text: 'New Entry'
on_press: _screen_manager.current = 'new_entry'
Button:
text: 'Graph'
on_press: _screen_manager.current = 'graph'
Button:
text: 'Diet'
on_press: _screen_manager.current = 'diet'
Button:
text: 'Settings'
on_press: _screen_manager.current = 'settings'
Screen:
name: 'profile'
GridLayout:
cols: 1
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Name[/color][/size]'
TextInput:
id: _name
hint_text: 'Name'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Gender[/color][/size]'
TextInput:
id: _gender1
hint_text: 'Gender'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=34][color=0000ff]Type of Diabetes[/color][/size]'
TextInput:
id: _type
hint_text: 'Type of Diabetes'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Height (in)[/color][/size]'
TextInput:
id: _h
hint_text: 'Height in inches'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Weight (lb)[/color][/size]'
TextInput:
id: _w
hint_text: 'Weight in pounds'
BoxLayout:
Button:
text: 'Calculate BMI'
on_press: root.product(*args)
Label:
size_hint_x: 4.5
id:_result
bold: True
markup: True
text: '[size=40][color=0000ff]BMI[/color][/size]'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=30][color=0000ff]List of Medications[/color][/size]'
TextInput:
id: _meds
hint_text: 'List of Medications'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=38][color=0000ff]Insulin Times[/color][/size]'
TextInput:
id: _times
hint_text: 'Please Enter Times to Take Insulin'
Screen:
name: 'history'
GridLayout:
cols:1
Screen:
name: 'new_entry'
GridLayout:
cols:1
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Time[/color][/size]'
TextInput:
id: _time
hint_text: 'Current Time'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=28][color=0000ff]Blood Sugar (mg/dL)[/color][/size]'
TextInput:
id: _glucose_reading
hint_text: 'Current Blood Sugar'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=40][color=0000ff]Carbs[/color][/size]'
TextInput:
id: _food
hint_text: 'Total Carbs for meal'
BoxLayout:
Label:
size_hint_x: 0.22
bold: True
markup: True
text: '[size=30][color=0000ff]Medications Taken[/color][/size]'
TextInput:
id: _meds_taken
hint_text: 'Please Enter Any Medications Taken'
Screen:
name: 'graph'
GridLayout:
cols: 3
padding: 50
Label:
markup: True
text: '[size=24][color=dd88ff]Your Graph[/color][/size]'
Screen:
name: 'diet'
GridLayout:
cols: 3
padding: 50
Label:
markup: True
text: '[size=24][color=dd88ff]Reccomended Diet[/color][/size]'
Screen:
name: 'settings'
GridLayout:
cols: 3
padding: 50
Label:
markup: True
text: '[size=24][color=dd88ff]Settings[/color][/size]'
AnchorLayout:
anchor_x: 'center'
anchor_y: 'bottom'
BoxLayout:
orientation: 'horizontal'
size_hint: 1, .1
Button:
id: btnExit
text: 'Exit'
on_press: app.stop()
Button:
text: 'Menu'
on_press: _screen_manager.current = 'menu'

You can save the info in a json (import json) file, and load it using on_start event method.

Kivy uses a subclass of ConfigParser to parse standard ini files. Documentation on how to use this to load app-specific settings is on the kivy.app doc page.
From the docs:
class TestApp(App):
def build_config(self, config):
config.setdefaults('section1', {
'key1': 'value1',
'key2': '42'
})
def build(self):
config = self.config
return Label(text='key1 is %s and key2 is %d' % (
config.get('section1', 'key1'),
config.getint('section1', 'key2')))

Well, each App starts with build() function expecting a root widget to be returned, so either you can make a simple file loading with a function inside your App class and push values to each widget through ids or through root's widget children
or do the same loading function inside __init__() of your class where the widget values you want to update are.
For example class MyBox(BoxLayout) is a class with children which values you want to update. Then you call your loading function inside MyBox.__init__(). You can simplify it even more: use the loading function inside __init__() and create a list/dictionary/variables where you'll pass the values. Inside kv file you'll just access the variables through for example root.<variable>.

Related

I need to put the source of TextInput inside a variable in my Main.py in kivy

I'm trying to use this id "self.ids.input_tornillo.text" and put it inside a variable in my main.py but when running this code I got this Error: "NameError: name 'self' is not define". I think the word self just work inside a function. But I don't know if it really necessary create a funcion for this or I can do it in another way. Pls someone can give me a hand? -
main.py
class FirstWindow(Screen):
#Variables Shopping Cart
var1= StringProperty("images/shoppingcart.png")
var2= StringProperty("images/shoppingcart2.png")
#Variables Items
variable= self.ids.input_tornillo.text
#Here is the problem with self, How can I put it in a variable?
main.kv
<FirstWindow>:
name: "Catalogue"
BoxLayout:
orientation:'vertical'
pos_hint: {'top': 1}
size: root.width, root.height
size_hint_y: .55
GridLayout:
size:(root.width, root.height)
size_hint_x: None
size_hint_y: None
cols:4
height: self.minimum_height
Label:
text: "Items"
#font_size: 25
Label:
text: "Number"
Label:
text: "Price"
Label:
text: "Add to Cart"
ScrollView:
size_hint_y: .80
pos_hint: {'x':0, 'y': .11}
do_scroll_x: True
do_scroll_y: True
GridLayout:
size:root.width, root.height
size_hint_x: None
size_hint_y: None
cols:4
#height: self.minimum_height
#Label:
# text: "Items"
#font_size: 25
#Label:
# text: "Number"
#Label:
# text: "Price"
#Label:
# text: "Add to Cart"
Label:
text: "Tornillos"
text_size: self.size
halign: 'center'
valign: 'bottom'
Image:
id: image_tornillos
allow_stretch: True
keep_ratio: True
size_hint: 0.2,0.2
width: 60
height: 80
#pos_hint: {'center_x':1, 'center_y':1}
source: "images/tornillo.png"
center_x: self.parent.center_x
center_y: self.parent.center_y+10
TextInput:
id: input_tornillo #I need to put this id in a variable in my main.py
text: ""
halign: "right"
font_size: 18
multiline: True
#size_hint: (1, .15)
I was thinking create a function too and make it like this
class FirstWindow(Screen):
#Variables Shopping Cart
var1= StringProperty("images/shoppingcart.png")
var2= StringProperty("images/shoppingcart2.png")
#Variables Items
def list_items(self):
tornillo= self.ids.input_tornillo.text
tornillo1= float(tornillo) * 0.10
tornillo2= str(tornillo1)
but I don't how to call my variable "tornillo2" in my main.kv either
TextInput:
id: input_tornillo
text: ""
halign: "right"
font_size: 18
multiline: True
#size_hint: (1, .15)
Label:
id: label_tornillo
#text: root.ids.input_tornillo.text*2
text: root.tornillo2
root.tornillo2 is giving me this error...
AttributeError: 'FirstWindow' object has no attribute 'tornillo2'
In the python code, define a property for the variable "tornillo2"
tornillo2 = StringProperty("")
Now you can use it in the kv file as you did it already
(text: root.tornillo2)

Create a recycle view(Gridlayout) inside a Boxlayout kivy

I need all the elements of my FirsWindow, put them in a recycleview. I'm thinking to do it from RecycleGridLayout instead of GridLayout, but I don't how to really apply it in the code. It's necesary that the GridLayout or RecycleGridLayout have cols:4, I think it's not necessary upload my py.file but I'm not sure. please I need help on this. thanks in advance.
kv.file
<FirstWindow>:
name: "Catalogue"
BoxLayout:
id: Boxmain
orientation: "vertical"
#size: root.width, root.height
#size_hint: 1, None
#height: 300
#padding: 50
spacing: 50
size: root.height, root.width
GridLayout:
cols: 4
padding: 4
Label:
text: "Items"
#font_size: 25
Label:
text: "Number"
Label:
text: "Price"
Label:
text: "Add to Cart"
Label:
text: "Tornillos"
text_size: self.size
halign: 'center'
valign: 'bottom'
Image:
id: image_tornillos
allow_stretch: True
keep_ratio: True
size_hint: 0.2,0.2
width: 60
height: 80
#pos_hint: {'center_x':1, 'center_y':1}
source: "images/tornillo.png"
center_x: self.parent.center_x
center_y: self.parent.center_y+10
TextInput:
id: input_tornillo
text: ""
halign: "right"
font_size: 18
multiline: True
#size_hint: (1, .15)
Label:
text: "0.0"
Button:
id: shopping1
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart1.source= root.var2
on_release: root.ids.Shoppingcart1.source= root.var1
Image:
id: Shoppingcart1
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: root.var1
center_x: self.parent.center_x
center_y: self.parent.center_y
#------------------------
Button:
text:"lala"
Button:
text:"lal2"
Button:
text:"lale"
Button:
text:"lal5"
Button:
text:"lala"
Button:
text:"lal54"
Button:
text:"lala"
#------------------------------------------------------------

Change mouse pointer to 'hand' when hovering over a button of a screen in kivy Python

How can I change the mouse pointer to 'hand' when hovering over a button present in a screen along with a different widget in kivy python?
I tried creating two functions in a python file. But it changes the mouse cursor for the entire page. How can I change the cursor for just the button present on the page?
#Kivy design file
<Loginpage>:
name: "login"
Image:
source: 'background.jpg'
allow_stretch: True
keep_ratio: False
Screen:
MDCard:
size_hint: None,None
size: 400, 550
pos_hint: {"center_x":0.5,"center_y":0.5}
elevation: 10
padding: 25
spacing: 25
orientation: 'vertical'
MDLabel:
id: welcome_label
text: "Welcome"
font_size: 40
halign: 'center'
size_hint_y: None
height: self.texture_size[1]
padding_y:15
font_style: 'H2'
MDTextField:
id: uid
hint_text: "Username"
icon_right: "account"
size_hint_x: None
width: 200
font_size: 20
pos_hint: {"center_x": 0.5}
MDTextField:
id: pwd
hint_text: "Password"
icon_right: "lock"
size_hint_x: None
width: 200
font_size: 20
pos_hint: {"center_x": 0.5}
password: True
MDRoundFlatButton:
text: "LOG IN"
font_size: 12
pos_hint: {"center_x": 0.5}
on_press: root.logger()
MDRoundFlatButton:
text: "CLEAR"
font_size: 12
pos_hint: {"center_x": 0.5}
on_press: root.clear()
MDLabel:
id: login_label
text: "Invalid Login"
font_size: 14
halign: 'center'
size_hint_y: None
height: self.texture_size[1]
pos_hint: {"center_x": 0.5}
padding_y:15
theme_text_color:'Custom'
text_color: 1,0,0,1
Widget:
size_hint_y: None
height: 10
Python File:
class Loginpage(Screen):
def enter(self, *args):
Window.set_system_cursor('hand')
class Loginpage(Screen):
def enter(self, *args):
Window.set_system_cursor('hand')
def leave(self, *args):
Window.set_system_cursor('arrow')
def logger(self):
'''code to login'''

How to create a dropdown that contain of buttons and label

I am working in kivy (python) and I need dropdown to place here instead of textinput. but I could not do this, help me to continue work.the screenshot is following. my goal is to replace these textinputs with dropdowns.
enter image description here
The py file code is
import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.dropdown import DropDown
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.properties import ObjectProperty
from kivy.lang import Builder
class CustomDropDown(DropDown):
pass
class delivery_managementWindow(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.dropdown = CustomDropDown()
self.mainbutton = Button(text ='Do you in college?',
size_hint_x = 0.6, size_hint_y = 0.15)
self.add_widget(self.mainbutton)
self.mainbutton.bind(on_release = self.dropdown.open)
self.dropdown.bind(on_select = lambda\
instance, x: setattr(self.mainbutton, 'text', x))
self.dropdown.bind(on_select = self.callback)
def callback(self, instance, x):
print ( "The chosen mode is: {0}" . format ( x ) )
class delivery_managementApp(App):
def build(self):
return delivery_managementWindow()
if __name__ =='__main__':
delivery_managementApp().run()
Now its kv file is also
<CustomDropDown>:
Button:
text: 'College Name'
size_hint_y: None
height: 44
on_release: root.select('College is')
Label:
text: 'Not in college'
size_hint_y: None
height: 44
Button:
text: 'KccItm'
size_hint_y: None
height: 44
on_release: root.select('Kcc')
<delivery_managementWindow>:
id:delivery_managment_main_window
orientation:'vertical'
padding:5
spacing:5
canvas.before:
Color:
rgba:(.1,.30,.35,1)
Rectangle:
pos:self.pos
size:self.size
BoxLayout:
id:header
size_hint_x:1
size_hint_y:None
height:50
canvas.before:
Color:
rgba:(.06,.45,.45,1)
Rectangle:
pos:self.pos
size:self.size
Label:
text:"Delivery Management"
bold: True
font_size:18
# color:(.06,.45,.45,1)
BoxLayout:
id:''
orientation:'horizontal'
BoxLayout:
id:add_edit_form
orientation:'vertical'
size_hint_y:1
size_hint_x:1.5
spacing:5
padding:5
# height:40
canvas.before:
Color:
# rgba:(.02,.25,.45,1)
Rectangle:
pos:self.pos
size:self.size
BoxLayout:
size_hint_y:None
size_hint_x:1
# padding:5
height:40
canvas.before:
Color:
rgba:(1,1,1,.8)
Rectangle:
pos:self.pos
size:self.size
Label:
id:lbl_header
text:"Add New/Edit Delivery"
font_size:17
bold: True
color:(0,0,1,1)
GridLayout:
id:grd
cols:2
size_hint_y:1
size_hint_x:1
canvas.before:
Color:
rgba:(.06,.45,.45,1)
Rectangle:
pos:self.pos
size:self.size
Label:
text:"Delivery :"
bold: True
font_size:17
BoxLayout:
id:dropdown_box
Label:
text:"Our Ref: Inv-sup :"
bold: True
font_size:17
TextInput:
Label:
text:"Invoice :"
bold: True
font_size:17
TextInput:
Label:
text:"Supplier :"
bold: True
font_size:17
TextInput:
Label:
text:"Date :"
bold: True
font_size:17
TextInput:
BoxLayout:
cols:2
CheckBox:
Label:
text:'Delivery for Store Room'
Button:
id:btn_proceed
text:'Proceed Next'
BoxLayout:
id:keyboard
size_hint_y:1
size_hint_x:1
canvas.before:
Color:
rgba:(0,0,1,1)
Rectangle:
pos:self.pos
size:self.size
BoxLayout:
id:keypad_section
orientation:'vertical'
size_hint_y:1
size_hint_x:.7
# padding:5
canvas.before:
Color:
rgba:(.1,.30,.35,1)
Rectangle:
pos:self.pos
size:self.size
AnchorLayout:
size_hint_x:1
size_hint_y:.2
anchor_x: 'center'
anchor_y: 'center'
canvas:
Color:
rgba:(1,1,1,.9)
Rectangle:
pos: self.pos
size: self.size
Button:
text: 'Go To Sale'
size_hint_y:.7
size_hint_x:.5
font_size:17
bold: True
background_normal:''
background_color:(.06,.45,.45,1)
GridLayout:
cols:3
id:keypad
size_hint_y:1
size_hint_x:1
spacing:5
padding:5
canvas.before:
Color:
rgba:(.1,.30,.35,1)
Rectangle:
pos:self.pos
size:self.size
Button:
text:'1'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'2'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'3'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'4'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'5'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'6'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'7'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'8'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'9'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'00'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'0'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'*'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'<--'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'-'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
Button:
text:'Enter'
bold: True
font_size:18
background_normal:''
background_color:(.06,.45,.45,1)
BoxLayout:
id:btn_section
size_hint_y:.2
size_hint_x:1
spacing:5
padding:5
canvas.before:
Color:
rgba:(.1,.30,.35,1)
Rectangle:
pos:self.pos
size:self.size
Button:
id:btn_exit
text:'Exit'
size_hint_x:1
size_hint_y:1
font_size:18
bold:True
color:(.8,0,0,.8)
background_normal:''
background_color:(.06,.45,.45,1)
size_hint_x:1
size_hint_y:1
Button:
id:btn_finish
text: "Finish Delivery"
font_size:18
bold:True
background_normal:''
background_color:(.06,.45,.45,1)
size_hint_x:1
size_hint_y:1
You can create a DropDown to replace each TextInput. I will provide an example of how to do that for the delivery option and you can follow that pattern for any other DropDowns that you want.
First, define the main button for the new DropDown in the kv:
Label:
text:"Delivery :"
bold: True
font_size:17
# BoxLayout:
# id:dropdown_box
Button:
id: del_opt_main_butt
text: 'Select delivery option'
on_release: root.open_delivery_options_dropdown()
Then make a rule for the new DropDown (also in the kv):
<DeliveryOptionDropDown>:
on_select:
app.root.ids.del_opt_main_butt.text = args[1]
app.delivery_option_callback(*args)
Button:
text: 'Overnight'
size_hint_y: None
height: 44
on_release: root.select(self.text)
Button:
text: 'Two Day'
size_hint_y: None
height: 44
on_release: root.select(self.text)
Button:
text: 'Snail Mail'
size_hint_y: None
height: 44
on_release: root.select(self.text)
and define the new DropDown class:
class DeliveryOptionDropDown(DropDown):
pass
Then add the method to open the new Dropdown to the delivery_managementWindow class:
def open_delivery_options_dropdown(self):
self.delivery_options_dropdown = DeliveryOptionDropDown()
self.delivery_options_dropdown.open(self.ids.del_opt_main_butt)
Then add a callback to the App class:
def delivery_option_callback(self, instance, selection):
print('chosen delivery option is', selection)
Those last two methods are located in the delivery_managementWindow and the App classes just for simplicity (root and app are predefined variables in the kv).

kivy scrollview is not working

I am trying to use kivy scrollview inside of EmployeeScreen class. it will not scroll!? what am I doing wrong? I hope this is not a duplicate, please help.
I went to this link Kivy ScrollView - Not Scrolling. which seems to be the only question relating to kivy scrollview not scrolling. this didn't solve my problem.
.py file:
`from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.uix.scrollview import ScrollView
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
class LogInScreen(Screen):
pass
class EmployeeScreen(Screen):
pass
class Manager(ScreenManager):
login_screen = ObjectProperty(None)
employee_screen = ObjectProperty(None)
class CptApp(App):
icon = 'Images\login\cptlogo.png'
title = 'CPT'
def build(self):
return Manager()
if __name__=='__main__':
CptApp().run()`
.kv file:
<Manager>:
id: screen_manager
login_screen: login_screen
employee_screen: employee_screen
LogInScreen:
id: login_screen
name: 'login'
manager: screen_manager
FloatLayout:
StackLayout:
orientation: 'lr-tb'
canvas:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
Image:
size_hint_y: .1
source: 'Images\login\cptbanner.jpg'
allow_stretch: True
keep_ratio: True
Image:
source: 'Images\login\HD7Brw.jpg'
allow_stretch: True
keep_ratio: False
Label:
size_hint_y: .05
size_hint_x: .5
pos_hint: {"x": .25, "y": .7}
markup: True
text: '[i][b][color=#000000]USER NAME[/color][/b][/i]'
TextInput:
id: 'username_input'
multiline: False
size_hint_x: .4
size_hint_y: .05
pos_hint: {"x": .3, "y": .65}
Label:
size_hint_y: .05
size_hint_x: .5
markup: True
text: '[i][b][color=#000000]PASSWORD[/color][/b][/i]'
pos_hint: {'x': .25, 'y': .5}
TextInput:
id: 'password_input'
multiline: False
password: True
size_hint_x: .4
size_hint_y: .05
pos_hint: {'x': .3, 'y': .45}
Image:
source: 'Images/login/loginbutton.png'
size_hint_x: .25
size_hint_y: .1
pos_hint: {'x': .375, 'y': .25}
Button:
id: 'login_button'
background_color: 0,0,0,0
markup: True
text: '[i][b][color=#000000]LOGIN[/color][/b][/i]'
size_hint_x: .25
size_hint_y: .1
pos_hint: {'x': .375, 'y': .25}
on_release: screen_manager.current = 'employeescreen'
EmployeeScreen:
id: employee_screen
name: 'employeescreen'
manager: screen_manager
StackLayout:
orientation: 'lr-tb'
canvas:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
Image:
size_hint_y: .1
source: 'Images\login\cptbanner.jpg'
allow_stretch: True
keep_ratio: True
ScrollView:
do_scroll_x: False
size: root.size
pos: root.pos
GridLayout:
cols: 2
size_hint_y: None
height: self.minimum_height
pos: root.pos
Button:
height: 40
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
Button:
size_hint_x: 1
size_hint_y: None
text: 'TEST'
I was trying to use GridLayout in my .kv file, wrong, I had to create a class and override its init.
class MyLayout(GridLayout):
def __init__(self,**kwargs):
super(MyLayout,self).__init__(**kwargs)
self.size_hint_y = (None)
self.bind(minimum_height = self.setter('height'))
then I placed the class in the .kv file where GridLayout was.

Categories

Resources