blocks add mixins behavior support

This commit is contained in:
yumoqing 2022-11-14 17:22:30 +08:00
parent 9b6084e15d
commit eea36456f1
3 changed files with 3 additions and 9 deletions

View File

@ -136,7 +136,6 @@ class Blocks(EventDispatcher):
'klass':Factory.get(n), 'klass':Factory.get(n),
'opts':d 'opts':d
}) })
print('mixins=', mixins)
env['klasses'] = klasses env['klasses'] = klasses
ids = [ i for i in range(len(klasses))] ids = [ i for i in range(len(klasses))]
ids.reverse() ids.reverse()
@ -144,12 +143,11 @@ class Blocks(EventDispatcher):
code = f"""class ClassX{klass_cnt}({klasslist}): code = f"""class ClassX{klass_cnt}({klasslist}):
def __init__(self): def __init__(self):
for i in range(len(klasses)): for i in range(len(klasses)):
print(klasses[i]['opts'])
klasses[i]['klass'].__init__(self, **klasses[i]['opts']) klasses[i]['klass'].__init__(self, **klasses[i]['opts'])
x = ClassX{klass_cnt}() x = ClassX{klass_cnt}()
""" """
print(code) # print(code)
exec(code, env, lenv) exec(code, env, lenv)
w = lenv.get('x', None) w = lenv.get('x', None)
klass_cnt += 1 klass_cnt += 1

View File

@ -28,17 +28,11 @@ class ModalBehavior(object):
self.open() self.open()
def on_touchdown(self, o, touch): def on_touchdown(self, o, touch):
print('on_touchdown() called')
if not self.collide_point(touch.x, touch.y): if not self.collide_point(touch.x, touch.y):
if self.auto_dismiss: if self.auto_dismiss:
print('on_touchdown():auto_dismiss()')
self.dispatch('on_pre_dismiss') self.dispatch('on_pre_dismiss')
self.dismiss() self.dismiss()
return True return True
else:
print('on_touchdown(): not auto_dismiss')
else:
print('on_touchdown():inside modal')
def on_target(self, *args): def on_target(self, *args):
self._target = None self._target = None

View File

@ -1,6 +1,7 @@
from kivyblocks.setconfig import config_set from kivyblocks.setconfig import config_set
from kivyblocks.blocksapp import BlocksApp from kivyblocks.blocksapp import BlocksApp
from kivyblocks.blocks import registerWidget, Blocks from kivyblocks.blocks import registerWidget, Blocks
from kivyblocks.i18n import I18n
import kivyblocks.register import kivyblocks.register
from kivyblocks.script import set_script_env from kivyblocks.script import set_script_env
@ -9,4 +10,5 @@ class ScriptApp(BlocksApp):
if __name__ == '__main__': if __name__ == '__main__':
set_script_env('userid', 'testuser') set_script_env('userid', 'testuser')
i18n = I18n()
ScriptApp().run() ScriptApp().run()