summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/icons.py
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/gui/icons.py')
-rw-r--r--jfr_playoff/gui/icons.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/jfr_playoff/gui/icons.py b/jfr_playoff/gui/icons.py
new file mode 100644
index 0000000..94d3d63
--- /dev/null
+++ b/jfr_playoff/gui/icons.py
@@ -0,0 +1,31 @@
+import os, sys
+
+import Tkinter as tk
+
+class GuiImage(object):
+ icons = {}
+
+ @staticmethod
+ def __get_base_path():
+ try:
+ return os.path.join(sys._MEIPASS, 'res').decode(
+ sys.getfilesystemencoding())
+ except:
+ return os.path.abspath(os.path.dirname(__file__)).decode(
+ sys.getfilesystemencoding())
+
+ @staticmethod
+ def get_path(imageType, code, fileType='gif'):
+ return os.path.join(
+ GuiImage.__get_base_path(), imageType, '%s.%s' % (code, fileType))
+
+ @staticmethod
+ def __get_image(imageType, cache, code, fileType='gif'):
+ if code not in cache:
+ path = GuiImage.get_path(imageType, code, fileType)
+ cache[code] = tk.PhotoImage(file=path)
+ return cache[code]
+
+ @staticmethod
+ def get_icon(code):
+ return GuiImage.__get_image('icons', GuiImage.icons, code)