diff 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
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Apr 06 16:11:00 2018 +0200
+++ b/cagou/core/cagou_main.py	Fri Apr 06 16:12:14 2018 +0200
@@ -376,9 +376,20 @@
     def _import_kv(self):
         """import all kv files in cagou.kv"""
         path = os.path.dirname(cagou.kv.__file__)
-        for kv_path in glob.glob(os.path.join(path, "*.kv")):
-            Builder.load_file(kv_path)
-            log.debug(u"kv file {} loaded".format(kv_path))
+        kv_files = glob.glob(os.path.join(path, "*.kv"))
+        # we want to be sure that base.kv is loaded first
+        # as it override some Kivy widgets properties
+        for kv_file in kv_files:
+            if kv_file.endswith('base.kv'):
+                kv_files.remove(kv_file)
+                kv_files.insert(0, kv_file)
+                break
+        else:
+            raise exceptions.InternalError("base.kv is missing")
+
+        for kv_file in kv_files:
+            Builder.load_file(kv_file)
+            log.debug(u"kv file {} loaded".format(kv_file))
 
     def _import_plugins(self):
         """import all plugins"""