From: Ismaƫl Bouya Date: Wed, 15 Jun 2016 10:42:48 +0000 (+0200) Subject: Allow to find files in pyinstaller X-Git-Tag: 1.0.0~102 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=1b79473633242db1c180e07d7165a5bd837eb62e;hp=4866eb9b13dc329c8a2bb53d410f5d779c165c76;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git Allow to find files in pyinstaller --- diff --git a/helpers/__init__.py b/helpers/__init__.py index c42b378..7dbffdd 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from pygame import * +import sys class Action: action_types = [ @@ -106,7 +107,11 @@ class Key: def draw(self, background_surface): self.surface = self.square().surface() - police = font.Font("Ubuntu-Regular.ttf", 14) + if getattr(sys, 'frozen', False): + police = font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14) + else: + police = font.Font("Ubuntu-Regular.ttf", 14) + text = police.render(self.key_sym, True, (0,0,0)) self.surface.blit(text, (5,5)) background_surface.blit(self.surface, self.position)