How to use the plenopticam.gui.constants.PX function in plenopticam

To help you get started, we’ve selected a few plenopticam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hahnec / plenopticam / plenopticam / gui / widget_cnfg.py View on Github external
self.obj_ents = {}

        # generate settings properties using dict consisting of lists containing names and types
        PROPERTIES = dict(zip(c.PARAMS_KEYS, (pair for pair in zip(c.PARAMS_NAME, c.PARAMS_TYPE))))

        # hide some config keys in user interface which are given as tuple
        EXCLUDED = ('opt_view', 'opt_refo', 'opt_prnt', 'opt_rota', 'opt_dbug', 'opt_colo', 'opt_lier')
        self.gui_keys = [key for key in PROPERTIES.keys() if key not in EXCLUDED]

        # place properties in tk frame
        for i, key in enumerate(self.gui_keys):
            tk.Label(self, text=PROPERTIES[key][0]).grid(row=i, column=0, sticky='W')
            obj_ent = None
            if PROPERTIES[key][1] == 'str':
                self.tk_vars[key] = tk.StringVar(value=self.cfg.params[key])
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=2*PX)

            elif PROPERTIES[key][1] == 'int':
                self.tk_vars[key] = tk.IntVar(value=int(self.cfg.params[key]))
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'list':
                self.tk_vars[key] = tk.StringVar(value=str(self.cfg.params[key]))
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'ran':
                self.tk_vars[key] = TwoStringVars(values=self.cfg.params[key])
                obj_ent = DoubleSpinbox(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'sel':
                # load value range
                if key == 'cal_meth':
github hahnec / plenopticam / plenopticam / gui / widget_file.py View on Github external
lyt_cal_exts = ['*.'+ext for ext in LYT_CAL_EXTS]
        merge_lfp_exts = lyt_lfp_exts+generic_exts
        merge_cal_exts = lyt_cal_exts+generic_exts
        LFP_EXTS = [('Supported files', ' '.join(merge_lfp_exts+[x.upper() for x in merge_lfp_exts])),
                    ('Lytro files', ' '.join(lyt_lfp_exts+[x.upper() for x in lyt_lfp_exts])),
                    ('Generic image files', ' '.join(generic_exts+[x.upper() for x in generic_exts])),
                    ('All files', ' '.join(ALL_EXTS+[x.upper() for x in ALL_EXTS]))]
        CAL_EXTS = [('Supported files', ' '.join(merge_cal_exts+[x.upper() for x in merge_cal_exts])),
                    ('Lytro files', ' '.join(LYT_CAL_EXTS+[x.upper() for x in lyt_cal_exts])),
                    ('Generic image files', ' '.join(generic_exts+[x.upper() for x in generic_exts])),
                    ('All files', ' '.join(ALL_EXTS+[x.upper() for x in ALL_EXTS]))]

        # instantiate light field path widget
        tk.Label(self, text='Light field image: ').grid(row=0, column=0, sticky='W')
        self.lfp_wid = PathWidget(self, path=self.cfg.params[self.cfg.lfp_path], path_type=False, file_exts=LFP_EXTS)
        self.lfp_wid.grid(row=0, column=1, padx=PX, pady=PY)
        self.lfp_wid.bind_to(self.set_lfp_path)     # observe change in path variable

        # instantiate calibration path widget
        tk.Label(self, text='Calibration source: ').grid(row=1, column=0, sticky='W')
        self.cal_wid = PathWidget(self, path=self.cfg.params[self.cfg.cal_path], path_type=False, file_exts=CAL_EXTS)
        self.cal_wid.grid(row=1, column=1, padx=PX, pady=PY)
        self.cal_wid.bind_to(self.set_cal_path)     # observe change in path variable

        # radio button to enable change from path to file type
        self.cal_wid.path_type = os.path.isdir(self.cfg.params[self.cfg.cal_path])
        self.chk_var = tk.BooleanVar(value=bool(self.cal_wid.path_type))
        self.chk_btn = tk.Checkbutton(self, text='Pick folder', variable=self.chk_var, command=self.btn_update)
        self.chk_btn.grid(row=1, column=2, sticky='W')

        # list of button and entry widgets (collected to disable/enable widgets)
        self.btn_list = [self.lfp_wid.btn, self.cal_wid.btn, self.chk_btn, self.lfp_wid.ent, self.cal_wid.ent]
github hahnec / plenopticam / plenopticam / gui / widget_view.py View on Github external
def create_buttons(self):

        # auto-play button
        self._btn_auto_text = tk.StringVar()
        self._btn_auto_text.set(self._loop_symbol)
        self.btn_auto = tk.Button(self, textvariable=self._btn_auto_text, command=self.auto_play, height=1, width=2)
        self.btn_auto.place(x=PX, y=PY, anchor=tk.NW)

        # mode button
        self.btn_mode = tk.Button(self, textvariable=self._mode_text, command=self.switch_mode, height=1, width=2)
        self.btn_mode.place(x=PX, y=PY*4, anchor=tk.NW)

        # instantiate button objects for light-field
        self.btn_arrows = list()
        btn_pos = [[self.shape[1]+PX*4.5, PX, self._wd/4, self._wd/4],
                   [self._ht/4, self._ht/4, PY, self.shape[0]+PY*4.5]]
        for i, text in enumerate(self._arrow_symbols):
            next_frame_arg = partial(self.show_image, i)
            self.btn_arrows.append(tk.Button(self, text=text, command=next_frame_arg, height=1, width=2))
            self.btn_arrows[i].place(x=btn_pos[0][i], y=btn_pos[1][i], anchor=tk.NW)

        return True
github hahnec / plenopticam / plenopticam / gui / widget_cnfg.py View on Github external
# hide some config keys in user interface which are given as tuple
        EXCLUDED = ('opt_view', 'opt_refo', 'opt_prnt', 'opt_rota', 'opt_dbug', 'opt_colo', 'opt_lier')
        self.gui_keys = [key for key in PROPERTIES.keys() if key not in EXCLUDED]

        # place properties in tk frame
        for i, key in enumerate(self.gui_keys):
            tk.Label(self, text=PROPERTIES[key][0]).grid(row=i, column=0, sticky='W')
            obj_ent = None
            if PROPERTIES[key][1] == 'str':
                self.tk_vars[key] = tk.StringVar(value=self.cfg.params[key])
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=2*PX)

            elif PROPERTIES[key][1] == 'int':
                self.tk_vars[key] = tk.IntVar(value=int(self.cfg.params[key]))
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'list':
                self.tk_vars[key] = tk.StringVar(value=str(self.cfg.params[key]))
                obj_ent = tk.Entry(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'ran':
                self.tk_vars[key] = TwoStringVars(values=self.cfg.params[key])
                obj_ent = DoubleSpinbox(self, textvariable=self.tk_vars[key], width=PX)

            elif PROPERTIES[key][1] == 'sel':
                # load value range
                if key == 'cal_meth':
                    value_ran, default = (c.CALI_METH, c.CALI_METH[0])
                    value_sel = self.cfg.params[self.cfg.cal_meth] if self.cfg.cal_meth in self.cfg.params else default
                elif key == 'ptc_leng':
                    value_ran, default = (c.PTCH_SIZE, c.PTCH_SIZE[2])
github hahnec / plenopticam / plenopticam / gui / widget_path.py View on Github external
def __init__(self, parent, path='', title="Browse", path_type=False, file_exts=()):

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

        # store extension names and types
        self.title = title
        self.path_type = path_type
        self.file_exts = file_exts

        # create current path and entry placeholder
        self._path = tk.StringVar(value=path)
        self._path_observers = []
        self.ent = tk.Entry(self, width=2*BTN_W, textvariable=self._path)
        self.ent.grid(row=0, column=0, padx=PX, pady=PY)
        self.ent.xview_moveto(1.0)  # display path from most right

        # create search button
        self.btn = tk.Button(self, width=BTN_W, text=self.title, command=self.choose_path)
        self.btn.grid(row=0, column=1, padx=PX, pady=PY)