kivyblocks/test/ttdg.py

70 lines
1.9 KiB
Python
Raw Normal View History

2019-12-19 11:13:47 +08:00
import os
import sys
from functools import partial
from kivyblocks.dg import DataGrid
from kivy.app import App
from kivy.clock import Clock
from appPublic.folderUtils import ProgramPath
from appPublic.jsonConfig import getConfig
from appPublic.timecost import TimeCost
2020-08-07 07:39:38 +08:00
from kivyblocks.blocksapp import appBlocksHack
2019-12-19 11:13:47 +08:00
if __name__ == '__main__':
pp = ProgramPath()
workdir = pp
if len(sys.argv) > 1:
workdir = sys.argv[1]
print('ProgramPath=',pp,'workdir=',workdir)
config = getConfig(workdir,NS={'workdir':workdir,'ProgramPath':pp})
desc = {
2020-11-24 16:38:39 +08:00
"id":"playlist_grid",
"widgettype":"DataGrid",
"options":{
"dataloader":{
"dataurl":"http://ktv.bsppo.com:10081/ktvplayer/playlist.dspy",
"params":{}
},
"fields":[
{
"name":"plid",
"label":"plid",
"uitype":"str"
},
{
"name":"userid",
"label":"Userid",
"uitype":"str"
},
{
"name":"plname",
"label":"plname",
"uitype":"str"
},
{
"name":"max_position",
"label":"max_position",
"uitype":"long"
}
]
}
2019-12-19 11:13:47 +08:00
}
class MyApp(App):
def build(self):
with TimeCost('create widget') as tc:
2020-11-24 16:38:39 +08:00
dg = DataGrid(**desc['options'])
dg.loadData()
2019-12-19 11:13:47 +08:00
return dg
2020-08-07 07:39:38 +08:00
def on_close(self,*args,**kwargs):
return True
myapp = MyApp()
appBlocksHack(myapp)
myapp.run()
2019-12-19 11:13:47 +08:00
tc = TimeCost('show')
tc.show()