From: stack Date: Sat, 20 Apr 2013 12:43:30 +0000 (+0200) Subject: icons path from installed package or script dir X-Git-Url: https://v.licheni.net/stack/code/dboxswitch.git/commitdiff_plain/5eb6beb682e921368745e6b7da5fd749c110251d?ds=inline;hp=cbd58c6f8539c857d0e88065d1ceb8ca503ca0e8 icons path from installed package or script dir --- diff --git a/dboxswitch/settings.py b/dboxswitch/settings.py index 3b7fdb1..b604488 100644 --- a/dboxswitch/settings.py +++ b/dboxswitch/settings.py @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ import os, sys +from apperror import AppError class Settings(): def __init__(self): @@ -42,10 +43,19 @@ class Settings(): self.appname = "dboxswitch" self.appversion = "0.1" - self.icon = os.path.join(__location__,"icon.png") - self.cpicon = os.path.join(__location__,"current-profile.png") - self.delpicon = os.path.join(__location__,"delete.png") - self.addpicon = os.path.join(__location__,"add.png") + if os.path.isdir(os.path.join(__location__,"/icons")): + path = os.path.join(__location__,"/icons") + else: + path = "" + try: + import pkg_resources + path = pkg_resources.resource_filename(__name__, 'icons/') + except: + print "unable to load resource icons" + self.icon = os.path.join(path,"icon.png") + self.cpicon = os.path.join(path,"current-profile.png") + self.delpicon = os.path.join(path,"delete.png") + self.addpicon = os.path.join(path,"add.png") global conf appconf = Settings()