This commit is contained in:
yumoqing 2022-01-19 14:37:58 +08:00
parent a16e627922
commit 8a8308a3fc
9 changed files with 3626 additions and 3293 deletions

View File

@ -2,7 +2,8 @@ import sys
import math
from traceback import print_exc
from kivy.properties import ObjectProperty, StringProperty
from kivy.properties import ObjectProperty, StringProperty, \
NumericProperty, BooleanProperty
from kivy.app import App
from kivy.utils import platform
from kivy.uix.button import Button, ButtonBehavior
@ -51,8 +52,7 @@ from kivy.uix.carousel import Carousel
from kivy.uix.bubble import Bubble
from kivy.uix.codeinput import CodeInput
from kivy.graphics import Color, Rectangle
from kivy.properties import ListProperty
from kivycalendar import DatePicker
from kivy.properties import ListProperty, DictProperty
from kivy.factory import Factory
from appPublic.dictObject import DictObject
@ -221,17 +221,16 @@ class Title6(Text):
kw.update({'texttype':'title6','bold':True})
Text.__init__(self, **kw)
class Modal(ModalView):
def __init__(self, auto_open=False,
content=None,
**kw):
ModalView.__init__(self, **kw)
self.auto_open = auto_open
if content:
class Modal(WidgetCSS, WidgetReady, ModalView):
content = DictProperty(None)
auto_open = BooleanProperty(True)
def __init__(self, **kw):
super(ModalView, self).__init__(**kw)
if self.content:
blocks = Factory.Blocks()
self.content = blocks.widgetBuild(content)
if self.content:
self.add_widget(self.content)
self.content_w = blocks.widgetBuild(self.content)
if self.content_w:
self.add_widget(self.content_w)
else:
print(content,':cannot build widget')
@ -242,12 +241,15 @@ class Modal(ModalView):
self.open()
class TimedModal(Modal):
def __init__(self, show_time=5, **kw):
self.show_time = show_time
show_time = NumericProperty(0)
def __init__(self, **kw):
self.time_task = None
Modal.__init__(self, **kw)
def open(self, *args, **kw):
if self.time_task is not None:
self.time_task.cancel()
self.time_task = None
if self.show_time > 0:
self.time_task = \
Clock.schedule_once(self.dismiss, self.show_time)

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ import codecs
import ujson as json
from traceback import print_exc
import kivy
from functools import partial
from appPublic.dictExt import dictExtend
@ -20,6 +19,7 @@ from kivy.metrics import sp,dp,mm
from kivy.core.window import WindowBase, Window
from kivy.properties import BooleanProperty
from kivy.uix.widget import Widget
from kivy.uix.modalview import ModalView
from kivy.app import App
from kivy.factory import Factory
from kivy.uix.video import Video
@ -128,7 +128,6 @@ class Blocks(EventDispatcher):
func =partial(blocks.conform_action,widget, desc)
return func
def eval(self, s:str, l:dict):
g = {}
forbidens = [
@ -413,6 +412,9 @@ class Blocks(EventDispatcher):
p.update(d)
opts['options'] = p
def doit(target:Widget, add_mode:str, o, w:Widget):
if isinstance(w, ModalView):
return
if target:
if add_mode == 'replace':
target.clear_widgets()
@ -429,6 +431,10 @@ class Blocks(EventDispatcher):
b.widgetBuild(opts)
def urlwidgetAction(self, widget:Widget, desc, *args):
Logger.info('Block: urlwidgetAction() called, desc=%s, args=%s', \
str(desc),
args
)
target = self.get_target(widget, desc)
add_mode = desc.get('mode','replace')
opts = desc.get('options').copy()
@ -445,6 +451,9 @@ class Blocks(EventDispatcher):
}
def doit(target:Widget, add_mode:str, o, w:Widget):
if isinstance(w, ModalView):
return
if target:
if add_mode == 'replace':
target.clear_widgets()
@ -459,13 +468,18 @@ class Blocks(EventDispatcher):
b.bind(on_failed=doerr)
b.widgetBuild(d)
def getActionData(self, widget:Widget, desc,*args):
def getActionData(self, widget:Widget, desc, *args):
Logger.info('Block: getActionData(): desc=%s args=%s'
,str(desc), args)
data = {}
rtdesc = self.build_rtdesc(desc)
rt = self.get_rtdata(widget, rtdesc, *args)
data.update(rt)
if desc.get('keymapping'):
data = keyMapping(data, desc.get('keymapping'))
if rtdesc:
rt = self.get_rtdata(widget, rtdesc, *args)
if rt:
data.update(rt)
if desc.get('keymapping'):
data = keyMapping(data, desc.get('keymapping'))
return data
def registedfunctionAction(self, widget:Widget, desc, *args):
@ -516,8 +530,6 @@ class Blocks(EventDispatcher):
else:
rtdesc['method'] = desc.get('datamethod', 'getValue')
rtdesc['kwargs'] = desc.get('datakwargs', {})
else:
return {}
return rtdesc
def get_rtdata(self, widget:Widget, desc, *args):
@ -730,6 +742,7 @@ class Blocks(EventDispatcher):
and Window.fullscreen == True \
and app.root != app.fs_widget:
w = find_widget_by_id(id, app.fs_widget)
if w is None:
print(id, 'not found ....')
return None

