From 8a4bdc92904ceda54cf43551346a9a36e33d53a1 Mon Sep 17 00:00:00 2001 From: Kliment Yanev Date: Fri, 18 Nov 2011 10:49:29 +0100 Subject: [PATCH] Fix path handling when frozen (__file__ should be avoided in the future, this is a workaround) --- xybuttons.py | 10 ++++++++-- zbuttons.py | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xybuttons.py b/xybuttons.py index 0a91b05..a47f441 100644 --- a/xybuttons.py +++ b/xybuttons.py @@ -1,9 +1,13 @@ import wx, os, math from bufferedcanvas import * -def imagefile(filename): - return os.path.join(os.path.dirname(__file__), "images", filename) +def imagefile(filename): + if os.path.exists(os.path.join(os.path.dirname(__file__), "images", filename)): + return os.path.join(os.path.dirname(__file__), "images", filename) + else: + return os.path.join(os.path.split(os.path.split(__file__)[0])[0], "images", filename) + def sign(n): if n < 0: return -1 elif n > 0: return 1 @@ -254,6 +258,8 @@ class XYButtons(BufferedCanvas): self.quadrant = 2 elif evt.GetKeyCode() == wx.WXK_RIGHT: self.quadrant = 0 + elif evt.GetKeyCode() == wx.WXK_SPACE: + pass else: evt.Skip() return diff --git a/zbuttons.py b/zbuttons.py index 567f1a8..43fe6c6 100644 --- a/zbuttons.py +++ b/zbuttons.py @@ -2,7 +2,12 @@ import wx, os, math from bufferedcanvas import * def imagefile(filename): - return os.path.join(os.path.dirname(__file__), "images", filename) + if os.path.exists(os.path.join(os.path.dirname(__file__), "images", filename)): + return os.path.join(os.path.dirname(__file__), "images", filename) + else: + return os.path.join(os.path.split(os.path.split(__file__)[0])[0], "images", filename) + + def sign(n): if n < 0: return -1