Example #1
0
    def test_view_widget(self):

        # dummy button with state key
        btn = {'state': 'normal'}

        # provide path from previously computed data
        lfp_list = [
            file for file in listdir(self.fp) if file.endswith(('lfr', 'lfp'))
        ]
        self.cfg.params[self.cfg.lfp_path] = join(self.fp, lfp_list[0])

        wid = ViewWidget(self.root, cfg=self.cfg, sta=self.sta, btn=btn)

        # verify view button has been disabled after view widget instantiation
        self.assertEqual(btn['state'], 'disabled')

        self.pump_events()
        wid.btn_mode.focus_set()
        wid.btn_auto.event_generate('<Return>')
        wid.btn_auto.focus_set()
        wid.btn_auto.event_generate('<Return>')
        self.pump_events()

        wid.destroy()

        # verify view button has been enabled
        self.assertEqual(btn['state'], 'normal')
Example #2
0
    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)
Example #3
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 #4
0
    def instantiate_viewer(self, btn):

        self.view_frame = tk.Toplevel(padx=PX, pady=PY)  # open window
        self.view_frame.resizable(width=0,
                                  height=0)  # make window not resizable
        ViewWidget(self.view_frame, cfg=self.cfg, sta=self.sta,
                   btn=btn).pack(expand="no", fill="both")
Example #5
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)
Example #6
0
    def test_viewer(self):

        try:
            import tkinter as tk
        except ImportError:
            import Tkinter as tk

        # dummy button with state key
        btn = {'state': 'normal'}

        # instantiate viewer
        self.view_frame = tk.Toplevel(padx=PX, pady=PY)  # open window
        self.view_frame.resizable(width=0,
                                  height=0)  # make window not resizable
        ViewWidget(self.view_frame, cfg=self.cfg, sta=self.sta,
                   btn=btn).pack(expand="no", fill="both")

        # close frame
        self.view_frame.destroy()

        return True