View File

@ -91,12 +91,14 @@ class ClickableIconText(ClickableText):
SUPER(ClickableIconText, self, kw)
def on_source(self, o, source):
if source is None:
source = blockIamge('broken.png')
if self.img_w:
if source is None:
source = blockIamge('broken.png')
self.img_w.source = source
return
self.img_w = AsyncImage(source=self.source, **self.img_kw)
self.img_w = AsyncImage(source=source, **self.img_kw)
self.add_widget(self.img_w, index=len(self.children))
class ToggleText(ClickableText):

View File

@ -0,0 +1,56 @@
from functools import partial
from kivy.logger import Logger
from kivy.factory import Factory
def get_cmd_desc(cmd_desc):
desc = {
}
v = cmd_desc
desc['target'] = v.get('target')
if v.get('datawidget'):
desc['datawidget'] = v.get('datawidget')
if v.get('datamethod'):
desc['datamethod'] = v['datamethod']
keys = v.keys()
if 'url' in keys:
desc['actiontype'] = 'urlwidget'
desc['mode'] = 'replace'
options = {
'params':v.get('params',{}),
'url':v.get('url')
}
desc['options'] = options
return desc
if 'rfname' in keys:
desc['actiontype'] = 'registedfunction'
desc['params'] = v.get('params',{})
return desc
if 'script' in keys:
desc['actiontype'] = 'script'
desc['script'] = v.get('script')
return desc
if 'method' in keys:
desc['actiontype'] = 'method'
desc['method'] = v.get('method')
return desc
if 'actions' in keys:
desc['actiontype'] = 'multiple'
desc['actions'] = v.get('actions')
return desc
return None
def cmd_action(cmd_desc, widget):
desc = get_cmd_desc(cmd_desc)
if desc is None:
Logger.error('CommandAction: cmd_desc=%s error')
return
blocks = Factory.Blocks()
if 'conform' in cmd_desc:
options = cmd_desc['conform']
w = Factory.Conform(**options)
f = partial(blocks.uniaction, widget, desc)
w.bind(on_conform=f)
return
blocks.uniaction(widget, desc)

View File

