コード例 #1
0
ファイル: solverdialog.py プロジェクト: tuchang/PySolFC
 def _createPresetVar(self, frame, row):
     var = tkinter.StringVar()
     var.set('none')
     om = tkinter.OptionMenu(frame, var, *(self.presets))
     om.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
     return var
コード例 #2
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, basestring):
                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)
コード例 #3
0
ファイル: tkstats.py プロジェクト: learnmove/PySolFC
    def __init__(self, parent, title, app, player, gameid, **kw):

        font_name = app.getFont('default')
        font = tkinter_font.Font(parent, font_name)
        tkfont = tkinter_font.Font(parent, font)
        font_metrics = font.metrics()
        measure = tkfont.measure
        self.text_height = font_metrics['linespace']
        self.text_width = measure('XX.XX.XX')

        self.items = []
        self.formatter = ProgressionFormatter(app, player, gameid)

        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 = tkinter.Frame(top_frame)
        frame.pack(expand=True, fill='both', padx=5, pady=10)
        frame.columnconfigure(0, weight=1)

        # constants
        self.canvas_width, self.canvas_height = 600, 250
        if parent.winfo_screenwidth() < 800 or \
                parent.winfo_screenheight() < 600:
            self.canvas_width, self.canvas_height = 400, 200
        self.xmargin, self.ymargin = 10, 10
        self.graph_dx, self.graph_dy = 10, 10
        self.played_color = '#ff7ee9'
        self.won_color = '#00dc28'
        self.percent_color = 'blue'
        # create canvas
        self.canvas = canvas = tkinter.Canvas(frame,
                                              bg='#dfe8ff',
                                              highlightthickness=1,
                                              highlightbackground='black',
                                              width=self.canvas_width,
                                              height=self.canvas_height)
        canvas.pack(side='left', padx=5)
        #
        dir = os.path.join('images', 'stats')
        try:
            fn = app.dataloader.findImage('progression', dir)
            self.bg_image = loadImage(fn)
            canvas.create_image(0, 0, image=self.bg_image, anchor='nw')
        except Exception:
            pass
        #
        tw = max(measure(_('Games/day')), measure(_('Games/week')),
                 measure(_('% won')))
        self.left_margin = self.xmargin + tw // 2
        self.right_margin = self.xmargin + tw // 2
        self.top_margin = 15 + self.text_height
        self.bottom_margin = 15 + self.text_height + 10 + self.text_height
        #
        x0, y0 = self.left_margin, self.canvas_height - self.bottom_margin
        x1, y1 = self.canvas_width - self.right_margin, self.top_margin
        canvas.create_rectangle(x0, y0, x1, y1, fill='white')
        # horizontal axis
        canvas.create_line(x0, y0, x1, y0, width=3)

        # left vertical axis
        canvas.create_line(x0, y0, x0, y1, width=3)
        t = _('Games/day')
        self.games_text_id = canvas.create_text(x0 - 4,
                                                y1 - 4,
                                                anchor='s',
                                                text=t)

        # right vertical axis
        canvas.create_line(x1, y0, x1, y1, width=3)
        canvas.create_text(x1 + 4, y1 - 4, anchor='s', text=_('% won'))

        # caption
        d = self.text_height
        x, y = self.xmargin, self.canvas_height - self.ymargin
        canvas.create_rectangle(x,
                                y,
                                x + d,
                                y - d,
                                outline='black',
                                fill=self.played_color)
        x += d + 5
        canvas.create_text(x, y, anchor='sw', text=_('Played'))
        x += measure(_('Played')) + 20
        canvas.create_rectangle(x,
                                y,
                                x + d,
                                y - d,
                                outline='black',
                                fill=self.won_color)
        x += d + 5
        canvas.create_text(x, y, anchor='sw', text=_('Won'))
        x += measure(_('Won')) + 20
        canvas.create_rectangle(x,
                                y,
                                x + d,
                                y - d,
                                outline='black',
                                fill=self.percent_color)
        x += d + 5
        canvas.create_text(x, y, anchor='sw', text=_('% won'))

        # right frame
        right_frame = tkinter.Frame(frame)
        right_frame.pack(side='left', fill='x', padx=5)
        self.all_games_variable = var = tkinter.StringVar()
        var.set('all')
        b = tkinter.Radiobutton(right_frame,
                                text=_('All games'),
                                variable=var,
                                value='all',
                                command=self.updateGraph,
                                justify='left',
                                anchor='w')
        b.pack(fill='x', expand=True, padx=3, pady=1)
        b = tkinter.Radiobutton(right_frame,
                                text=_('Current game'),
                                variable=var,
                                value='current',
                                command=self.updateGraph,
                                justify='left',
                                anchor='w')
        b.pack(fill='x', expand=True, padx=3, pady=1)
        label_frame = tkinter.LabelFrame(right_frame, text=_('Statistics for'))
        label_frame.pack(side='top', fill='x', pady=10)
        self.variable = var = tkinter.StringVar()
        var.set('week')
        for v, t in (
            ('week', _('Last 7 days')),
            ('month', _('Last month')),
            ('year', _('Last year')),
            ('all', _('All time')),
        ):
            b = tkinter.Radiobutton(label_frame,
                                    text=t,
                                    variable=var,
                                    value=v,
                                    command=self.updateGraph,
                                    justify='left',
                                    anchor='w')
            b.pack(fill='x', expand=True, padx=3, pady=1)
        label_frame = tkinter.LabelFrame(right_frame, text=_('Show graphs'))
        label_frame.pack(side='top', fill='x')
        self.played_graph_var = tkinter.BooleanVar()
        self.played_graph_var.set(True)
        b = tkinter.Checkbutton(label_frame,
                                text=_('Played'),
                                command=self.updateGraph,
                                variable=self.played_graph_var,
                                justify='left',
                                anchor='w')
        b.pack(fill='x', expand=True, padx=3, pady=1)
        self.won_graph_var = tkinter.BooleanVar()
        self.won_graph_var.set(True)
        b = tkinter.Checkbutton(label_frame,
                                text=_('Won'),
                                command=self.updateGraph,
                                variable=self.won_graph_var,
                                justify='left',
                                anchor='w')
        b.pack(fill='x', expand=True, padx=3, pady=1)
        self.percent_graph_var = tkinter.BooleanVar()
        self.percent_graph_var.set(True)
        b = tkinter.Checkbutton(label_frame,
                                text=_('% won'),
                                command=self.updateGraph,
                                variable=self.percent_graph_var,
                                justify='left',
                                anchor='w')
        b.pack(fill='x', expand=True, padx=3, pady=1)

        self.updateGraph()

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
コード例 #4
0
    def __init__(self, dialog, parent, app, player, gameid, **kw):
        ttk.Frame.__init__(self, parent)

        self.mapped = False

        self.dialog = dialog
        self.app = app
        self.player = player
        self.gameid = gameid
        self.items = []
        self.formatter = ProgressionFormatter(app, player, gameid)

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

        # constants
        w = dialog.tkfont.measure('M') * 42
        w = max(w, 500)
        w = min(w, 600)
        self.canvas_width, self.canvas_height = w, 250
        cond = parent.winfo_screenwidth() < 800 or \
            parent.winfo_screenheight() < 600
        if cond:
            self.canvas_width, self.canvas_height = 400, 200
        self.xmargin, self.ymargin = 10, 10
        self.graph_dx, self.graph_dy = 10, 10
        self.played_color = '#ff7ee9'
        self.won_color = '#00dc28'
        self.percent_color = 'blue'
        # create canvas
        self.canvas = canvas = tkinter.Canvas(frame, bg='#dfe8ff', bd=0,
                                              highlightthickness=1,
                                              highlightbackground='black',
                                              width=self.canvas_width,
                                              height=self.canvas_height)
        canvas.pack(side='left', padx=5)

        # right frame
        right_frame = ttk.Frame(frame)
        right_frame.pack(side='left', fill='x', padx=5)
        self.all_games_variable = var = tkinter.StringVar()
        var.set('all')
        b = ttk.Radiobutton(right_frame, text=_('All games'),
                            variable=var, value='all',
                            command=self.updateGraph)
        b.pack(fill='x', expand=True, padx=3, pady=1)
        b = ttk.Radiobutton(right_frame, text=_('Current game'),
                            variable=var, value='current',
                            command=self.updateGraph)
        b.pack(fill='x', expand=True, padx=3, pady=1)
        label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for'))
        label_frame.pack(side='top', fill='x', pady=10)
        self.variable = var = tkinter.StringVar()
        var.set('week')
        for v, t in (
            ('week',  _('Last 7 days')),
            ('month', _('Last month')),
            ('year',  _('Last year')),
            ('all',   _('All time')),
                ):
            b = ttk.Radiobutton(label_frame, text=t, variable=var,
                                value=v, command=self.updateGraph)
            b.pack(fill='x', expand=True, padx=3, pady=1)
        label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs'))
        label_frame.pack(side='top', fill='x')
        self.played_graph_var = tkinter.BooleanVar()
        self.played_graph_var.set(True)
        b = ttk.Checkbutton(label_frame, text=_('Played'),
                            command=self.updateGraph,
                            variable=self.played_graph_var)
        b.pack(fill='x', expand=True, padx=3, pady=1)
        self.won_graph_var = tkinter.BooleanVar()
        self.won_graph_var.set(True)
        b = ttk.Checkbutton(label_frame, text=_('Won'),
                            command=self.updateGraph,
                            variable=self.won_graph_var)
        b.pack(fill='x', expand=True, padx=3, pady=1)
        self.percent_graph_var = tkinter.BooleanVar()
        self.percent_graph_var.set(True)
        b = ttk.Checkbutton(label_frame, text=_('% won'),
                            command=self.updateGraph,
                            variable=self.percent_graph_var)
        b.pack(fill='x', expand=True, padx=3, pady=1)

        # self.createGraph()
        bind(canvas, '<Map>', self.createGraph)
