質問編集履歴

1

コードの追記

2018/01/17 12:55

投稿

isopyon
isopyon

スコア8

test CHANGED
File without changes
test CHANGED
@@ -27,3 +27,207 @@
27
27
  こちらのサイトを参考にexe化しました
28
28
 
29
29
  https://www.closetoyou.jp/kivy/introduction-to-kivy16/
30
+
31
+
32
+
33
+
34
+
35
+ 追記
36
+
37
+ 下記のコードで試したのですが、やはりexe化の際にエラーがでてきます。
38
+
39
+
40
+
41
+ OS windows10
42
+
43
+
44
+
45
+
46
+
47
+ 使用ファイル
48
+
49
+ ・main.py
50
+
51
+ ・timer.kv
52
+
53
+ ・default.mp3
54
+
55
+
56
+
57
+ >pyinstaller --noconsole main.py
58
+
59
+ >pyinstaller main.spec
60
+
61
+
62
+
63
+ ```python
64
+
65
+ from kivy.app import App
66
+
67
+ from kivy.uix.screenmanager import ScreenManager, Screen
68
+
69
+ from kivy.core.audio import SoundLoader
70
+
71
+ from kivy.resources import resource_add_path
72
+
73
+ import sys
74
+
75
+
76
+
77
+ if hasattr(sys, '_MEIPASS'):
78
+
79
+ resource_add_path(sys._MEIPASS)
80
+
81
+
82
+
83
+ sm = ScreenManager()
84
+
85
+ endSound = SoundLoader.load('default.mp3')
86
+
87
+ endSound.volume = 0.1
88
+
89
+
90
+
91
+
92
+
93
+ class TimerScreen(Screen):
94
+
95
+
96
+
97
+ def start(self):
98
+
99
+ endSound.play()
100
+
101
+
102
+
103
+ def stop(self):
104
+
105
+ endSound.stop()
106
+
107
+
108
+
109
+
110
+
111
+ class TimerApp(App):
112
+
113
+
114
+
115
+ def build(self):
116
+
117
+ sm.add_widget(TimerScreen(name='time'))
118
+
119
+ return sm
120
+
121
+
122
+
123
+
124
+
125
+ if __name__ == '__main__':
126
+
127
+ TimerApp().run()
128
+
129
+
130
+
131
+ ```
132
+
133
+
134
+
135
+ ```kv
136
+
137
+ #:kivy 1.10.0
138
+
139
+ <TimerScreen>:
140
+
141
+ BoxLayout:
142
+
143
+ Button:
144
+
145
+ text: 'start'
146
+
147
+ on_press: root.start()
148
+
149
+ Button:
150
+
151
+ text: 'stop'
152
+
153
+ on_press: root.stop()
154
+
155
+
156
+
157
+ ```
158
+
159
+
160
+
161
+ ```spec
162
+
163
+ # -*- mode: python -*-
164
+
165
+ from kivy.deps import sdl2, glew
166
+
167
+ block_cipher = None
168
+
169
+
170
+
171
+
172
+
173
+ a = Analysis(['main.py'],
174
+
175
+ pathex=['D:\Users\UserName\Documents\kivy_project_files\20180117 timer'],
176
+
177
+ binaries=[],
178
+
179
+ datas=[('default.mp3', '.'), ('timer.kv', '.')],
180
+
181
+ hiddenimports=[],
182
+
183
+ hookspath=[],
184
+
185
+ runtime_hooks=[],
186
+
187
+ excludes=[],
188
+
189
+ win_no_prefer_redirects=False,
190
+
191
+ win_private_assemblies=False,
192
+
193
+ cipher=block_cipher)
194
+
195
+ pyz = PYZ(a.pure, a.zipped_data,
196
+
197
+ cipher=block_cipher)
198
+
199
+ exe = EXE(pyz,
200
+
201
+ a.scripts,
202
+
203
+ exclude_binaries=True,
204
+
205
+ name='main',
206
+
207
+ debug=False,
208
+
209
+ strip=False,
210
+
211
+ upx=True,
212
+
213
+ console=False )
214
+
215
+ coll = COLLECT(exe,
216
+
217
+ a.binaries,
218
+
219
+ a.zipfiles,
220
+
221
+ a.datas,
222
+
223
+ *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
224
+
225
+ strip=False,
226
+
227
+ upx=True,
228
+
229
+ name='main')
230
+
231
+
232
+
233
+ ```