bugfix
This commit is contained in:
parent
ae89547b70
commit
1bb2fa02c6
@ -1,6 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
|
|
||||||
|
from kivy.properties import ObjectProperty, StringProperty
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
from kivy.uix.button import Button, ButtonBehavior
|
from kivy.uix.button import Button, ButtonBehavior
|
||||||
@ -53,6 +54,7 @@ from kivycalendar import DatePicker
|
|||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
|
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
|
from appPublic.jsonConfig import getConfig
|
||||||
from appPublic.folderUtils import listFile
|
from appPublic.folderUtils import listFile
|
||||||
|
|
||||||
from .widgetExt.scrollwidget import ScrollWidget
|
from .widgetExt.scrollwidget import ScrollWidget
|
||||||
@ -68,6 +70,7 @@ from .login import LoginForm
|
|||||||
from .tab import TabsPanel
|
from .tab import TabsPanel
|
||||||
from .qrdata import QRCodeWidget
|
from .qrdata import QRCodeWidget
|
||||||
from .threadcall import HttpClient
|
from .threadcall import HttpClient
|
||||||
|
from .i18n import I18n
|
||||||
|
|
||||||
if platform == 'android':
|
if platform == 'android':
|
||||||
from .widgetExt.phonebutton import PhoneButton
|
from .widgetExt.phonebutton import PhoneButton
|
||||||
@ -79,9 +82,33 @@ class WrapText(Label):
|
|||||||
self.bind(width=lambda *x: self.setter('text_size')(self, (self.width, None)),
|
self.bind(width=lambda *x: self.setter('text_size')(self, (self.width, None)),
|
||||||
texture_size=lambda *x: self.setter('height')(self, self.texture_size[1]))
|
texture_size=lambda *x: self.setter('height')(self, self.texture_size[1]))
|
||||||
|
|
||||||
|
|
||||||
class Text(Label):
|
class Text(Label):
|
||||||
pass
|
lang=StringProperty('')
|
||||||
|
otext = StringProperty('')
|
||||||
|
def __init__(self,i18n=False, textype='text', **kw):
|
||||||
|
self._i18n = i18n
|
||||||
|
kwargs = kw.copy()
|
||||||
|
config = getConfig()
|
||||||
|
if config.texttypes:
|
||||||
|
attrs = config.texttypes.get('texttype',{})
|
||||||
|
kwargs.update(attrs)
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
if self._i18n:
|
||||||
|
self.i18n = I18n()
|
||||||
|
self.i18n.addI18nWidget(self)
|
||||||
|
self.otext = kw.get('text','')
|
||||||
|
|
||||||
|
def on_otext(self,o,v=None):
|
||||||
|
if self._i18n:
|
||||||
|
self.text = self.i18n(v)
|
||||||
|
else:
|
||||||
|
self.text = v
|
||||||
|
|
||||||
|
def changeLang(self,lang):
|
||||||
|
self.lang = lang
|
||||||
|
|
||||||
|
def on_lang(self,o,lang):
|
||||||
|
self.text = self.i18n(self.otext)
|
||||||
|
|
||||||
class PressableImage(ButtonBehavior,AsyncImage):
|
class PressableImage(ButtonBehavior,AsyncImage):
|
||||||
def on_press(self):
|
def on_press(self):
|
||||||
|
@ -32,12 +32,11 @@ from .form import InputBox, Form, StrSearchForm
|
|||||||
from .boxViewer import BoxViewer
|
from .boxViewer import BoxViewer
|
||||||
from .tree import Tree, TextTree
|
from .tree import Tree, TextTree
|
||||||
from .newvideo import Video
|
from .newvideo import Video
|
||||||
# from .qrcodereader import QRCodeReader
|
|
||||||
from .ready import WidgetReady
|
from .ready import WidgetReady
|
||||||
from .bgcolorbehavior import BGColorBehavior
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
from .orientationlayout import OrientationLayout
|
from .orientationlayout import OrientationLayout
|
||||||
from .threadcall import HttpClient
|
from .threadcall import HttpClient
|
||||||
from .twosides import TwoSides
|
from .register import *
|
||||||
|
|
||||||
def showError(e):
|
def showError(e):
|
||||||
print('error',e)
|
print('error',e)
|
||||||
@ -278,11 +277,11 @@ class Blocks(EventDispatcher):
|
|||||||
return self.dictValueExpr(obj,localnamespace)
|
return self.dictValueExpr(obj,localnamespace)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def __build(self,desc:dict):
|
def w_build(self,desc:dict):
|
||||||
# print('__build(),desc=',desc)
|
# print('w_build(),desc=',desc)
|
||||||
widgetClass = desc.get('widgettype',None)
|
widgetClass = desc.get('widgettype',None)
|
||||||
if not widgetClass:
|
if not widgetClass:
|
||||||
print("__build(), desc invalid", desc)
|
print("w_build(), desc invalid", desc)
|
||||||
raise Exception(desc)
|
raise Exception(desc)
|
||||||
|
|
||||||
widgetClass = desc['widgettype']
|
widgetClass = desc['widgettype']
|
||||||
@ -387,11 +386,14 @@ class Blocks(EventDispatcher):
|
|||||||
b.widgetBuild(opts)
|
b.widgetBuild(opts)
|
||||||
|
|
||||||
def urlwidgetAction(self,widget,desc, *args):
|
def urlwidgetAction(self,widget,desc, *args):
|
||||||
|
print('urlwidgetAction():args=',args)
|
||||||
target = Blocks.getWidgetById(desc.get('target','self'),widget)
|
target = Blocks.getWidgetById(desc.get('target','self'),widget)
|
||||||
add_mode = desc.get('mode','replace')
|
add_mode = desc.get('mode','replace')
|
||||||
opts = desc.get('options').copy()
|
opts = desc.get('options').copy()
|
||||||
d = self.getActionData(widget,desc)
|
d = self.getActionData(widget,desc)
|
||||||
p = opts.get('params',{}).copy()
|
p = opts.get('params',{}).copy()
|
||||||
|
if len(args) >= 1 and isinstance(args[0],dict):
|
||||||
|
p.update(p)
|
||||||
p.update(d)
|
p.update(d)
|
||||||
opts['params'] = p
|
opts['params'] = p
|
||||||
d = {
|
d = {
|
||||||
@ -416,8 +418,8 @@ class Blocks(EventDispatcher):
|
|||||||
data = {}
|
data = {}
|
||||||
if desc.get('datawidget',False):
|
if desc.get('datawidget',False):
|
||||||
dwidget = Blocks.getWidgetById(desc.get('datawidget','self'),widget)
|
dwidget = Blocks.getWidgetById(desc.get('datawidget','self'),widget)
|
||||||
if dwidget and hasattr(dwidget,'getData'):
|
if dwidget and hasattr(dwidget,'getValue'):
|
||||||
data = dwidget.getData()
|
data = dwidget.getValue()
|
||||||
if desc.get('keymapping'):
|
if desc.get('keymapping'):
|
||||||
data = keyMapping(data, desc.get('keymapping'))
|
data = keyMapping(data, desc.get('keymapping'))
|
||||||
return data
|
return data
|
||||||
@ -476,6 +478,7 @@ class Blocks(EventDispatcher):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
name = desc['widgettype']
|
name = desc['widgettype']
|
||||||
|
print('desc=',desc,'type=',type(desc))
|
||||||
|
|
||||||
def doit(desc):
|
def doit(desc):
|
||||||
if not isinstance(desc,dict):
|
if not isinstance(desc,dict):
|
||||||
@ -483,7 +486,7 @@ class Blocks(EventDispatcher):
|
|||||||
raise Exception('desc must be a dict')
|
raise Exception('desc must be a dict')
|
||||||
|
|
||||||
desc = self.valueExpr(desc)
|
desc = self.valueExpr(desc)
|
||||||
widget = self.__build(desc)
|
widget = self.w_build(desc)
|
||||||
self.dispatch('on_built',widget)
|
self.dispatch('on_built',widget)
|
||||||
if hasattr(widget,'ready'):
|
if hasattr(widget,'ready'):
|
||||||
widget.ready()
|
widget.ready()
|
||||||
|
@ -17,6 +17,7 @@ BoxViewer options:
|
|||||||
"""
|
"""
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from appPublic.dictExt import dictExtend
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
from kivy.utils import platform
|
from kivy.utils import platform
|
||||||
@ -27,24 +28,32 @@ from .paging import Paging, RelatedLoader
|
|||||||
from .utils import CSize
|
from .utils import CSize
|
||||||
from .ready import WidgetReady
|
from .ready import WidgetReady
|
||||||
|
|
||||||
|
|
||||||
class BoxViewer(WidgetReady, BoxLayout):
|
class BoxViewer(WidgetReady, BoxLayout):
|
||||||
def __init__(self, **options):
|
def __init__(self, **options):
|
||||||
|
self.options = options
|
||||||
|
self.subwidgets = []
|
||||||
self.toolbar = None
|
self.toolbar = None
|
||||||
self.parenturl = None
|
self.parenturl = None
|
||||||
self.dataloader = None
|
self.dataloader = None
|
||||||
self.initflag = False
|
self.initflag = False
|
||||||
self.selected_box = None
|
|
||||||
remind = ['toolbar',
|
remind = ['toolbar',
|
||||||
'dataloader',
|
'dataloader',
|
||||||
'orientation',
|
'orientation',
|
||||||
'viewer',
|
'viewer',
|
||||||
'boxwidth',
|
'boxwidth',
|
||||||
'boxheight']
|
'boxheight',
|
||||||
|
'color_level',
|
||||||
|
'radius',
|
||||||
|
'viewer_url'
|
||||||
|
'viewer'
|
||||||
|
]
|
||||||
kwargs = {k:v for k,v in options.items() if k not in remind }
|
kwargs = {k:v for k,v in options.items() if k not in remind }
|
||||||
BoxLayout.__init__(self, orientation='vertical', **kwargs)
|
BoxLayout.__init__(self, orientation='vertical', **kwargs)
|
||||||
WidgetReady.__init__(self)
|
WidgetReady.__init__(self)
|
||||||
self.selected_data = None
|
self.selected_data = None
|
||||||
self.options = options
|
self.color_level = self.options.get('color_level',-1)
|
||||||
|
self.radius = self.options.get('radius',[])
|
||||||
self.box_width = CSize(options['boxwidth'])
|
self.box_width = CSize(options['boxwidth'])
|
||||||
self.box_height = CSize(options['boxheight'])
|
self.box_height = CSize(options['boxheight'])
|
||||||
self.viewContainer = VResponsiveLayout(cols=2,box_width=self.box_width)
|
self.viewContainer = VResponsiveLayout(cols=2,box_width=self.box_width)
|
||||||
@ -81,6 +90,7 @@ class BoxViewer(WidgetReady, BoxLayout):
|
|||||||
|
|
||||||
def deleteAllWidgets(self,o):
|
def deleteAllWidgets(self,o):
|
||||||
self.viewContainer.clear_widgets()
|
self.viewContainer.clear_widgets()
|
||||||
|
self.subwidgets = []
|
||||||
|
|
||||||
def addPageWidgets(self,o,data):
|
def addPageWidgets(self,o,data):
|
||||||
widgets = []
|
widgets = []
|
||||||
@ -94,6 +104,8 @@ class BoxViewer(WidgetReady, BoxLayout):
|
|||||||
for r in recs:
|
for r in recs:
|
||||||
self.showObject(widgets, r, index=idx)
|
self.showObject(widgets, r, index=idx)
|
||||||
|
|
||||||
|
self.subwidgets += widgets
|
||||||
|
|
||||||
self.dataloader.bufferObjects(page, widgets)
|
self.dataloader.bufferObjects(page, widgets)
|
||||||
x = self.dataloader.getLocater()
|
x = self.dataloader.getLocater()
|
||||||
self.locater(x)
|
self.locater(x)
|
||||||
@ -101,8 +113,9 @@ class BoxViewer(WidgetReady, BoxLayout):
|
|||||||
def deleteWidgets(self,o,data):
|
def deleteWidgets(self,o,data):
|
||||||
for w in data:
|
for w in data:
|
||||||
self.viewContainer.remove_widget(w)
|
self.viewContainer.remove_widget(w)
|
||||||
|
self.subwidget = [i for i in self.subwidgets if i in data]
|
||||||
|
|
||||||
def on_selected(self, o, v=None):
|
def on_selected(self, data=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def locater(self, pos):
|
def locater(self, pos):
|
||||||
@ -122,25 +135,46 @@ class BoxViewer(WidgetReady, BoxLayout):
|
|||||||
self.initflag = True
|
self.initflag = True
|
||||||
|
|
||||||
def showObject(self, holders, rec,index=0):
|
def showObject(self, holders, rec,index=0):
|
||||||
def doit(self,holders,idx,o,w):
|
opts = {
|
||||||
w.bind(on_press=self.select_record)
|
"size_hint":[None,None],
|
||||||
w.boxviewer = self
|
"height":self.box_height,
|
||||||
self.viewContainer.add_widget(w,index=idx)
|
"width":self.box_width,
|
||||||
holders.append(w)
|
"color_level":self.color_level,
|
||||||
|
"radius":self.radius
|
||||||
def doerr(o,e):
|
}
|
||||||
print_exc()
|
desc = {
|
||||||
print('showObject(),error=',e)
|
"widgettype":"PressableBox",
|
||||||
raise e
|
"options":opts
|
||||||
options = self.options['viewer'].copy()
|
}
|
||||||
options['options']['record'] = rec
|
|
||||||
options['options']['size_hint'] = None,None
|
|
||||||
options['options']['width'] = self.box_width
|
|
||||||
options['options']['height'] = self.box_height
|
|
||||||
blocks = Factory.Blocks()
|
blocks = Factory.Blocks()
|
||||||
blocks.bind(on_built=partial(doit,self,holders,index))
|
box = blocks.w_build(desc)
|
||||||
blocks.bind(on_failed=doerr)
|
box.setValue(rec)
|
||||||
blocks.widgetBuild(options)
|
box.bind(on_press=self.select_record)
|
||||||
|
self.viewContainer.add_widget(box,index=index)
|
||||||
|
self.subwidgets.append(box)
|
||||||
|
holders.append(box)
|
||||||
|
desc = {}
|
||||||
|
if self.options.get('viewer_url'):
|
||||||
|
desc = {
|
||||||
|
"widgettype":"urlwidget",
|
||||||
|
"optons":{
|
||||||
|
"params":rec,
|
||||||
|
"method":"GET",
|
||||||
|
"url":self.options.get('viewer_url')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
desc = self.options.get('viewer').copy()
|
||||||
|
if desc['widgettype'] == 'urlwidget':
|
||||||
|
desc = dictExtend(desc,{'options':{'params':rec}})
|
||||||
|
else:
|
||||||
|
desc = dictExtend(desc,{'options':{'record':rec}})
|
||||||
|
def add2box(p,o,w):
|
||||||
|
p.add_widget(w)
|
||||||
|
|
||||||
|
blocks = Factory.Blocks()
|
||||||
|
blocks.bind(on_built=partial(add2box,box))
|
||||||
|
blocks.widgetBuild(desc)
|
||||||
|
|
||||||
def on_scroll_stop(self,o,v=None):
|
def on_scroll_stop(self,o,v=None):
|
||||||
if o.scroll_y <= 0.001:
|
if o.scroll_y <= 0.001:
|
||||||
@ -149,22 +183,19 @@ class BoxViewer(WidgetReady, BoxLayout):
|
|||||||
self.dataloader.loadPreviousPage()
|
self.dataloader.loadPreviousPage()
|
||||||
|
|
||||||
def select_record(self,o,v=None):
|
def select_record(self,o,v=None):
|
||||||
if self.selected_box:
|
print('BoxViewer(),on_selected() called\n',
|
||||||
self.selected_box.unselected()
|
'normal_bgcolor=',o.normal_bgcolor,'\n',
|
||||||
|
'selected_bgcolor=',o.selected_bgcolor,'\n',
|
||||||
|
'bg_color=',o.bgcolor,'\n',
|
||||||
|
'color_level=',self.color_level)
|
||||||
|
|
||||||
|
for w in self.subwidgets:
|
||||||
|
w.unselected()
|
||||||
o.selected()
|
o.selected()
|
||||||
self.selected_box = o
|
self.selected_data = o.getValue()
|
||||||
|
self.dispatch('on_selected',self.selected_data)
|
||||||
|
|
||||||
self.selected_data = o.getRecord()
|
def getValue(self):
|
||||||
d = {
|
|
||||||
"target":self.selected_box,
|
|
||||||
"page_rows":1,
|
|
||||||
"page":self.selected_data['__posInSet__'],
|
|
||||||
"dataurl":self.options['dataloader']['options']['dataurl'],
|
|
||||||
"params":self.params
|
|
||||||
}
|
|
||||||
self.dispatch('on_selected',d)
|
|
||||||
|
|
||||||
def getData(self):
|
|
||||||
return self.selected_data
|
return self.selected_data
|
||||||
d = {
|
d = {
|
||||||
"caller":self,
|
"caller":self,
|
||||||
|
@ -21,7 +21,6 @@ from .widgetExt import ScrollWidget
|
|||||||
from .paging import Paging, RelatedLoader
|
from .paging import Paging, RelatedLoader
|
||||||
from .ready import WidgetReady
|
from .ready import WidgetReady
|
||||||
from .toolbar import Toolbar
|
from .toolbar import Toolbar
|
||||||
from .i18n import I18nText
|
|
||||||
from .bgcolorbehavior import BGColorBehavior
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
class BLabel(ButtonBehavior, Text):
|
class BLabel(ButtonBehavior, Text):
|
||||||
@ -59,7 +58,7 @@ class Cell(BoxLayout):
|
|||||||
self.add_widget(w)
|
self.add_widget(w)
|
||||||
return
|
return
|
||||||
if desc['header']:
|
if desc['header']:
|
||||||
bl = I18nText(otext=str(desc['value']),
|
bl = Text(i18n=True, text=str(desc['value']),
|
||||||
font_size=CSize(1),
|
font_size=CSize(1),
|
||||||
halign='left'
|
halign='left'
|
||||||
)
|
)
|
||||||
@ -230,6 +229,7 @@ class DataGrid(WidgetReady, BGColorBehavior, BoxLayout):
|
|||||||
kw.orientation = 'vertical'
|
kw.orientation = 'vertical'
|
||||||
self.color_level = color_level
|
self.color_level = color_level
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
|
self.select_rowid = None
|
||||||
WidgetReady.__init__(self)
|
WidgetReady.__init__(self)
|
||||||
BoxLayout.__init__(self,**kw)
|
BoxLayout.__init__(self,**kw)
|
||||||
BGColorBehavior.__init__(self,color_level=color_level,
|
BGColorBehavior.__init__(self,color_level=color_level,
|
||||||
@ -299,8 +299,8 @@ class DataGrid(WidgetReady, BGColorBehavior, BoxLayout):
|
|||||||
if o.scroll_y >= 0.999:
|
if o.scroll_y >= 0.999:
|
||||||
self.dataloader.loadPreviousPage()
|
self.dataloader.loadPreviousPage()
|
||||||
|
|
||||||
def getData(self):
|
def getValue(self):
|
||||||
if not self.row_selected:
|
if not self.select_rowid:
|
||||||
return None
|
return None
|
||||||
return self._getRowData(self.select_rowid)
|
return self._getRowData(self.select_rowid)
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ class DataGrid(WidgetReady, BGColorBehavior, BoxLayout):
|
|||||||
if self.freeze_part:
|
if self.freeze_part:
|
||||||
d.update(self.freeze_part.body.getRowData(rowid))
|
d.update(self.freeze_part.body.getRowData(rowid))
|
||||||
d.update(self.normal_part.body.getRowData(rowid))
|
d.update(self.normal_part.body.getRowData(rowid))
|
||||||
print('getData() return=',d)
|
print('getValue() return=',d)
|
||||||
return DictObject(**d)
|
return DictObject(**d)
|
||||||
|
|
||||||
def bodyOnSize(self,o,s):
|
def bodyOnSize(self,o,s):
|
||||||
@ -408,4 +408,3 @@ class DataGrid(WidgetReady, BGColorBehavior, BoxLayout):
|
|||||||
fs.append(f)
|
fs.append(f)
|
||||||
return fs
|
return fs
|
||||||
|
|
||||||
Factory.register('DataGrid',DataGrid)
|
|
||||||
|
@ -113,8 +113,6 @@ class FileLoaderBrowser(Popup):
|
|||||||
self.control_box.add_widget(self.btn_load)
|
self.control_box.add_widget(self.btn_load)
|
||||||
self.control_box.add_widget(self.btn_icon_view)
|
self.control_box.add_widget(self.btn_icon_view)
|
||||||
|
|
||||||
Factory.register('FileLoaderBrowser',FileLoaderBrowser)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
class Test(App):
|
class Test(App):
|
||||||
|
@ -10,7 +10,7 @@ from .widgetExt.inputext import FloatInput,IntegerInput, \
|
|||||||
StrInput,SelectInput, BoolInput, AmountInput, Password
|
StrInput,SelectInput, BoolInput, AmountInput, Password
|
||||||
from .baseWidget import *
|
from .baseWidget import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .i18n import I18nText, I18n
|
from .i18n import I18n
|
||||||
from .toolbar import Toolbar
|
from .toolbar import Toolbar
|
||||||
from .color_definitions import getColors
|
from .color_definitions import getColors
|
||||||
from .bgcolorbehavior import BGColorBehavior
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
@ -161,14 +161,15 @@ class InputBox(BoxLayout):
|
|||||||
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 = {
|
||||||
"otext":label,
|
"i18n":True,
|
||||||
|
"text":label,
|
||||||
"font_size":CSize(1),
|
"font_size":CSize(1),
|
||||||
"size_hint_x":None,
|
"size_hint_x":None,
|
||||||
"width":CSize(len(label)),
|
"width":CSize(len(label)),
|
||||||
"size_hint_y":None,
|
"size_hint_y":None,
|
||||||
"height":CSize(3)
|
"height":CSize(3)
|
||||||
}
|
}
|
||||||
self.labeltext = I18nText(**kwargs)
|
self.labeltext = Text(**kwargs)
|
||||||
bl.add_widget(self.labeltext)
|
bl.add_widget(self.labeltext)
|
||||||
Logger.info('kivyblock:label.widht=%f,label.height=%f',
|
Logger.info('kivyblock:label.widht=%f,label.height=%f',
|
||||||
self.labeltext.width,self.labeltext.height)
|
self.labeltext.width,self.labeltext.height)
|
||||||
@ -300,7 +301,7 @@ class Form(BGColorBehavior, BoxLayout):
|
|||||||
w.input_widget.focus_previous = p.input_widget
|
w.input_widget.focus_previous = p.input_widget
|
||||||
p = w
|
p = w
|
||||||
|
|
||||||
def getData(self):
|
def getValue(self):
|
||||||
d = {}
|
d = {}
|
||||||
for f in self.fieldWidgets:
|
for f in self.fieldWidgets:
|
||||||
v = f.getValue()
|
v = f.getValue()
|
||||||
@ -325,7 +326,7 @@ class Form(BGColorBehavior, BoxLayout):
|
|||||||
if not self.checkData():
|
if not self.checkData():
|
||||||
Logger.info('kivyblocks: CheckData False')
|
Logger.info('kivyblocks: CheckData False')
|
||||||
return
|
return
|
||||||
d = self.getData()
|
d = self.getValue()
|
||||||
Logger.info('kivyblocks: fire on_submit')
|
Logger.info('kivyblocks: fire on_submit')
|
||||||
self.dispatch('on_submit',d)
|
self.dispatch('on_submit',d)
|
||||||
|
|
||||||
@ -348,7 +349,7 @@ class StrSearchForm(BoxLayout):
|
|||||||
self.register_event_type('on_submit')
|
self.register_event_type('on_submit')
|
||||||
self.input_widget.bind(on_text_validate=self.submit_input)
|
self.input_widget.bind(on_text_validate=self.submit_input)
|
||||||
|
|
||||||
def getData(self):
|
def getValue(self):
|
||||||
d = {
|
d = {
|
||||||
self.name:self.input_widget.text
|
self.name:self.input_widget.text
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import locale
|
import locale
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.properties import StringProperty
|
from kivy.properties import StringProperty
|
||||||
|
from kivy.uix.label import Label
|
||||||
from appPublic.Singleton import SingletonDecorator
|
from appPublic.Singleton import SingletonDecorator
|
||||||
from appPublic.jsonConfig import getConfig
|
from appPublic.jsonConfig import getConfig
|
||||||
from .baseWidget import Text
|
|
||||||
from .threadcall import HttpClient
|
from .threadcall import HttpClient
|
||||||
|
|
||||||
@SingletonDecorator
|
@SingletonDecorator
|
||||||
@ -42,26 +42,3 @@ class I18n:
|
|||||||
for w in self.i18nWidgets:
|
for w in self.i18nWidgets:
|
||||||
w.changeLang(lang)
|
w.changeLang(lang)
|
||||||
|
|
||||||
class I18nText(Text):
|
|
||||||
lang=StringProperty('')
|
|
||||||
otext=StringProperty('')
|
|
||||||
|
|
||||||
def __init__(self,**kw):
|
|
||||||
self.options = kw.copy()
|
|
||||||
otext = kw.get('otext',kw.get('text'))
|
|
||||||
if kw.get('otext'):
|
|
||||||
del kw['otext']
|
|
||||||
super().__init__(**kw)
|
|
||||||
self.i18n = I18n()
|
|
||||||
self.i18n.addI18nWidget(self)
|
|
||||||
self.otext = otext
|
|
||||||
|
|
||||||
def on_otext(self,o,v=None):
|
|
||||||
self.text = self.i18n(self.otext)
|
|
||||||
|
|
||||||
def changeLang(self,lang):
|
|
||||||
self.lang = lang
|
|
||||||
|
|
||||||
def on_lang(self,o,lang):
|
|
||||||
self.text = self.i18n(self.otext)
|
|
||||||
|
|
||||||
|
@ -86,4 +86,3 @@ class KivyCamera(Image):
|
|||||||
self.update_task = None
|
self.update_task = None
|
||||||
# self.cupture.close()
|
# self.cupture.close()
|
||||||
|
|
||||||
Factory.register('KivyCamera',KivyCamera)
|
|
||||||
|
@ -132,8 +132,6 @@ class QRCodeWidget(FloatLayout):
|
|||||||
img.texture = texture
|
img.texture = texture
|
||||||
img.canvas.ask_update()
|
img.canvas.ask_update()
|
||||||
|
|
||||||
Factory.register('QRCodeWidget',QRCodeWidget)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from kivy.app import runTouchApp
|
from kivy.app import runTouchApp
|
||||||
import sys
|
import sys
|
||||||
|
@ -9,8 +9,20 @@ from .form import Form, StrSearchForm
|
|||||||
from .boxViewer import BoxViewer
|
from .boxViewer import BoxViewer
|
||||||
from .pagescontainer import PageContainer
|
from .pagescontainer import PageContainer
|
||||||
from .hostimage import HostImage
|
from .hostimage import HostImage
|
||||||
|
from .toggleitems import PressableBox, ToggleItems
|
||||||
|
from .twosides import TwoSides
|
||||||
|
from .tab import TabsPanel
|
||||||
|
from .qrdata import QRCodeWidget
|
||||||
|
from .kivycamera import KivyCamera
|
||||||
|
from .filebrowser import FileLoaderBrowser
|
||||||
|
|
||||||
r = Factory.register
|
r = Factory.register
|
||||||
|
r('DataGrid',DataGrid)
|
||||||
|
r('FileLoaderBrowser',FileLoaderBrowser)
|
||||||
|
r('KivyCamera',KivyCamera)
|
||||||
|
r('QRCodeWidget',QRCodeWidget)
|
||||||
|
r('TabsPanel',TabsPanel)
|
||||||
|
r('TwoSides',TwoSides)
|
||||||
r('PageContainer', PageContainer)
|
r('PageContainer', PageContainer)
|
||||||
r('BoxViewer', BoxViewer)
|
r('BoxViewer', BoxViewer)
|
||||||
r('Form', Form)
|
r('Form', Form)
|
||||||
@ -41,6 +53,8 @@ r('PopupMenu',PopupMenu)
|
|||||||
r('HostImage',HostImage)
|
r('HostImage',HostImage)
|
||||||
r('APlayer',APlayer)
|
r('APlayer',APlayer)
|
||||||
r('WrapText',WrapText)
|
r('WrapText',WrapText)
|
||||||
|
r('PressableBox',PressableBox)
|
||||||
|
r('ToggleItems',ToggleItems)
|
||||||
if platform == 'android':
|
if platform == 'android':
|
||||||
r('PhoneButton',PhoneButton)
|
r('PhoneButton',PhoneButton)
|
||||||
r('AWebView',AWebView)
|
r('AWebView',AWebView)
|
||||||
|
@ -57,8 +57,6 @@ class TabsPanel(BGColorBehavior, TabbedPanel):
|
|||||||
desc = d['content']
|
desc = d['content']
|
||||||
self.add_tab(name,text,desc)
|
self.add_tab(name,text,desc)
|
||||||
|
|
||||||
Factory.register('TabsPanel',TabsPanel)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
pass
|
pass
|
||||||
|
@ -28,10 +28,10 @@ class PressableBox(BGColorBehavior, TouchRippleButtonBehavior, BoxLayout):
|
|||||||
def on_press(self,o=None):
|
def on_press(self,o=None):
|
||||||
self.selected()
|
self.selected()
|
||||||
|
|
||||||
def set_data(self,d):
|
def setValue(self,d):
|
||||||
self.user_data = d
|
self.user_data = d
|
||||||
|
|
||||||
def get_data(self):
|
def getValue(self):
|
||||||
return self.user_data
|
return self.user_data
|
||||||
|
|
||||||
class ToggleItems(BGColorBehavior, BoxLayout):
|
class ToggleItems(BGColorBehavior, BoxLayout):
|
||||||
@ -73,7 +73,7 @@ class ToggleItems(BGColorBehavior, BoxLayout):
|
|||||||
c = PressableBox(**kw)
|
c = PressableBox(**kw)
|
||||||
d = desc.get('data')
|
d = desc.get('data')
|
||||||
if d:
|
if d:
|
||||||
c.set_data(d)
|
c.setValue(d)
|
||||||
self.item_widgets.append(c)
|
self.item_widgets.append(c)
|
||||||
self.add_widget(c)
|
self.add_widget(c)
|
||||||
c.bind(on_press=self.select_item)
|
c.bind(on_press=self.select_item)
|
||||||
@ -98,20 +98,18 @@ class ToggleItems(BGColorBehavior, BoxLayout):
|
|||||||
|
|
||||||
def select_item(self,o=None):
|
def select_item(self,o=None):
|
||||||
[i.unselected() for i in self.item_widgets if i != o]
|
[i.unselected() for i in self.item_widgets if i != o]
|
||||||
self.dispatch('on_press',o.get_data())
|
self.dispatch('on_press',o.getValue())
|
||||||
|
|
||||||
def getValue(self):
|
def getValue(self):
|
||||||
for i in self.item_widgets:
|
for i in self.item_widgets:
|
||||||
if i.is_selected():
|
if i.is_selected():
|
||||||
return i.get_data()
|
return i.getValue()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def setValue(self,v):
|
def setValue(self,v):
|
||||||
for i in self.item_widgets:
|
for i in self.item_widgets:
|
||||||
if i.get_data() == v:
|
if i.getValue() == v:
|
||||||
i.selected()
|
i.selected()
|
||||||
self.select_iten(i)
|
self.select_iten(i)
|
||||||
return
|
return
|
||||||
|
|
||||||
Factory.register('PressableBox',PressableBox)
|
|
||||||
Factory.register('ToggleItems',ToggleItems)
|
|
||||||
|
@ -13,9 +13,9 @@ from appPublic.dictObject import DictObject
|
|||||||
from .widgetExt.scrollwidget import ScrollWidget
|
from .widgetExt.scrollwidget import ScrollWidget
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .ready import WidgetReady
|
from .ready import WidgetReady
|
||||||
from .i18n import I18nText
|
|
||||||
from .color_definitions import getColors
|
from .color_definitions import getColors
|
||||||
from .bgcolorbehavior import BGColorBehavior
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
from .baseWidget import Text
|
||||||
|
|
||||||
"""
|
"""
|
||||||
toobar={
|
toobar={
|
||||||
@ -62,7 +62,8 @@ class Tool(ButtonBehavior, BGColorBehavior, BoxLayout):
|
|||||||
|
|
||||||
tsize = CSize(self.opts.text_size)
|
tsize = CSize(self.opts.text_size)
|
||||||
label = self.opts.label or self.opts.name
|
label = self.opts.label or self.opts.name
|
||||||
self.lbl = I18nText( otext=label,
|
self.lbl = Text(i18n=True,
|
||||||
|
text=label,
|
||||||
font_size=int(tsize),
|
font_size=int(tsize),
|
||||||
text_size=(CSize(len(label)), tsize),
|
text_size=(CSize(len(label)), tsize),
|
||||||
height=tsize,
|
height=tsize,
|
||||||
|
@ -56,5 +56,3 @@ class TwoSides(WidgetReady, BoxLayout):
|
|||||||
self.clear_widgets()
|
self.clear_widgets()
|
||||||
self.add_widget(self.portrait_widget)
|
self.add_widget(self.portrait_widget)
|
||||||
|
|
||||||
|
|
||||||
Factory.register('TwoSides',TwoSides)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user