list.py
import kivy
kivy.require('1.9.0') # replace with your current kivy version !
import sqlite3 as lite
from kivy.uix.screenmanager import Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
Window.clearcolor = (0, 0.517, 0.705, 1)
Window.size = (500, 330)
from easygui import msgbox
con = lite.connect('demo.db')
con.text_factory = str
cur = con.cursor()
class TestScreen(Screen):
pass
def get_user(self):
cur.execute("SELECT * FROM `user` order by id asc")
self.rows = cur.fetchall()
print(self.rows)
class List(App):
def build(self):
self.root = Builder.load_file('list.kv')
return TestScreen().get_user()
if __name__ == '__main__':
List().run()
above code fetch result but i dont know how to list like table
How to retrieve data from database and list in table like
id Name
1 abc
2 def
When click on row then it show in new window contain text type with edit value.
Thanks in advance
The solution is to use RecycleView with SelectableButton, SelectableRecycleGridLayout, Popup and TextInput. Please refer to the example below for details.
Example
main.py
test.kv
Output