Exemplo n.º 1
0
    def selected_properties(self):
        selected = self.get_selection()[0]
        path = self.item_path(selected)

        props = None
        entry_type = ''
        if len(self.tree.get_children(selected)) > 0 or selected != path:
            # directories have children or have their iid different from
            # their path
            props = self.catalog.directory_properties(path)
            entry_type = 'Directory'
        else:
            # file properties
            props = self.catalog.file_properties(path)
            entry_type = 'File'

        if props is None or len(props) == 0:
            return

        tl = tk.Toplevel(self.master)
        tl.title(entry_type + ' properties: ' + path)

        nb = ttk.Notebook(tl)
        nb.pack(fill=tk.BOTH, expand=1)

        for t, p in props.items():
            nb.add(p.get_widget(nb), text=t, sticky='nsew')

        tl.wait_window()
Exemplo n.º 2
0
    def __init__(self, parent, title, app, player, gameid, **kw):

        kw = self.initKw(kw)
        title = _('Statistics')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        self.font = app.getFont('default')
        self.tkfont = tkinter_font.Font(parent, self.font)
        self.font_metrics = self.tkfont.metrics()
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkinter_font.Font(parent, heading_font)

        self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        single_frame = SingleGameFrame(self, notebook, app, player, gameid)
        notebook.add(single_frame, text=_('Current game'))
        self.notebook_tabs.append(single_frame._w)

        all_frame = AllGamesFrame(self, notebook, app, player)
        notebook.add(all_frame, text=_('All games'))
        self.all_games_frame = all_frame
        self.notebook_tabs.append(all_frame._w)

        top_frame = TopFrame(self, notebook, app, player, gameid)
        notebook.add(top_frame, text=TOP_TITLE)
        self.notebook_tabs.append(top_frame._w)

        if player is not None:
            progr_frame = ProgressionFrame(self, notebook, app, player, gameid)
            notebook.add(progr_frame, text=_('Progression'))
            self.notebook_tabs.append(progr_frame._w)

        if StatsDialog.SELECTED_TAB < len(self.notebook_tabs):
            notebook.select(StatsDialog.SELECTED_TAB)
        bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
        # notebook.enableTraversal()
        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)
Exemplo n.º 3
0
    def body(self, master):
        self.cfg = config.load_config()
        self.old_cfg = copy.deepcopy(self.cfg)

        self.notebook = ttk.Notebook(master)
        self.notebook.pack(expand=True, fill=tk.BOTH, side=tk.TOP)

        self.notebook.rowconfigure(0, weight=1)
        self.notebook.columnconfigure(0, weight=1)

        self.connection_manager = ConnectionManager(self.notebook, self.cfg)

        self.notebook.add(self.connection_manager, text='Connections')

        self.column_manager = ColumnManager(self.notebook, self.cfg,
                                            TreeWidget.columns_def)
        self.notebook.add(self.column_manager, text='Display')

        self.changed = False

        return self.notebook
Exemplo n.º 4
0
    def __init__(self, parent, title, app, player, **kw):

        self.font = app.getFont('default')
        self.tkfont = tkinter_font.Font(parent, self.font)
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkinter_font.Font(parent, heading_font)
        self.font_metrics = self.tkfont.metrics()

        self.CHAR_H = self.font_metrics['linespace']
        self.CHAR_W = self.tkfont.measure('M')

        kw = self.initKw(kw)
        title = _('Log')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        # self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        full_frame = FullLogFrame(self, notebook, app, player)
        notebook.add(full_frame, text=_('Full log'))
        self.notebook_tabs.append(full_frame._w)

        session_frame = SessionLogFrame(self, notebook, app, player)
        notebook.add(session_frame, text=_('Session log'))
        self.notebook_tabs.append(session_frame._w)

        notebook.select(LogDialog.SELECTED_TAB)
        #  bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)

        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        # self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)
