bugfix
This commit is contained in:
parent
94d898ce13
commit
51315fdaee
@ -20,10 +20,11 @@ class BGColorBehavior(object):
|
||||
fg,bg= getColors(color_level,selected=True)
|
||||
self.selected_bgcolor = bg
|
||||
self.selected_fgcolor = fg
|
||||
self.on_bgcolor()
|
||||
# self.on_bgcolor()
|
||||
|
||||
self.bind(size=self.onSize_bgcolor_behavior,
|
||||
pos=self.onSize_bgcolor_behavior)
|
||||
self.bind(children=self.on_bgcolor)
|
||||
|
||||
def onSize_bgcolor_behavior(self,o,v=None):
|
||||
if not hasattr(self,'rect'):
|
||||
|
@ -543,11 +543,15 @@ class Blocks(EventDispatcher):
|
||||
return None
|
||||
|
||||
# desc = self.valueExpr(desc)
|
||||
widget = self.w_build(desc)
|
||||
self.dispatch('on_built',widget)
|
||||
if hasattr(widget,'ready'):
|
||||
widget.ready()
|
||||
return widget
|
||||
try:
|
||||
widget = self.w_build(desc)
|
||||
self.dispatch('on_built',widget)
|
||||
if hasattr(widget,'ready'):
|
||||
widget.ready()
|
||||
return widget
|
||||
except Exception as e:
|
||||
self.dispatch('on_failed',e)
|
||||
return None
|
||||
|
||||
if not (isinstance(desc, DictObject) or isinstance(desc, dict)):
|
||||
print('Block: desc must be a dict object',
|
||||
@ -555,7 +559,8 @@ class Blocks(EventDispatcher):
|
||||
self.dispatch('on_failed',Exception('miss url'))
|
||||
return
|
||||
|
||||
while desc['widgettype'] == "urlwidget":
|
||||
widgettype = desc.get('widgettype')
|
||||
while widgettype == "urlwidget":
|
||||
opts = desc.get('options',{}).copy()
|
||||
extend = desc.get('extend')
|
||||
addon = None
|
||||
@ -578,6 +583,11 @@ class Blocks(EventDispatcher):
|
||||
|
||||
if addon:
|
||||
desc = dictExtend(desc,addon)
|
||||
widgettype = desc.get('widgettype')
|
||||
if widgettype is None:
|
||||
print('Block: desc must be a dict object',
|
||||
desc,type(desc))
|
||||
return None
|
||||
return doit(desc)
|
||||
|
||||
@classmethod
|
||||
|
BIN
kivyblocks/imgs/backword.png
Normal file
BIN
kivyblocks/imgs/backword.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
BIN
kivyblocks/imgs/right_menu.png
Normal file
BIN
kivyblocks/imgs/right_menu.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -22,8 +22,10 @@ from .graph import Graph, MeshLinePlot, MeshStemPlot, LinePlot, \
|
||||
from .mapview import MapView
|
||||
from .chart2d import Chart2d
|
||||
from .message import Conform
|
||||
from .pagepanel import PagePanel
|
||||
|
||||
r = Factory.register
|
||||
r('PagePanel', PagePanel)
|
||||
r('Conform', Conform)
|
||||
r('Chart2d', Chart2d)
|
||||
r('Popup', Popup)
|
||||
|
@ -7,6 +7,7 @@ from kivy.uix.gridlayout import GridLayout
|
||||
from kivy.uix.label import Label
|
||||
from kivy.app import App
|
||||
from kivy.clock import Clock
|
||||
from kivy.factory import Factory
|
||||
|
||||
from appPublic.dictObject import DictObject
|
||||
|
||||
@ -107,15 +108,17 @@ class Toolbar(BoxLayout):
|
||||
"""
|
||||
Toolpage options
|
||||
{
|
||||
img_size=1.5,
|
||||
text_size=0.7,
|
||||
img_size:1.5,
|
||||
text_size:0.7,
|
||||
tool_at:"left","right","top","bottom",
|
||||
color_level=0,
|
||||
color_level:0,
|
||||
show_name:
|
||||
tools:[
|
||||
{
|
||||
"name":"myid",
|
||||
"img_src":"gggggg",
|
||||
"text":"gggggg"
|
||||
"flush":true
|
||||
"url":"ggggggggg"
|
||||
},
|
||||
...
|
||||
@ -123,12 +126,21 @@ Toolpage options
|
||||
|
||||
"""
|
||||
class ToolPage(BGColorBehavior, BoxLayout):
|
||||
def __init__(self,color_level=-1,radius=[],tool_at='top', **opts):
|
||||
def __init__(self,color_level=-1,radius=[],
|
||||
show_name=None, tool_at='top', **opts):
|
||||
self.opts = DictObject(**opts)
|
||||
if tool_at in [ 'top','bottom']:
|
||||
orient = 'vertical'
|
||||
else:
|
||||
orient = 'horizontal'
|
||||
names = [i.name for i in self.opts.tools]
|
||||
|
||||
if not show_name or \
|
||||
not show_name not in names:
|
||||
show_name = self.opts.tools[0].name
|
||||
|
||||
self.content_widgets = {}
|
||||
self.show_name = show_name
|
||||
self.color_level=self.opts.color_level or 0
|
||||
self.sub_radius = self.opts.radius
|
||||
self.tool_at = tool_at
|
||||
@ -139,7 +151,14 @@ class ToolPage(BGColorBehavior, BoxLayout):
|
||||
self.content = None
|
||||
self.toolbar = None
|
||||
self.init()
|
||||
# self.show_firstpage()
|
||||
Clock.schedule_once(self.show_page, 0.5)
|
||||
|
||||
def show_page(self, *args):
|
||||
toggle_items = self.toolbar.toggle_items
|
||||
for c in toggle_items.children:
|
||||
cvalue = c.getValue()
|
||||
if cvalue == self.show_name:
|
||||
c.dispatch('on_press')
|
||||
|
||||
def on_size(self,obj,size):
|
||||
if self.content is None:
|
||||
@ -153,13 +172,6 @@ class ToolPage(BGColorBehavior, BoxLayout):
|
||||
self.content.height = self.height
|
||||
self.content.width = self.width - self.toolbar.width
|
||||
|
||||
def showPage(self,obj):
|
||||
self._show_page(obj.opts)
|
||||
|
||||
def show_firstpage(self,t=None):
|
||||
d = self.children[0]
|
||||
d.dispatch('on_press', d)
|
||||
|
||||
def init(self):
|
||||
self.initFlag = True
|
||||
self.mywidgets = {}
|
||||
@ -185,4 +197,34 @@ class ToolPage(BGColorBehavior, BoxLayout):
|
||||
else:
|
||||
self.add_widget(self.content)
|
||||
self.add_widget(self.toolbar)
|
||||
toggle_items = self.toolbar.toggle_items
|
||||
for t in toggle_items.children:
|
||||
t.bind(on_press=self.on_press_handle)
|
||||
|
||||
def get_tool_by_name(self,name):
|
||||
for t in self.opts.tools:
|
||||
if t.name == name:
|
||||
return t
|
||||
return None
|
||||
|
||||
def build_widget(self, url):
|
||||
desc = {
|
||||
"widgettype":"urlwidget",
|
||||
"options":{
|
||||
"url":url
|
||||
}
|
||||
}
|
||||
b = Factory.Blocks()
|
||||
return b.widgetBuild(desc)
|
||||
|
||||
def on_press_handle(self, o):
|
||||
name = o.getValue()
|
||||
t = self.get_tool_by_name(name)
|
||||
w = self.content_widgets.get(name)
|
||||
if w is None or t.fresh:
|
||||
w = self.build_widget(t.url)
|
||||
self.content_widgets[name] = w
|
||||
if w:
|
||||
self.content.clear_widgets()
|
||||
self.content.add_widget(w)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user