コード例 #5
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)
コード例 #6
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)
コード例 #7
0
    def __init__(self, parent, title, app, **kw):
        kw = self.initKw(kw)
        self._calc_MfxDialog().__init__(self, parent, title, kw.resizable,
                                        kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

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

        self.text_var = tkinter.StringVar()
        self.text_var.set(app.opt.colors['text'])
        self.piles_var = tkinter.StringVar()
        self.piles_var.set(app.opt.colors['piles'])
        self.cards_1_var = tkinter.StringVar()
        self.cards_1_var.set(app.opt.colors['cards_1'])
        self.cards_2_var = tkinter.StringVar()
        self.cards_2_var.set(app.opt.colors['cards_2'])
        self.samerank_1_var = tkinter.StringVar()
        self.samerank_1_var.set(app.opt.colors['samerank_1'])
        self.samerank_2_var = tkinter.StringVar()
        self.samerank_2_var.set(app.opt.colors['samerank_2'])
        self.hintarrow_var = tkinter.StringVar()
        self.hintarrow_var.set(app.opt.colors['hintarrow'])
        self.not_matching_var = tkinter.StringVar()
        self.not_matching_var.set(app.opt.colors['not_matching'])
        #
        row = 0
        for title, var in (
            (_('Text foreground:'), self.text_var),
            (_('Highlight piles:'), self.piles_var),
            (_('Highlight cards 1:'), self.cards_1_var),
            (_('Highlight cards 2:'), self.cards_2_var),
            (_('Highlight same rank 1:'), self.samerank_1_var),
            (_('Highlight same rank 2:'), self.samerank_2_var),
            (_('Hint arrow:'), self.hintarrow_var),
            (_('Highlight not matching:'), self.not_matching_var),
        ):
            self._calcLabel()(
                frame,
                text=title,
                anchor='w',
            ).grid(row=row, column=0, sticky='we')
            label = tkinter.Label(frame,
                                  width=10,
                                  height=2,
                                  bg=var.get(),
                                  textvariable=var)
            label.grid(row=row, column=1, padx=5)
            b = self._calcButton()(
                frame,
                text=_('Change...'),
                width=10,
                command=lambda label=label: self.selectColor(label))
            b.grid(row=row, column=2)
            row += 1
        #
        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
        #
        self.text_color = self.text_var.get()
        self.piles_color = self.piles_var.get()
        self.cards_1_color = self.cards_1_var.get()
        self.cards_2_color = self.cards_2_var.get()
        self.samerank_1_color = self.samerank_1_var.get()
        self.samerank_2_color = self.samerank_2_var.get()
        self.hintarrow_color = self.hintarrow_var.get()
        self.not_matching_color = self.not_matching_var.get()
コード例 #8
0
    def __init__(self, odf, plotter):
        self.f = Figure()

        # Save reference to the model
        self.odf = odf
        # Save reference to the plotter
        self.plotter = plotter

        self.leftMask = None
        self.rightMask = None
        self.activeLine = None

        self.root = tk.Tk()
        self.root.wm_title("PyA Model Explorer")
        # Make the widgets expand/shrink as window size changes
        self.root.columnconfigure(0, weight=1)
        self.root.rowconfigure(0, weight=1)

        # Bind the mouse wheel
        if platform.system() == "Linux":
            self.root.bind("<Button-4>", self._mouseWheel)
            self.root.bind("<Button-5>", self._mouseWheel)
        elif platform.system() == "Darwin":
            self.root.bind("<MouseWheel>", self._onWheel)  # for OS X

        # A frame containing the mpl plot
        self.plotFrame = tk.Frame()
        self.plotFrame.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
        self.canvas = FigureCanvasTkAgg(self.f, master=self.plotFrame)

        # A frame containing the box with selected points
        # and control buttons
        self.controlFrame = tk.Frame(self.root)
        self.controlFrame.pack(side=tk.RIGHT, expand=False, fill=tk.BOTH)
        self.selectedPar = tk.StringVar(self.controlFrame)

        # Get parameters of model
        ps = list(self.odf.parameters().keys())
        # Set default modification properties
        # Saves these properties for all parameters
        self.modProps = {}
        for p in ps:
            self.modProps[p] = {
                "modus": "mul",
                "modValMul": 1.02,
                "modValAdd": 0.01
            }

        # Frame containing all parameters
        self.parameterFrame = tk.Frame(self.controlFrame,
                                       height=2,
                                       bd=1,
                                       relief=tk.SUNKEN)

        # Dictionaries holding the specific information for each parameter
        self.singleParameterFrames = {}
        self.singleParameterEntry = {}
        self.singleParameterVar = {}
        # knows whether the parameter is free (value=True) or frozen (=False)
        self.singleParameterFree = {}

        # Closures around the functions adapting thaw/freeze
        def frozenChanged(k):
            def change():
                if self.singleParameterFree[k].get() == True:
                    self.odf.thaw(k)
                else:
                    self.odf.freeze(k)
                self._updateDof()

            return change

        # define what happens when a value is set to the entered parameter (closures)
        def hitReturn(k):
            def change(*args):
                self.selectedPar.set(k)
                self.odf[k] = float(self.singleParameterVar[k].get())
                self._parameterValueChanged()

            return change

        # defines what happens when a parameter's value is changed, but not set yet, i.e., not current (closures)
        def parameterValueChanged(k):
            def valueChanged(*args):
                pp, ll = str(self.singleParameterVar[k].get()).find("."), len(
                    str(self.singleParameterVar[k].get()))
                if round(self.odf[k], ll - pp - 1) != round(
                        self.singleParameterVar[k].get(), ll - pp - 1):
                    self.singleParameterEntry[k].configure(bg="red")
                else:
                    self.singleParameterEntry[k].configure(bg="white")

            return valueChanged

        # Create an entry for each parameter
        # Create a scrollable region
        # Check maximum number of characters for parameter names:
        maxParamLen = 0
        for k in sorted(self.odf.parameters().keys()):
            if len(k) > maxParamLen:
                maxParamLen = len(k)
            # Create an entry for each parameter
        for k in sorted(self.odf.parameters().keys()):
            x = tk.Frame(self.parameterFrame,
                         height=2,
                         bd=2,
                         relief=tk.SUNKEN,
                         pady=2)
            self.singleParameterFrames[k] = x
            y0 = tk.Radiobutton(x,
                                text=k,
                                variable=self.selectedPar,
                                value=k,
                                width=maxParamLen + 1,
                                indicatoron=0)
            y0.pack(side=tk.LEFT)
            #y1 = tk.StringVar()
            y1 = tk.DoubleVar()
            y1.set(self.odf[k])
            y2 = tk.Entry(x, textvariable=y1, width=8)
            y2.bind('<Return>', hitReturn(k))
            self.singleParameterVar[k] = y1
            self.singleParameterVar[k].trace('w', parameterValueChanged(k))
            self.singleParameterEntry[k] = y2
            y2.pack(side=tk.LEFT)
            self.singleParameterFrames[k].pack()
            modModus = tk.StringVar()
            modModus.set(self.modProps[k]["modus"])
            self.singleParameterFree[k] = tk.BooleanVar()
            self.singleParameterFree[k].set(k in self.odf.freeParamNames())
            y3 = tk.Radiobutton(x,
                                text="Thawed",
                                value=True,
                                variable=self.singleParameterFree[k],
                                command=frozenChanged(k))
            y4 = tk.Radiobutton(x,
                                text="Frozen",
                                value=False,
                                variable=self.singleParameterFree[k],
                                command=frozenChanged(k))
            y3.pack(side=tk.RIGHT)
            y4.pack(side=tk.RIGHT)
            self.parameterFrame.pack(fill=tk.X, expand=False)

        # Set of the menu to select the current parameter
        self.selectedPar.set(ps[0])

        # Chi2 frame:
        # , relief=tk.SUNKEN)
        self.chi2Frame = tk.Frame(self.controlFrame, borderwidth=10)
        self.chi2value = tk.DoubleVar()
        self.chi2value.set(self.plotter.chi2)
        self.dofValue = tk.IntVar()
        # self.dofValue.set(len(self.plotter.fitIdx))
        # self.dofValue.set(100)
        self.dofValue.set(
            len(self.plotter.x) - len(self.odf.freeParameters()) - 1)
        self.chi2Label = tk.Label(self.chi2Frame, text="Chi2: ")
        self.dofLabel = tk.Label(self.chi2Frame, text="dof: ")
        self.chi2Entry = tk.Entry(self.chi2Frame,
                                  textvariable=self.chi2value,
                                  bd=2,
                                  width=10)
        self.dofEntry = tk.Entry(self.chi2Frame,
                                 textvariable=self.dofValue,
                                 bd=2,
                                 width=10)
        self.chi2Label.pack(side=tk.LEFT)
        self.chi2Entry.pack(side=tk.LEFT)
        self.dofLabel.pack(side=tk.LEFT)
        self.dofEntry.pack(side=tk.LEFT)
        self.chi2Frame.pack()

        # Frame to bundle mouse-wheel inputs
        self.mouseWheelFrame = tk.Frame(self.controlFrame,
                                        height=2,
                                        bd=3,
                                        relief=tk.SUNKEN)
        self.mwmLabel = tk.Label(self.mouseWheelFrame,
                                 text="Mouse wheel manipulation")
        self.mwmLabel.pack()
        # Modify by multiplication or addition (modModus)
        self.modModus = tk.StringVar()
        self.modModus.set("mul")
        # Entry field and radiobutton to specify factor to be used
        self.factorFrame = tk.Frame(self.mouseWheelFrame)
        self.modEntryTextMul = tk.StringVar()
        self.modEntryFactor = tk.Entry(self.factorFrame,
                                       textvariable=self.modEntryTextMul,
                                       width=6)
        self.modEntryFactor.pack(side=tk.LEFT)
        self.radioMultipli = tk.Radiobutton(self.factorFrame,
                                            text="Multiply",
                                            value="mul",
                                            variable=self.modModus)
        self.radioMultipli.pack(side=tk.LEFT)
        self.factorFrame.pack(fill=tk.BOTH)
        # Entry field and radiobutton to specify step (delta) to be used
        self.addFrame = tk.Frame(self.mouseWheelFrame)
        self.modEntryTextAdd = tk.StringVar()
        self.modEntryAdd = tk.Entry(self.addFrame,
                                    textvariable=self.modEntryTextAdd,
                                    width=6)
        self.modEntryAdd.pack(side=tk.LEFT)
        self.radioAdd = tk.Radiobutton(self.addFrame,
                                       text="Add",
                                       value="add",
                                       variable=self.modModus)
        self.radioAdd.pack(side=tk.LEFT)
        self.addFrame.pack(fill=tk.BOTH)
        # Set text fields for modification factor/step to default
        self.modEntryTextMul.set(
            self.modProps[self.selectedPar.get()]["modValMul"])
        self.modEntryTextAdd.set(
            self.modProps[self.selectedPar.get()]["modValAdd"])
        self.modEntryTextAdd.trace("w", self._modModeChangedAdd)
        self.modEntryTextMul.trace("w", self._modModeChangedMul)
        # Show the frame
        #     self.mouseWheelFrame.grid(row=4, column=0, columnspan=3, pady=10)
        self.mouseWheelFrame.pack()

        # React to change in modify Modus
        self.modModus.trace('w', self._modModusChanged)
        # React to a change in the active parameter
        self.selectedPar.trace("w", self._activeParameterChanged)

        dummyLabel = tk.Label(self.controlFrame)
        dummyLabel.pack()

        # Fit button and fit ranges
        self.fitRangeFrame = tk.Frame(self.controlFrame,
                                      bd=3,
                                      relief=tk.SUNKEN)
        self.fit_lo = tk.DoubleVar()
        self.fit_hi = tk.DoubleVar()
        self.fit_lo.set(min(plotter.x))
        self.fit_hi.set(max(plotter.x))
        self.fitRangeLoLim = tk.Entry(self.fitRangeFrame,
                                      textvariable=self.fit_lo,
                                      width=9,
                                      bd=2)
        self.fitRangeHiLim = tk.Entry(self.fitRangeFrame,
                                      textvariable=self.fit_hi,
                                      width=9,
                                      bd=2)
        self.fitRangeLabel = tk.Label(self.fitRangeFrame, text="Fit range:")
        self.fitButton = tk.Button(self.fitRangeFrame,
                                   text="Fit",
                                   command=self._fitClicked)
        self.fitButton.pack(side=tk.BOTTOM, fill=tk.X)
        self.fitRangeLabel.pack(side=tk.LEFT, fill=tk.X)
        self.fitRangeHiLim.pack(side=tk.RIGHT)
        self.fitRangeLoLim.pack(side=tk.RIGHT)
        self.fitRangeFrame.pack(fill=tk.X)
        #self.fitRangeLoLim.bind('<Return>', self._fitRangeChanged())
        self.fit_lo.trace("w", self._fitRangeChanged)
        self.fit_hi.trace("w", self._fitRangeChanged)
        self.numberClicked = 0
        #self.modModus.trace('w', self._modModusChanged)
        #self.modModus.trace('w', self._modModusChanged)

        dummyLabel = tk.Label(self.controlFrame)
        dummyLabel.pack()

        # , relief=tk.SUNKEN)
        self.showFrame = tk.Frame(self.controlFrame, bd=3)
        self.showFrame.pack(side=tk.TOP)

        self.parSumButton = tk.Button(self.showFrame,
                                      text="Parameter summary",
                                      command=self._parameterSummaryClicked)
        self.parSumButton.pack(side=tk.LEFT)

        self.valSetButton = tk.Button(self.showFrame,
                                      text="Value set code",
                                      command=self._valueSetClicked)
        #     self.valSetButton.grid(row=7, column=2)
        self.valSetButton.pack(side=tk.RIGHT)

        # a tk.DrawingArea
        #     self.canvas.get_tk_widget().grid(column=0, columnspan=7, row=0, rowspan=10)
        self.canvas.get_tk_widget().pack()
        self.cid = self.f.canvas.mpl_connect('button_press_event',
                                             self._mouseButtonClicked)
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.plotFrame)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        def _quit():
            # stops main loop
            self.root.quit()
            # this is necessary on Windows to prevent
            # Fatal Python Error: PyEval_RestoreThread: NULL tstate
            self.root.destroy()

        self.quitButton = tk.Button(master=self.controlFrame,
                                    text='Quit',
                                    command=_quit)
        self.quitButton.pack(side=tk.BOTTOM)

        # Plot the model for the first time
        self._parameterValueChanged()

        # Whether or not parameter summary exists
        self.root.parSumWin = None

        if platform.system() == "Darwin":
            self.root.bind("<MouseWheel>", self._onWheel)  # for OS X
