comparison cagou/core/cagou_main.py @ 130:0ec3c3c0ed92

core (kv): new base.kv to handle default properties overriding on Kivy widgets
author Goffi <goffi@goffi.org>
date Fri, 06 Apr 2018 16:12:14 +0200
parents cd99f70ea592
children 36fc269e2a32
comparison
equal deleted inserted replaced
129:0704f3be65cb 130:0ec3c3c0ed92
374 ## plugins & kv import ## 374 ## plugins & kv import ##
375 375
376 def _import_kv(self): 376 def _import_kv(self):
377 """import all kv files in cagou.kv""" 377 """import all kv files in cagou.kv"""
378 path = os.path.dirname(cagou.kv.__file__) 378 path = os.path.dirname(cagou.kv.__file__)
379 for kv_path in glob.glob(os.path.join(path, "*.kv")): 379 kv_files = glob.glob(os.path.join(path, "*.kv"))
380 Builder.load_file(kv_path) 380 # we want to be sure that base.kv is loaded first
381 log.debug(u"kv file {} loaded".format(kv_path)) 381 # as it override some Kivy widgets properties
382 for kv_file in kv_files:
383 if kv_file.endswith('base.kv'):
384 kv_files.remove(kv_file)
385 kv_files.insert(0, kv_file)
386 break
387 else:
388 raise exceptions.InternalError("base.kv is missing")
389
390 for kv_file in kv_files:
391 Builder.load_file(kv_file)
392 log.debug(u"kv file {} loaded".format(kv_file))
382 393
383 def _import_plugins(self): 394 def _import_plugins(self):
384 """import all plugins""" 395 """import all plugins"""
385 self.default_wid = None 396 self.default_wid = None
386 plugins_path = os.path.dirname(cagou.plugins.__file__) 397 plugins_path = os.path.dirname(cagou.plugins.__file__)