From 4700ba32a3cce71bb72f3aeecd1c8fec83102214 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 26 Sep 2022 13:23:00 +0800 Subject: [PATCH] bugfix --- kivyblocks/baseWidget.py | 24 ++++++++++++++++++------ kivyblocks/dataloader.py | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/kivyblocks/baseWidget.py b/kivyblocks/baseWidget.py index 82dbed5..9454f1a 100755 --- a/kivyblocks/baseWidget.py +++ b/kivyblocks/baseWidget.py @@ -256,11 +256,13 @@ class Modal(VBox): content = DictProperty(None) auto_open = BooleanProperty(True) auto_dismiss = BooleanProperty(True) - position = OptionProperty('tc',options=['tl', 'tc', 'tr', + target = StringProperty(None) + position = OptionProperty('cc',options=['tl', 'tc', 'tr', 'cl', 'cc', 'cr', 'bl', 'bc', 'br']) def __init__(self, **kw): + self._target = None SUPER(Modal, self, kw) self.register_event_type('on_open') self.register_event_type('on_pre_open') @@ -283,7 +285,15 @@ class Modal(VBox): return super().on_touch_down(touch) - def set_modal_position(self, w): + def set_modal_position(self): + if self._target is None: + if self.target is None: + w = Window + else: + w = Factory.Blocks.getWidgetById(self.target) + if w is None: + w = Window + self._target = w xn = self.position[1] yn = self.position[0] x, y = 0, 0 @@ -295,7 +305,7 @@ class Modal(VBox): x = 0 if yn == 'c': y = (w.height - self.height) / 2 - elif yn == 'b': + elif yn == 't': y = w.height - self.height if y < 0: y = 0 @@ -308,16 +318,18 @@ class Modal(VBox): if self.parent: return self.dispatch('on_pre_open') - if widget is None: - widget = Window - self.set_modal_position(widget) + self.set_modal_position() Window.add_widget(self) self.dispatch('on_open') + if self._target != Window: + self._target.disable() def dismiss(self, *args): self.dispatch('on_pre_dismiss') self.dispatch('on_dismiss') Window.remove_widget(self) + if self._target != Window: + self._Target.enable() def on_open(self, *args): pass diff --git a/kivyblocks/dataloader.py b/kivyblocks/dataloader.py index 9171d46..c2987cc 100644 --- a/kivyblocks/dataloader.py +++ b/kivyblocks/dataloader.py @@ -129,7 +129,7 @@ class DataLoader(EventDispatcher): class HttpDataLoader(DataLoader): def load(self, *args, **kw): app = App.get_running_app() - url = app.realurl(self.data_user.url) + url = self.data_user.url method = self.data_user.method params = self.data_user.params.copy() params.update({