コード例 #9
0
    def __init__(self, x, y, yerr=None, mode="gauss", config=None):
        self.windowTitle = "PyA interactive GV"
        self.f = Figure()
        self.a = self.f.add_subplot(111)

        self._config = {"modelLS":'r--', \
                        "dataLS":'bp', \
                        "dataLSerr":'b+', \
                        "activeCompLS":'k-', \
                        "inactiveCompLS":'y--', \
                        "plotIndComps":True, \
                        "rangeLS":'m--', \
                        "defaultFreeVoigt":["A", "ad", "al", "mu"], \
                        "default_alad":0.1, \
                        "defaultFreeGauss":["A", "sig", "mu"], \
                        "defaultWheelAdd":0.01, \
                        "defaultWheelMult": 2}

        # Modify configuration according to input
        if config is not None:
            for k in six.iterkeys(self._config):
                if k in config:
                    # Value has been modified
                    self._config[k] = config[k]

        # Tk root
        self.root = tk.Tk()

        # Create data plot
        self._x = x
        self._y = y
        self._yerr = yerr
        if self._yerr is None:
            self.a.plot(x, y, self._config["dataLS"])
        else:
            self.a.errorbar(x,
                            y,
                            yerr=self._yerr,
                            fmt=self._config["dataLSerr"])

        # The input mode determines how clicks on the mouse wheel are
        # interpreted.
        self._inputMode = "newComp"

        # Component count/assignment starts at 1
        self._activeComponent = 1
        self._compoCount = 0

        # Create model and parameter lists
        self._mode = mode
        if self._mode == "voigt":
            self._model = fuf.MultiVoigt1d(1)
            self._compPars = ["mu", "ad", "al", "A"]
        elif self._mode == "gauss":
            self._model = fuf.MultiGauss1d(1)
            self._compPars = ["mu", "sig", "A"]
        else:
            raise(PE.PyAValError("No such mode: " + str(self._mode), \
                                 solution="Choose either 'voigt' or 'gauss'."))
        self._model["off"] = 1.0

        # List used to cache points used to add component
        # as long as component is not completely specified
        self._pointCache = []

        # What to consider in the fit
        self._rangeIndices = np.arange(self._x.size, dtype=np.int)

        # A frame containing the mpl plot
        self.plotFrame = tk.Frame()
        self.plotFrame.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
        self.canvas = FigureCanvasTkAgg(self.f, master=self.plotFrame)

        # A frame containing the box with selected points
        # and control buttons
        self.pointFrame = tk.Frame(self.root)
        self.pointFrame.pack(side=tk.LEFT, fill=tk.BOTH)

        # Manage active component
        self.activeCompoFrame = tk.Frame(self.pointFrame)
        self.activeCompoFrame.pack(side=tk.TOP)
        self.currentComponentLabel = tk.Label(self.activeCompoFrame,
                                              text="Active component")
        self.currentComponentLabel.pack(side=tk.TOP)
        # De- and increase no. of active component
        self.downACB = tk.Button(self.activeCompoFrame,
                                 text="-",
                                 command=self._downAC)
        self._acstring = tk.StringVar()
        self._acstring.set(str(self._activeComponent))
        self.ACLabel = tk.Label(self.activeCompoFrame,
                                textvariable=self._acstring)
        self.upACB = tk.Button(self.activeCompoFrame,
                               text="+",
                               command=self._upAC)
        self.downACB.pack(side=tk.LEFT)
        self.ACLabel.pack(side=tk.LEFT)
        self.upACB.pack(side=tk.RIGHT)

        # Show and work with parameters
        self.parameterFrame = tk.Frame(self.pointFrame,
                                       relief=tk.RAISED,
                                       borderwidth=1)
        self.parameterFrame.pack(side=tk.TOP)
        # Headline
        tk.Label(self.parameterFrame,
                 text="Parameters (active comp.)").pack(side=tk.TOP)
        # List of parameters to show
        pars = ["off"]
        pars.extend(self._compPars)
        self._parSelect = tk.IntVar()
        # Frames for individual parameters
        self._parFrames = []
        self._parValues = []
        self._parFreeVars = []

        for i, p in enumerate(pars):
            self._parFrames.append(tk.Frame(self.parameterFrame))
            self._parFrames[-1].pack(side=tk.TOP)
            b = tk.Radiobutton(self._parFrames[-1],
                               text="",
                               variable=self._parSelect,
                               value=i)
            b.pack(side=tk.LEFT, anchor=tk.W)
            l = tk.Label(self._parFrames[-1], text=("%3s" % p), width=3)
            l.pack(side=tk.LEFT, anchor=tk.W)
            self._parValues.append(tk.StringVar())
            self._parValues[-1].set("0.0")
            l = tk.Label(self._parFrames[-1],
                         textvariable=self._parValues[-1],
                         width=10)
            l.pack(side=tk.LEFT)

            self._parFreeVars.append(tk.IntVar())
            c = tk.Checkbutton(self._parFrames[-1], text="free", variable=self._parFreeVars[-1], \
                               command=self._freeCheckboxClicked)
            c.pack(side=tk.LEFT)

        # Wheel modification
        self._wheelModFrame = tk.Frame(self.pointFrame,
                                       relief=tk.RAISED,
                                       borderwidth=1)
        self._wheelModFrame.pack(side=tk.TOP)
        # Headline
        tk.Label(self._wheelModFrame, text="Mouse wheel").pack(side=tk.TOP)
        self._multAddSelect = tk.IntVar()
        self._multAddSelect.set(1)
        multiFrame = tk.Frame(self._wheelModFrame)
        addFrame = tk.Frame(self._wheelModFrame)
        multiFrame.pack(side=tk.TOP)
        addFrame.pack(side=tk.TOP)
        tk.Radiobutton(multiFrame,
                       text="multiply [%]",
                       variable=self._multAddSelect,
                       value=1,
                       width=9,
                       anchor=tk.W).pack(side=tk.LEFT)
        tk.Radiobutton(addFrame,
                       text="add",
                       variable=self._multAddSelect,
                       value=2,
                       width=9,
                       anchor=tk.W).pack(side=tk.LEFT)
        self._multNumber = tk.StringVar()
        self._addNumber = tk.StringVar()
        self._multNumber.set(str(self._config["defaultWheelMult"]))
        self._addNumber.set(str(self._config["defaultWheelAdd"]))
        self._multNumberEntry = tk.Entry(multiFrame,
                                         textvariable=self._multNumber,
                                         width=10)
        self._multNumberEntry.pack(side=tk.RIGHT)
        self._addNumberEntry = tk.Entry(addFrame,
                                        textvariable=self._addNumber,
                                        width=10)
        self._addNumberEntry.pack(side=tk.RIGHT)

        # Common width
        if self._mode == "gauss":
            commonSigFrame = tk.Frame(self.pointFrame)
            commonSigFrame.pack(side=tk.TOP)
            self._commonSig = tk.IntVar()
            c = tk.Checkbutton(commonSigFrame, text="Common width (sig)", variable=self._commonSig, \
                               command=self._commonSigClicked)
            c.pack(side=tk.LEFT)

        # Fit button
        self._fitButton = tk.Button(self.pointFrame,
                                    text="Fit",
                                    command=self._fitModel)
        self._fitButton.pack(side=tk.TOP, fill=tk.X)

        # Range button
        self._rangeButton = tk.Button(self.pointFrame,
                                      text="Set fit range",
                                      command=self._rangeButtonClicked)
        self._rangeButton.pack(side=tk.TOP, fill=tk.X)

        # Remove button
        self.removeButton = tk.Button(master=self.pointFrame, text="Remove component", \
                                      command=self._removeButtonClicked)
        self.removeButton.pack(side=tk.TOP, fill=tk.X)

        # a tk.DrawingArea
        self.canvas.get_tk_widget().pack()
        self.cid = self.f.canvas.mpl_connect('button_press_event',
                                             self._mouseButtonClicked)
        self.mwe = self.f.canvas.mpl_connect('scroll_event', self._mouseWheel)

        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.plotFrame)
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        def _quit():
            # stops main loop
            self.root.quit()
            # this is necessary on Windows to prevent
            # Fatal Python Error: PyEval_RestoreThread: NULL tstate
            self.root.destroy()

        self.quitButton = tk.Button(master=self.pointFrame,
                                    text='Quit',
                                    command=_quit)
        self.quitButton.pack(side=tk.BOTTOM, fill=tk.X)
