I would say I am pretty new but I already have the layout of the app i want...but whenever I try to add the functionality from database into the button widgets defined below I run into some error or it simply does not work and most of the stuff I found online teach to form databse on the main.py file instead.This is the .kv file I have built:
<Manager>:
Grid:
name:'main'
View:
name:'view'
<Grid>:
title:title
author:author
year_Published:year
shelf_No:shelf
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'b.jpg'
FloatLayout:
size:root.width,root.height
Button:
id:bt1
text:"Add_Entry"
font_size: (root.width**2 + root.height**2) / 15**4
on_press:print('New Book Added!')
on_release:root.show_popup()
background_color:(1,0,0,0.2) if bt1.state=='normal' else (0,1,0,1)
pos_hint:{'x':0,'top':1}
size_hint: 0.2, 0.4
color:0,0,1,1
Button:
id:bt2
text:'View_All'
on_press:print('Showing All Books:')
on_release:
app.root.current='view'
root.manager.transition.direction='right'
background_color:(1,0,0,0.2) if bt2.state=='normal' else (0,1,0,1)
pos_hint:{'x':0.2,'top':1}
size_hint: 0.2, 0.4
font_size: (root.width**2 + root.height**2) / 15**4
color:0,0,1,1
Button:
id:bt3
text:'Update_Entry'
on_press:print('Entry has been Updated!')
background_color:(1,0,0,0.2) if bt3.state=='normal' else (0,1,0,1)
pos_hint:{'x':0.4,'top':1}
font_size: (root.width**2 + root.height**2) / 16**4
size_hint: 0.2, 0.4
color:0,0,1,1
Button:
id:bt4
text:'Search'
on_press:print('Searching....:')
on_release:
app.root.current='view'
root.manager.transition.direction='right'
background_color:(1,0,0,0.2) if bt4.state=='normal' else (0,1,0,1)
pos_hint:{'x':0.6,'top':1}
size_hint: 0.2, 0.4
font_size: (root.width**2 + root.height**2) / 15**4
color:0,0,1,1
Label:
text:'Title: '
pos_hint:{'x':0,'top':0.6}
font_size: (root.width**2 + root.height**2) / 14**4
size_hint:0.2,0.2
TextInput:
id:title
pos_hint:{'x':0.2,'top':0.6}
size_hint:0.2,0.3
font_size: (root.width**2 + root.height**2) / 16**4
background_color:1,1,1,0.5
Label:
text:'Author: '
pos_hint:{'x':0.4,'top':0.6}
font_size: (root.width**2 + root.height**2) / 14**4
size_hint:0.2,0.2
TextInput:
id:author
pos_hint:{'x':0.6,'top':0.6}
size_hint:0.2,0.3
font_size: (root.width**2 + root.height**2) / 16**4
background_color:1,1,1,0.5
Label:
text:'Year: '
multiline:False
pos_hint:{'x':0,'top':0.3}
font_size: (root.width**2 + root.height**2) / 14**4
size_hint:0.2,0.2
TextInput:
id:year
multiline:False
pos_hint:{'x':0.2,'top':0.3}
size_hint:0.2,0.3
font_size: (root.width**2 + root.height**2) / 16**4
background_color:1,1,1,0.5
Label:
text:'Shelf_No: '
pos_hint:{'x':0.4,'top':0.3}
font_size: (root.width**2 + root.height**2) / 14.5**4
size_hint:0.2,0.2
TextInput:
id:shelf
multiline:False
pos_hint:{'x':0.6,'top':0.3}
size_hint:0.2,0.3
font_size: (root.width**2 + root.height**2) / 16**4
background_color:1,1,1,0.5
Button:
id:bt5
text:'Exit'
text_orientation:'vertical'
pos_hint:{'x':0.8,'top':1}
on_press:app.stop()
background_color:(0,0,1,0.2) if bt5.state=='normal' else (1,0,0,1)
font_size:(root.width**2+root.height**2)/14**4
size_hint:0.2,1
color:1,0,0,1
<View>:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'lib.jpg'
FloatLayout:
size:root.width,root.height
Button:
text:'Go Back'
on_release:
app.root.current='main'
root.manager.transition.direction='left'
font_size:(root.width**2+root.height**2)/14**4
pos_hint:{'x':0,'y':0}
size_hint:1,0.2
background_color:1,1,1,0.5
Thank you for your time and response!