Example #1
0
class PlenopticamApp(tk.Tk):

    REL_PATH = os.path.join('icns', '1055104.gif')

    def __init__(self, parent):

        # inheritance
        tk.Tk.__init__(self, parent)
        self.parent = parent

        # window title
        self.wm_title("PlenoptiCam-v" + __version__)

        # icon handling
        self.icon_handling()

        # initialize parameters
        self.sta = PlenopticamStatus()

        # instantiate controller
        self.ctrl_wid = CtrlWidget(self)
        self.ctrl_wid.pack(fill='both',
                           expand=True,
                           side='top',
                           padx=PX,
                           pady=PY)

        # instantiate view
        self.view_wid = ViewWidget(self)
        self.view_wid.pack(fill='both',
                           expand=True,
                           side='bottom',
                           padx=PX,
                           pady=PY)

    def icon_handling(self):
        ''' use OS temp folder if present or current working directory '''

        # icon path for app bundle (tmp) or non-bundled package (cwd)
        cwd = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                           self.REL_PATH)
        fp = os.path.join(sys._MEIPASS, self.REL_PATH) if hasattr(
            sys, '_MEIPASS') else cwd

        if sys.platform == 'linux':
            # load icon on linux
            logo = tk.PhotoImage(file=fp)
            self.call('wm', 'iconphoto', self._w, logo)

        elif sys.platform == 'win32':
            # generate blank window icon
            _, ICON_PATH = mkstemp()
            with open(ICON_PATH, 'wb') as icon_file:
                icon_file.write(ICON)

            # load icon on Windows
            fp = fp.replace('gif', 'ico')
            fp = ICON_PATH if not os.path.exists(fp) else fp
            self.iconbitmap(fp)
            self.wm_iconbitmap(default=fp)
Example #2
0
class PlenopticamApp(tk.Tk):
    def __init__(self, parent):

        # inheritance
        tk.Tk.__init__(self, parent)
        self.parent = parent

        # window title
        self.wm_title("Plenopticam-" + __version__)

        # icon handling
        if sys.platform == 'win32':
            self.wm_iconbitmap(default=ICON_PATH)
            cwd = sys._MEIPASS if hasattr(sys, '_MEIPASS') else os.getcwd()
            fp = os.path.join(cwd, 'icns', '1055104.ico')
            fp = fp if os.path.exists(fp) else ICON_PATH
            self.iconbitmap(fp)

        # initialize parameters
        self.sta = PlenopticamStatus()

        # instantiate controller
        self.ctrl_wid = CtrlWidget(self)
        self.ctrl_wid.pack(fill='both',
                           expand=True,
                           side='top',
                           padx=PX,
                           pady=PY)

        # instantiate view
        self.view_wid = ViewWidget(self)
        self.view_wid.pack(fill='both',
                           expand=True,
                           side='bottom',
                           padx=PX,
                           pady=PY)

        # enable tkinter resizing
        self.resizable(True, False)