コード例 #10
0
def create_widgets():
    global list_box, canvas, label, zoom_label
    #
    root = tkinter.Tk()
    #
    list_box = tkinter.Listbox(root, exportselection=False)
    list_box.grid(row=0, column=0, rowspan=2, sticky=tkinter.NS)
    cardsets_list = list(cardsets_dict)
    cardsets_list.sort()
    for cs in cardsets_list:
        list_box.insert(tkinter.END, cs)
    list_box.bind('<<ListboxSelect>>', show_cardset)
    #
    sb = tkinter.Scrollbar(root)
    sb.grid(row=0, column=1, rowspan=2, sticky=tkinter.NS)
    list_box.config(yscrollcommand=sb.set)
    sb.config(command=list_box.yview)
    #
    canvas = tkinter.Canvas(root, bg='#5eab6b')
    canvas.grid(row=0, column=2, sticky=tkinter.NSEW)
    canvas.bind('<4>', lambda e: canvas.yview_scroll(-5, 'unit'))
    canvas.bind('<5>', lambda e: canvas.yview_scroll(5, 'unit'))
    #
    sb = tkinter.Scrollbar(root)
    sb.grid(row=0, column=3, sticky=tkinter.NS)
    canvas.config(yscrollcommand=sb.set)
    sb.config(command=canvas.yview)
    #
    if True:
        sb = tkinter.Scrollbar(root, orient=tkinter.HORIZONTAL)
        sb.grid(row=1, column=2, sticky=tkinter.EW)
        canvas.config(xscrollcommand=sb.set)
        sb.config(command=canvas.xview)
    #
    label = tkinter.Label(root)
    label.grid(row=2, column=0, columnspan=4)
    #
    b_frame = tkinter.Frame(root)
    b_frame.grid(row=3, column=0, columnspan=4, sticky=tkinter.EW)
    button = tkinter.Button(b_frame, text='Quit', command=root.quit, width=8)
    button.pack(side=tkinter.RIGHT)
    button = tkinter.Button(b_frame, text='Info', command=show_info, width=8)
    button.pack(side=tkinter.RIGHT)
    if Image:
        global rotate_var, filter_var
        rotate_var = tkinter.IntVar(root)
        filter_var = tkinter.StringVar(root)
        button = tkinter.Button(b_frame, text='  +  ', command=zoom_in)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Button(b_frame, text='  -  ', command=zoom_out)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Button(b_frame, text='  =  ', command=zoom_cancel)
        button.pack(side=tkinter.LEFT)
        button = tkinter.Checkbutton(b_frame,
                                     text='Rotate',
                                     indicatoron=0,
                                     selectcolor=b_frame['bg'],
                                     width=8,
                                     variable=rotate_var,
                                     command=show_cardset)
        button.pack(side=tkinter.LEFT, fill='y')
        om = tkinter.OptionMenu(b_frame,
                                filter_var,
                                'NEAREST',
                                'BILINEAR',
                                'BICUBIC',
                                'ANTIALIAS',
                                command=show_cardset)
        filter_var.set('NEAREST')
        om.pack(side=tkinter.LEFT, fill='y')

        zoom_label = tkinter.Label(b_frame)
        zoom_label.pack(side=tkinter.LEFT)
    #
    root.columnconfigure(2, weight=1)
    root.rowconfigure(0, weight=1)

    root.title('Show Cardsets')

    return root