@ -17152,6 +17152,7 @@ static PyObject *__pyx_pw_10kivyblocks_2dg_8DataGrid_65get_selected_data(PyObjec
static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
PyObject *__pyx_v_data = NULL;
PyObject *__pyx_v_row_id = NULL;
PyObject *__pyx_v_row = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
@ -17160,7 +17161,6 @@ static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_
int __pyx_t_3;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
PyObject *__pyx_t_6 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
@ -17185,7 +17185,7 @@ static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_
* if not self.selected_rowid:
* return {} # <<<<<<<<<<<<<<
* data = {}
* if self.freeze_part:
* row_id = self.selected_rowid
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __pyx_L1_error)
@ -17207,8 +17207,8 @@ static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_
* if not self.selected_rowid:
* return {}
* data = {} # <<<<<<<<<<<<<<
* row_id = self.selected_rowid
* if self.freeze_part:
* row = self.freeze_part.body.get_row_by_id(row_id)
*/
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 606, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
@ -17218,122 +17218,140 @@ static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_
/* "kivyblocks/dg.pyx":607
* return {}
* data = {}
* row_id = self.selected_rowid # <<<<<<<<<<<<<<
* if self.freeze_part:
* row = self.freeze_part.body.get_row_by_id(row_id)
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_selected_rowid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_row_id = __pyx_t_1;
__pyx_t_1 = 0;
/* "kivyblocks/dg.pyx":608
* data = {}
* row_id = self.selected_rowid
* if self.freeze_part: # <<<<<<<<<<<<<<
* row = self.freeze_part.body.get_row_by_id(row_id)
* data.update(row.row_data)
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freeze_part); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 607, __pyx_L1_error)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freeze_part); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 608, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_3) {
/* "kivyblocks/dg.pyx":608
* data = {}
/* "kivyblocks/dg.pyx":609
* row_id = self.selected_rowid
* if self.freeze_part:
* row = self.freeze_part.body.get_row_by_id(row_id) # <<<<<<<<<<<<<<
* data.update(row.row_data)
* row = self.normal_part.body.get_row_by_id(row_id)
*/
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freeze_part); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_freeze_part); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_body); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 608, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_body); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_row_by_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_row_by_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_row_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 608, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
__pyx_t_5 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_6)) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
}
}
__pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 608, __pyx_L1_error)
__pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_row_id) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_row_id);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_row = __pyx_t_1;
__pyx_t_1 = 0;
/* "kivyblocks/dg.pyx":609
/* "kivyblocks/dg.pyx":610
* if self.freeze_part:
* row = self.freeze_part.body.get_row_by_id(row_id)
* data.update(row.row_data) # <<<<<<<<<<<<<<
* row = self.normal_part.body.get_row_by_id(row_id)
* data.update(row.row_data)
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_row_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_row_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_data, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
__pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_data, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
/* "kivyblocks/dg.pyx":607
* return {}
/* "kivyblocks/dg.pyx":608
* data = {}
* row_id = self.selected_rowid
* if self.freeze_part: # <<<<<<<<<<<<<<
* row = self.freeze_part.body.get_row_by_id(row_id)
* data.update(row.row_data)
*/
}
/* "kivyblocks/dg.pyx":610
/* "kivyblocks/dg.pyx":611
* row = self.freeze_part.body.get_row_by_id(row_id)
* data.update(row.row_data)
* row = self.normal_part.body.get_row_by_id(row_id) # <<<<<<<<<<<<<<
* data.update(row.row_data)
* return data
*/
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_normal_part); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_normal_part); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_body); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 610, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_body); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_row_by_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 610, __pyx_L1_error)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get_row_by_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_row_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 610, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
__pyx_t_5 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_6)) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_1, function);
}
}
__pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 610, __pyx_L1_error)
__pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v_row_id) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_row_id);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_4);
__pyx_t_4 = 0;
/* "kivyblocks/dg.pyx":611
/* "kivyblocks/dg.pyx":612
* data.update(row.row_data)
* row = self.normal_part.body.get_row_by_id(row_id)
* data.update(row.row_data) # <<<<<<<<<<<<<<
* return data
*/
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_row_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_row_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_data, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
__pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_update, __pyx_v_data, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "kivyblocks/dg.pyx":613
* row = self.normal_part.body.get_row_by_id(row_id)
* data.update(row.row_data)
* return data # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_data);
__pyx_r = __pyx_v_data;
goto __pyx_L0;
/* "kivyblocks/dg.pyx":603
* return fs
*
@ -17343,17 +17361,15 @@ static PyObject *__pyx_pf_10kivyblocks_2dg_8DataGrid_64get_selected_data(CYTHON_
*/
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("kivyblocks.dg.DataGrid.get_selected_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_row_id);
__Pyx_XDECREF(__pyx_v_row);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
@ -18703,10 +18719,10 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
* if not self.selected_rowid:
* return {}
*/
__pyx_tuple__129 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_data, __pyx_n_s_row); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 603, __pyx_L1_error)
__pyx_tuple__129 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_data, __pyx_n_s_row_id, __pyx_n_s_row); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 603, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__129);
__Pyx_GIVEREF(__pyx_tuple__129);
__pyx_codeobj__130 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__129, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_kivyblocks_dg_pyx, __pyx_n_s_get_selected_data, 603, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__130)) __PYX_ERR(0, 603, __pyx_L1_error)
__pyx_codeobj__130 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__129, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_kivyblocks_dg_pyx, __pyx_n_s_get_selected_data, 603, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__130)) __PYX_ERR(0, 603, __pyx_L1_error)
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;