Exemplo n.º 5
0
 def __init__(self, master=None):
     """Initialise the GUI."""
     ttk.Frame.__init__(self, master)
     # Load the merged metadata from file, and extract the template experiment
     user_metadata = metadata.read_user_config()
     self.template_expt = user_metadata['experiments'].pop('template')
     del user_metadata['devices']  # Until we support editing it
     self.metadata = wrap_dict(user_metadata)
     add_yaml_representers()
     # self.original_metadata = copy.deepcopy(self.metadata)
     # Action buttons
     # ttk.Button(self, text="REVERT", command=self.revert).grid(
     #     row=0, column=0, sticky=T.W, padx=5, pady=5)
     ttk.Button(self, text="SAVE", command=self.save).grid(row=0,
                                                           column=1,
                                                           sticky=T.W,
                                                           padx=5,
                                                           pady=5)
     ttk.Button(self, text="DONE", command=self.done).grid(row=0,
                                                           column=2,
                                                           sticky=T.W,
                                                           padx=5,
                                                           pady=5)
     # Content tabs
     tabs = self.tabs = ttk.Notebook(self, padding=2)
     self.session_tab = self.make_session_tab(tabs)
     self.people_tab = self.make_people_tab(tabs)
     self.expts_tab = self.make_expts_tab(tabs)
     tabs.enable_traversal()
     tabs.grid(row=1, column=0, columnspan=3)
     # Resize support - make the content section take it all
     self.rowconfigure(1, weight=1)
     self.columnconfigure('all', weight=1)
     tabs.rowconfigure('all', weight=1)
     tabs.columnconfigure('all', weight=1)
     self.pack(side="top", fill="both", expand=True)
Exemplo n.º 6
0
    def __init__(self, parent, title, app, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        frame = ttk.Frame(top_frame)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)

        notebook = ttk.Notebook(frame)
        notebook.pack(expand=True, fill='both')

        for w in WizardWidgets:
            if isinstance(w, six.string_types):
                frame = ttk.Frame(notebook)
                notebook.add(frame, text=w, sticky='nsew', padding=5)
                frame.columnconfigure(1, weight=1)
                row = 0
                continue

            ttk.Label(frame, text=w.label).grid(row=row, column=0)

            if w.widget == 'preset':
                if w.variable is None:
                    w.variable = tkinter.StringVar()
                values = [_(v) for v in w.values]
                default = _(w.default)
                values.remove(default)
                values.sort()
                values.insert(0, default)

                def callback(e, w=w):
                    self.presetSelected(e, w)

                cb = PysolCombo(frame,
                                values=tuple(values),
                                textvariable=w.variable,
                                exportselection=False,
                                selectcommand=callback,
                                state='readonly',
                                width=32)
                cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
            elif w.widget == 'entry':
                if w.variable is None:
                    w.variable = tkinter.StringVar()
                en = ttk.Entry(frame, textvariable=w.variable)
                en.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
            elif w.widget == 'menu':
                if w.variable is None:
                    w.variable = tkinter.StringVar()
                values = [_(v) for v in w.values]
                cb = PysolCombo(frame,
                                values=tuple(values),
                                textvariable=w.variable,
                                exportselection=False,
                                state='readonly',
                                width=32)
                cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
            elif w.widget == 'spin':
                if w.variable is None:
                    w.variable = tkinter.IntVar()
                else:
                    # delete all trace callbacks
                    for mod, cbname in w.variable.trace_vinfo():
                        w.variable.trace_vdelete(mod, cbname)
                from_, to = w.values
                # s = Spinbox(
                #   frame, textvariable=w.variable, from_=from_, to=to)
                s = PysolScale(frame,
                               from_=from_,
                               to=to,
                               resolution=1,
                               orient='horizontal',
                               variable=w.variable)
                s.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
            elif w.widget == 'check':
                if w.variable is None:
                    w.variable = tkinter.BooleanVar()
                ch = ttk.Checkbutton(frame,
                                     variable=w.variable,
                                     takefocus=False)
                ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)

            if w.current_value is None:
                v = w.default
            else:
                v = w.current_value
            if w.widget in ('menu', 'preset'):
                v = _(v)
            w.variable.set(v)

            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Exemplo n.º 7
