bugfix
This commit is contained in:
parent
ab79735f7f
commit
211fee42ec
@ -55,6 +55,7 @@ from .widgetExt.inputext import FloatInput,IntegerInput, \
|
|||||||
StrInput,SelectInput, BoolInput, AmountInput
|
StrInput,SelectInput, BoolInput, AmountInput
|
||||||
from .widgetExt.messager import Messager
|
from .widgetExt.messager import Messager
|
||||||
from .charts.bar import Bar
|
from .charts.bar import Bar
|
||||||
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
if platform == 'android':
|
if platform == 'android':
|
||||||
from .widgetExt.phonebutton import PhoneButton
|
from .widgetExt.phonebutton import PhoneButton
|
||||||
@ -64,28 +65,17 @@ class PressableImage(ButtonBehavior,AsyncImage):
|
|||||||
def on_press(self):
|
def on_press(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class PressableLabel(ButtonBehavior, Label):
|
class Text(BGColorBehavior, Label):
|
||||||
def on_press(self):
|
def __init__(self,bgcolor=[0,0,0,1],**kw):
|
||||||
pass
|
|
||||||
|
|
||||||
class Text(Label):
|
|
||||||
bgColor = ListProperty([0.5,0.5,0.5,1])
|
|
||||||
def __init__(self,**kw):
|
|
||||||
self.options = DictObject(**kw)
|
self.options = DictObject(**kw)
|
||||||
kwargs = kw.copy()
|
kwargs = kw.copy()
|
||||||
self.bind(pos=self._update,size=self._update)
|
|
||||||
if kwargs.get('bgColor'):
|
if kwargs.get('bgColor'):
|
||||||
self.bgColor = kwargs['bgColor']
|
self.bgColor = kwargs['bgColor']
|
||||||
del kwargs['bgColor']
|
del kwargs['bgColor']
|
||||||
super().__init__(**kwargs)
|
Label.__init__(self,**kwargs)
|
||||||
self.bind(pos=self.sizeChange,size=self.sizeChange)
|
BGColorBehavior.__init__(self,bgcolor=bgcolor)
|
||||||
|
|
||||||
def _update(self,t,v):
|
class PressableLabel(ButtonBehavior, Text):
|
||||||
self.pos = t.pos
|
def on_press(self):
|
||||||
self.size = t.size
|
pass
|
||||||
|
|
||||||
def sizeChange(self,o,t=None):
|
|
||||||
self.canvas.before.clear()
|
|
||||||
with self.canvas.before:
|
|
||||||
Color(*self.bgColor)
|
|
||||||
Rectangle(pos=self.pos,size=self.size)
|
|
||||||
|
27
kivyblocks/bgcolorbehavior.py
Normal file
27
kivyblocks/bgcolorbehavior.py
Normal file
@ -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)
|
||||||
|
|
@ -93,7 +93,7 @@ def closeWorkers():
|
|||||||
|
|
||||||
def appBlocksHack(app):
|
def appBlocksHack(app):
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
app.on_close = on_close
|
# app.on_close = on_close
|
||||||
app.getAuthHeader = getAuthHeader
|
app.getAuthHeader = getAuthHeader
|
||||||
app.__del__ = closeWorkers
|
app.__del__ = closeWorkers
|
||||||
Window.bind(on_request_close=app.on_close)
|
Window.bind(on_request_close=app.on_close)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from kivy.logger import logging
|
from kivy.logger import Logger
|
||||||
|
from .colorcalc import *
|
||||||
|
from appPublic.jsonConfig import getConfig
|
||||||
|
|
||||||
colors = {
|
colors = {
|
||||||
'Red': {
|
'Red': {
|
||||||
@ -343,337 +345,64 @@ light_colors = {
|
|||||||
'Light': ['White', 'MainBackground', 'DialogBackground']
|
'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 = [
|
level_bg_colors = [
|
||||||
'900',
|
'900',
|
||||||
'800',
|
'800',
|
||||||
'700',
|
'700',
|
||||||
'600',
|
'600',
|
||||||
]
|
|
||||||
|
|
||||||
level_selected_bg_colors = [
|
|
||||||
'500',
|
'500',
|
||||||
'400',
|
'400',
|
||||||
'300',
|
'300',
|
||||||
'200'
|
'200',
|
||||||
|
'100',
|
||||||
|
'50'
|
||||||
]
|
]
|
||||||
|
|
||||||
def getColors(style,level=0):
|
text_colors = {
|
||||||
i = level % len(level_bg_colors)
|
'normal':['eeeeee','111111'],
|
||||||
logging.info('TEST : style=%s,level=%d', style, level)
|
'highlight':['ffffff','000000']
|
||||||
text_color = text_colors[style][ level_bg_colors[i]]
|
}
|
||||||
bg_color = colors[style][ level_bg_colors[i]]
|
|
||||||
return text_color,bg_color
|
|
||||||
|
|
||||||
def getSelectedColors(style,level=0):
|
def getConfigStyle():
|
||||||
i = level % len(level_selected_bg_colors)
|
config = getConfig()
|
||||||
text_color = text_colors[style][ level_selected_bg_colors[i]]
|
stype = config.color_style or 'Blue'
|
||||||
bg_color = colors[style][ level_selected_bg_colors[i]]
|
return stype
|
||||||
return text_color, bg_color
|
|
||||||
|
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',
|
error_color_id = '100',
|
||||||
info_color_id = '50'
|
info_color_id = '50'
|
||||||
def getErrorColors(style):
|
def getErrorColors():
|
||||||
text_color = text_colors[style][ error_color_id ]
|
style = getConfigStyle()
|
||||||
bg_color = colors[style][ error_color_id ]
|
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):
|
def getInfoColors():
|
||||||
text_color = text_colors[style][ info_color_id ]
|
style = getConfigStyle()
|
||||||
bg_color = colors[style][ info_color_id ]
|
bg_color = colors[style][ info_color_id ]
|
||||||
return text_color, bg_color
|
text_color = getTextColor(bg_color)
|
||||||
|
return toArrayColor(text_color),toArrayColor(bg_color)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from kivy.utils import get_color_from_hex
|
from kivy.utils import get_color_from_hex
|
||||||
from kivy.app import App
|
#from kivy.app import App
|
||||||
from kivy.uix.widget import Widget
|
#from kivy.uix.widget import Widget
|
||||||
from kivy.graphics import Color, Rectangle, Ellipse
|
#from kivy.graphics import Color, Rectangle, Ellipse
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
#from kivy.uix.boxlayout import BoxLayout
|
||||||
import math
|
import math
|
||||||
|
|
||||||
def toArrayColor(color):
|
def toArrayColor(color):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from kivy.logger import Logger
|
||||||
from kivy.uix.textinput import TextInput
|
from kivy.uix.textinput import TextInput
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
@ -10,6 +11,9 @@ from .baseWidget import *
|
|||||||
from .utils import *
|
from .utils import *
|
||||||
from .i18n import I18nText, I18n
|
from .i18n import I18nText, I18n
|
||||||
from .toolbar import Toolbar
|
from .toolbar import Toolbar
|
||||||
|
from .color_definitions import getColors
|
||||||
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
"""
|
"""
|
||||||
form options
|
form options
|
||||||
{
|
{
|
||||||
@ -120,16 +124,17 @@ class InputBox(BoxLayout):
|
|||||||
self.bind(on_size=self.setSize,
|
self.bind(on_size=self.setSize,
|
||||||
pos=self.setSize)
|
pos=self.setSize)
|
||||||
self.register_event_type("on_datainput")
|
self.register_event_type("on_datainput")
|
||||||
|
self.register_event_type("on_ready")
|
||||||
|
|
||||||
def on_datainput(self,o,v=None):
|
def on_datainput(self,o,v=None):
|
||||||
print('on_datainput fired ...',o,v)
|
print('on_datainput fired ...',o,v)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
i18n = I18n()
|
|
||||||
if self.initflag:
|
if self.initflag:
|
||||||
return
|
return
|
||||||
|
i18n = I18n()
|
||||||
opts = {
|
opts = {
|
||||||
"orientation":"vertical",
|
"orientation":"horizontal",
|
||||||
"size_hint_y":None,
|
"size_hint_y":None,
|
||||||
"height":CSize(3)
|
"height":CSize(3)
|
||||||
}
|
}
|
||||||
@ -139,6 +144,8 @@ class InputBox(BoxLayout):
|
|||||||
opts['size_hint_x'] = None
|
opts['size_hint_x'] = None
|
||||||
opts['width'] = self.labelwidth
|
opts['width'] = self.labelwidth
|
||||||
bl = BoxLayout(**opts)
|
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)
|
self.add_widget(bl)
|
||||||
label = self.options.get('label',self.options.get('name'))
|
label = self.options.get('label',self.options.get('name'))
|
||||||
kwargs = {
|
kwargs = {
|
||||||
@ -151,6 +158,8 @@ class InputBox(BoxLayout):
|
|||||||
}
|
}
|
||||||
self.labeltext = I18nText(**kwargs)
|
self.labeltext = I18nText(**kwargs)
|
||||||
bl.add_widget(self.labeltext)
|
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):
|
if self.options.get('required',False):
|
||||||
star = Label(text='*',
|
star = Label(text='*',
|
||||||
color=(1,0,0,1),
|
color=(1,0,0,1),
|
||||||
@ -173,6 +182,21 @@ class InputBox(BoxLayout):
|
|||||||
self.initflag = True
|
self.initflag = True
|
||||||
self.input_widget.bind(on_focus=self.on_focus)
|
self.input_widget.bind(on_focus=self.on_focus)
|
||||||
self.input_widget.setValue(self.options.get('default',''))
|
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):
|
def clear(self):
|
||||||
self.input_widget.setValue('')
|
self.input_widget.setValue('')
|
||||||
@ -195,8 +219,8 @@ class InputBox(BoxLayout):
|
|||||||
|
|
||||||
def defaultToolbar():
|
def defaultToolbar():
|
||||||
return {
|
return {
|
||||||
"img_size":1.5,
|
"img_size":2,
|
||||||
"text_size":0.7,
|
"text_size":1,
|
||||||
"tools":[
|
"tools":[
|
||||||
{
|
{
|
||||||
"name":"__submit",
|
"name":"__submit",
|
||||||
@ -212,11 +236,15 @@ def defaultToolbar():
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Form(BoxLayout):
|
class Form(BGColorBehavior, BoxLayout):
|
||||||
def __init__(self, **options):
|
def __init__(self, **options):
|
||||||
self.options = options
|
self.options = options
|
||||||
BoxLayout.__init__(self, orientation='vertical')
|
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.widget_ids = {}
|
||||||
|
self.readiedInput = 0
|
||||||
self.cols = self.options_cols = self.options.get('cols',1)
|
self.cols = self.options_cols = self.options.get('cols',1)
|
||||||
if isHandHold() and Window.width < Window.height:
|
if isHandHold() and Window.width < Window.height:
|
||||||
self.cols = 1
|
self.cols = 1
|
||||||
@ -239,11 +267,11 @@ class Form(BoxLayout):
|
|||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar)
|
||||||
self.add_widget(self.fsc)
|
self.add_widget(self.fsc)
|
||||||
self.fieldWidgets=[]
|
self.fieldWidgets=[]
|
||||||
previous_w = None
|
|
||||||
for f in self.options['fields']:
|
for f in self.options['fields']:
|
||||||
w = InputBox(self, **f)
|
w = InputBox(self, **f)
|
||||||
self.fsc.add_widget(w)
|
self.fsc.add_widget(w)
|
||||||
self.fieldWidgets.append(w)
|
self.fieldWidgets.append(w)
|
||||||
|
w.bind(on_ready=self.makeInputLink)
|
||||||
blocks = App.get_running_app().blocks
|
blocks = App.get_running_app().blocks
|
||||||
# wid = self.widget_ids['__submit']
|
# wid = self.widget_ids['__submit']
|
||||||
wid = blocks.getWidgetByIdPath(self,'__submit')
|
wid = blocks.getWidgetByIdPath(self,'__submit')
|
||||||
@ -253,6 +281,15 @@ class Form(BoxLayout):
|
|||||||
wid.bind(on_press=self.on_clear_button)
|
wid.bind(on_press=self.on_clear_button)
|
||||||
self.initflag = True
|
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):
|
def getData(self):
|
||||||
d = {}
|
d = {}
|
||||||
for f in self.fieldWidgets:
|
for f in self.fieldWidgets:
|
||||||
@ -260,12 +297,26 @@ class Form(BoxLayout):
|
|||||||
d.update(v)
|
d.update(v)
|
||||||
return d
|
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):
|
def on_submit(self,v=None):
|
||||||
print('Form():on_submit fired ...',v)
|
print('Form():on_submit fired ...',v)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_submit_button(self,o,v=None):
|
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()
|
d = self.getData()
|
||||||
|
Logger.info('kivyblocks: fire on_submit')
|
||||||
self.dispatch('on_submit',d)
|
self.dispatch('on_submit',d)
|
||||||
|
|
||||||
def on_clear_button(self,o,v=None):
|
def on_clear_button(self,o,v=None):
|
||||||
@ -274,19 +325,20 @@ class Form(BoxLayout):
|
|||||||
|
|
||||||
def on_size(self,o, v=None):
|
def on_size(self,o, v=None):
|
||||||
self.init()
|
self.init()
|
||||||
|
textcolor, self.bgcolor = getColors(self.color_level)
|
||||||
|
|
||||||
class StrSearchForm(BoxLayout):
|
class StrSearchForm(BoxLayout):
|
||||||
def __init__(self,img_url=None,**options):
|
def __init__(self,img_url=None,**options):
|
||||||
self.name = options.get('name','search_string')
|
self.name = options.get('name','search_string')
|
||||||
BoxLayout.__init__(self,orientation='horizontal',size_hint_y=None,height=CSize(3))
|
BoxLayout.__init__(self,orientation='horizontal',size_hint_y=None,height=CSize(3))
|
||||||
self.inputwidget = TextInput(
|
self.input_widget = TextInput(
|
||||||
text='',
|
text='',
|
||||||
multiline=False,
|
multiline=False,
|
||||||
allow_copy=True,
|
allow_copy=True,
|
||||||
font_size=CSize(1),
|
font_size=CSize(1),
|
||||||
size_hint_y=None,
|
size_hint_y=None,
|
||||||
height=CSize(3))
|
height=CSize(3))
|
||||||
self.add_widget(self.inputwidget)
|
self.add_widget(self.input_widget)
|
||||||
imgsrc = img_url if img_url else blockImage('search.png')
|
imgsrc = img_url if img_url else blockImage('search.png')
|
||||||
self.search = PressableImage(source=imgsrc,
|
self.search = PressableImage(source=imgsrc,
|
||||||
size_hint=(None,None),
|
size_hint=(None,None),
|
||||||
@ -295,16 +347,16 @@ class StrSearchForm(BoxLayout):
|
|||||||
self.add_widget(self.search)
|
self.add_widget(self.search)
|
||||||
self.register_event_type('on_submit')
|
self.register_event_type('on_submit')
|
||||||
self.search.bind(on_press=self.submit_input)
|
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):
|
def getData(self):
|
||||||
d = {
|
d = {
|
||||||
self.name:self.inputwidget.text
|
self.name:self.input_widget.text
|
||||||
}
|
}
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def submit_input(self,o,v=None):
|
def submit_input(self,o,v=None):
|
||||||
text = self.inputwidget.text
|
text = self.input_widget.text
|
||||||
if text != '':
|
if text != '':
|
||||||
d = {
|
d = {
|
||||||
self.name:text
|
self.name:text
|
||||||
|
BIN
kivyblocks/imgs/menu.png
Normal file
BIN
kivyblocks/imgs/menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
78
kivyblocks/kivymdPlugin.py
Normal file
78
kivyblocks/kivymdPlugin.py
Normal file
@ -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)
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
from kivy.logger import Logger
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
from kivy.uix.popup import Popup
|
from kivy.uix.popup import Popup
|
||||||
@ -45,7 +46,10 @@ class LoginForm(Popup):
|
|||||||
print('build Content ....... ....')
|
print('build Content ....... ....')
|
||||||
self.initflag = True
|
self.initflag = True
|
||||||
app = App.get_running_app()
|
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)
|
self.content.bind(on_submit=self.on_submit)
|
||||||
|
|
||||||
def on_submit(self,o,userinfo):
|
def on_submit(self,o,userinfo):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from kivy.logger import Logger
|
||||||
from kivy.graphics import Color, Rectangle
|
from kivy.graphics import Color, Rectangle
|
||||||
from kivy.uix.button import ButtonBehavior
|
from kivy.uix.button import ButtonBehavior
|
||||||
from kivy.uix.image import AsyncImage
|
from kivy.uix.image import AsyncImage
|
||||||
@ -11,14 +12,16 @@ from appPublic.dictObject import DictObject
|
|||||||
|
|
||||||
from .widgetExt.scrollwidget import ScrollWidget
|
from .widgetExt.scrollwidget import ScrollWidget
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .kivysize import KivySizes
|
|
||||||
from .ready import WidgetReady
|
from .ready import WidgetReady
|
||||||
from .i18n import I18nText
|
from .i18n import I18nText
|
||||||
|
from .color_definitions import getColors
|
||||||
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
"""
|
"""
|
||||||
toobar={
|
toobar={
|
||||||
"mode":"icon", "icontext","text"
|
"mode":"icon", "icontext","text"
|
||||||
img_size=1.5,
|
img_size=2,
|
||||||
text_size=0.7,
|
text_size=1,
|
||||||
"tools":[
|
"tools":[
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -30,49 +33,62 @@ tool options
|
|||||||
img=''
|
img=''
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
class Tool(ButtonBehavior, WidgetReady,BoxLayout):
|
class Tool(ButtonBehavior, BGColorBehavior, BoxLayout):
|
||||||
normal_bgColor=[0.1,0,0,1]
|
|
||||||
active_bgColor=[0.4,0.4,0.4,1]
|
|
||||||
def __init__(self,ancestor=None,**opts):
|
def __init__(self,ancestor=None,**opts):
|
||||||
if ancestor is None:
|
if ancestor is None:
|
||||||
ancestor = App.get_running_app().root
|
ancestor = App.get_running_app().root
|
||||||
ancestor.widget_ids[opts['name']] = self
|
ancestor.widget_ids[opts['name']] = self
|
||||||
|
self.ancestor = ancestor
|
||||||
ButtonBehavior.__init__(self)
|
ButtonBehavior.__init__(self)
|
||||||
bc = opts.get('bg_color',self.normal_bgColor)
|
|
||||||
WidgetReady.__init__(self,bg_color=self.normal_bgColor)
|
|
||||||
BoxLayout.__init__(self,
|
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)
|
self.opts = DictObject(**opts)
|
||||||
if not self.opts.img_size:
|
if not self.opts.img_size:
|
||||||
self.opts.img_size = 2
|
self.opts.img_size = 2
|
||||||
if not self.opts.text_size:
|
if not self.opts.text_size:
|
||||||
self.opts.text_size = 0.7
|
self.opts.text_size = 1
|
||||||
app = App.get_running_app()
|
app = App.get_running_app()
|
||||||
ks = KivySizes()
|
size = 0
|
||||||
size = ks.unitedSize(self.opts.img_size or 2)
|
if self.opts.img_src:
|
||||||
img = AsyncImage(source=self.opts.img_src,size_hint=(None,None),
|
size = CSize(self.opts.img_size or 2)
|
||||||
size=(size,size))
|
img = AsyncImage(source=self.opts.img_src,
|
||||||
tsize = ks.unitedSize(self.opts.text_size)
|
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
|
label = self.opts.label or self.opts.name
|
||||||
lbl = I18nText(otext=label,font_size=int(tsize))
|
self.lbl = I18nText(otext=label,
|
||||||
lbl.text_size = (size, 1.3 * tsize)
|
font_size=int(tsize),
|
||||||
self.add_widget(img)
|
text_size=(CSize(len(label)), tsize),
|
||||||
self.add_widget(lbl)
|
height=tsize,
|
||||||
self.size = (size * 1.1, (size + 2 * tsize)*1.1)
|
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):
|
def on_size(self,obj,size):
|
||||||
if self.parent:
|
Logger.info('toolbar: Tool() on_size fired')
|
||||||
print('********center*dd**********')
|
self.lbl.color, self.bgcolor = getColors(self.ancestor.color_level,
|
||||||
self.center = self.parent.center
|
selected=False)
|
||||||
|
self.lbl.bgcolor = self.bgcolor
|
||||||
|
|
||||||
def on_press(self):
|
def on_press(self):
|
||||||
print('Tool(). pressed ...............')
|
print('Tool(). pressed ...............')
|
||||||
|
|
||||||
def setActive(self,flag):
|
def setActive(self,flag):
|
||||||
if flag:
|
text_color, self.bgcolor = getColors(self.ancestor.color_level,
|
||||||
self.setBackgroundColor(self.active_bgColor)
|
selected=flag)
|
||||||
else:
|
self.lbl.bgcolor = self.bgcolor
|
||||||
self.setBackgroundColor(self.normal_bgColor)
|
self.lbl.color = text_color
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -100,10 +116,11 @@ class Toolbar(GridLayout):
|
|||||||
for opt in self.opts.tools:
|
for opt in self.opts.tools:
|
||||||
opt.img_size = self.opts.img_size
|
opt.img_size = self.opts.img_size
|
||||||
opt.text_size = self.opts.text_size
|
opt.text_size = self.opts.text_size
|
||||||
purl = None
|
if opt.img_src:
|
||||||
if ancestor and hasattr(ancestor, 'parenturl'):
|
purl = None
|
||||||
purl = ancestor.parenturl
|
if ancestor and hasattr(ancestor, 'parenturl'):
|
||||||
opt.img_src = absurl(opt.img_src,purl)
|
purl = ancestor.parenturl
|
||||||
|
opt.img_src = absurl(opt.img_src,purl)
|
||||||
tool = Tool(ancestor=ancestor, **opt)
|
tool = Tool(ancestor=ancestor, **opt)
|
||||||
if first:
|
if first:
|
||||||
first = False
|
first = False
|
||||||
@ -119,12 +136,12 @@ class Toolbar(GridLayout):
|
|||||||
self.height = tool.height * 1.1
|
self.height = tool.height * 1.1
|
||||||
|
|
||||||
def on_size(self,obj,size):
|
def on_size(self,obj,size):
|
||||||
|
return
|
||||||
with self.canvas.before:
|
with self.canvas.before:
|
||||||
Color(0.3,0.3,0.3,1)
|
Color(0.3,0.3,0.3,1)
|
||||||
Rectangle(pos=self.pos,size=self.size)
|
Rectangle(pos=self.pos,size=self.size)
|
||||||
|
|
||||||
def tool_press(self,o,v=None):
|
def tool_press(self,o,v=None):
|
||||||
o.background_color = [0.3,1,1,0.5]
|
|
||||||
for n,w in self.tool_widgets.items():
|
for n,w in self.tool_widgets.items():
|
||||||
active = False
|
active = False
|
||||||
if w == o:
|
if w == o:
|
||||||
@ -137,6 +154,7 @@ Toolpage options
|
|||||||
img_size=1.5,
|
img_size=1.5,
|
||||||
text_size=0.7,
|
text_size=0.7,
|
||||||
tool_at:"left","right","top","bottom",
|
tool_at:"left","right","top","bottom",
|
||||||
|
color_level=0,
|
||||||
tools:[
|
tools:[
|
||||||
{
|
{
|
||||||
"name":"myid",
|
"name":"myid",
|
||||||
@ -148,7 +166,7 @@ Toolpage options
|
|||||||
]
|
]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
class ToolPage(BoxLayout):
|
class ToolPage(BGColorBehavior, BoxLayout):
|
||||||
def __init__(self,**opts):
|
def __init__(self,**opts):
|
||||||
self.opts = DictObject(**opts)
|
self.opts = DictObject(**opts)
|
||||||
self.parenturl = opts.get('parenturl',None)
|
self.parenturl = opts.get('parenturl',None)
|
||||||
@ -158,7 +176,8 @@ class ToolPage(BoxLayout):
|
|||||||
else:
|
else:
|
||||||
orient = 'horizontal'
|
orient = 'horizontal'
|
||||||
|
|
||||||
super().__init__(orientation=orient)
|
BoxLayout.__init__(self,orientation=orient)
|
||||||
|
BGColorBehavior.__init__(self)
|
||||||
self.content = None
|
self.content = None
|
||||||
self.toolbar = None
|
self.toolbar = None
|
||||||
self.init()
|
self.init()
|
||||||
@ -171,6 +190,7 @@ class ToolPage(BoxLayout):
|
|||||||
self.toolbar.width = x
|
self.toolbar.width = x
|
||||||
self.content.width = x
|
self.content.width = x
|
||||||
self.content.height = y - self.toolbar.height
|
self.content.height = y - self.toolbar.height
|
||||||
|
self.color, self.bgcolor = getColors(self.color_level)
|
||||||
|
|
||||||
def showPage(self,obj):
|
def showPage(self,obj):
|
||||||
self._show_page(obj.opts)
|
self._show_page(obj.opts)
|
||||||
@ -191,6 +211,8 @@ class ToolPage(BoxLayout):
|
|||||||
t.img_src = absurl(t.img_src,parenturl)
|
t.img_src = absurl(t.img_src,parenturl)
|
||||||
|
|
||||||
opts = self.opts
|
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)
|
self.toolbar = Toolbar(ancestor=self, **self.opts)
|
||||||
if self.opts.tool_at in ['top','left']:
|
if self.opts.tool_at in ['top','left']:
|
||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar)
|
||||||
@ -198,7 +220,7 @@ class ToolPage(BoxLayout):
|
|||||||
else:
|
else:
|
||||||
self.add_widget(self.content)
|
self.add_widget(self.content)
|
||||||
self.add_widget(self.toolbar)
|
self.add_widget(self.toolbar)
|
||||||
Clock.schedule_once(self.show_firstpage,0.5)
|
# Clock.schedule_once(self.show_firstpage,0.5)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from blocksapp import BlocksApp
|
from blocksapp import BlocksApp
|
||||||
|
@ -9,7 +9,8 @@ from kivyblocks.widgetExt import ScrollWidget
|
|||||||
from kivyblocks.utils import CSize
|
from kivyblocks.utils import CSize
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
from .baseWidget import PressableLabel
|
from .baseWidget import PressableLabel
|
||||||
from .stylebehavior import StyleBehavior
|
from .color_definitions import getColors
|
||||||
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
class EmptyBox(Label):
|
class EmptyBox(Label):
|
||||||
def __init__(self,size_cnt=1):
|
def __init__(self,size_cnt=1):
|
||||||
@ -202,6 +203,7 @@ tree options
|
|||||||
"url":
|
"url":
|
||||||
"params",
|
"params",
|
||||||
"bg_color",
|
"bg_color",
|
||||||
|
"color_level",
|
||||||
"color",
|
"color",
|
||||||
"checkbox",
|
"checkbox",
|
||||||
"multplecheck",
|
"multplecheck",
|
||||||
@ -210,12 +212,11 @@ tree options
|
|||||||
"data" # array of {children:{},...}
|
"data" # array of {children:{},...}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
# class Tree(StyleBehavior,ScrollWidget):
|
class Tree(BGColorBehavior, ScrollWidget):
|
||||||
class Tree(ScrollWidget):
|
|
||||||
def __init__(self,**options):
|
def __init__(self,**options):
|
||||||
|
self.color_level = options.get('color_level',0)
|
||||||
ScrollWidget.__init__(self)
|
ScrollWidget.__init__(self)
|
||||||
level = options.get('level',0)
|
BGColorBehavior.__init__(self)
|
||||||
# StyleBehavior.__init__(self,level=level)
|
|
||||||
self.options = DictObject(**options)
|
self.options = DictObject(**options)
|
||||||
self.nodes = []
|
self.nodes = []
|
||||||
self.initflag = False
|
self.initflag = False
|
||||||
@ -262,7 +263,7 @@ class Tree(ScrollWidget):
|
|||||||
data = self.options.data
|
data = self.options.data
|
||||||
logging.info("Tree : buildTree,data=%s",data)
|
logging.info("Tree : buildTree,data=%s",data)
|
||||||
self.dataLoaded(data)
|
self.dataLoaded(data)
|
||||||
|
self.color, self.bgcolor = getColors(self.color_level)
|
||||||
|
|
||||||
def dataLoaded(self,d):
|
def dataLoaded(self,d):
|
||||||
self.data = d
|
self.data = d
|
||||||
@ -283,6 +284,13 @@ class TextContent(PressableLabel):
|
|||||||
def __init__(self,level=0,**options):
|
def __init__(self,level=0,**options):
|
||||||
PressableLabel.__init__(self,**options)
|
PressableLabel.__init__(self,**options)
|
||||||
|
|
||||||
|
def selected(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def unselected(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TextTreeNode(TreeNode):
|
class TextTreeNode(TreeNode):
|
||||||
def buildContent(self):
|
def buildContent(self):
|
||||||
txt = self.data.get(self.treeObj.options.textField,
|
txt = self.data.get(self.treeObj.options.textField,
|
||||||
@ -294,7 +302,8 @@ class TextTreeNode(TreeNode):
|
|||||||
halign='left',
|
halign='left',
|
||||||
height=CSize(2),
|
height=CSize(2),
|
||||||
width=CSize(len(txt)))
|
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)
|
self.content.bind(on_press=self.onPress)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -309,11 +318,17 @@ class TextTreeNode(TreeNode):
|
|||||||
|
|
||||||
def selected(self):
|
def selected(self):
|
||||||
logging.info('content selected ........')
|
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):
|
def unselected(self):
|
||||||
logging.info('content unselected ........')
|
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):
|
class TextTree(Tree):
|
||||||
def __init__(self,**options):
|
def __init__(self,**options):
|
||||||
|
@ -70,6 +70,19 @@ class BaseVPlayer(FloatLayout):
|
|||||||
if hasattr(self._video._video, '_ffplayer'):
|
if hasattr(self._video._video, '_ffplayer'):
|
||||||
self.ffplayer = 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):
|
def on_source_error(self,o,v):
|
||||||
Logger.info('safecorner: {} error'.format(v))
|
Logger.info('safecorner: {} error'.format(v))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user