コード例 #11
0
ファイル: input_gui.py プロジェクト: normoes/money
    def initialize(self):
        """
            Initialize the tKinter app (GUI)
            by creating frames and graphical components,
            setting the window size etc.
        """
        # self.bind("<Escape>", lambda x: self.destroy())
        self.bind("<Escape>", on_close)

        listFrame0 = Frame(self)
        listFrame0.pack(side=TOP, fill=BOTH, expand=True)
        listFrame = Frame(listFrame0)
        listFrame.pack(side=LEFT, fill=BOTH, expand=True)

        scrollbary = Scrollbar(listFrame, orient=VERTICAL)
        scrollbary.pack(side=RIGHT, fill=Y)
        scrollbarx = Scrollbar(listFrame, orient=HORIZONTAL)
        scrollbarx.pack(side=BOTTOM, fill=X)
        # bd --> border
        self.listbox = Listbox(listFrame, bd=1, selectmode=SINGLE, yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set)
        self.listbox.bind('<<ListboxSelect>>', self.on_select_click)
        scrollbary.config(command=self.listbox.yview)
        scrollbarx.config(command=self.listbox.xview)
        self.listbox.config(width=self.listbox.winfo_reqwidth() // 3)  # width=self.listbox.winfo_reqwidth()
        self.listbox.pack(side=LEFT, fill=BOTH, expand=True)

        listFrame1 = Frame(listFrame0)
        listFrame1.pack(side=LEFT, fill=BOTH, expand=True)
        scrollbary1 = Scrollbar(listFrame1, orient=VERTICAL)
        scrollbary1.pack(side=RIGHT, fill=Y)
        scrollbarx1 = Scrollbar(listFrame1, orient=HORIZONTAL)
        scrollbarx1.pack(side=BOTTOM, fill=X)
        # bd --> border
        self.listbox1 = Listbox(listFrame1, bd=0, selectmode=SINGLE, yscrollcommand=scrollbary1.set, xscrollcommand=scrollbarx1.set)
        self.listbox1.bind('<<ListboxSelect>>', self.on_update_select_click)
        scrollbary1.config(command=self.listbox1.yview)
        scrollbarx1.config(command=self.listbox1.xview)
        self.listbox1.config(width=self.listbox1.winfo_reqwidth() // 2)  # width=self.listbox.winfo_reqwidth()
        self.listbox1.pack(side=LEFT, fill=BOTH, expand=True)

        text_frame = Frame(self)
        text_frame.pack(fill=X)  # ,expand=True)
        self.created_str = tk.StringVar()
        created = tk.Entry(text_frame, textvariable=self.created_str)
        self.created_months = ttk.Combobox(text_frame)
        self.created_months['values'] = ('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12')
        self.created_months.set(datetime.date.today().strftime('%m'))
        self.created_months.state(['readonly'])
        # self.created_months.bind('<<ComboboxSelected>>', self.On_table_select)
        self.value_str = tk.StringVar()
        value = tk.Entry(text_frame, textvariable=self.value_str)
        self.category_str = tk.StringVar()
        category = tk.Entry(text_frame, textvariable=self.category_str)  # , state='readonly')
        self.description_str = tk.StringVar()
        description = tk.Entry(text_frame, textvariable=self.description_str)
        fill_from_csv_button = Button(text_frame, text="fill from csv")
        fill_from_csv_button.bind('<Button-1>', self.on_fill_from_csv_click)
        self.db_tables = ttk.Combobox(text_frame)
        self.db_tables.state(['readonly'])
        self.db_tables.bind('<<ComboboxSelected>>', self.on_table_select)
        created.pack(side=LEFT)
        self.created_months.pack(side=LEFT)
        value.pack(side=LEFT)
        category.pack(side=LEFT)
        description.pack(side=LEFT)
        # check.pack(side=LEFT)
        fill_from_csv_button.pack(side=LEFT)
        self.db_tables.pack(side=LEFT)

        button_frame = Frame(self)
        button_frame.pack(fill=X)  # ,expand=True)

        save_button = Button(button_frame, text="save entry")
        save_button.bind('<Button-1>', self.on_save_entry_click)

        database_button = Button(button_frame, text="select database")
        database_button.bind('<Button-1>', self.on_database_click)
        self.database_path_str = tk.StringVar()
        self.database_path = tk.Label(button_frame, textvariable=self.database_path_str, bg="white", anchor=tk.W)

        save_button.pack(side=LEFT)
        database_button.pack(side=RIGHT)
        self.database_path.pack(side=RIGHT)   # , expand=True, fill=BOTH fill=BOTH,

        debugFrame = Frame(self)
        debugFrame.pack(side=BOTTOM, fill=X)  # ,expand=True)
        self.last_entry = tk.StringVar()
        self.path_label = tk.Label(debugFrame, textvariable=self.last_entry, bg="white", anchor=tk.W)

        self.path_label.pack(side=LEFT, fill=BOTH, expand=True)

        # print self.geometry()
        self.update()
        # self.geometry(self.geometry())
        # self.update()
        # print self.geometry()
        # fix the size of the window by setting the window size to its own size
        w = self.winfo_screenwidth()
        # print w
        # print 'reqwidth',self.winfo_reqwidth()
        # h = self.winfo_screenheight()
        self.geometry('{0}x{1}+{2}+{3}'.format(self.winfo_reqwidth(), self.winfo_reqheight() * 3, w - self.winfo_reqwidth() - 20, 0))  # self.geometry()
        self.update()
        self.minsize(self.winfo_reqwidth(), self.winfo_reqheight())
コード例 #12
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)
コード例 #13
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)