aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-26 00:18:52 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-26 00:18:52 +0200
commitbb69f62e140efde8e93f7b62bf8723113bf30b06 (patch)
treef1426515f90010e21b3832351c604a028c788a05
parent4b2d79ca27dcbb85465829595ad81cec5fc63983 (diff)
downloadMusicSampler-bb69f62e140efde8e93f7b62bf8723113bf30b06.tar.gz
MusicSampler-bb69f62e140efde8e93f7b62bf8723113bf30b06.tar.zst
MusicSampler-bb69f62e140efde8e93f7b62bf8723113bf30b06.zip
Make kivy compatible with pyinstaller
-rw-r--r--helpers/__init__.py10
-rw-r--r--music_sampler.py7
-rw-r--r--music_sampler.spec3
-rw-r--r--musicsampler.kv17
4 files changed, 27 insertions, 10 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py
index 40a96af..70667fd 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -1 +1,11 @@
1# -*- coding: utf-8 -*- 1# -*- coding: utf-8 -*-
2import sys
3import os
4
5def path():
6 if getattr(sys, 'frozen', False):
7 return sys._MEIPASS + "/"
8 else:
9 path = os.path.dirname(os.path.realpath(__file__))
10 return path + "/../"
11
diff --git a/music_sampler.py b/music_sampler.py
index 0d9a7a9..7c0fc32 100644
--- a/music_sampler.py
+++ b/music_sampler.py
@@ -4,10 +4,15 @@ from kivy.uix.relativelayout import RelativeLayout
4from kivy.properties import ListProperty, StringProperty 4from kivy.properties import ListProperty, StringProperty
5from kivy.clock import Clock 5from kivy.clock import Clock
6from kivy.core.window import Window 6from kivy.core.window import Window
7 7from kivy.lang import Builder
8from helpers.key import Key 8from helpers.key import Key
9from helpers.mapping import Mapping 9from helpers.mapping import Mapping
10 10
11import sys
12
13if getattr(sys, 'frozen', False):
14 Builder.load_file(sys._MEIPASS + '/musicsampler.kv')
15
11class PlayList(RelativeLayout): 16class PlayList(RelativeLayout):
12 playlist = ListProperty([]) 17 playlist = ListProperty([])
13 18
diff --git a/music_sampler.spec b/music_sampler.spec
index 912edb7..fca4005 100644
--- a/music_sampler.spec
+++ b/music_sampler.spec
@@ -6,7 +6,8 @@ a = Analysis(['music_sampler.py'],
6 binaries=None, 6 binaries=None,
7 datas=[ 7 datas=[
8 ('config.yml', '.'), 8 ('config.yml', '.'),
9 ('fonts/*', 'fonts') 9 ('fonts/*', 'fonts'),
10 ('musicsampler.kv', '.')
10 ], 11 ],
11 hiddenimports=[ 12 hiddenimports=[
12 'six', 13 'six',
diff --git a/musicsampler.kv b/musicsampler.kv
index 17be1f5..3bf344e 100644
--- a/musicsampler.kv
+++ b/musicsampler.kv
@@ -1,4 +1,5 @@
1#:import math math 1#:import math math
2#:import h helpers
2 3
3<Key>: 4<Key>:
4 pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x 5 pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x
@@ -32,7 +33,7 @@
32 width: self.line_width 33 width: self.line_width
33 Label: 34 Label:
34 id: key_label 35 id: key_label
35 font_name: "fonts/Ubuntu-B.ttf" 36 font_name: h.path() + "fonts/Ubuntu-B.ttf"
36 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size)) 37 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size))
37 color: 0, 0, 0, 1 38 color: 0, 0, 0, 1
38 text: self.parent.key_sym 39 text: self.parent.key_sym
@@ -44,7 +45,7 @@
44 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 45 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
45 Label: 46 Label:
46 id: key_description_title 47 id: key_description_title
47 font_name: "fonts/Ubuntu-Regular.ttf" 48 font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
48 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) 49 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2))
49 color: 0, 0, 0, 1 50 color: 0, 0, 0, 1
50 text: self.parent.description_title 51 text: self.parent.description_title
@@ -55,7 +56,7 @@
55 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 56 center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5
56 Label: 57 Label:
57 id: key_description 58 id: key_description
58 font_name: "fonts/Ubuntu-Regular.ttf" 59 font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
59 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) 60 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2))
60 color: 0, 0, 0, 1 61 color: 0, 0, 0, 1
61 text: "\n".join(self.parent.description) 62 text: "\n".join(self.parent.description)
@@ -121,7 +122,7 @@
121 size: self.width, self.height 122 size: self.width, self.height
122 Label: 123 Label:
123 id: action_list_title 124 id: action_list_title
124 font_name: "fonts/Ubuntu-B.ttf" 125 font_name: h.path() + "fonts/Ubuntu-B.ttf"
125 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 126 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
126 color: 0, 0, 0, 1 127 color: 0, 0, 0, 1
127 text: self.parent.action_title 128 text: self.parent.action_title
@@ -132,7 +133,7 @@
132 size: self.texture_size[0], self.parent.height 133 size: self.texture_size[0], self.parent.height
133 Label: 134 Label:
134 id: action_list_icons 135 id: action_list_icons
135 font_name: "fonts/Symbola.ttf" 136 font_name: h.path() + "fonts/Symbola.ttf"
136 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 137 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
137 line_height: 1.2 # FIXME: Donner la bonne taille de label 138 line_height: 1.2 # FIXME: Donner la bonne taille de label
138 color: 0, 0, 0, 1 139 color: 0, 0, 0, 1
@@ -144,7 +145,7 @@
144 size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size 145 size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size
145 Label: 146 Label:
146 id: action_list_names 147 id: action_list_names
147 font_name: "fonts/Ubuntu-Regular.ttf" 148 font_name: h.path() + "fonts/Ubuntu-Regular.ttf"
148 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 149 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
149 color: 0, 0, 0, 1 150 color: 0, 0, 0, 1
150 text: "\n".join(map(lambda x: x[1], self.parent.action_list)) 151 text: "\n".join(map(lambda x: x[1], self.parent.action_list))
@@ -165,7 +166,7 @@
165 size: self.width, self.height 166 size: self.width, self.height
166 Label: 167 Label:
167 id: playlist_icons 168 id: playlist_icons
168 font_name: "fonts/Symbola.ttf" 169 font_name: h.path() + "fonts/Symbola.ttf"
169 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 170 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
170 line_height: 1.2 # FIXME: Donner la bonne taille de label 171 line_height: 1.2 # FIXME: Donner la bonne taille de label
171 color: 0, 0, 0, 1 172 color: 0, 0, 0, 1
@@ -177,7 +178,7 @@
177 size: self.texture_size[0], self.parent.height 178 size: self.texture_size[0], self.parent.height
178 Label: 179 Label:
179 id: playlist_names 180 id: playlist_names
180 font_name: "fonts/Ubuntu-Regular.ttf" # FIXME: Mettre en gras quand c'est en cours 181 font_name: h.path() + "fonts/Ubuntu-Regular.ttf" # FIXME: Mettre en gras quand c'est en cours
181 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) 182 font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10))
182 color: 0, 0, 0, 1 183 color: 0, 0, 0, 1
183 text: "\n".join(map(lambda x: x[1], self.parent.playlist)) 184 text: "\n".join(map(lambda x: x[1], self.parent.playlist))