View File

@ -604,8 +604,10 @@ class DataGrid(VBox):
if not self.selected_rowid:
return {}
data = {}
row_id = self.selected_rowid
if self.freeze_part:
row = self.freeze_part.body.get_row_by_id(row_id)
data.update(row.row_data)
row = self.normal_part.body.get_row_by_id(row_id)
data.update(row.row_data)
return data

View File

@ -1,29 +1,60 @@
from kivy.factory import Factory
from kivy.properties import StringProperty, NumericProperty
from kivy.uix.image import AsyncImage
from .utils import *
from .baseWidget import Modal, Text, HBox,VBox
from .widget_css import register_css
from .clickable import ClickableIconText
from .toggleitems import PressableBox
conform_default_title_css = {
"bgcolor":[0.88,0.88,0.88,1],
"fgcolor":[0.12,0.12,0.12,1]
}
conform_default_body_css = {
"bgcolor":[0.92,0.92,0.92,1],
"fgcolor":[0.16,0.16,0.16,1]
}
conform_button_default_css = {
"bgcolor":[0.05,0.85,0.05,1],
"fgcolor":[0.95,0.95,0.95,1]
}
cancel_button_default_css = {
"bgcolor":[0.85, 0.5, 0.5, 1],
"fgcolor":[0.9, 0.90, 0.9, 1]
}
register_css('conform_default_title_css', conform_default_title_css)
register_css('conform_default_body_css', conform_default_body_css)
register_css('conform_button_default_css', conform_button_default_css)
register_css('cancel_button_default_css', cancel_button_default_css)
class Conform(Modal):
def __init__(self, title_icon=None,
title = None,
message = None,
conform_icon=None,
cancel_icon=None,
**kw):
Modal.__init__(self, **kw)
title = StringProperty(None)
title_icon = StringProperty(None)
message = StringProperty(None)
conform_icon = StringProperty(None)
cancel_icon = StringProperty(None)
title_css = StringProperty('conform_default_title_css')
body_css = StringProperty('conform_default_body_css')
conform_css = StringProperty('conform_button_default_css')
cancel_css = StringProperty('cancel_button_default_css')
def __init__(self, **kw):
super(Conform, self).__init__(**kw)
self.register_event_type('on_cancel')
self.register_event_type('on_conform')
self.auto_dismiss = False
b = VBox()
b1 = HBox(size_hint_y=None, height=CSize(1.4))
b1.add_widget(AsyncImage(source=title_icon or \
b = VBox(csscls=self.title_css)
b1 = HBox(size_hint_y=None, height=CSize(2))
b1.add_widget(AsyncImage(source=self.title_icon or \
blockImage('question.png'),
size_hint=[None,None],
height=CSize(1.2),
width=CSize(1.2)))
b1.add_widget(Text(text=title or 'Conform',
b1.add_widget(Text(otext=self.title or 'Conform',
font_size=CSize(1.2),
i18n=True,
wrap=True,
@ -31,75 +62,43 @@ class Conform(Modal):
valign='center',
))
b.add_widget(b1)
b2 = HBox()
b2 = HBox(csscls=self.body_css)
b2.add_widget(Text(text=message or 'Please conform',
b2.add_widget(Text(text=self.message or 'Please conform',
i18n=True,
wrap=True,
halign='left',
size_hint=(1,1),
font_size=CSize(1)))
b.add_widget(b2)
b3 = HBox(size_hint_y=None, height=CSize(2))
w_cancel = PressableBox()
blocks = Factory.Blocks()
w_cancel.add_widget(blocks.widgetBuild({
"widgettype":"HBox",
"options":{},
"subwidgets":[
{
"widgettype":"AsyncImage",
"options":{
"source":cancel_icon or blockImage('cancel.png'),
"size_hint":[None,None],
"height":CSize(1),
"width":CSize(1)
}
},
{
"widgettype":"Text",
"options":{
"text":'Cancel',
"wrap":True,
"font_size":CSize(1),
"halign":'left',
"i18n":True
}
}
]
}))
w_conform = PressableBox()
blocks = Factory.Blocks()
w_conform.add_widget(blocks.widgetBuild({
"widgettype":"HBox",
"options":{},
"subwidgets":[
{
"widgettype":"AsyncImage",
"options":{
"source":conform_icon or blockImage('conform.png'),
"size_hint":[None,None],
"height":CSize(1),
"width":CSize(1)
}
},
{
"widgettype":"Text",
"options":{
"text":'Conform',
"wrap":True,
"font_size":CSize(1),
"halign":'left',
"i18n":True
}
}
]
}))
b3 = HBox(size_hint_y=None,
height=CSize(2),
csscls=self.body_css)
w_cancel = ClickableIconText(text='Cancel',
source=self.cancel_icon or
blockImage('cancel.png'),
img_kw={
"size_hint":[None, None],
"height":CSize(1),
"width":CSize(1)
},
csscls=self.cancel_css
)
w_conform = ClickableIconText(text='Conform',
source=self.conform_icon or
blockImage('question.png'),
img_kw={
"size_hint":[None, None],
"height":CSize(1),
"width":CSize(1)
},
csscls=self.conform_css
)
w_cancel.bind(on_press=self.cancel_press)
w_conform.bind(on_press=self.conform_press)
b3.add_widget(w_cancel)
b3.add_widget(w_conform)
b3.add_widget(w_cancel)
b.add_widget(b3)
self.add_widget(b)

View File

@ -22,7 +22,7 @@ from .ready import WidgetReady
from .color_definitions import getColors
from .baseWidget import Text, Box
from .scrollpanel import ScrollPanel
from .toggleitems import ToggleItems
from .command_action import cmd_action
class Toolbar(ScrollPanel):
"""
@ -191,30 +191,11 @@ class Toolbar(ScrollPanel):
self.dispatch('on_press', ret_v)
return
blocks = Factory.Blocks()
desc = {
}
v = self.w_dic[o]
desc['target'] = v.get('target', self.target)
if v.get('datatarget'):
desc['datatarget'] = v.get('datatarget')
if v.get('datamethod'):
desc['datamethod'] = v['datamethod']
keys = v.keys()
if 'url' in keys:
desc['mode'] = 'replace'
options = {
'params':v.get('params',{}),
'url':v.get('url')
}
desc['options'] = options
Factory.Blocks().urlwidgetAction(self, desc)
if 'rfname' in keys:
desc['params'] = v.get('params',{})
Factory.Blocks().registedfunctionAction(self, desc)
if 'script' in keys:
desc['script'] = v.get('script')
Factory.Blocks().scriptAction(self, desc)
desc = self.w_dic[o].copy()
if not desc.get('target'):
desc['target'] = self.target
cmd_action(desc, self)
class ToolPage(Box):
"""