From 211fee42ec448486608966456907cc156cc3a646 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 2 Apr 2020 13:18:10 +0800 Subject: [PATCH] bugfix --- kivyblocks/baseWidget.py | 28 +-- kivyblocks/bgcolorbehavior.py | 27 +++ kivyblocks/blocksapp.py | 2 +- kivyblocks/color_definitions.py | 363 ++++---------------------------- kivyblocks/colorcalc.py | 8 +- kivyblocks/form.py | 74 ++++++- kivyblocks/imgs/menu.png | Bin 0 -> 11658 bytes kivyblocks/kivymdPlugin.py | 78 +++++++ kivyblocks/login.py | 6 +- kivyblocks/toolbar.py | 92 +++++--- kivyblocks/tree.py | 33 ++- kivyblocks/vplayer.py | 13 ++ 12 files changed, 327 insertions(+), 397 deletions(-) create mode 100644 kivyblocks/bgcolorbehavior.py create mode 100644 kivyblocks/imgs/menu.png create mode 100644 kivyblocks/kivymdPlugin.py diff --git a/kivyblocks/baseWidget.py b/kivyblocks/baseWidget.py index b4b395d..caad591 100755 --- a/kivyblocks/baseWidget.py +++ b/kivyblocks/baseWidget.py @@ -55,6 +55,7 @@ from .widgetExt.inputext import FloatInput,IntegerInput, \ StrInput,SelectInput, BoolInput, AmountInput from .widgetExt.messager import Messager from .charts.bar import Bar +from .bgcolorbehavior import BGColorBehavior if platform == 'android': from .widgetExt.phonebutton import PhoneButton @@ -64,28 +65,17 @@ class PressableImage(ButtonBehavior,AsyncImage): def on_press(self): pass -class PressableLabel(ButtonBehavior, Label): - def on_press(self): - pass - -class Text(Label): - bgColor = ListProperty([0.5,0.5,0.5,1]) - def __init__(self,**kw): +class Text(BGColorBehavior, Label): + def __init__(self,bgcolor=[0,0,0,1],**kw): self.options = DictObject(**kw) kwargs = kw.copy() - self.bind(pos=self._update,size=self._update) if kwargs.get('bgColor'): self.bgColor = kwargs['bgColor'] del kwargs['bgColor'] - super().__init__(**kwargs) - self.bind(pos=self.sizeChange,size=self.sizeChange) + Label.__init__(self,**kwargs) + BGColorBehavior.__init__(self,bgcolor=bgcolor) + +class PressableLabel(ButtonBehavior, Text): + def on_press(self): + pass - def _update(self,t,v): - self.pos = t.pos - self.size = t.size - - def sizeChange(self,o,t=None): - self.canvas.before.clear() - with self.canvas.before: - Color(*self.bgColor) - Rectangle(pos=self.pos,size=self.size) diff --git a/kivyblocks/bgcolorbehavior.py b/kivyblocks/bgcolorbehavior.py new file mode 100644 index 0000000..48538b0 --- /dev/null +++ b/kivyblocks/bgcolorbehavior.py @@ -0,0 +1,27 @@ +from kivy.logger import Logger +from kivy.graphics import Color, Rectangle +from kivy.properties import ListProperty + +_logcnt = 0 +class BGColorBehavior(object): + bgcolor = ListProperty([]) + def __init__(self, bgcolor=[1,0,0,1],**kwargs): + self.bgcolor = bgcolor + self.bind(size=self.on_bgcolor,pos=self.on_bgcolor) + + def on_bgcolor(self,o=None,v=None): + global _logcnt + Logger.info('bgcolorBehavior: on_bgcolor(),o=%s,v=%s,logcnt=%d',\ + o.text if hasattr(o,'text') else o,v,_logcnt) + _logcnt += 1 + x = abs(self.size[0] - 100.0) + y = abs(self.size[1] - 100.0) + if self.size[0] < 0.0001 or self.size[1] < 0.0001: + return + if x < 0.0001 and y < 0.0001: + return + if self.canvas: + with self.canvas.before: + Color(*self.bgcolor) + Rectangle(pos=self.pos, size=self.size) + diff --git a/kivyblocks/blocksapp.py b/kivyblocks/blocksapp.py index 26ba5bb..b7ee0fe 100644 --- a/kivyblocks/blocksapp.py +++ b/kivyblocks/blocksapp.py @@ -93,7 +93,7 @@ def closeWorkers(): def appBlocksHack(app): config = getConfig() - app.on_close = on_close + # app.on_close = on_close app.getAuthHeader = getAuthHeader app.__del__ = closeWorkers Window.bind(on_request_close=app.on_close) diff --git a/kivyblocks/color_definitions.py b/kivyblocks/color_definitions.py index 058b49c..9ef46cc 100644 --- a/kivyblocks/color_definitions.py +++ b/kivyblocks/color_definitions.py @@ -1,4 +1,6 @@ -from kivy.logger import logging +from kivy.logger import Logger +from .colorcalc import * +from appPublic.jsonConfig import getConfig colors = { 'Red': { @@ -343,337 +345,64 @@ light_colors = { 'Light': ['White', 'MainBackground', 'DialogBackground'] } -text_colors = { - 'Red': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'Pink': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': 'ffffff', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'Purple': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': 'ffffff', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'DeepPurple': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': 'ffffff', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'Indigo': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': 'ffffff', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'Blue': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': 'ffffff', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'LightBlue': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': 'ffffff', - }, - 'Cyan': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Teal': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Green': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'LightGreen': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Lime': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': '000000', - '800': '000000', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Yellow': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': '000000', - '800': '000000', - '900': '000000', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Amber': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': '000000', - '800': '000000', - '900': '000000', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'Orange': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': '000000', - '700': '000000', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': '000000', - 'A700': '000000', - }, - 'DeepOrange': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - 'A100': '000000', - 'A200': '000000', - 'A400': 'ffffff', - 'A700': 'ffffff', - }, - 'Brown': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': 'ffffff', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - }, - 'Grey': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': '000000', - '500': '000000', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - }, - 'BlueGrey': { - '50': '000000', - '100': '000000', - '200': '000000', - '300': '000000', - '400': 'ffffff', - '500': 'ffffff', - '600': 'ffffff', - '700': 'ffffff', - '800': 'ffffff', - '900': 'ffffff', - }, -} - level_bg_colors = [ '900', '800', '700', '600', -] - -level_selected_bg_colors = [ '500', '400', '300', - '200' + '200', + '100', + '50' ] -def getColors(style,level=0): - i = level % len(level_bg_colors) - logging.info('TEST : style=%s,level=%d', style, level) - text_color = text_colors[style][ level_bg_colors[i]] - bg_color = colors[style][ level_bg_colors[i]] - return text_color,bg_color +text_colors = { + 'normal':['eeeeee','111111'], + 'highlight':['ffffff','000000'] +} -def getSelectedColors(style,level=0): - i = level % len(level_selected_bg_colors) - text_color = text_colors[style][ level_selected_bg_colors[i]] - bg_color = colors[style][ level_selected_bg_colors[i]] - return text_color, bg_color +def getConfigStyle(): + config = getConfig() + stype = config.color_style or 'Blue' + return stype + +def getTextColor(bgcolor,type='normal'): + colors = text_colors.get(type,text_colors.get('normal')) + d = 0 + tcolor = None + for c in colors: + d1 = distance(bgcolor,c) + if d1>d: + d = d1 + tcolor = c + return tcolor + +def getColors(level=0,selected=False): + style = getConfigStyle() + i = level % 8 + Logger.info('TEST : style=%s,level=%d', style, level) + bg_color = colors[style][ level_bg_colors[i]] + if selected: + k = level_bg_colors[i] + k1 = level_bg_colors[i+1] + colors1 = divideColor(colors[style][k],colors[style][k1],2) + bg_color = colors1[1] + text_color = getTextColor(bg_color) + return toArrayColor(text_color),toArrayColor(bg_color) error_color_id = '100', info_color_id = '50' -def getErrorColors(style): - text_color = text_colors[style][ error_color_id ] +def getErrorColors(): + style = getConfigStyle() bg_color = colors[style][ error_color_id ] - return text_color, bg_color + text_color = getTextColor(bg_color,type='highlight') + return toArrayColor(text_color),toArrayColor(bg_color) -def getInfoColors(style): - text_color = text_colors[style][ info_color_id ] +def getInfoColors(): + style = getConfigStyle() bg_color = colors[style][ info_color_id ] - return text_color, bg_color + text_color = getTextColor(bg_color) + return toArrayColor(text_color),toArrayColor(bg_color) diff --git a/kivyblocks/colorcalc.py b/kivyblocks/colorcalc.py index aaabf01..6ff3be8 100644 --- a/kivyblocks/colorcalc.py +++ b/kivyblocks/colorcalc.py @@ -1,8 +1,8 @@ from kivy.utils import get_color_from_hex -from kivy.app import App -from kivy.uix.widget import Widget -from kivy.graphics import Color, Rectangle, Ellipse -from kivy.uix.boxlayout import BoxLayout +#from kivy.app import App +#from kivy.uix.widget import Widget +#from kivy.graphics import Color, Rectangle, Ellipse +#from kivy.uix.boxlayout import BoxLayout import math def toArrayColor(color): diff --git a/kivyblocks/form.py b/kivyblocks/form.py index 41b8ed2..7f023e4 100644 --- a/kivyblocks/form.py +++ b/kivyblocks/form.py @@ -1,3 +1,4 @@ +from kivy.logger import Logger from kivy.uix.textinput import TextInput from kivy.uix.boxlayout import BoxLayout from kivy.core.window import Window @@ -10,6 +11,9 @@ from .baseWidget import * from .utils import * from .i18n import I18nText, I18n from .toolbar import Toolbar +from .color_definitions import getColors +from .bgcolorbehavior import BGColorBehavior + """ form options { @@ -120,16 +124,17 @@ class InputBox(BoxLayout): self.bind(on_size=self.setSize, pos=self.setSize) self.register_event_type("on_datainput") + self.register_event_type("on_ready") def on_datainput(self,o,v=None): print('on_datainput fired ...',o,v) def init(self): - i18n = I18n() if self.initflag: return + i18n = I18n() opts = { - "orientation":"vertical", + "orientation":"horizontal", "size_hint_y":None, "height":CSize(3) } @@ -139,6 +144,8 @@ class InputBox(BoxLayout): opts['size_hint_x'] = None opts['width'] = self.labelwidth bl = BoxLayout(**opts) + Logger.info('kivyblock:labelwidth=%f,opts=%s', self.labelwidth,str(opts)) + Logger.info('kivyblock:bl.widht=%f,bl.height=%f',bl.width,bl.height) self.add_widget(bl) label = self.options.get('label',self.options.get('name')) kwargs = { @@ -151,6 +158,8 @@ class InputBox(BoxLayout): } self.labeltext = I18nText(**kwargs) bl.add_widget(self.labeltext) + Logger.info('kivyblock:label.widht=%f,label.height=%f', + self.labeltext.width,self.labeltext.height) if self.options.get('required',False): star = Label(text='*', color=(1,0,0,1), @@ -173,7 +182,22 @@ class InputBox(BoxLayout): self.initflag = True self.input_widget.bind(on_focus=self.on_focus) self.input_widget.setValue(self.options.get('default','')) + self.dispatch('on_ready', self) + def check(self): + d = self.getValue() + v = d.get(self.options.get('name')) + Logger.info('InputWidget() getValue=%s, name=%s', + v,self.options.get('name')) + if self.options.get('required',False) and \ + (v == '' or v is None): + return False + + return True + + def on_ready(self, obj): + Logger.info('kivyblocks: Form input ready') + def clear(self): self.input_widget.setValue('') @@ -195,8 +219,8 @@ class InputBox(BoxLayout): def defaultToolbar(): return { - "img_size":1.5, - "text_size":0.7, + "img_size":2, + "text_size":1, "tools":[ { "name":"__submit", @@ -212,11 +236,15 @@ def defaultToolbar(): } -class Form(BoxLayout): +class Form(BGColorBehavior, BoxLayout): def __init__(self, **options): self.options = options BoxLayout.__init__(self, orientation='vertical') + self.color_level = self.options.get('color_level', 0) + textcolor, bgcolor = getColors(self.color_level) + BGColorBehavior.__init__(self,bgcolor=bgcolor) self.widget_ids = {} + self.readiedInput = 0 self.cols = self.options_cols = self.options.get('cols',1) if isHandHold() and Window.width < Window.height: self.cols = 1 @@ -239,11 +267,11 @@ class Form(BoxLayout): self.add_widget(self.toolbar) self.add_widget(self.fsc) self.fieldWidgets=[] - previous_w = None for f in self.options['fields']: w = InputBox(self, **f) self.fsc.add_widget(w) self.fieldWidgets.append(w) + w.bind(on_ready=self.makeInputLink) blocks = App.get_running_app().blocks # wid = self.widget_ids['__submit'] wid = blocks.getWidgetByIdPath(self,'__submit') @@ -253,6 +281,15 @@ class Form(BoxLayout): wid.bind(on_press=self.on_clear_button) self.initflag = True + def makeInputLink(self,o,v=None): + self.readiedInput += 1 + if self.readiedInput >= len(self.options['fields']): + p = self.fieldWidgets[0] + for w in self.fieldWidgets[1:]: + p.input_widget.focus_next = w.input_widget + w.input_widget.focus_previous = p.input_widget + p = w + def getData(self): d = {} for f in self.fieldWidgets: @@ -260,12 +297,26 @@ class Form(BoxLayout): d.update(v) return d + def checkData(self): + for w in self.fieldWidgets: + if not w.check(): + w.input_widget.focus = True + Logger.info('kivyblcks: input check false') + return False + Logger.info('kivyblcks: input check success') + return True + def on_submit(self,v=None): print('Form():on_submit fired ...',v) return False def on_submit_button(self,o,v=None): + Logger.info('kivyblcks: submit button press') + if not self.checkData(): + Logger.info('kivyblocks: CheckData False') + return d = self.getData() + Logger.info('kivyblocks: fire on_submit') self.dispatch('on_submit',d) def on_clear_button(self,o,v=None): @@ -274,19 +325,20 @@ class Form(BoxLayout): def on_size(self,o, v=None): self.init() + textcolor, self.bgcolor = getColors(self.color_level) class StrSearchForm(BoxLayout): def __init__(self,img_url=None,**options): self.name = options.get('name','search_string') BoxLayout.__init__(self,orientation='horizontal',size_hint_y=None,height=CSize(3)) - self.inputwidget = TextInput( + self.input_widget = TextInput( text='', multiline=False, allow_copy=True, font_size=CSize(1), size_hint_y=None, height=CSize(3)) - self.add_widget(self.inputwidget) + self.add_widget(self.input_widget) imgsrc = img_url if img_url else blockImage('search.png') self.search = PressableImage(source=imgsrc, size_hint=(None,None), @@ -295,16 +347,16 @@ class StrSearchForm(BoxLayout): self.add_widget(self.search) self.register_event_type('on_submit') self.search.bind(on_press=self.submit_input) - self.inputwidget.bind(on_text_validate=self.submit_input) + self.input_widget.bind(on_text_validate=self.submit_input) def getData(self): d = { - self.name:self.inputwidget.text + self.name:self.input_widget.text } return d def submit_input(self,o,v=None): - text = self.inputwidget.text + text = self.input_widget.text if text != '': d = { self.name:text diff --git a/kivyblocks/imgs/menu.png b/kivyblocks/imgs/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..364c52c3fd8309ce7be1912c695303775e937e96 GIT binary patch literal 11658 zcmeHtcUV)|+wEbP5tQbP3Mg$HM^UMY6sansC>T(B$B2pnsR0s7zy>G?s0b(>B_JIH zqz5MuP+E{)5|AJXH4u8|+b1}4?|q*8{rlZN?(eK;p2(cG&o1w~*1Pu8Yx+8Tdk*b^ zAc*hE<-ZIe=qK>cpP;?Fz)#v3cRBd^+2K6mJOmX+@@yb~0e^F#4RtO+d99-3;E&(! zFB>8t$oCio-G2;0Yv6y~AA=w-c?g=g0YR#-AxOwAq2jtaII-)dp3Yz37aXhFm4V=A zx7%e4H2A&D{_oNkCrt>FK6&M@^TyczX{z6=E|bk!RyCPhfx#;j^~$i*F7y6df#{TL z$1dASC@5$nWJs4!bxdSDrIj>iTq~U2dQDe!J$}m(^#?66`8Ut=L9B;|Y(L9Ce}fKg zO4!^u)hE|I$9Shwz?k#hRCZcz@RPA{z%4T>m$!mJ1O9XT+XJ4LPGO+pAY(+A@$_Kz zxCmnC?%Jj8t)O>%bPhxulK)*(A~}*QAiVcj$QPu?5CLUk8Ex9t6H<hd<$^}MsVf6W+fIw^W4m6c)QA6jrXr0ge4B7<3VN zT~AL`l&j(IB8Q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~r&7)G+&?zaf& zKLQl!D|k;M^~R&d`Dlg|S>WJr4)t%`>F=)tjr-!rh!iV&r7=S@nu%CW_fsBJ!N>uT z+j>A~_&;uNcD;qV zU>)cdCM8)B8Refb&f$Nq>Fmb-%g+7`M)9`GtvgPxo^tj`)GefoEO-i%r_&fb6uNRz|F66YHy-{MlQ?B% literal 0 HcmV?d00001 diff --git a/kivyblocks/kivymdPlugin.py b/kivyblocks/kivymdPlugin.py new file mode 100644 index 0000000..0861d8b --- /dev/null +++ b/kivyblocks/kivymdPlugin.py @@ -0,0 +1,78 @@ + +from kivymd.bottomsheet import MDListBottomSheet, MDGridBottomSheet +from kivymd.button import MDIconButton +from kivymd.date_picker import MDDatePicker +from kivymd.dialog import MDDialog +from kivymd.label import MDLabel +from kivymd.list import ILeftBody, ILeftBodyTouch, \ + IRightBodyTouch, BaseListItem +from kivymd.material_resources import DEVICE_TYPE +from kivymd.navigationdrawer import MDNavigationDrawer, NavigationDrawerHeaderBase +from kivymd.navigationdrawer import NavigationLayout +from kivymd.navigationdrawer import NavigationDrawerDivider +from kivymd.navigationdrawer import NavigationDrawerToolbar +from kivymd.navigationdrawer import NavigationDrawerSubheader +from kivymd.selectioncontrols import MDSwitch +from kivymd.selectioncontrols import MDCheckbox +from kivymd.snackbar import Snackbar +from kivymd.theming import ThemeManager +from kivymd.time_picker import MDTimePicker +from kivymd.toolbar import Toolbar +from kivymd.list import MDList +from kivymd.textfields import MDTextField +from kivymd.spinner import MDSpinner +from kivymd.card import MDCard +from kivymd.card import MDSeparator +from kivymd.menu import MDDropdownMenu +from kivymd.grid import SmartTile +from kivymd.slider import MDSlider +from kivymd.tabs import MDTabbedPanel, MDTab, MDBottomNavigation, \ + MDBottomNavigationItem +from kivymd.progressbar import MDProgressBar +from kivymd.accordion import MDAccordion, MDAccordionItem +from kivymd.theme_picker import MDThemePicker + +from kivyblocks.blocks import registerWidget + +class TabbedPannel(MDTabbedPanel): + def __init__(self,**options): + +def kivyMDPlugin(): + registerWidget('MDSlider',MDSlider) + registerWidget('MDTabbedPanel',MDTabbedPanel) + registerWidget('MDTab',MDTab) + registerWidget('MDBottomNavigation',MDBottomNavigation) + registerWidget('MDBottomNavigationItem',MDBottomNavigationItem) + registerWidget('MDProgressBar',MDProgressBar) + registerWidget('MDAccordion',MDAccordion) + registerWidget('MDAccordionItem',MDAccordionItem) + registerWidget('MDThemePicker',MDThemePicker) + registerWidget('MDListBottomSheet',MDListBottomSheet) + registerWidget('MDGridBottomSheet',MDGridBottomSheet) + registerWidget('MDIconButton', MDIconButton) + registerWidget('MDDatePicker', MDDatePicker) + registerWidget('MDDialog', MDDialog) + registerWidget('MDLabel', MDLabel) + registerWidget('ILeftBody',ILeftBody) + registerWidget('ILeftBodyTouch',ILeftBodyTouch) + registerWidget('IRightBodyTouch',IRightBodyTouch) + registerWidget('BaseListItem',BaseListItem) + registerWidget('MDNavigationDrawer',MDNavigationDrawer) + registerWidget('NavigationDrawerHeaderBase',NavigationDrawerHeaderBase) + registerWidget('MDCheckbox',MDCheckbox) + registerWidget('Snackbar',Snackbar) + registerWidget('ThemeManager',ThemeManager) + registerWidget('MDTimePicker',MDTimePicker) + registerWidget('Toolbar',Toolbar) + registerWidget('NavigationLayout',NavigationLayout) + registerWidget('NavigationDrawerDivider',NavigationDrawerDivider) + registerWidget('NavigationDrawerToolbar',NavigationDrawerToolbar) + registerWidget('NavigationDrawerSubheader',NavigationDrawerSubheader) + registerWidget('MDSwitch',MDSwitch) + registerWidget('MDList',MDList) + registerWidget('MDTextField',MDTextField) + registerWidget('MDSpinner',MDSpinner) + registerWidget('MDCard',MDCard) + registerWidget('MDSeparator',MDSeparator) + registerWidget('SmartTile',SmartTile) + diff --git a/kivyblocks/login.py b/kivyblocks/login.py index 9b6f841..7c7f1ab 100644 --- a/kivyblocks/login.py +++ b/kivyblocks/login.py @@ -1,3 +1,4 @@ +from kivy.logger import Logger from kivy.app import App from kivy.core.window import Window from kivy.uix.popup import Popup @@ -45,7 +46,10 @@ class LoginForm(Popup): print('build Content ....... ....') self.initflag = True app = App.get_running_app() - self.content = app.blocks.widgetBuild(logformdesc) + try: + self.content = app.blocks.widgetBuild(logformdesc) + except Exception as e: + Logger.info('login: Error %s', e) self.content.bind(on_submit=self.on_submit) def on_submit(self,o,userinfo): diff --git a/kivyblocks/toolbar.py b/kivyblocks/toolbar.py index ff874c9..655e75f 100644 --- a/kivyblocks/toolbar.py +++ b/kivyblocks/toolbar.py @@ -1,3 +1,4 @@ +from kivy.logger import Logger from kivy.graphics import Color, Rectangle from kivy.uix.button import ButtonBehavior from kivy.uix.image import AsyncImage @@ -11,14 +12,16 @@ from appPublic.dictObject import DictObject from .widgetExt.scrollwidget import ScrollWidget from .utils import * -from .kivysize import KivySizes from .ready import WidgetReady from .i18n import I18nText +from .color_definitions import getColors +from .bgcolorbehavior import BGColorBehavior + """ toobar={ "mode":"icon", "icontext","text" - img_size=1.5, - text_size=0.7, + img_size=2, + text_size=1, "tools":[ ] } @@ -30,49 +33,62 @@ tool options img='' } """ -class Tool(ButtonBehavior, WidgetReady,BoxLayout): - normal_bgColor=[0.1,0,0,1] - active_bgColor=[0.4,0.4,0.4,1] +class Tool(ButtonBehavior, BGColorBehavior, BoxLayout): def __init__(self,ancestor=None,**opts): if ancestor is None: ancestor = App.get_running_app().root ancestor.widget_ids[opts['name']] = self + self.ancestor = ancestor ButtonBehavior.__init__(self) - bc = opts.get('bg_color',self.normal_bgColor) - WidgetReady.__init__(self,bg_color=self.normal_bgColor) BoxLayout.__init__(self, - orientation='vertical',size_hint=(None,None)) + size_hint_y=None) + BGColorBehavior.__init__(self) + self.bl = BoxLayout(orientation='vertical', + size_hint_y=None) + self.add_widget(self.bl) self.opts = DictObject(**opts) if not self.opts.img_size: self.opts.img_size = 2 if not self.opts.text_size: - self.opts.text_size = 0.7 + self.opts.text_size = 1 app = App.get_running_app() - ks = KivySizes() - size = ks.unitedSize(self.opts.img_size or 2) - img = AsyncImage(source=self.opts.img_src,size_hint=(None,None), - size=(size,size)) - tsize = ks.unitedSize(self.opts.text_size) + size = 0 + if self.opts.img_src: + size = CSize(self.opts.img_size or 2) + img = AsyncImage(source=self.opts.img_src, + size_hint=(None,None), + size=(size,size)) + self.bl.add_widget(img) + + tsize = CSize(self.opts.text_size) label = self.opts.label or self.opts.name - lbl = I18nText(otext=label,font_size=int(tsize)) - lbl.text_size = (size, 1.3 * tsize) - self.add_widget(img) - self.add_widget(lbl) - self.size = (size * 1.1, (size + 2 * tsize)*1.1) + self.lbl = I18nText(otext=label, + font_size=int(tsize), + text_size=(CSize(len(label)), tsize), + height=tsize, + width=CSize(len(label)), + size_hint=(None,None), + ) + self.bl.add_widget(self.lbl) + self.height = (size + tsize)*1.1 + self.lbl.color, self.bgcolor = getColors(self.ancestor.color_level, + selected=False) + self.lbl.bgcolor = self.bgcolor def on_size(self,obj,size): - if self.parent: - print('********center*dd**********') - self.center = self.parent.center + Logger.info('toolbar: Tool() on_size fired') + self.lbl.color, self.bgcolor = getColors(self.ancestor.color_level, + selected=False) + self.lbl.bgcolor = self.bgcolor def on_press(self): print('Tool(). pressed ...............') def setActive(self,flag): - if flag: - self.setBackgroundColor(self.active_bgColor) - else: - self.setBackgroundColor(self.normal_bgColor) + text_color, self.bgcolor = getColors(self.ancestor.color_level, + selected=flag) + self.lbl.bgcolor = self.bgcolor + self.lbl.color = text_color """ @@ -100,10 +116,11 @@ class Toolbar(GridLayout): for opt in self.opts.tools: opt.img_size = self.opts.img_size opt.text_size = self.opts.text_size - purl = None - if ancestor and hasattr(ancestor, 'parenturl'): - purl = ancestor.parenturl - opt.img_src = absurl(opt.img_src,purl) + if opt.img_src: + purl = None + if ancestor and hasattr(ancestor, 'parenturl'): + purl = ancestor.parenturl + opt.img_src = absurl(opt.img_src,purl) tool = Tool(ancestor=ancestor, **opt) if first: first = False @@ -119,12 +136,12 @@ class Toolbar(GridLayout): self.height = tool.height * 1.1 def on_size(self,obj,size): + return with self.canvas.before: Color(0.3,0.3,0.3,1) Rectangle(pos=self.pos,size=self.size) def tool_press(self,o,v=None): - o.background_color = [0.3,1,1,0.5] for n,w in self.tool_widgets.items(): active = False if w == o: @@ -137,6 +154,7 @@ Toolpage options img_size=1.5, text_size=0.7, tool_at:"left","right","top","bottom", + color_level=0, tools:[ { "name":"myid", @@ -148,7 +166,7 @@ Toolpage options ] """ -class ToolPage(BoxLayout): +class ToolPage(BGColorBehavior, BoxLayout): def __init__(self,**opts): self.opts = DictObject(**opts) self.parenturl = opts.get('parenturl',None) @@ -158,7 +176,8 @@ class ToolPage(BoxLayout): else: orient = 'horizontal' - super().__init__(orientation=orient) + BoxLayout.__init__(self,orientation=orient) + BGColorBehavior.__init__(self) self.content = None self.toolbar = None self.init() @@ -171,6 +190,7 @@ class ToolPage(BoxLayout): self.toolbar.width = x self.content.width = x self.content.height = y - self.toolbar.height + self.color, self.bgcolor = getColors(self.color_level) def showPage(self,obj): self._show_page(obj.opts) @@ -191,6 +211,8 @@ class ToolPage(BoxLayout): t.img_src = absurl(t.img_src,parenturl) opts = self.opts + self.color_level = self.opts.color_level or 0 + self.color, self.bgcolor = getColors(self.color_level) self.toolbar = Toolbar(ancestor=self, **self.opts) if self.opts.tool_at in ['top','left']: self.add_widget(self.toolbar) @@ -198,7 +220,7 @@ class ToolPage(BoxLayout): else: self.add_widget(self.content) self.add_widget(self.toolbar) - Clock.schedule_once(self.show_firstpage,0.5) + # Clock.schedule_once(self.show_firstpage,0.5) if __name__ == '__main__': from blocksapp import BlocksApp diff --git a/kivyblocks/tree.py b/kivyblocks/tree.py index 1e4dd13..e635d2b 100644 --- a/kivyblocks/tree.py +++ b/kivyblocks/tree.py @@ -9,7 +9,8 @@ from kivyblocks.widgetExt import ScrollWidget from kivyblocks.utils import CSize from appPublic.dictObject import DictObject from .baseWidget import PressableLabel -from .stylebehavior import StyleBehavior +from .color_definitions import getColors +from .bgcolorbehavior import BGColorBehavior class EmptyBox(Label): def __init__(self,size_cnt=1): @@ -202,6 +203,7 @@ tree options "url": "params", "bg_color", + "color_level", "color", "checkbox", "multplecheck", @@ -210,12 +212,11 @@ tree options "data" # array of {children:{},...} } """ -# class Tree(StyleBehavior,ScrollWidget): -class Tree(ScrollWidget): +class Tree(BGColorBehavior, ScrollWidget): def __init__(self,**options): + self.color_level = options.get('color_level',0) ScrollWidget.__init__(self) - level = options.get('level',0) - # StyleBehavior.__init__(self,level=level) + BGColorBehavior.__init__(self) self.options = DictObject(**options) self.nodes = [] self.initflag = False @@ -262,7 +263,7 @@ class Tree(ScrollWidget): data = self.options.data logging.info("Tree : buildTree,data=%s",data) self.dataLoaded(data) - + self.color, self.bgcolor = getColors(self.color_level) def dataLoaded(self,d): self.data = d @@ -283,6 +284,13 @@ class TextContent(PressableLabel): def __init__(self,level=0,**options): PressableLabel.__init__(self,**options) + def selected(self): + pass + + def unselected(self): + pass + + class TextTreeNode(TreeNode): def buildContent(self): txt = self.data.get(self.treeObj.options.textField, @@ -294,7 +302,8 @@ class TextTreeNode(TreeNode): halign='left', height=CSize(2), width=CSize(len(txt))) - self.content.text_color = [0,0,0,1] #self.treeObj.text_color + self.content.color, self.content.bgcolor = getColors(self.treeObj.color_level, + selected=False) self.content.bind(on_press=self.onPress) return @@ -309,11 +318,17 @@ class TextTreeNode(TreeNode): def selected(self): logging.info('content selected ........') - self.content.selected() + color, bgcolor = getColors(self.treeObj.color_level, + selected=True) + self.content.bgcolor = bgcolor + self.content.color = color def unselected(self): logging.info('content unselected ........') - self.content.unselected() + color, bgcolor = getColors(self.treeObj.color_level, + selected=False) + self.content.bgcolor = bgcolor + self.content.color = color class TextTree(Tree): def __init__(self,**options): diff --git a/kivyblocks/vplayer.py b/kivyblocks/vplayer.py index 2642a25..b13fe79 100644 --- a/kivyblocks/vplayer.py +++ b/kivyblocks/vplayer.py @@ -70,6 +70,19 @@ class BaseVPlayer(FloatLayout): if hasattr(self._video._video, '_ffplayer'): self.ffplayer = self._video._video._ffplayer + def setSource(self,s): + self.stop() + self.curplay = 0 + self.playlist = [s] + Logger.info('kivyblocks: Vplayer().setSource,s=%s',s) + self.play() + + def setPlaylist(self,pl): + self.stop() + self.curplay = 0 + self.playlist = pl + self.play() + def on_source_error(self,o,v): Logger.info('safecorner: {} error'.format(v))