This commit is contained in:
yumoqing 2021-02-07 19:49:10 +08:00
parent b51cd43b73
commit ac8ff8b36e
2 changed files with 22 additions and 8 deletions

View File

@ -627,6 +627,7 @@ class Blocks(EventDispatcher):
@classmethod
def getWidgetById(self,id,from_widget=None):
print('getWidgetById(%s,%s) ...' % (id, from_widget))
def find_widget_by_id(id, from_widget):
if id=='self':
return from_widget
@ -641,12 +642,6 @@ class Blocks(EventDispatcher):
ret = find_widget_by_id(id,from_widget=c)
if ret:
return ret
app = App.get_running_app()
if from_widget == app.root:
if Window.fullscreen == True:
w = app.fs_widget
if w:
return find_widget_by_id(id, w)
return None
ids = id.split('.')
@ -654,18 +649,29 @@ class Blocks(EventDispatcher):
fid = ids[0]
if fid == '/self' or fid == 'root':
from_widget = app.root
ids[0] = 'self'
if len(ids) == 1:
return from_widget
ids = ids[1:]
if fid == 'Window':
from_widget == Window
ids[0] = 'self'
if len(ids) == 1:
return from_widget
ids = ids[1:]
if fid == 'app':
return app
if from_widget is None:
from_widget = app.root
for id in ids:
print('finding', id)
w = find_widget_by_id(id,from_widget=from_widget)
if w is None \
and id == ids[0] \
and Window.fullscreen == True \
and app.root != app.fs_widget:
w = find_widget_by_id(id, app.fs_widget)
if w is None:
print(id, 'not found ....')
return None
from_widget = w
return w

View File

@ -25,6 +25,12 @@ description file format
self.bind(source=self.load_text)
if self.source:
Clock.schedule_once(self.load_text, 0.3)
self.bind(size=self.setChildMinWidth)
def setChildMinWidth(self, *args):
print('size changed')
for c in self._inner.children:
c.width = self.width
def load_text(self, *args):
print('source fired, hahaha', *args)
@ -52,6 +58,7 @@ description file format
"text":txt,
"size_hint_x":None,
"width":self.width,
"minimum_width":self.width,
"size_hint_y":None,
"markup":True,
"wrap":True,
@ -95,6 +102,7 @@ description file format
"wrap":True,
"size_hint_x":None,
"width":self.width,
"minimum_width":self.width,
"markup":True,
"valign":"middle",
"halign":"left"