0
    def __init__(self, parent, title, app, manager, key=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)
        #
        if key is None:
            key = manager.getSelected()
        self.manager = manager
        self.key = key
        self.app = app
        self.cardset_values = None
        # padx, pady = kw.padx, kw.pady
        padx, pady = 4, 4
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.grid(row=0, column=0, sticky='nsew', padx=padx, pady=pady)
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        # Tree
        font = app.getFont("default")
        self.tree = self.Tree_Class(self,
                                    tree_frame,
                                    key=key,
                                    default=kw.default,
                                    font=font,
                                    width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame,
                                              text="Search:",
                                              justify='left',
                                              anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top",
                                  fill='both',
                                  padx=padx,
                                  pady=pady,
                                  ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx,
                       pady=pady,
                       expand=True,
                       side='left',
                       fill='both',
                       ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        if USE_PIL:
            #
            var = tkinter.DoubleVar()
            var.set(app.opt.scale_x)
            self.scale_x = PysolScale(left_frame,
                                      label=_('Scale X:'),
                                      from_=0.5,
                                      to=4.0,
                                      resolution=0.1,
                                      orient='horizontal',
                                      variable=var,
                                      value=app.opt.scale_x,
                                      command=self._updateScale)
            self.scale_x.grid(row=1,
                              column=0,
                              sticky='ew',
                              padx=padx,
                              pady=pady)
            #
            var = tkinter.DoubleVar()
            var.set(app.opt.scale_y)
            self.scale_y = PysolScale(left_frame,
                                      label=_('Scale Y:'),
                                      from_=0.5,
                                      to=4.0,
                                      resolution=0.1,
                                      orient='horizontal',
                                      variable=var,
                                      value=app.opt.scale_y,
                                      command=self._updateScale)
            self.scale_y.grid(row=2,
                              column=0,
                              sticky='ew',
                              padx=padx,
                              pady=pady)
            #
            # sliders at new position
            cs = self.manager.get(self.tree.selection_key)

            var = tkinter.IntVar()
            self.x_offset = PysolScale(left_frame,
                                       label=_('X offset:'),
                                       from_=5,
                                       to=100,
                                       resolution=1,
                                       orient='horizontal',
                                       variable=var,
                                       value=cs.CARD_XOFFSET)

            self.x_offset.grid(row=3,
                               column=0,
                               sticky='ew',
                               padx=padx,
                               pady=pady)

            var = tkinter.IntVar()
            self.y_offset = PysolScale(left_frame,
                                       label=_('Y offset:'),
                                       from_=5,
                                       to=100,
                                       resolution=1,
                                       orient='horizontal',
                                       variable=var,
                                       value=cs.CARD_YOFFSET)
            self.y_offset.grid(row=4,
                               column=0,
                               sticky='ew',
                               padx=padx,
                               pady=pady)

            self.auto_scale = tkinter.BooleanVar()
            self.auto_scale.set(app.opt.auto_scale)
            check = ttk.Checkbutton(left_frame,
                                    text=_('Auto scaling'),
                                    variable=self.auto_scale,
                                    takefocus=False,
                                    command=self._updateAutoScale)
            check.grid(row=5,
                       column=0,
                       columnspan=2,
                       sticky='ew',
                       padx=padx,
                       pady=pady)
            #
            self.preserve_aspect = tkinter.BooleanVar()
            self.preserve_aspect.set(app.opt.preserve_aspect_ratio)
            self.aspect_check = ttk.Checkbutton(
                left_frame,
                text=_('Preserve aspect ratio'),
                variable=self.preserve_aspect,
                takefocus=False,
                # command=self._updateScale
            )
            self.aspect_check.grid(row=6,
                                   column=0,
                                   sticky='ew',
                                   padx=padx,
                                   pady=pady)

            self._updateAutoScale()

        #
        left_frame.rowconfigure(0, weight=1)
        left_frame.columnconfigure(0, weight=1)
        #
        self.preview = MfxScrolledCanvas(right_frame)
        self.preview.setTile(app, app.tabletile_index, force=True)
        self.preview.pack(fill='both', expand=True, padx=padx, pady=pady)
        self.preview.canvas.preview = 1
        # create a preview of the current state
        self.preview_key = -1
        self.preview_images = []
        self.scale_images = []
        self.updatePreview(key)
        #
        focus = self.createButtons(bottom_frame, kw)
        focus = self.tree.frame
        self.mainloop(focus, kw.timeout, geometry=geometry)
Exemplo n.º 8
0
    def _create_widgets(self):
        """Create a nice GUI using the enhanced widget set provided by
        the ttk extension to Tkinter, available in Python 2.7 or newer
        """
        #---- create the GUIs
        insts = ['NIRCam', 'NIRSpec', 'NIRISS', 'MIRI', 'FGS']
        self.root = tk.Tk()
        self.root.geometry('+50+50')
        self.root.title("James Webb Space Telescope PSF Calculator")

        frame = ttk.Frame(self.root)
        #frame = ttk.Frame(self.root, padx=10,pady=10)

        #ttk.Label(frame, text='James Webb PSF Calculator' ).grid(row=0)

        #-- star
        lf = ttk.LabelFrame(frame, text='Source Properties')

        if _HAS_PYSYNPHOT:
            self._add_labeled_dropdown("SpType",
                                       lf,
                                       label='    Spectral Type:',
                                       values=poppy.specFromSpectralType(
                                           "", return_list=True),
                                       default='G0V',
                                       width=25,
                                       position=(0, 0),
                                       sticky='W')
            ttk.Button(lf, text='Plot spectrum',
                       command=self.ev_plotspectrum).grid(row=0,
                                                          column=2,
                                                          sticky='E',
                                                          columnspan=4)

        r = 1
        fr2 = ttk.Frame(lf)

        self._add_labeled_entry("source_off_r",
                                fr2,
                                label='    Source Position: r=',
                                value='0.0',
                                width=5,
                                position=(r, 0),
                                sticky='W')
        self._add_labeled_entry("source_off_theta",
                                fr2,
                                label='arcsec,  PA=',
                                value='0',
                                width=3,
                                position=(r, 2),
                                sticky='W')

        self.vars["source_off_centerpos"] = tk.StringVar()
        self.vars["source_off_centerpos"].set('corner')

        ttk.Label(fr2, text='deg, centered on ').grid(row=r, column=4)
        pixel = ttk.Radiobutton(fr2,
                                text='pixel',
                                variable=self.vars["source_off_centerpos"],
                                value='pixel')
        pixel.grid(row=r, column=5)
        corner = ttk.Radiobutton(fr2,
                                 text='corner',
                                 variable=self.vars["source_off_centerpos"],
                                 value='corner')
        corner.grid(row=r, column=6)
        fr2.grid(row=r, column=0, columnspan=5, sticky='W')

        lf.columnconfigure(2, weight=1)
        lf.grid(row=1, sticky='E,W', padx=10, pady=5)

        #-- instruments
        lf = ttk.LabelFrame(frame, text='Instrument Config')
        notebook = ttk.Notebook(lf)
        self.widgets['tabset'] = notebook
        notebook.pack(fill='both')
        for iname, i in zip(insts, range(len(insts))):
            page = ttk.Frame(notebook)
            notebook.add(page, text=iname)
            notebook.select(i)  # make it active
            self.widgets[notebook.select(
            )] = iname  # save reverse lookup from meaningless widget "name" to string name
            if iname == 'NIRCam':
                lframe = ttk.Frame(page)

                ttk.Label(lframe,
                          text='Configuration Options for ' + iname +
                          ',     module: ').grid(row=0, column=0, sticky='W')
                mname = 'NIRCam module'
                self.vars[mname] = tk.StringVar()
                self.widgets[mname] = ttk.Combobox(
                    lframe,
                    textvariable=self.vars[mname],
                    width=2,
                    state='readonly')
                self.widgets[mname].grid(row=0, column=1, sticky='W')
                self.widgets[mname]['values'] = ['A', 'B']
                self.widgets[mname].set('A')

                lframe.grid(row=0, columnspan=2, sticky='W')
            else:
                ttk.Label(page,
                          text='Configuration Options for ' + iname +
                          "                      ").grid(row=0,
                                                         columnspan=2,
                                                         sticky='W')

            ttk.Button(page,
                       text='Display Optics',
                       command=self.ev_displayOptics).grid(column=2,
                                                           row=0,
                                                           sticky='E',
                                                           columnspan=3)

            #if  iname != 'TFI':
            self._add_labeled_dropdown(
                iname + "_filter",
                page,
                label='    Filter:',
                values=self.instrument[iname].filter_list,
                default=self.instrument[iname].filter,
                width=12,
                position=(1, 0),
                sticky='W')
            #else:
            #ttk.Label(page, text='Etalon wavelength: ' , state='disabled').grid(row=1, column=0, sticky='W')
            #self.widgets[iname+"_wavelen"] = ttk.Entry(page, width=7) #, disabledforeground="#A0A0A0")
            #self.widgets[iname+"_wavelen"].insert(0, str(self.instrument[iname].etalon_wavelength))
            #self.widgets[iname+"_wavelen"].grid(row=1, column=1, sticky='W')
            #ttk.Label(page, text=' um' ).grid(row=1, column=2, sticky='W')

            #self.vars[iname+"_filter"] = tk.StringVar()
            #self.widgets[iname+"_filter"] = ttk.Combobox(page,textvariable =self.vars[iname+"_filter"], width=10, state='readonly')
            #self.widgets[iname+"_filter"]['values'] = self.instrument[iname].filter_list
            #self.widgets[iname+"_filter"].set(self.instrument[iname].filter)
            #self.widgets[iname+"_filter"]['readonly'] = True
            #ttk.Label(page, text='    Filter: ' ).grid(row=1, column=0)
            #self.widgets[iname+"_filter"].grid(row=1, column=1)

            #if hasattr(self.instrument[iname], 'ifu_wavelength'):
            if iname == 'NIRSpec' or iname == 'MIRI':
                fr2 = ttk.Frame(page)
                #label = 'IFU' if iname !='TFI' else 'TF'
                ttk.Label(fr2, text='   IFU wavelen: ',
                          state='disabled').grid(row=0, column=0)
                self.widgets[iname + "_ifu_wavelen"] = ttk.Entry(
                    fr2, width=5)  #, disabledforeground="#A0A0A0")
                self.widgets[iname + "_ifu_wavelen"].insert(
                    0, str(self.instrument[iname].monochromatic))
                self.widgets[iname + "_ifu_wavelen"].grid(row=0, column=1)
                self.widgets[iname + "_ifu_wavelen"].state(['disabled'])
                ttk.Label(fr2, text=' um', state='disabled').grid(row=0,
                                                                  column=2)
                fr2.grid(row=1, column=2, columnspan=6, sticky='E')

                iname2 = iname + ""  # need to make a copy so the following lambda function works right:
                self.widgets[iname + "_filter"].bind(
                    '<<ComboboxSelected>>',
                    lambda e: self.ev_update_ifu_label(iname2))

            if len(self.instrument[iname].image_mask_list) > 0:
                masks = self.instrument[iname].image_mask_list
                masks.insert(0, "")

                self._add_labeled_dropdown(iname + "_coron",
                                           page,
                                           label='    Coron:',
                                           values=masks,
                                           width=12,
                                           position=(2, 0),
                                           sticky='W')
                #self.vars[iname+"_coron"] = tk.StringVar()
                #self.widgets[iname+"_coron"] = ttk.Combobox(page,textvariable =self.vars[iname+"_coron"], width=10, state='readonly')
                #self.widgets[iname+"_coron"]['values'] = masks
                #ttk.Label(page, text='    Coron: ' ).grid(row=2, column=0)
                #self.widgets[iname+"_coron"].set(self.widgets[iname+"_coron"]['values'][0])
                #self.widgets[iname+"_coron"].grid(row=2, column=1)

                #fr2 = ttk.Frame(page)
                #self.vars[iname+"_cor_off_r"] = tk.StringVar()
                #self.vars[iname+"_cor_off_theta"] = tk.StringVar()
                #ttk.Label(fr2, text='target offset:  r=' ).grid(row=2, column=4)
                #self.widgets[iname+"_cor_off_r"] = ttk.Entry(fr2,textvariable =self.vars[iname+"_cor_off_r"], width=5)
                #self.widgets[iname+"_cor_off_r"].insert(0,"0.0")
                #self.widgets[iname+"_cor_off_r"].grid(row=2, column=5)
                #ttk.Label(fr2, text='arcsec,  PA=' ).grid(row=2, column=6)
                #self.widgets[iname+"_cor_off_theta"] = ttk.Entry(fr2,textvariable =self.vars[iname+"_cor_off_theta"], width=3)
                #self.widgets[iname+"_cor_off_theta"].insert(0,"0")
                #self.widgets[iname+"_cor_off_theta"].grid(row=2, column=7)
                #ttk.Label(fr2, text='deg' ).grid(row=2, column=8)
                #fr2.grid(row=2,column=3, sticky='W')

            if len(self.instrument[iname].image_mask_list) > 0:
                masks = self.instrument[iname].pupil_mask_list
                masks.insert(0, "")
                self._add_labeled_dropdown(iname + "_pupil",
                                           page,
                                           label='    Pupil:',
                                           values=masks,
                                           width=12,
                                           position=(3, 0),
                                           sticky='W')

                fr2 = ttk.Frame(page)
                self._add_labeled_entry(iname + "_pupilshift_x",
                                        fr2,
                                        label='  pupil shift in X:',
                                        value='0',
                                        width=3,
                                        position=(3, 4),
                                        sticky='W')
                self._add_labeled_entry(iname + "_pupilshift_y",
                                        fr2,
                                        label=' Y:',
                                        value='0',
                                        width=3,
                                        position=(3, 6),
                                        sticky='W')

                ttk.Label(fr2, text='% of pupil').grid(row=3, column=8)
                fr2.grid(row=3, column=3, sticky='W')

            ttk.Label(page, text='Configuration Options for the OTE').grid(
                row=4, columnspan=2, sticky='W')
            fr2 = ttk.Frame(page)

            opd_list = self.instrument[iname].opd_list
            opd_list.insert(0, "Zero OPD (perfect)")
            #if os.getenv("WEBBPSF_ITM") or 1:
            if self._enable_opdserver:
                opd_list.append("OPD from ITM Server")
            default_opd = self.instrument[iname].pupilopd if self.instrument[
                iname].pupilopd is not None else "Zero OPD (perfect)"
            self._add_labeled_dropdown(iname + "_opd",
                                       fr2,
                                       label='    OPD File:',
                                       values=opd_list,
                                       default=default_opd,
                                       width=21,
                                       position=(0, 0),
                                       sticky='W')

            self._add_labeled_dropdown(iname + "_opd_i",
                                       fr2,
                                       label=' # ',
                                       values=[str(i) for i in range(10)],
                                       width=3,
                                       position=(0, 2),
                                       sticky='W')

            self.widgets[iname + "_opd_label"] = ttk.Label(
                fr2, text=' 0 nm RMS            ', width=35)
            self.widgets[iname + "_opd_label"].grid(column=4,
                                                    sticky='W',
                                                    row=0)

            self.widgets[iname + "_opd"].bind(
                '<<ComboboxSelected>>', lambda e: self.ev_update_OPD_labels())
            # The below code does not work, and I can't tell why. This only ever has iname = 'FGS' no matter which instrument.
            # So instead brute-force it with the above to just update all 5.
            #lambda e: self.ev_update_OPD_label(self.widgets[iname+"_opd"], self.widgets[iname+"_opd_label"], iname) )
            ttk.Button(fr2, text='Display',
                       command=self.ev_displayOPD).grid(column=5,
                                                        sticky='E',
                                                        row=0)

            fr2.grid(row=5, column=0, columnspan=4, sticky='S')

            # ITM interface here - build the widgets now but they will be hidden by default until the ITM option is selected
            fr2 = ttk.Frame(page)
            self._add_labeled_entry(iname + "_coords",
                                    fr2,
                                    label='    Source location:',
                                    value='0, 0',
                                    width=12,
                                    position=(1, 0),
                                    sticky='W')
            units_list = ['V1,V2 coords', 'detector pixels']
            self._add_labeled_dropdown(iname + "_coord_units",
                                       fr2,
                                       label='in:',
                                       values=units_list,
                                       default=units_list[0],
                                       width=11,
                                       position=(1, 2),
                                       sticky='W')
            choose_list = [
                '', 'SI center', 'SI upper left corner',
                'SI upper right corner', 'SI lower left corner',
                'SI lower right corner'
            ]
            self._add_labeled_dropdown(iname + "_coord_choose",
                                       fr2,
                                       label='or select:',
                                       values=choose_list,
                                       default=choose_list[0],
                                       width=21,
                                       position=(1, 4),
                                       sticky='W')

            ttk.Label(fr2, text='    ITM output:').grid(row=2,
                                                        column=0,
                                                        sticky='W')
            self.widgets[iname + "_itm_output"] = ttk.Label(
                fr2, text='    - no file available yet -')
            self.widgets[iname + "_itm_output"].grid(row=2,
                                                     column=1,
                                                     columnspan=4,
                                                     sticky='W')
            ttk.Button(fr2,
                       text='Access ITM...',
                       command=self.ev_launch_ITM_dialog).grid(column=5,
                                                               sticky='E',
                                                               row=2)

            fr2.grid(row=6, column=0, columnspan=4, sticky='SW')
            self.widgets[iname + "_itm_coords"] = fr2

        self.ev_update_OPD_labels()
        lf.grid(row=2, sticky='E,W', padx=10, pady=5)
        notebook.select(0)

        lf = ttk.LabelFrame(frame, text='Calculation Options')
        r = 0
        self._add_labeled_entry('FOV',
                                lf,
                                label='Field of View:',
                                width=3,
                                value='5',
                                postlabel='arcsec/side',
                                position=(r, 0))
        r += 1
        self._add_labeled_entry(
            'detector_oversampling',
            lf,
            label='Output Oversampling:',
            width=3,
            value='2',
            postlabel='x finer than instrument pixels       ',
            position=(r, 0))

        #self.vars['downsamp'] = tk.BooleanVar()
        #self.vars['downsamp'].set(True)
        #self.widgets['downsamp'] = ttk.Checkbutton(lf, text='Save in instr. pixel scale, too?', onvalue=True, offvalue=False,variable=self.vars['downsamp'])
        #self.widgets['downsamp'].grid(row=r, column=4, sticky='E')

        output_options = [
            'Oversampled PSF only', 'Oversampled + Detector Res. PSFs',
            'Mock full image from JWST DMS'
        ]
        self._add_labeled_dropdown("output_type",
                                   fr2,
                                   label='Output format:',
                                   values=output_options,
                                   default=output_options[1],
                                   width=31,
                                   position=(r, 4),
                                   sticky='W')

        r += 1
        self._add_labeled_entry('fft_oversampling',
                                lf,
                                label='Coronagraph FFT Oversampling:',
                                width=3,
                                value='2',
                                postlabel='x finer than Nyquist',
                                position=(r, 0))
        r += 1
        self._add_labeled_entry('nlambda',
                                lf,
                                label='# of wavelengths:',
                                width=3,
                                value='',
                                position=(r, 0),
                                postlabel='Leave blank for autoselect')
        r += 1

        self._add_labeled_dropdown("jitter",
                                   lf,
                                   label='Jitter model:',
                                   values=[
                                       'Just use OPDs', 'Gaussian - 7 mas rms',
                                       'Gaussian - 30 mas rms'
                                   ],
                                   width=20,
                                   position=(r, 0),
                                   sticky='W',
                                   columnspan=2)
        r += 1
        self._add_labeled_dropdown("output_format",
                                   lf,
                                   label='Output Format:',
                                   values=[
                                       'Oversampled image',
                                       'Detector sampled image',
                                       'Both as FITS extensions',
                                       'Mock JWST DMS Output'
                                   ],
                                   width=30,
                                   position=(r, 0),
                                   sticky='W',
                                   columnspan=2)
        #self._add_labeled_dropdown("jitter", lf, label='Jitter model:', values=  ['Just use OPDs', 'Gaussian blur', 'Accurate yet SLOW grid'], width=20, position=(r,0), sticky='W', columnspan=2)

        lf.grid(row=4, sticky='E,W', padx=10, pady=5)

        lf = ttk.Frame(frame)

        def addbutton(self, lf, text, command, pos, disabled=False):
            self.widgets[text] = ttk.Button(lf, text=text, command=command)
            self.widgets[text].grid(column=pos, row=0, sticky='E')
            if disabled:
                self.widgets[text].state(['disabled'])

        addbutton(self, lf, 'Compute PSF', self.ev_calc_psf, 0)
        addbutton(self,
                  lf,
                  'Display PSF',
                  self.ev_displayPSF,
                  1,
                  disabled=True)
        addbutton(self,
                  lf,
                  'Display profiles',
                  self.ev_displayProfiles,
                  2,
                  disabled=True)
        addbutton(self, lf, 'Save PSF As...', self.ev_SaveAs, 3, disabled=True)
        addbutton(self,
                  lf,
                  'More options...',
                  self.ev_options,
                  4,
                  disabled=False)

        ttk.Button(lf, text='Quit', command=self.quit).grid(column=5, row=0)
        lf.columnconfigure(2, weight=1)
        lf.columnconfigure(4, weight=1)
        lf.grid(row=5, sticky='E,W', padx=10, pady=15)

        frame.grid(row=0, sticky='N,E,S,W')
        frame.columnconfigure(0, weight=1)
        frame.rowconfigure(0, weight=1)
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=1)
Exemplo n.º 9
0
    def __init__(self, parent, title, app, manager, key=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)
        #
        if key is None:
            key = manager.getSelected()
        self.app = app
        self.manager = manager
        self.key = key
        self.table_color = app.opt.colors['table']
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        padx, pady = 4, 4

        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.pack(expand=True, fill='both')
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        font = app.getFont("default")
        padx, pady = 4, 4
        self.tree = self.Tree_Class(self, tree_frame, key=key,
                                    default=kw.default,
                                    font=font, width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame, text="Search:",
                                              justify='left', anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top", fill='both',
                                  padx=padx, pady=pady, ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx, pady=pady, expand=True, side='left',
                       fill='both', ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        self.preview = MfxScrolledCanvas(right_frame, hbar=0, vbar=0)
        self.preview.pack(side="right", fill='both', expand=True,
                          padx=padx, pady=pady)

        self.preview.canvas.preview = 1
        # create a preview of the current state
        self.preview_key = -1
        self.updatePreview(key)
        #
        focus = self.createButtons(bottom_frame, kw)
        focus = self.tree.frame

        self.mainloop(focus, kw.timeout, geometry=geometry)
Exemplo n.º 10
0
    def __init__(self, parent, title, app, gameid, bookmark=None, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)

        self.createBitmaps(top_frame, kw)
        #
        self.app = app
        self.gameid = gameid
        self.bookmark = bookmark
        self.random = None
        if self.TreeDataHolder_Class.data is None:
            self.TreeDataHolder_Class.data = self.TreeData_Class(app)
        #
        sw = self.top.winfo_screenwidth()
        sh = self.top.winfo_screenheight()

        h = int(sh * .8)
        w = int(sw * .8)
        w1 = int(min(275, sw / 2.5))
        geometry = ("%dx%d+%d+%d" % (w, h, (sw - w) / 2, (sh - h) / 2))
        self.top.wm_minsize(400, 200)

        # print sw, w1, w2
        # w2 = max(200, min(w2, 10 + 12 * (app.subsampled_images.CARDW + 10)))
        # print sw, w1, w2
        # padx, pady = kw.padx, kw.pady
        # padx, pady = kw.padx/2, kw.pady/2
        padx, pady = 4, 4
        # PanedWindow
        paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
        paned_window.pack(expand=True, fill='both', padx=8, pady=8)
        left_frame = ttk.Frame(paned_window)
        right_frame = ttk.Frame(paned_window)
        paned_window.add(left_frame)
        paned_window.add(right_frame)

        notebook = ttk.Notebook(left_frame)
        notebook.pack(expand=True, fill='both')
        tree_frame = ttk.Frame(notebook)
        notebook.add(tree_frame, text=_('Tree View'))
        search_frame = ttk.Frame(notebook)
        notebook.add(search_frame, text=_('Search'))

        # Tree
        font = app.getFont("default")
        self.tree = self.Tree_Class(self,
                                    tree_frame,
                                    key=gameid,
                                    default=kw.default,
                                    font=font,
                                    width=w1)
        self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')

        # Search
        searchText = tkinter.StringVar()
        self.list_searchlabel = tkinter.Label(search_frame,
                                              text="Search:",
                                              justify='left',
                                              anchor='w')
        self.list_searchlabel.pack(side="top", fill='both', ipadx=1)
        self.list_searchtext = tkinter.Entry(search_frame,
                                             textvariable=searchText)
        self.list_searchtext.pack(side="top",
                                  fill='both',
                                  padx=padx,
                                  pady=pady,
                                  ipadx=1)
        searchText.trace('w', self.performSearch)

        self.list_scrollbar = tkinter.Scrollbar(search_frame)
        self.list_scrollbar.pack(side="right", fill='both')

        self.createBitmaps(search_frame, kw)
        self.list = tkinter.Listbox(search_frame, exportselection=False)
        self.list.pack(padx=padx,
                       pady=pady,
                       expand=True,
                       side='left',
                       fill='both',
                       ipadx=1)
        self.updateSearchList("")
        bind(self.list, '<<ListboxSelect>>', self.selectSearchResult)
        bind(self.list, '<FocusOut>',
             lambda e: self.list.selection_clear(0, 'end'))

        self.list.config(yscrollcommand=self.list_scrollbar.set)
        self.list_scrollbar.config(command=self.list.yview)

        # LabelFrame
        info_frame = ttk.LabelFrame(right_frame, text=_('About game'))
        info_frame.grid(row=0,
                        column=0,
                        padx=padx,
                        pady=pady,
                        ipadx=4,
                        ipady=4,
                        sticky='nws')
        stats_frame = ttk.LabelFrame(right_frame, text=_('Statistics'))
        stats_frame.grid(row=0,
                         column=1,
                         padx=padx,
                         pady=pady,
                         ipadx=4,
                         ipady=4,
                         sticky='nws')
        # Info
        self.info_labels = {}
        for n, t, f, row in (
            ('name', _('Name:'), info_frame, 0),
            ('altnames', _('Alternate names:'), info_frame, 1),
            ('category', _('Category:'), info_frame, 2),
            ('type', _('Type:'), info_frame, 3),
            ('skill_level', _('Skill level:'), info_frame, 4),
            ('decks', _('Decks:'), info_frame, 5),
            ('redeals', _('Redeals:'), info_frame, 6),
                #
            ('played', _('Played:'), stats_frame, 0),
            ('won', _('Won:'), stats_frame, 1),
            ('lost', _('Lost:'), stats_frame, 2),
            ('time', _('Playing time:'), stats_frame, 3),
            ('moves', _('Moves:'), stats_frame, 4),
            ('percent', _('% won:'), stats_frame, 5),
        ):
            title_label = ttk.Label(f, text=t, justify='left', anchor='w')
            title_label.grid(row=row, column=0, sticky='nw', padx=4)
            text_label = ttk.Label(f, justify='left', anchor='w')
            text_label.grid(row=row, column=1, sticky='nw', padx=4)
            self.info_labels[n] = (title_label, text_label)
        # info_frame.columnconfigure(1, weight=1)
        info_frame.rowconfigure(6, weight=1)
        stats_frame.rowconfigure(6, weight=1)
        # Canvas
        self.preview = MfxScrolledCanvas(right_frame)
        self.preview.setTile(app, app.tabletile_index, force=True)
        self.preview.grid(row=1,
                          column=0,
                          columnspan=3,
                          padx=padx,
                          pady=pady,
                          sticky='nsew')
        right_frame.columnconfigure(1, weight=1)
        right_frame.rowconfigure(1, weight=1)
        #
        focus = self.createButtons(bottom_frame, kw)
        # set the scale factor
        self.preview.canvas.preview = 2
        # create a preview of the current game
        self.preview_key = -1
        self.preview_game = None
        self.preview_app = None
        self.updatePreview(gameid, animations=0)
        # focus = self.tree.frame
        self.mainloop(focus, kw.timeout, geometry=geometry)