diff --git a/kivyblocks/.uitype.py.swp b/kivyblocks/.uitype.py.swp new file mode 100644 index 0000000..3a6fdb9 Binary files /dev/null and b/kivyblocks/.uitype.py.swp differ diff --git a/kivyblocks/__pycache__/__init__.cpython-39.pyc b/kivyblocks/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..7c585c6 Binary files /dev/null and b/kivyblocks/__pycache__/__init__.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/bgcolorbehavior.cpython-39.pyc b/kivyblocks/__pycache__/bgcolorbehavior.cpython-39.pyc new file mode 100644 index 0000000..8d29fd9 Binary files /dev/null and b/kivyblocks/__pycache__/bgcolorbehavior.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/blocksapp.cpython-39.pyc b/kivyblocks/__pycache__/blocksapp.cpython-39.pyc new file mode 100644 index 0000000..9b18860 Binary files /dev/null and b/kivyblocks/__pycache__/blocksapp.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/color_definitions.cpython-39.pyc b/kivyblocks/__pycache__/color_definitions.cpython-39.pyc new file mode 100644 index 0000000..000e594 Binary files /dev/null and b/kivyblocks/__pycache__/color_definitions.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/colorcalc.cpython-39.pyc b/kivyblocks/__pycache__/colorcalc.cpython-39.pyc new file mode 100644 index 0000000..28a55cb Binary files /dev/null and b/kivyblocks/__pycache__/colorcalc.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/kivysize.cpython-39.pyc b/kivyblocks/__pycache__/kivysize.cpython-39.pyc new file mode 100644 index 0000000..b4f5aa9 Binary files /dev/null and b/kivyblocks/__pycache__/kivysize.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/login.cpython-39.pyc b/kivyblocks/__pycache__/login.cpython-39.pyc new file mode 100644 index 0000000..6fe25e8 Binary files /dev/null and b/kivyblocks/__pycache__/login.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/pagescontainer.cpython-39.pyc b/kivyblocks/__pycache__/pagescontainer.cpython-39.pyc new file mode 100644 index 0000000..0b8e262 Binary files /dev/null and b/kivyblocks/__pycache__/pagescontainer.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/ready.cpython-39.pyc b/kivyblocks/__pycache__/ready.cpython-39.pyc new file mode 100644 index 0000000..af62367 Binary files /dev/null and b/kivyblocks/__pycache__/ready.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/threadcall.cpython-39.pyc b/kivyblocks/__pycache__/threadcall.cpython-39.pyc new file mode 100644 index 0000000..d66717a Binary files /dev/null and b/kivyblocks/__pycache__/threadcall.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/uitype.cpython-39.pyc b/kivyblocks/__pycache__/uitype.cpython-39.pyc new file mode 100644 index 0000000..415604e Binary files /dev/null and b/kivyblocks/__pycache__/uitype.cpython-39.pyc differ diff --git a/kivyblocks/__pycache__/utils.cpython-39.pyc b/kivyblocks/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..439e805 Binary files /dev/null and b/kivyblocks/__pycache__/utils.cpython-39.pyc differ diff --git a/kivyblocks/blocksapp.py b/kivyblocks/blocksapp.py index 7dbc688..1b49761 100644 --- a/kivyblocks/blocksapp.py +++ b/kivyblocks/blocksapp.py @@ -2,6 +2,7 @@ import os import sys from kivy.resources import resource_add_path +from kivy.config import Config resource_add_path(os.path.join(os.path.dirname(__file__),'./ttf')) Config.set('kivy', 'default_font', [ 'msgothic', @@ -17,7 +18,6 @@ from appPublic.uniqueID import getID from appPublic.rsa import RSA from kivy.factory import Factory -from kivy.config import Config from kivy.metrics import sp,dp,mm from kivy.core.window import WindowBase, Window from kivy.clock import Clock diff --git a/kivyblocks/imgs/crud_add.png b/kivyblocks/imgs/crud_add.png new file mode 100644 index 0000000..f96d28f Binary files /dev/null and b/kivyblocks/imgs/crud_add.png differ diff --git a/kivyblocks/imgs/crud_browser.png b/kivyblocks/imgs/crud_browser.png new file mode 100644 index 0000000..7ef9ee3 Binary files /dev/null and b/kivyblocks/imgs/crud_browser.png differ diff --git a/kivyblocks/imgs/crud_del.png b/kivyblocks/imgs/crud_del.png new file mode 100644 index 0000000..d4de513 Binary files /dev/null and b/kivyblocks/imgs/crud_del.png differ diff --git a/kivyblocks/imgs/crud_edit.png b/kivyblocks/imgs/crud_edit.png new file mode 100644 index 0000000..70c0bae Binary files /dev/null and b/kivyblocks/imgs/crud_edit.png differ diff --git a/kivyblocks/imgs/crud_filter.png b/kivyblocks/imgs/crud_filter.png new file mode 100644 index 0000000..54e175f Binary files /dev/null and b/kivyblocks/imgs/crud_filter.png differ diff --git a/kivyblocks/uitype.py b/kivyblocks/uitype.py index c6a1752..a12f180 100644 --- a/kivyblocks/uitype.py +++ b/kivyblocks/uitype.py @@ -8,6 +8,8 @@ we use a register machinans to maintian the ui type information to build the vie import ujson as json from kivy.factory import Factory +from kivy.properties import NumericProperty, StringProperty, \ + BooleanProperty from kivy.uix.label import Label from appPublic.myTE import string_template_render @@ -17,6 +19,36 @@ from .baseWidget import WrapText, Text from .widgetExt.inputext import FloatInput,IntegerInput, \ StrInput,SelectInput, BoolInput, AmountInput, Password +class StringView(Label): + def __init__(self, **kw): + super(StringView, self).__init__(**kw) + self.wrap = True + self.halign = 'left' + self.valign = 'middle' + + def getValue(self): + return self.text + + def setValue(self, v): + self.text = str(v) + +class PasswordView(StringView): + def __init__(self, text='*', **kw): + super(PasswordView, self).__init__(text=text, **kw) + + def getValue(self): + return None + + def setValue(self, v): + pass + +class TextView(WrapText): + def getValue(self): + return self.text + + def setValue(self, v): + self.text = v + view_widget_builders = { } @@ -62,7 +94,7 @@ def get_value(desc, rec=None): def build_view_str_widget(desc, rec=None): txt = get_value(desc, rec=rec) - return Label(text=str(txt) if txt else '', + return StringView(text=str(txt) if txt else '', font_size=CSize(1), halign='left', valign='middle') @@ -74,7 +106,7 @@ view_register('timestamp', build_view_str_widget) def build_view_text_widget(desc, rec=None): txt = get_value(desc, rec=rec) - return WrapText(text=str(txt) if txt else '', + return TextView(text=str(txt) if txt else '', font_size=CSize(1), halign='left', valign='middle') @@ -82,32 +114,74 @@ def build_view_text_widget(desc, rec=None): view_register('text', build_view_text_widget) def build_view_passwd_widget(desc, rec=None): - return Label(text='*', + return PasswordView(text='*', font_size=CSize(1), halign='left', valign='middle') view_register('password', build_view_passwd_widget) + +class BoolView(Label): + value = BooleanProperty(False) + def __init__(self, text='', **kw): + super(BoolView, self).__init__(text='', **kw) + self.wrap = True + self.halign = 'center' + self.valign = 'middle' + + def on_value(self, *args): + if self.value: + self.text = 'true' + else: + self.text = 'false' + + def getValue(self): + return self.value + + def setValue(self, v): + self.value = v + def build_view_bool_widget(desc, rec=None): v = get_value(desc, rec) if v is not None: - return Label(text='True' if v else 'False', + return BoolView(value=v, font_size=CSize(1), halign='left', valign='middle') - default_value = desc.get('nullvalue','') - return Label(text=default_value, + default_value = desc.get('nullvalue',False) + return BoolView(value=default_Value, font_size=CSize(1), halign='left', valign='middle') view_register('bool', build_view_bool_widget) +class IntView(Text): + value = NumericProperty(None) + nullstr = StringProperty('') + def __init__(self, **kw): + super(IntView, self).__init__(text='', **kw) + self.wrap = True + self.halign = 'right' + self.valign = 'middle' + + def on_value(self, *args): + if self.value is not None: + self.text = str(v) + else: + self.text = self.nullstr + + def setValue(self, v): + self.value = v + + def getValue(self): + return self.value + def build_view_int_widget(desc, rec=None): v = get_value(desc, rec=rec) - default_value = desc.get('nullvalue','') - return Label(text=str(v) if v is not None else default_value, + return IntValue(value=v, + nullstr=desc.get('nullstr',''), font_size=CSize(1), halign='right', valign='middle' @@ -115,11 +189,33 @@ def build_view_int_widget(desc, rec=None): view_register('int', build_view_int_widget) +class FloatView(Text): + value = NumericProperty(None) + nullstr = StringProperty('') + dec = NumericProperty(2) + def __init__(self, **kw): + super(FloatView, self).__init__(text=self.nullstr, **kw) + self.wrap = True + self.halign = 'right' + self.valign = 'middle' + + def on_value(self, *args): + if self.value is None: + self.text = self.bullstr + f = '%%.0%df' % self.dec + self.text = f % self.value + + def getValue(self): + return self.value + + def setValue(self, v): + self.value = v + def build_view_float_widget(desc, rec=None): v = get_value(desc, rec=rec) - f = '%%.0%df' % desc.get('dec',2) - default_value = desc.get('nullvalue','') - return Label(text=f % float(v) if v is not None else default_value, + return FloatView(value=v, + dec=desc.get('dec', 2), + nullstr=desc.get('nullstr',''), font_size=CSize(1), halign='right', valign='middle' @@ -141,38 +237,45 @@ def build_view_code_widget(desc, rec=None): view_register('code', build_view_code_widget) -def amount_str(v, dec): - f = '%%.0%df' % dec - s = f % v - parts = s.split('.') - p_int = parts[0] - subs = [] - if p_int[0] == '-': - subs.append('-') - p_int = p_int[1:] - l = [i for i in p_int] - l.reverse() - k = [] - for i,c in enumerate(l): - if i and (i) % 3 == 0: - k.append(',') - k.append(c) - k.reverse() - subs.append(''.join(k)) - if len(parts) > 1: - subs.append(f'.{parts[1]}') - return ''.join(subs) +class AmountView(FloatView): + def on_value(self, *args): + if self.value is None: + self.text = self.nullstr + else: + self.text = self.amount_str() + def amount_str(self): + f = '%%.0%df' % self.dec + s = f % self.value + parts = s.split('.') + p_int = parts[0] + subs = [] + if p_int[0] == '-': + subs.append('-') + p_int = p_int[1:] + l = [i for i in p_int] + l.reverse() + k = [] + for i,c in enumerate(l): + if i and (i) % 3 == 0: + k.append(',') + k.append(c) + k.reverse() + subs.append(''.join(k)) + if len(parts) > 1: + subs.append(f'.{parts[1]}') + return ''.join(subs) + def build_view_amount_widget(desc, rec=None): v = get_value(desc, rec=rec) - defaultvalue = desc.get('nullvalue', '') - if v: - f = '%%.0%df' % desc.get('dec',2) - return Label(text=amount_str(v, dec), + defaultvalue = desc.get('nullstr', '') + return Amount(value=v, + dec=desc.get('dec', 2), + nullstr=defaultvale, font_size=CSize(1), halign='right', valign='middle' - ) + ) view_register('amount', build_view_amount_widget)