-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatatable.py
57 lines (51 loc) · 1.61 KB
/
datatable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
import sqlite3
from collections import OrderedDict
Builder.load_string('''
<DataTable>:
id:main_table
RecycleView:
viewclass:'ItemLabel'
id: table_top
RecycleGridLayout:
id:table_top_layout
cols:5
default_size:(None,250)
default_size_hint:(1,None)
size_hint_y: None
height: self.minimum_height
spacing:5
<ItemLabel@Label>:
bcolor:(1,1,1,1)
canvas.before:
Color:
rgba: root.bcolor
Rectangle:
size: self.size
pos: self.pos
''')
class DataTable(BoxLayout):
def __init__(self,table='',**kwargs):
super().__init__(**kwargs)
#entries = self.get_items()
entries = table
col_titles = [k for k in entries.keys()]
row_length = len(entries[col_titles[0]])
self.columns = len(col_titles)
table_data = []
for t in col_titles:
table_data.append({'text':str(t),'size_hint_y':None,'height':30,'bcolor':(.25,.25,.8,1)})
for r in range(row_length):
for t in col_titles:
table_data.append({'text':str(entries[t][r]),'size_hint_y':None,'height':30,'bcolor':(.25,.25,.7,1)})
self.ids.table_top_layout.cols = self.columns
self.ids.table_top.data = table_data
#class DataTableApp(App):
# def build(self):
#
# return DataTable()
#
#if __name__ == '__main__':
# DataTableApp().run()