Beispiel #1
0
        def hpanel(params, cols, pack):
            res = []
            if len(cols) >= 2:
                widget = Widgets.Splitter(orientation='horizontal')
                process_common_params('hpanel', widget, params)

                sizes = []
                for col in cols:
                    c = make(col, lambda w: widget.add_widget(w))
                    res.append(c)

                    # collect widths to set width of panes
                    params = col[1]
                    if 'width' in params:
                        sizes.append(params['width'])

                sizes = params.get('sizes', sizes)
                if len(sizes) == len(cols):
                    widget.set_sizes(sizes)
                    params.update(dict(sizes=sizes))

            elif len(cols) == 1:
                widget = Widgets.HBox()
                widget.set_border_width(0)
                process_common_params('hbox', widget, params)

                c = make(cols[0], lambda w: widget.add_widget(w, stretch=1))
                res.append(c)
                # widget.show()

            pack(widget)
            return ['hpanel', params] + res
Beispiel #2
0
        def hpanel(params, cols, pack):
            if len(cols) >= 2:
                widget = Widgets.Splitter(orientation='horizontal')
                process_common_params(widget, params)

                sizes = []
                for col in cols:
                    make(col, lambda w: widget.add_widget(w))

                    # collect widths to set width of panes
                    params = col[1]
                    if 'width' in params:
                        sizes.append(params['width'])

                if len(sizes) == len(cols):
                    widget.set_sizes(sizes)

            elif len(cols) == 1:
                widget = Widgets.HBox()
                widget.set_border_width(0)
                process_common_params(widget, params)

                make(cols[0], lambda w: widget.add_widget(w, stretch=1))
                #widget.show()

            pack(widget)
Beispiel #3
0
        def vpanel(params, rows, pack):
            res = []
            if len(rows) >= 2:
                widget = Widgets.Splitter(orientation='vertical')
                process_common_params('vpanel', widget, params)

                sizes = []
                for row in rows:
                    r = make(row, lambda w: widget.add_widget(w))
                    res.append(r)

                    # collect heights to set height of panes
                    params = row[1]
                    if 'height' in params:
                        sizes.append(params['height'])

                sizes = params.get('sizes', sizes)
                if len(sizes) == len(rows):
                    widget.set_sizes(sizes)
                    params.update(dict(sizes=sizes))

            elif len(rows) == 1:
                widget = Widgets.VBox()
                widget.set_border_width(0)
                process_common_params('vbox', widget, params)

                r = make(rows[0], lambda w: widget.add_widget(w, stretch=1))
                res.append(r)
                # widget.show()

            pack(widget)
            return ['vpanel', params] + res
Beispiel #4
0
        def vpanel(params, rows, pack):
            if len(rows) >= 2:
                widget = Widgets.Splitter(orientation='vertical')
                process_common_params(widget, params)

                sizes = []
                for row in rows:
                    make(row, lambda w: widget.add_widget(w))

                    # collect heights to set height of panes
                    params = row[1]
                    if 'height' in params:
                        sizes.append(params['height'])

                if len(sizes) == len(rows):
                    widget.set_sizes(sizes)

            elif len(rows) == 1:
                widget = Widgets.VBox()
                widget.set_border_width(0)
                process_common_params(widget, params)

                make(rows[0], lambda w: widget.add_widget(w, stretch=1))
                #widget.show()

            pack(widget)
Beispiel #5
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        msgFont = self.fv.getFont('sansFont', 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(msgFont)
        self.tw = tw

        fr = Widgets.Expander('Instructions')
        fr.set_widget(tw)
        vbox.add_widget(fr, stretch=0)

        fr = Widgets.Frame('Single Pixel')
        captions = [('X:', 'label', 'X', 'entry'),
                    ('Y:', 'label', 'Y', 'entry'),
                    ('DQ Flag:', 'label', 'DQ', 'llabel')]
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.x.set_tooltip('X of pixel')
        b.x.set_text(str(self.xcen))
        b.x.add_callback('activated', lambda w: self.set_xcen())

        b.y.set_tooltip('Y of pixel')
        b.y.set_text(str(self.ycen))
        b.y.add_callback('activated', lambda w: self.set_ycen())

        b.dq.set_tooltip('DQ value of pixel')
        b.dq.set_text(self._no_keyword)

        # Create the Treeview
        self.pxdqlist = Widgets.TreeView(auto_expand=True,
                                         sortable=True,
                                         selection='multiple',
                                         use_alt_row_color=True)
        self.pxdqlist.setup_table(self.pxdqcolumns, 1, 'FLAG')

        splitter = Widgets.Splitter('vertical')
        splitter.add_widget(w)
        splitter.add_widget(self.pxdqlist)
        fr.set_widget(splitter)
        vbox.add_widget(fr, stretch=1)

        fr = Widgets.Frame('Whole Image')
        captions = [('Number of pixels:', 'llabel', 'npix', 'llabel',
                     'spacer1', 'spacer')]
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.npix.set_tooltip('Number of affected pixels')
        b.npix.set_text(self._no_keyword)

        # Create the Treeview
        self.imdqlist = Widgets.TreeView(auto_expand=True,
                                         sortable=True,
                                         selection='multiple',
                                         use_alt_row_color=True)
        self.imdqlist.setup_table(self.imdqcolumns, 1, 'FLAG')
        self.imdqlist.add_callback('selected', self.mark_dqs_cb)

        splitter = Widgets.Splitter('vertical')
        splitter.add_widget(w)
        splitter.add_widget(self.imdqlist)
        fr.set_widget(splitter)
        vbox.add_widget(fr, stretch=1)

        top.add_widget(sw, stretch=1)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        btn = Widgets.Button('Close')
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)
        container.add_widget(top, stretch=1)

        self.gui_up = True

        # Populate fields based on active image
        self.redo()
Beispiel #6
0
    def build_gui(self, container):

        vtop = Widgets.VBox()
        vtop.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container)
        # Uncomment to debug; passing parent logger generates too
        # much noise in the main logger
        #zi = Viewers.CanvasView(logger=self.logger)
        zi = Viewers.CanvasView(logger=None)
        zi.set_desired_size(self._wd, self._ht)
        zi.enable_autozoom('off')
        zi.enable_autocuts('off')
        zi.zoom_to(self.default_zoom)
        settings = zi.get_settings()
        settings.get_setting('zoomlevel').add_callback('set', self.zoomset, zi)
        zi.set_bg(0.4, 0.4, 0.4)
        zi.show_pan_mark(True)
        cmname = self.settings.get('zoom_cmap_name', None)
        if cmname is not None:
            zi.set_color_map(cmname)
        imname = self.settings.get('zoom_imap_name', None)
        if imname is not None:
            zi.set_intensity_map(imname)
        # for debugging
        zi.set_name('zoomimage')
        self.zoomimage = zi

        bd = zi.get_bindings()
        bd.enable_zoom(False)
        bd.enable_pan(False)
        bd.enable_cmap(False)

        iw = Viewers.GingaViewerWidget(zi)
        iw.resize(self._wd, self._ht)
        paned = Widgets.Splitter(orientation=orientation)
        paned.add_widget(iw)

        vbox2 = Widgets.VBox()
        captions = (
            ("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'),
            ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'),
        )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        vbox2.add_widget(w, stretch=0)

        self.w.zoom_radius.set_limits(1, 300, incr_value=1)
        self.w.zoom_radius.set_value(self.zoom_radius)
        self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb)
        self.w.zoom_radius.set_tracking(True)

        self.w.zoom_amount.set_limits(-20, 30, incr_value=1)
        self.w.zoom_amount.set_value(self.zoom_amount)
        self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb)
        self.w.zoom_amount.set_tracking(True)

        captions = (
            ("Zoom:", 'label', 'Zoom', 'label'),
            ("Relative Zoom", 'checkbutton'),
            ("Refresh Interval", 'label', 'Refresh Interval', 'spinbutton'),
            ("Defaults", 'button'),
        )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.zoom.set_text(self.fv.scale2text(zi.get_scale()))
        b.relative_zoom.set_state(not self.t_abszoom)
        b.relative_zoom.add_callback("activated", self.set_absrel_cb)
        b.defaults.add_callback("activated", lambda w: self.set_defaults())
        b.refresh_interval.set_limits(0, 200, incr_value=1)
        b.refresh_interval.set_value(int(self.refresh_interval * 1000))
        b.refresh_interval.add_callback('value-changed', self.set_refresh_cb)

        row = Widgets.HBox()
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        vbox2.add_widget(row, stretch=0)

        # stretch
        spacer = Widgets.Label('')
        vbox2.add_widget(spacer, stretch=1)

        box.add_widget(vbox2, stretch=1)

        paned.add_widget(sw)
        # hack to set a reasonable starting position for the splitter
        _sz = max(self._wd, self._ht)
        paned.set_sizes([_sz, _sz])

        vtop.add_widget(paned, stretch=5)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)
        vtop.add_widget(btns, stretch=0)

        container.add_widget(vtop, stretch=5)
        self.gui_up = True
Beispiel #7
0
    def build_gui(self, container):
        assert iqcalc.have_scipy == True, \
               Exception("Please install python-scipy to use this plugin")

        self.pickcenter = None

        vtop = Widgets.VBox()
        vtop.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container, fill=True)
        box.set_border_width(4)
        box.set_spacing(2)

        self.msg_font = self.fv.get_font("sansFont", 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msg_font)
        self.tw = tw

        fr = Widgets.Expander("Instructions")
        fr.set_widget(tw)
        box.add_widget(fr, stretch=0)

        vpaned = Widgets.Splitter(orientation=orientation)

        nb = Widgets.TabWidget(tabpos='bottom')
        self.w.nb1 = nb
        vpaned.add_widget(nb)

        cm, im = self.fv.cm, self.fv.im

        di = Viewers.CanvasView(logger=self.logger)
        width, height = 300, 300
        di.set_desired_size(width, height)
        di.enable_autozoom('off')
        di.enable_autocuts('off')
        di.zoom_to(3)
        settings = di.get_settings()
        settings.getSetting('zoomlevel').add_callback('set', self.zoomset, di)
        di.set_cmap(cm)
        di.set_imap(im)
        di.set_callback('none-move', self.detailxy)
        di.set_bg(0.4, 0.4, 0.4)
        # for debugging
        di.set_name('pickimage')
        self.pickimage = di

        bd = di.get_bindings()
        bd.enable_pan(True)
        bd.enable_zoom(True)
        bd.enable_cuts(True)

        di.configure(width, height)
        iw = Viewers.GingaViewerWidget(viewer=di)
        iw.resize(300, 300)
        nb.add_widget(iw, title="Image")

        if have_mpl:
            # Contour plot
            hbox = Widgets.HBox()
            self.contour_plot = plots.ContourPlot(logger=self.logger,
                                                  width=400,
                                                  height=300)
            self.contour_plot.add_axis(axisbg='black')
            pw = Plot.PlotWidget(self.contour_plot)
            pw.resize(400, 300)
            hbox.add_widget(pw, stretch=1)
            zoom = Widgets.Slider(orientation='vertical', track=True)
            zoom.set_limits(1, 100, incr_value=1)
            zoom.set_value(self.contour_plot.plot_zoomlevel)

            def zoom_contour_cb(w, val):
                self.contour_plot.plot_zoom(val / 10.0)

            zoom.add_callback('value-changed', zoom_contour_cb)
            hbox.add_widget(zoom, stretch=0)
            nb.add_widget(hbox, title="Contour")

            # FWHM gaussians plot
            self.fwhm_plot = plots.FWHMPlot(logger=self.logger,
                                            width=400,
                                            height=300)
            self.fwhm_plot.add_axis(axisbg='white')
            pw = Plot.PlotWidget(self.fwhm_plot)
            pw.resize(400, 300)
            nb.add_widget(pw, title="FWHM")

            # Radial profile plot
            self.radial_plot = plots.RadialPlot(logger=self.logger,
                                                width=400,
                                                height=300)
            self.radial_plot.add_axis(axisbg='white')
            pw = Plot.PlotWidget(self.radial_plot)
            pw.resize(400, 300)
            nb.add_widget(pw, title="Radial")

        fr = Widgets.Frame(self._textlabel)

        nb = Widgets.TabWidget(tabpos='bottom')
        self.w.nb2 = nb

        # Build report panel
        captions = (
            ('Zoom:', 'label', 'Zoom', 'llabel'),
            ('Object_X', 'label', 'Object_X', 'llabel', 'Object_Y', 'label',
             'Object_Y', 'llabel'),
            ('RA:', 'label', 'RA', 'llabel', 'DEC:', 'label', 'DEC', 'llabel'),
            ('Equinox:', 'label', 'Equinox', 'llabel', 'Background:', 'label',
             'Background', 'llabel'),
            ('Sky Level:', 'label', 'Sky Level', 'llabel', 'Brightness:',
             'label', 'Brightness', 'llabel'),
            ('FWHM X:', 'label', 'FWHM X', 'llabel', 'FWHM Y:', 'label',
             'FWHM Y', 'llabel'),
            ('FWHM:', 'label', 'FWHM', 'llabel', 'Star Size:', 'label',
             'Star Size', 'llabel'),
            ('Sample Area:', 'label', 'Sample Area', 'llabel',
             'Default Region', 'button'),
            ('Pan to pick', 'button'),
        )

        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        b.zoom.set_text(self.fv.scale2text(di.get_scale()))
        self.wdetail = b
        b.default_region.add_callback('activated',
                                      lambda w: self.reset_region())
        b.default_region.set_tooltip("Reset region size to default")
        b.pan_to_pick.add_callback('activated',
                                   lambda w: self.pan_to_pick_cb())
        b.pan_to_pick.set_tooltip("Pan image to pick center")

        vbox1 = Widgets.VBox()
        vbox1.add_widget(w, stretch=0)

        # spacer
        vbox1.add_widget(Widgets.Label(''), stretch=0)

        # Pick field evaluation status
        hbox = Widgets.HBox()
        hbox.set_spacing(4)
        hbox.set_border_width(4)
        label = Widgets.Label()
        #label.set_alignment(0.05, 0.5)
        self.w.eval_status = label
        hbox.add_widget(self.w.eval_status, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox1.add_widget(hbox, stretch=0)

        # Pick field evaluation progress bar and stop button
        hbox = Widgets.HBox()
        hbox.set_spacing(4)
        hbox.set_border_width(4)
        btn = Widgets.Button("Stop")
        btn.add_callback('activated', lambda w: self.eval_intr())
        btn.set_enabled(False)
        self.w.btn_intr_eval = btn
        hbox.add_widget(btn, stretch=0)

        self.w.eval_pgs = Widgets.ProgressBar()
        hbox.add_widget(self.w.eval_pgs, stretch=1)
        vbox1.add_widget(hbox, stretch=0)

        nb.add_widget(vbox1, title="Readout")

        # Build settings panel
        captions = (
            ('Show Candidates', 'checkbutton'),
            ('Radius:', 'label', 'xlbl_radius', 'label', 'Radius',
             'spinbutton'),
            ('Threshold:', 'label', 'xlbl_threshold', 'label', 'Threshold',
             'entry'),
            ('Min FWHM:', 'label', 'xlbl_min_fwhm', 'label', 'Min FWHM',
             'spinbutton'),
            ('Max FWHM:', 'label', 'xlbl_max_fwhm', 'label', 'Max FWHM',
             'spinbutton'),
            ('Ellipticity:', 'label', 'xlbl_ellipticity', 'label',
             'Ellipticity', 'entry'),
            ('Edge:', 'label', 'xlbl_edge', 'label', 'Edge', 'entry'),
            ('Max side:', 'label', 'xlbl_max_side', 'label', 'Max side',
             'spinbutton'),
            ('Coordinate Base:', 'label', 'xlbl_coordinate_base', 'label',
             'Coordinate Base', 'entry'),
            ('Redo Pick', 'button'),
        )

        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        b.radius.set_tooltip("Radius for peak detection")
        b.threshold.set_tooltip("Threshold for peak detection (blank=default)")
        b.min_fwhm.set_tooltip("Minimum FWHM for selection")
        b.max_fwhm.set_tooltip("Maximum FWHM for selection")
        b.ellipticity.set_tooltip("Minimum ellipticity for selection")
        b.edge.set_tooltip("Minimum edge distance for selection")
        b.show_candidates.set_tooltip("Show all peak candidates")
        b.max_side.set_tooltip("Maximum dimension to search for peaks")
        b.coordinate_base.set_tooltip("Base of pixel coordinate system")
        # radius control
        #b.radius.set_digits(2)
        #b.radius.set_numeric(True)
        b.radius.set_limits(5.0, 200.0, incr_value=1.0)

        def chg_radius(w, val):
            self.radius = float(val)
            self.w.xlbl_radius.set_text(str(self.radius))
            return True

        b.xlbl_radius.set_text(str(self.radius))
        b.radius.add_callback('value-changed', chg_radius)

        # threshold control
        def chg_threshold(w):
            threshold = None
            ths = w.get_text().strip()
            if len(ths) > 0:
                threshold = float(ths)
            self.threshold = threshold
            self.w.xlbl_threshold.set_text(str(self.threshold))
            return True

        b.xlbl_threshold.set_text(str(self.threshold))
        b.threshold.add_callback('activated', chg_threshold)

        # min fwhm
        #b.min_fwhm.set_digits(2)
        #b.min_fwhm.set_numeric(True)
        b.min_fwhm.set_limits(0.1, 200.0, incr_value=0.1)
        b.min_fwhm.set_value(self.min_fwhm)

        def chg_min(w, val):
            self.min_fwhm = float(val)
            self.w.xlbl_min_fwhm.set_text(str(self.min_fwhm))
            return True

        b.xlbl_min_fwhm.set_text(str(self.min_fwhm))
        b.min_fwhm.add_callback('value-changed', chg_min)

        # max fwhm
        #b.max_fwhm.set_digits(2)
        #b.max_fwhm.set_numeric(True)
        b.max_fwhm.set_limits(0.1, 200.0, incr_value=0.1)
        b.max_fwhm.set_value(self.max_fwhm)

        def chg_max(w, val):
            self.max_fwhm = float(val)
            self.w.xlbl_max_fwhm.set_text(str(self.max_fwhm))
            return True

        b.xlbl_max_fwhm.set_text(str(self.max_fwhm))
        b.max_fwhm.add_callback('value-changed', chg_max)

        # Ellipticity control
        def chg_ellipticity(w):
            minellipse = None
            val = w.get_text().strip()
            if len(val) > 0:
                minellipse = float(val)
            self.min_ellipse = minellipse
            self.w.xlbl_ellipticity.set_text(str(self.min_ellipse))
            return True

        b.xlbl_ellipticity.set_text(str(self.min_ellipse))
        b.ellipticity.add_callback('activated', chg_ellipticity)

        # Edge control
        def chg_edgew(w):
            edgew = None
            val = w.get_text().strip()
            if len(val) > 0:
                edgew = float(val)
            self.edgew = edgew
            self.w.xlbl_edge.set_text(str(self.edgew))
            return True

        b.xlbl_edge.set_text(str(self.edgew))
        b.edge.add_callback('activated', chg_edgew)

        #b.max_side.set_digits(0)
        #b.max_side.set_numeric(True)
        b.max_side.set_limits(5, 10000, incr_value=10)
        b.max_side.set_value(self.max_side)

        def chg_max_side(w, val):
            self.max_side = int(val)
            self.w.xlbl_max_side.set_text(str(self.max_side))
            return True

        b.xlbl_max_side.set_text(str(self.max_side))
        b.max_side.add_callback('value-changed', chg_max_side)

        b.redo_pick.add_callback('activated', lambda w: self.redo())
        b.show_candidates.set_state(self.show_candidates)
        b.show_candidates.add_callback('activated', self.show_candidates_cb)
        self.w.xlbl_coordinate_base.set_text(str(self.pixel_coords_offset))
        b.coordinate_base.set_text(str(self.pixel_coords_offset))
        b.coordinate_base.add_callback('activated', self.coordinate_base_cb)

        vbox3 = Widgets.VBox()
        vbox3.add_widget(w, stretch=0)
        vbox3.add_widget(Widgets.Label(''), stretch=1)
        nb.add_widget(vbox3, title="Settings")

        # Build controls panel
        vbox3 = Widgets.VBox()
        captions = (
            ('Sky cut', 'button', 'Delta sky:', 'label', 'xlbl_delta_sky',
             'label', 'Delta sky', 'entry'),
            ('Bright cut', 'button', 'Delta bright:', 'label',
             'xlbl_delta_bright', 'label', 'Delta bright', 'entry'),
        )

        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        b.sky_cut.set_tooltip("Set image low cut to Sky Level")
        b.delta_sky.set_tooltip("Delta to apply to low cut")
        b.bright_cut.set_tooltip("Set image high cut to Sky Level+Brightness")
        b.delta_bright.set_tooltip("Delta to apply to high cut")

        b.sky_cut.set_enabled(False)
        self.w.btn_sky_cut = b.sky_cut
        self.w.btn_sky_cut.add_callback('activated', lambda w: self.sky_cut())
        self.w.sky_cut_delta = b.delta_sky
        b.xlbl_delta_sky.set_text(str(self.delta_sky))
        b.delta_sky.set_text(str(self.delta_sky))

        def chg_delta_sky(w):
            delta_sky = 0.0
            val = w.get_text().strip()
            if len(val) > 0:
                delta_sky = float(val)
            self.delta_sky = delta_sky
            self.w.xlbl_delta_sky.set_text(str(self.delta_sky))
            return True

        b.delta_sky.add_callback('activated', chg_delta_sky)

        b.bright_cut.set_enabled(False)
        self.w.btn_bright_cut = b.bright_cut
        self.w.btn_bright_cut.add_callback('activated',
                                           lambda w: self.bright_cut())
        self.w.bright_cut_delta = b.delta_bright
        b.xlbl_delta_bright.set_text(str(self.delta_bright))
        b.delta_bright.set_text(str(self.delta_bright))

        def chg_delta_bright(w):
            delta_bright = 0.0
            val = w.get_text().strip()
            if len(val) > 0:
                delta_bright = float(val)
            self.delta_bright = delta_bright
            self.w.xlbl_delta_bright.set_text(str(self.delta_bright))
            return True

        b.delta_bright.add_callback('activated', chg_delta_bright)

        vbox3.add_widget(w, stretch=0)
        vbox3.add_widget(Widgets.Label(''), stretch=1)
        nb.add_widget(vbox3, title="Controls")

        vbox3 = Widgets.VBox()
        msg_font = self.fv.get_font("fixedFont", 10)
        tw = Widgets.TextArea(wrap=False, editable=True)
        tw.set_font(msg_font)
        self.w.report = tw
        sw1 = Widgets.ScrollArea()
        sw1.set_widget(tw)
        vbox3.add_widget(sw1, stretch=1)
        tw.append_text(self._make_report_header())

        btns = Widgets.HBox()
        btns.set_spacing(4)
        btn = Widgets.Button("Add Pick")
        btn.add_callback('activated', lambda w: self.add_pick_cb())
        btns.add_widget(btn)
        btn = Widgets.CheckBox("Record Picks automatically")
        btn.set_state(self.do_record)
        btn.add_callback('activated', self.record_cb)
        btns.add_widget(btn)
        btns.add_widget(Widgets.Label(''), stretch=1)
        vbox3.add_widget(btns, stretch=0)

        btns = Widgets.HBox()
        btns.set_spacing(4)
        btn = Widgets.CheckBox("Log Records")
        btn.set_state(self.do_report_log)
        btn.add_callback('activated', self.do_report_log_cb)
        btns.add_widget(btn)
        btns.add_widget(Widgets.Label("File:"))
        ent = Widgets.TextEntry()
        ent.set_text(self.report_log)
        ent.add_callback('activated', self.set_report_log_cb)
        btns.add_widget(ent, stretch=1)
        vbox3.add_widget(btns, stretch=0)

        nb.add_widget(vbox3, title="Report")

        ## sw2 = Widgets.ScrollArea()
        ## sw2.set_widget(nb)
        ## fr.set_widget(sw2)
        fr.set_widget(nb)

        vpaned.add_widget(fr)

        mode = self.canvas.get_draw_mode()
        hbox = Widgets.HBox()
        btn1 = Widgets.RadioButton("Move")
        btn1.set_state(mode == 'move')
        btn1.add_callback('activated',
                          lambda w, val: self.set_mode_cb('move', val))
        btn1.set_tooltip("Choose this to position pick")
        self.w.btn_move = btn1
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Draw", group=btn1)
        btn2.set_state(mode == 'draw')
        btn2.add_callback('activated',
                          lambda w, val: self.set_mode_cb('draw', val))
        btn2.set_tooltip("Choose this to draw a replacement pick")
        self.w.btn_draw = btn2
        hbox.add_widget(btn2)

        btn3 = Widgets.RadioButton("Edit", group=btn1)
        btn3.set_state(mode == 'edit')
        btn3.add_callback('activated',
                          lambda w, val: self.set_mode_cb('edit', val))
        btn3.set_tooltip("Choose this to edit a pick")
        self.w.btn_edit = btn3
        hbox.add_widget(btn3)

        hbox.add_widget(Widgets.Label(''), stretch=1)
        #box.add_widget(hbox, stretch=0)
        vpaned.add_widget(hbox)

        box.add_widget(vpaned, stretch=1)

        vtop.add_widget(sw, stretch=5)

        ## spacer = Widgets.Label('')
        ## vtop.add_widget(spacer, stretch=0)

        btns = Widgets.HBox()
        btns.set_spacing(4)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vtop.add_widget(btns, stretch=0)

        container.add_widget(vtop, stretch=5)
Beispiel #8
0
    def build_gui(self, container):
        if not have_mpl:
            raise ImportError('Install matplotlib to use this plugin')

        top = Widgets.VBox()
        top.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_border_width(4)
        box.set_spacing(2)

        paned = Widgets.Splitter(orientation=orientation)

        self.plot = plots.Plot(logger=self.logger, width=400, height=400)
        ax = self.plot.add_axis()
        ax.grid(True)
        self._ax2 = self.plot.ax.twiny()

        w = Plot.PlotWidget(self.plot)
        w.resize(400, 400)
        paned.add_widget(Widgets.hadjust(w, orientation))

        captions = (('Plot All', 'checkbutton'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.plot_all.set_state(False)
        b.plot_all.add_callback('activated', lambda *args: self.redraw_mark())
        b.plot_all.set_tooltip("Plot all marks")

        box.add_widget(w, stretch=0)

        fr = Widgets.Frame("Axes controls")
        self.hbox_axes = Widgets.HBox()
        self.hbox_axes.set_border_width(4)
        self.hbox_axes.set_spacing(1)
        fr.set_widget(self.hbox_axes)

        box.add_widget(fr, stretch=0)

        captions = (('marks', 'combobox', 'New Mark Type:', 'label',
                     'Mark Type', 'combobox'), ('Pan to mark', 'button'),
                    ('Delete', 'button', 'Delete All', 'button'))
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        # control for selecting a mark
        cbox2 = b.marks
        for tag in self.marks:
            cbox2.append_text(tag)
        cbox2.show_text(self.mark_selected)
        cbox2.add_callback('activated', self.mark_select_cb)
        self.w.marks = cbox2
        cbox2.set_tooltip("Select a mark")

        # control for selecting mark type
        cbox2 = b.mark_type
        for tag in self.mark_types:
            cbox2.append_text(tag)
        self.w.marks_type = cbox2
        cbox2.set_index(self.mark_types.index(self.mark_type))
        cbox2.add_callback('activated', self.set_marksdrawtype_cb)
        cbox2.set_tooltip("Choose the mark type to draw")

        b.pan_to_mark.add_callback('activated', self.pan2mark_cb)
        b.pan_to_mark.set_tooltip("Pan follows selected mark")

        b.delete.add_callback('activated', self.clear_mark_cb)
        b.delete.set_tooltip("Delete selected mark")

        b.delete_all.add_callback('activated', self.clear_all_cb)
        b.delete_all.set_tooltip("Clear all marks")

        vbox2 = Widgets.VBox()
        vbox2.add_widget(w, stretch=0)

        mode = self.canvas.get_draw_mode()
        captions = (('Move', 'radiobutton', 'Draw', 'radiobutton', 'Edit',
                     'radiobutton'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.move.set_state(mode == 'move')
        b.move.add_callback('activated',
                            lambda w, val: self.set_mode_cb('move', val))
        b.move.set_tooltip("Choose this to position marks")
        self.w.btn_move = b.move

        b.draw.set_state(mode == 'draw')
        b.draw.add_callback('activated',
                            lambda w, val: self.set_mode_cb('draw', val))
        b.draw.set_tooltip("Choose this to draw a new mark")
        self.w.btn_draw = b.draw

        b.edit.set_state(mode == 'edit')
        b.edit.add_callback('activated',
                            lambda w, val: self.set_mode_cb('edit', val))
        b.edit.set_tooltip("Choose this to edit a mark")
        self.w.btn_edit = b.edit

        vbox2.add_widget(w, stretch=0)

        fr = Widgets.Frame("Mark controls")
        fr.set_widget(vbox2)
        box.add_widget(fr, stretch=0)

        box.add_widget(Widgets.Label(''), stretch=1)
        paned.add_widget(sw)
        # hack to set a reasonable starting position for the splitter
        paned.set_sizes([400, 500])

        top.add_widget(paned, stretch=5)

        # A button box that is always visible at the bottom
        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        # Add a close button for the convenience of the user
        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(btns, stretch=0)

        # Add our GUI to the container
        container.add_widget(top, stretch=1)
        self.gui_up = True

        self.select_mark(self._new_mark)
        self.build_axes()
Beispiel #9
0
    def build_gui(self, container):
        if not have_mpl:
            raise ImportError('Install matplotlib to use this plugin')

        top = Widgets.VBox()
        top.set_border_width(4)

        # Make the plot
        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_margins(4, 4, 4, 4)
        vbox.set_spacing(2)

        paned = Widgets.Splitter(orientation=orientation)
        self.w.splitter = paned

        # Add Tab Widget
        nb = Widgets.TabWidget(tabpos='top')
        paned.add_widget(Widgets.hadjust(nb, orientation))

        self.tab_plot = plots.Plot(logger=self.logger, width=400, height=400)
        self.plot = Plot.PlotWidget(self.tab_plot)
        self.plot.resize(400, 400)
        ax = self.tab_plot.add_axis()
        ax.grid(True)

        # Add plot to its tab
        vbox_plot = Widgets.VBox()
        vbox_plot.add_widget(self.plot, stretch=1)
        nb.add_widget(vbox_plot, title='Plot')

        captions = (('X:', 'label', 'x_combo',
                     'combobox'), ('Y:', 'label', 'y_combo', 'combobox'),
                    ('Log X', 'checkbutton', 'Log Y', 'checkbutton',
                     'Show Marker', 'checkbutton'), ('X Low:', 'label', 'x_lo',
                                                     'entry'),
                    ('X High:', 'label', 'x_hi', 'entry'), ('Y Low:', 'label',
                                                            'y_lo', 'entry'),
                    ('Y High:', 'label', 'y_hi', 'entry'), ('Save', 'button'))
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        # Controls for X-axis column listing
        combobox = b.x_combo
        combobox.add_callback('activated', self.x_select_cb)
        self.w.xcombo = combobox
        combobox.set_tooltip('Select a column to plot on X-axis')

        # Controls for Y-axis column listing
        combobox = b.y_combo
        combobox.add_callback('activated', self.y_select_cb)
        self.w.ycombo = combobox
        combobox.set_tooltip('Select a column to plot on Y-axis')

        b.log_x.set_state(self.tab_plot.logx)
        b.log_x.add_callback('activated', self.log_x_cb)
        b.log_x.set_tooltip('Plot X-axis in log scale')

        b.log_y.set_state(self.tab_plot.logy)
        b.log_y.add_callback('activated', self.log_y_cb)
        b.log_y.set_tooltip('Plot Y-axis in log scale')

        b.x_lo.add_callback('activated', lambda w: self.set_xlim_cb())
        b.x_lo.set_tooltip('Set X lower limit')

        b.x_hi.add_callback('activated', lambda w: self.set_xlim_cb())
        b.x_hi.set_tooltip('Set X upper limit')

        b.y_lo.add_callback('activated', lambda w: self.set_ylim_cb())
        b.y_lo.set_tooltip('Set Y lower limit')

        b.y_hi.add_callback('activated', lambda w: self.set_ylim_cb())
        b.y_hi.set_tooltip('Set Y upper limit')

        b.show_marker.set_state(self.settings.get('show_marker', True))
        b.show_marker.add_callback('activated', self.set_marker_cb)
        b.show_marker.set_tooltip('Mark data points')

        # Button to save plot
        self.save_plot = b.save
        self.save_plot.set_tooltip('Save table plot')
        self.save_plot.add_callback('activated', lambda w: self.save_cb())
        self.save_plot.set_enabled(False)

        vbox2 = Widgets.VBox()
        vbox2.add_widget(w, stretch=0)
        vbox.add_widget(vbox2, stretch=0)

        paned.add_widget(sw)
        paned.set_sizes(self._split_sizes)

        top.add_widget(paned, stretch=5)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        btn = Widgets.Button('Close')
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button('Help')
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)

        container.add_widget(top, stretch=1)
        self.gui_up = True
Beispiel #10
0
    def build_gui(self, container):
        if not have_mpl:
            raise ImportError('Install matplotlib to use this plugin')

        top = Widgets.VBox()
        top.set_border_width(4)

        # Make the cuts plot
        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_border_width(4)
        box.set_spacing(2)

        paned = Widgets.Splitter(orientation=orientation)
        self.w.splitter = paned

        self.plot = plots.Plot(logger=self.logger,
                               width=400, height=400)
        ax = self.plot.add_axis()
        ax.grid(True)
        w = Plot.PlotWidget(self.plot)
        w.resize(400, 400)
        paned.add_widget(Widgets.hadjust(w, orientation))

        captions = (('Cut Low:', 'label', 'Cut Low', 'entry'),
                    ('Cut High:', 'label', 'Cut High', 'entry',
                     'Cut Levels', 'button'),
                    ('Auto Levels', 'button'),
                    ('Log Histogram', 'checkbutton',
                     'Plot By Cuts', 'checkbutton'),
                    ('NumBins:', 'label', 'NumBins', 'entry'),
                    ('Full Image', 'button'),
                    )

        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        b.cut_levels.set_tooltip("Set cut levels manually")
        b.auto_levels.set_tooltip("Set cut levels by algorithm")
        b.cut_low.set_tooltip("Set low cut level (press Enter)")
        b.cut_high.set_tooltip("Set high cut level (press Enter)")
        b.log_histogram.set_tooltip("Use the log of the pixel values for the "
                                    "histogram (empty bins map to 10^-1)")
        b.plot_by_cuts.set_tooltip("Only show the part of the histogram "
                                   "between the cuts")
        b.numbins.set_tooltip("Number of bins for the histogram")
        b.full_image.set_tooltip("Use the full image for calculating the "
                                 "histogram")
        b.numbins.set_text(str(self.numbins))
        b.cut_low.add_callback('activated', lambda w: self.cut_levels())
        b.cut_high.add_callback('activated', lambda w: self.cut_levels())
        b.cut_levels.add_callback('activated', lambda w: self.cut_levels())
        b.auto_levels.add_callback('activated', lambda w: self.auto_levels())

        b.log_histogram.set_state(self.plot.logy)
        b.log_histogram.add_callback('activated', self.log_histogram_cb)
        b.plot_by_cuts.set_state(self.xlimbycuts)
        b.plot_by_cuts.add_callback('activated', self.plot_by_cuts_cb)
        b.numbins.add_callback('activated', lambda w: self.set_numbins_cb())
        b.full_image.add_callback('activated', lambda w: self.full_image_cb())

        fr = Widgets.Frame("Histogram")
        fr.set_widget(w)
        box.add_widget(fr, stretch=0)
        paned.add_widget(sw)
        paned.set_sizes(self._split_sizes)

        mode = self.canvas.get_draw_mode()
        hbox = Widgets.HBox()
        btn1 = Widgets.RadioButton("Move")
        btn1.set_state(mode == 'move')
        btn1.add_callback('activated',
                          lambda w, val: self.set_mode_cb('move', val))
        btn1.set_tooltip("Choose this to position box")
        self.w.btn_move = btn1
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Draw", group=btn1)
        btn2.set_state(mode == 'draw')
        btn2.add_callback('activated',
                          lambda w, val: self.set_mode_cb('draw', val))
        btn2.set_tooltip("Choose this to draw a replacement box")
        self.w.btn_draw = btn2
        hbox.add_widget(btn2)

        btn3 = Widgets.RadioButton("Edit", group=btn1)
        btn3.set_state(mode == 'edit')
        btn3.add_callback('activated',
                          lambda w, val: self.set_mode_cb('edit', val))
        btn3.set_tooltip("Choose this to edit a box")
        self.w.btn_edit = btn3
        hbox.add_widget(btn3)

        if self.histtag is None:
            self.w.btn_move.set_enabled(False)
            self.w.btn_edit.set_enabled(False)

        hbox.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(paned, stretch=5)
        top.add_widget(hbox, stretch=0)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)

        container.add_widget(top, stretch=1)
        self.gui_up = True
Beispiel #11
0
    def build_gui(self, container):

        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        vbox1 = Widgets.VBox()

        # Uncomment to debug; passing parent logger generates too
        # much noise in the main logger
        #zi = Viewers.CanvasView(logger=self.logger)
        zi = Viewers.CanvasView(logger=None)
        zi.set_desired_size(self._wd, self._ht)
        zi.enable_autozoom('once')
        zi.enable_autocuts('once')
        zi.enable_autocenter('override')
        zi.set_zoom_algorithm('step')
        zi.cut_levels(0, 255)
        zi.transform(False, True, False)
        #zi.set_scale_limits(0.001, 1000.0)
        zi.set_bg(0.4, 0.4, 0.4)
        zi.set_color_map('gray')
        zi.set_intensity_map('ramp')
        # for debugging
        zi.set_name('scrnimage')
        self.scrnimage = zi

        bd = zi.get_bindings()
        bd.enable_zoom(True)
        bd.enable_pan(True)
        bd.enable_cmap(False)
        zi.show_mode_indicator(True)

        iw = Viewers.ScrolledView(zi)
        iw.resize(self._wd, self._ht)
        vbox1.add_widget(iw, stretch=1)

        captions = (('Screen size', 'checkbutton', 'Width:', 'label', 'width',
                     'entry', 'Height:', 'label', 'height', 'entry'),
                    ('Lock aspect', 'checkbutton', 'Aspect:', 'label',
                     'aspect', 'entry'))
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w = b

        if self._sg_wd is None:
            wd, ht = self.fitsimage.get_window_size()
            self.shot_generator.configure_surface(wd, ht)
        else:
            wd, ht = self._sg_wd, self._sg_ht

        b.screen_size.set_state(self._screen_size)
        b.screen_size.set_tooltip("From screen viewer actual size")
        b.screen_size.add_callback('activated', self._screen_size_cb)
        b.lock_aspect.set_state(self._lock_aspect)
        b.lock_aspect.set_tooltip("Lock aspect ratio of screen shot")
        b.lock_aspect.add_callback('activated', self._lock_aspect_cb)
        b.width.set_text(str(wd))
        b.height.set_text(str(ht))
        b.width.set_enabled(not self._screen_size)
        b.height.set_enabled(not self._screen_size)
        if self._sg_aspect is None:
            _as = self.calc_aspect_str(wd, ht)
            b.aspect.set_text(_as)
        else:
            b.aspect.set_text(str(self._sg_aspect))
        b.aspect.set_enabled(self._lock_aspect)
        b.lock_aspect.set_enabled(not self._screen_size)

        b.width.add_callback('activated', lambda *args: self._set_width_cb())
        b.height.add_callback('activated', lambda *args: self._set_height_cb())
        b.aspect.add_callback('activated', lambda *args: self._set_aspect_cb())

        vbox1.add_widget(w, stretch=0)

        captions = (('Type:', 'label', 'grtype', 'combobox', 'Snap', 'button'),
                    ('Clear', 'button', 'Center', 'button', 'Fit', 'button',
                     'Full', 'button'))
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w.update(b)

        combobox = b.grtype
        for name in self.savetypes:
            combobox.append_text(name)
        index = self.savetypes.index(self.tosave_type)
        combobox.set_index(index)
        combobox.add_callback('activated', lambda w, idx: self.set_type(idx))
        combobox.set_tooltip("Set the format of the snap image")

        b.snap.set_tooltip(
            "Click to grab a snapshot of this channel viewer image")
        b.snap.add_callback('activated', self._snap_cb)
        b.clear.set_tooltip("Clear the snap image")
        b.clear.add_callback('activated', self._clear_cb)
        b.center.set_tooltip("Center the snap image")
        b.center.add_callback('activated', self._center_cb)
        b.fit.set_tooltip("Fit snap image to window")
        b.fit.add_callback('activated', self._fit_cb)
        b.full.set_tooltip("View at 100% (1:1)")
        b.full.add_callback('activated', self._full_cb)

        vbox1.add_widget(w, stretch=0)

        fr = Widgets.Frame("Screenshot")
        fr.set_widget(vbox1)

        vpaned = Widgets.Splitter(orientation='vertical')
        self.w.splitter = vpaned
        vpaned.add_widget(fr)
        vpaned.add_widget(Widgets.Label(''))
        vpaned.set_sizes(self._split_sizes)

        vbox2 = Widgets.VBox()

        fr = Widgets.Frame("Save File")

        captions = (
            ('Folder:', 'label', 'folder', 'entry'),
            ('Name:', 'label', 'name', 'entry'),
            ('Save', 'button'),
        )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w.update(b)

        b.folder.set_text(self.save_path)
        b.folder.set_tooltip("Set the folder path for the snap image")
        b.name.set_text(self.save_name)
        b.name.set_tooltip("Set the name for the snap image")
        b.save.set_tooltip("Click to save the last snap")
        b.save.add_callback('activated', self._save_cb)

        fr.set_widget(w)
        vbox2.add_widget(fr, stretch=0)

        # stretch
        spacer = Widgets.Label('')
        vbox2.add_widget(spacer, stretch=1)

        btns = Widgets.HBox()
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2.add_widget(btns, stretch=0)

        #vpaned.add_widget(vbox2)

        vbox.add_widget(vpaned, stretch=1)

        container.add_widget(vbox, stretch=1)
        container.add_widget(vbox2, stretch=0)
        self.gui_up = True
Beispiel #12
0
    vbox.add_widget(w)

elif wname == 'hbox':
    w = Widgets.HBox()
    w.add_widget(Widgets.Label("Item 1"), stretch=0)
    w.add_widget(Widgets.Label("Item 2"), stretch=1)
    vbox.add_widget(w)

elif wname == 'vbox':
    w = Widgets.VBox()
    w.add_widget(Widgets.Label("Item 1"), stretch=0)
    w.add_widget(Widgets.Label("Item 2"), stretch=1)
    vbox.add_widget(w)

elif wname == 'splitter':
    w = Widgets.Splitter(orientation='horizontal')
    w.add_widget(Widgets.Label('Content of Pane 1'))
    w.add_widget(Widgets.Label('Content of Pane 2'))
    vbox.add_widget(w, stretch=1)

elif wname == 'scrollarea':
    w = Widgets.ScrollArea()
    img = Widgets.Image()
    img.load_file(os.path.join(icondir, 'ginga-512x512.png'))
    w.set_widget(img)
    vbox.add_widget(w, stretch=1)

elif wname == 'tabwidget':
    w = Widgets.TabWidget()
    w.add_widget(Widgets.Label('Content of Tab 1'), title='Tab 1')
    w.add_widget(Widgets.Label('Content of Tab 2'), title='Tab 2')
Beispiel #13
0
    vbox.add_widget(w)

elif wname == 'hbox':
    w = Widgets.HBox()
    w.add_widget(Widgets.Label("Item 1"), stretch=0)
    w.add_widget(Widgets.Label("Item 2"), stretch=1)
    vbox.add_widget(w)

elif wname == 'vbox':
    w = Widgets.VBox()
    w.add_widget(Widgets.Label("Item 1"), stretch=0)
    w.add_widget(Widgets.Label("Item 2"), stretch=1)
    vbox.add_widget(w)

elif wname == 'splitter':
    w = Widgets.Splitter()
    w.add_widget(Widgets.Label('Content of Pane 1'))
    w.add_widget(Widgets.Label('Content of Pane 2'))
    vbox.add_widget(w, stretch=1)

elif wname == 'scrollarea':
    w = Widgets.ScrollArea()
    img = Widgets.Image()
    img.load_file(os.path.join(icondir, 'ginga-512x512.png'))
    w.set_widget(img)
    vbox.add_widget(w, stretch=1)

elif wname == 'tabwidget':
    w = Widgets.TabWidget()
    w.add_widget(Widgets.Label('Content of Tab 1'), title='Tab 1')
    w.add_widget(Widgets.Label('Content of Tab 2'), title='Tab 2')
Beispiel #14
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        fr = Widgets.Frame("Compositing")

        captions = (
            ("Compose Type:", 'label', "Compose Type", 'combobox'),
            ("New Image", 'button', "Insert from Channel", 'button'),
        )
        w, b = Widgets.build_info(captions)
        self.w.update(b)

        fr.set_widget(w)
        vbox.add_widget(fr, stretch=0)

        combobox = b.compose_type
        index = 0
        for name in ('Alpha', 'RGB'):
            combobox.append_text(name)
            index += 1
        combobox.set_index(1)

        b.new_image.add_callback('activated', lambda w: self.new_cb())
        b.new_image.set_tooltip("Start a new composite image")
        b.insert_from_channel.add_callback('activated',
                                           lambda w: self.insert_cb())
        b.insert_from_channel.set_tooltip("Insert channel image as layer")

        zi = Viewers.CanvasView(logger=None)
        zi.set_desired_size(self._wd, self._ht)
        zi.enable_autozoom('on')
        zi.enable_autocuts('off')
        zi.cut_levels(0, 255)
        zi.set_bg(0.4, 0.4, 0.4)
        zi.set_name('compose_image')
        self.preview_image = zi

        bd = zi.get_bindings()
        bd.enable_zoom(True)
        bd.enable_pan(True)
        bd.enable_flip(True)
        bd.enable_cuts(True)
        bd.enable_cmap(True)

        iw = Viewers.GingaViewerWidget(zi)
        iw.resize(self._wd, self._ht)

        zi.get_canvas().add(self.canvas)
        self.canvas.set_surface(zi)
        self.canvas.ui_set_active(True)

        fr = Widgets.Frame("Preview")
        fr.set_widget(iw)

        vpaned = Widgets.Splitter(orientation=orientation)
        vpaned.add_widget(fr)
        # spacer
        vpaned.add_widget(Widgets.Label(''))

        fr = Widgets.Frame("Layers")
        self.w.scales = fr
        #vpaned.add_widget(fr)
        vbox.add_widget(vpaned, stretch=1)
        vbox.add_widget(fr, stretch=0)

        captions = (
            ("Save Image As", 'button', "Save Path", 'entry'),
            ("Save to Channel", 'button'),
        )
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        b.save_to_channel.add_callback('activated',
                                       lambda w: self.save_to_channel_cb())
        b.save_to_channel.set_tooltip("Save composite image to channel")
        b.save_image_as.add_callback('activated', lambda w: self.save_as_cb())
        self.entry2 = b.save_path
        self.entry2.add_callback('activated', lambda *args: self.save_as_cb())
        vbox.add_widget(w, stretch=0)

        top.add_widget(vbox, stretch=1)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)

        container.add_widget(top, stretch=1)
        self.gui_up = True
Beispiel #15
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_border_width(4)
        box.set_spacing(2)

        fr = Widgets.Frame("Pixel Values")

        # We just use a ginga widget to implement the pixtable
        pixview = Viewers.CanvasView(logger=self.logger)
        pixview.set_desired_size(self._wd, self._ht)
        bg = colors.lookup_color('#202030')
        pixview.set_bg(*bg)

        bd = pixview.get_bindings()
        bd.enable_zoom(True)
        bd.enable_pan(True)

        self.pixview = pixview
        self.pix_w = Viewers.GingaViewerWidget(pixview)
        fr.set_widget(self.pix_w)
        self.pix_w.resize(self._wd, self._ht)

        paned = Widgets.Splitter(orientation=orientation)
        self.w.splitter = paned
        paned.add_widget(fr)

        self._rebuild_table()

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        cbox1 = Widgets.ComboBox()
        index = 0
        for i in self.sizes:
            j = 1 + i * 2
            name = "%dx%d" % (j, j)
            cbox1.append_text(name)
            index += 1
        index = self.sizes.index(self.pixtbl_radius)
        cbox1.set_index(index)
        cbox1.add_callback('activated', self.set_cutout_size_cb)
        cbox1.set_tooltip("Select size of pixel table")
        btns.add_widget(cbox1, stretch=0)

        # control for selecting a mark
        cbox2 = Widgets.ComboBox()
        for tag in self.marks:
            cbox2.append_text(tag)
        if self.mark_selected is None:
            cbox2.set_index(0)
        else:
            cbox2.show_text(self.mark_selected)
        cbox2.add_callback('activated', self.mark_select_cb)
        self.w.marks = cbox2
        cbox2.set_tooltip("Select a mark")
        #cbox2.setMinimumContentsLength(8)
        btns.add_widget(cbox2, stretch=0)

        btn1 = Widgets.Button("Delete")
        btn1.add_callback('activated', lambda w: self.clear_mark_cb())
        btn1.set_tooltip("Delete selected mark")
        btn1.set_enabled(len(self.marks) > 1)
        self.w.btn_delete = btn1
        btns.add_widget(btn1, stretch=0)

        btn2 = Widgets.Button("Delete All")
        btn2.add_callback('activated', lambda w: self.clear_all())
        btn2.set_tooltip("Clear all marks")
        btns.add_widget(btn2, stretch=0)
        btn2.set_enabled(len(self.marks) > 1)
        self.w.btn_delete_all = btn2
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2 = Widgets.VBox()
        vbox2.add_widget(btns, stretch=0)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn3 = Widgets.CheckBox("Pan to mark")
        btn3.set_state(self.pan2mark)
        btn3.add_callback('activated', self.pan2mark_cb)
        btn3.set_tooltip("Pan follows selected mark")
        btns.add_widget(btn3)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2.add_widget(btns, stretch=0)

        captions = [
            ('Font size:', 'label', 'Font size', 'combobox', 'Caption:',
             'label', 'Caption', 'entry'),
        ]
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        vbox2.add_widget(w, stretch=0)

        b.font_size.set_tooltip("Set font size for pixel display")
        for size in self.fontsizes:
            b.font_size.append_text(str(size))
        b.font_size.show_text(str(self.fontsize))
        b.font_size.add_callback('activated', self.set_font_size_cb)

        b.caption.set_tooltip("Text to append to the marker")

        vbox2.add_widget(Widgets.Label(''), stretch=1)
        box.add_widget(vbox2, stretch=1)

        ## spacer = Widgets.Label('')
        ## box.add_widget(spacer, stretch=1)

        paned.add_widget(sw)
        paned.set_sizes(self._split_sizes)

        top.add_widget(paned, stretch=1)

        mode = self.canvas.get_draw_mode()
        hbox = Widgets.HBox()
        btn1 = Widgets.RadioButton("Move")
        btn1.set_state(mode == 'move')
        btn1.add_callback('activated',
                          lambda w, val: self.set_mode_cb('move', val))
        btn1.set_tooltip("Choose this to add or move a mark")
        self.w.btn_move = btn1
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Draw", group=btn1)
        btn2.set_state(mode == 'draw')
        btn2.add_callback('activated',
                          lambda w, val: self.set_mode_cb('draw', val))
        btn2.set_tooltip("Choose this to draw a new or replacement mark")
        self.w.btn_draw = btn2
        hbox.add_widget(btn2)

        btn3 = Widgets.RadioButton("Edit", group=btn1)
        btn3.set_state(mode == 'edit')
        btn3.add_callback('activated',
                          lambda w, val: self.set_mode_cb('edit', val))
        btn3.set_tooltip("Choose this to edit a mark")
        self.w.btn_edit = btn3
        hbox.add_widget(btn3)

        hbox.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(hbox, stretch=0)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)
        container.add_widget(top, stretch=1)
        self.gui_up = True
Beispiel #16
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_border_width(4)
        box.set_spacing(2)

        fr = Widgets.Frame("Pixel Values")

        # We just use a ginga widget to implement the pixtable
        pixview = Viewers.CanvasView(logger=self.logger)
        pixview.set_desired_size(self._wd, self._ht)
        bg = colors.lookup_color('#202030')
        pixview.set_bg(*bg)

        bd = pixview.get_bindings()
        bd.enable_zoom(True)
        bd.enable_pan(True)

        self.pixview = pixview
        self.pix_w = Viewers.GingaViewerWidget(pixview)
        fr.set_widget(self.pix_w)
        self.pix_w.resize(self._wd, self._ht)

        paned = Widgets.Splitter(orientation=orientation)
        paned.add_widget(fr)

        self._rebuild_table()

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        cbox1 = Widgets.ComboBox()
        index = 0
        for i in self.sizes:
            j = 1 + i * 2
            name = "%dx%d" % (j, j)
            cbox1.append_text(name)
            index += 1
        index = self.sizes.index(self.pixtbl_radius)
        cbox1.set_index(index)
        cbox1.add_callback('activated', self.set_cutout_size_cb)
        cbox1.set_tooltip("Select size of pixel table")
        btns.add_widget(cbox1, stretch=0)

        # control for selecting a mark
        cbox2 = Widgets.ComboBox()
        for tag in self.marks:
            cbox2.append_text(tag)
        if self.mark_selected is None:
            cbox2.set_index(0)
        else:
            cbox2.show_text(self.mark_selected)
        cbox2.add_callback('activated', self.mark_select_cb)
        self.w.marks = cbox2
        cbox2.set_tooltip("Select a mark")
        #cbox2.setMinimumContentsLength(8)
        btns.add_widget(cbox2, stretch=0)

        btn1 = Widgets.Button("Delete")
        btn1.add_callback('activated', lambda w: self.clear_mark_cb())
        btn1.set_tooltip("Delete selected mark")
        btns.add_widget(btn1, stretch=0)

        btn2 = Widgets.Button("Delete All")
        btn2.add_callback('activated', lambda w: self.clear_all())
        btn2.set_tooltip("Clear all marks")
        btns.add_widget(btn2, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2 = Widgets.VBox()
        vbox2.add_widget(btns, stretch=0)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn3 = Widgets.CheckBox("Pan to mark")
        btn3.set_state(self.pan2mark)
        btn3.add_callback('activated', self.pan2mark_cb)
        btn3.set_tooltip("Pan follows selected mark")
        btns.add_widget(btn3)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2.add_widget(btns, stretch=0)

        captions = [
            ('Font size:', 'label', 'Font size', 'combobox'),
        ]
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        vbox2.add_widget(w, stretch=0)

        b.font_size.set_tooltip("Set font size for pixel display")
        for size in self.fontsizes:
            b.font_size.append_text(str(size))
        b.font_size.show_text(str(self.fontsize))
        b.font_size.add_callback('activated', self.set_font_size_cb)

        vbox2.add_widget(Widgets.Label(''), stretch=1)
        box.add_widget(vbox2, stretch=1)

        ## spacer = Widgets.Label('')
        ## box.add_widget(spacer, stretch=1)

        paned.add_widget(sw)
        # hack to set a reasonable starting position for the splitter
        _sz = max(self._wd, self._ht)
        paned.set_sizes([_sz, _sz])

        top.add_widget(paned, stretch=1)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(4)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)
        container.add_widget(top, stretch=1)
Beispiel #17
0
    def build_gui(self, container):
        if not have_mpl:
            raise ImportError('Install matplotlib to use this plugin')

        top = Widgets.VBox()
        top.set_border_width(4)

        # Make the cuts plot
        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_margins(4, 4, 4, 4)
        box.set_spacing(2)

        paned = Widgets.Splitter(orientation=orientation)

        # Add Tab Widget
        nb = Widgets.TabWidget(tabpos='top')
        paned.add_widget(Widgets.hadjust(nb, orientation))

        self.cuts_plot = plots.CutsPlot(logger=self.logger,
                                        width=400,
                                        height=400)
        self.plot = Plot.PlotWidget(self.cuts_plot)
        self.plot.resize(400, 400)
        ax = self.cuts_plot.add_axis()
        ax.grid(True)

        self.slit_plot = plots.Plot(logger=self.logger, width=400, height=400)
        if plots.MPL_GE_2_0:
            kwargs = {'facecolor': 'black'}
        else:
            kwargs = {'axisbg': 'black'}
        self.slit_plot.add_axis(**kwargs)
        self.plot2 = Plot.PlotWidget(self.slit_plot)
        self.plot2.resize(400, 400)

        captions = (
            ('Cut:', 'label', 'Cut', 'combobox', 'New Cut Type:', 'label',
             'Cut Type', 'combobox'),
            ('Delete Cut', 'button', 'Delete All', 'button'),
            ('Save', 'button'),
        )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        # control for selecting a cut
        combobox = b.cut
        for tag in self.tags:
            combobox.append_text(tag)
        combobox.show_text(self.cutstag)
        combobox.add_callback('activated', self.cut_select_cb)
        self.w.cuts = combobox
        combobox.set_tooltip("Select a cut to redraw or delete")

        # control for selecting cut type
        combobox = b.cut_type
        for cuttype in self.cuttypes:
            combobox.append_text(cuttype)
        self.w.cuts_type = combobox
        index = self.cuttypes.index(self.cuttype)
        combobox.set_index(index)
        combobox.add_callback('activated', self.set_cutsdrawtype_cb)
        combobox.set_tooltip("Choose the cut type to draw")

        self.save_cuts = b.save
        self.save_cuts.set_tooltip("Save cuts plot and data")
        self.save_cuts.add_callback('activated',
                                    lambda w: self.save_cb(mode='cuts'))
        self.save_cuts.set_enabled(self.save_enabled)

        btn = b.delete_cut
        btn.add_callback('activated', self.delete_cut_cb)
        btn.set_tooltip("Delete selected cut")

        btn = b.delete_all
        btn.add_callback('activated', self.delete_all_cb)
        btn.set_tooltip("Clear all cuts")

        fr = Widgets.Frame("Cuts")
        fr.set_widget(w)

        box.add_widget(fr, stretch=0)

        exp = Widgets.Expander("Cut Width")

        captions = (('Width Type:', 'label', 'Width Type', 'combobox',
                     'Width radius:', 'label', 'Width radius', 'spinbutton'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        # control for selecting width cut type
        combobox = b.width_type
        for atype in self.widthtypes:
            combobox.append_text(atype)
        index = self.widthtypes.index(self.widthtype)
        combobox.set_index(index)
        combobox.add_callback('activated', self.set_width_type_cb)
        combobox.set_tooltip("Direction of summation orthogonal to cut")

        sb = b.width_radius
        sb.add_callback('value-changed', self.width_radius_changed_cb)
        sb.set_tooltip("Radius of cut width")
        sb.set_limits(1, 100)
        sb.set_value(self.width_radius)

        fr = Widgets.Frame()
        fr.set_widget(w)
        exp.set_widget(fr)

        box.add_widget(exp, stretch=0)
        box.add_widget(Widgets.Label(''), stretch=1)
        paned.add_widget(sw)
        # hack to set a reasonable starting position for the splitter
        paned.set_sizes([400, 500])

        top.add_widget(paned, stretch=5)

        mode = self.canvas.get_draw_mode()
        hbox = Widgets.HBox()
        btn1 = Widgets.RadioButton("Move")
        btn1.set_state(mode == 'move')
        btn1.add_callback('activated',
                          lambda w, val: self.set_mode_cb('move', val))
        btn1.set_tooltip("Choose this to position cuts")
        self.w.btn_move = btn1
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Draw", group=btn1)
        btn2.set_state(mode == 'draw')
        btn2.add_callback('activated',
                          lambda w, val: self.set_mode_cb('draw', val))
        btn2.set_tooltip("Choose this to draw a new or replacement cut")
        self.w.btn_draw = btn2
        hbox.add_widget(btn2)

        btn3 = Widgets.RadioButton("Edit", group=btn1)
        btn3.set_state(mode == 'edit')
        btn3.add_callback('activated',
                          lambda w, val: self.set_mode_cb('edit', val))
        btn3.set_tooltip("Choose this to edit a cut")
        self.w.btn_edit = btn3
        hbox.add_widget(btn3)

        hbox.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(hbox, stretch=0)

        # Add Cuts plot to its tab
        vbox_cuts = Widgets.VBox()
        vbox_cuts.add_widget(self.plot, stretch=1)
        nb.add_widget(vbox_cuts, title="Cuts")

        captions = (("Enable Slit", 'checkbutton', "Transpose Plot",
                     'checkbutton', "Save", 'button'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        def chg_enable_slit(w, val):
            self.use_slit = val
            if val:
                self.build_axes()
            return True

        b.enable_slit.set_state(self.use_slit)
        b.enable_slit.set_tooltip("Enable the slit function")
        b.enable_slit.add_callback('activated', chg_enable_slit)

        self.t_btn = b.transpose_plot
        self.t_btn.set_tooltip("Flip the plot")
        self.t_btn.set_state(self.transpose_enabled)
        self.t_btn.add_callback('activated', self.transpose_plot)

        self.save_slit = b.save
        self.save_slit.set_tooltip("Save slit plot and data")
        self.save_slit.add_callback('activated',
                                    lambda w: self.save_cb(mode='slit'))
        self.save_slit.set_enabled(self.save_enabled)

        # Add frame to hold the slit controls
        fr = Widgets.Frame("Axes controls")
        self.hbox_axes = Widgets.HBox()
        self.hbox_axes.set_border_width(4)
        self.hbox_axes.set_spacing(1)
        fr.set_widget(self.hbox_axes)

        # Add Slit plot and controls to its tab
        vbox_slit = Widgets.VBox()
        vbox_slit.add_widget(self.plot2, stretch=1)
        vbox_slit.add_widget(w)
        vbox_slit.add_widget(fr)
        nb.add_widget(vbox_slit, title="Slit")

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)

        container.add_widget(top, stretch=1)

        self.select_cut(self.cutstag)
        self.gui_up = True

        if self.use_slit:
            self.build_axes()
Beispiel #18
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        fr = Widgets.Frame('Single Pixel')
        captions = [('Move', 'radiobutton', 'Draw', 'radiobutton'),
                    ('X:', 'label', 'X', 'entry'),
                    ('Y:', 'label', 'Y', 'entry'),
                    ('DQ Flag:', 'label', 'DQ', 'llabel')]
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        mode = self.canvas.get_draw_mode()
        b.move.set_state(mode == 'move')
        b.move.add_callback('activated',
                            lambda w, val: self.set_mode_cb('move', val))
        b.move.set_tooltip('Choose this to move marked pixel')
        b.draw.set_state(mode == 'draw')
        b.draw.add_callback('activated',
                            lambda w, val: self.set_mode_cb('draw', val))
        b.draw.set_tooltip('Choose this to mark pixel')

        b.x.set_tooltip('X of pixel')
        b.x.set_text(str(self.xcen))
        b.x.add_callback('activated', lambda w: self.set_xcen())

        b.y.set_tooltip('Y of pixel')
        b.y.set_text(str(self.ycen))
        b.y.add_callback('activated', lambda w: self.set_ycen())

        b.dq.set_tooltip('DQ value of pixel')
        b.dq.set_text(self._no_keyword)

        # Create the Treeview
        self.pxdqlist = Widgets.TreeView(auto_expand=True,
                                         sortable=True,
                                         selection='multiple',
                                         use_alt_row_color=True)
        self.pxdqlist.setup_table(self.pxdqcolumns, 1, 'FLAG')

        splitter = Widgets.Splitter('vertical')
        splitter.add_widget(w)
        splitter.add_widget(self.pxdqlist)
        fr.set_widget(splitter)
        vbox.add_widget(fr, stretch=1)

        fr = Widgets.Frame('Whole Image')
        captions = [('Number of pixels:', 'llabel', 'npix', 'llabel',
                     'spacer1', 'spacer')]
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.npix.set_tooltip('Number of affected pixels')
        b.npix.set_text(self._no_keyword)

        # Create the Treeview
        self.imdqlist = Widgets.TreeView(auto_expand=True,
                                         sortable=True,
                                         selection='multiple',
                                         use_alt_row_color=True)
        self.imdqlist.setup_table(self.imdqcolumns, 1, 'FLAG')
        self.imdqlist.add_callback('selected', self.mark_dqs_cb)

        splitter = Widgets.Splitter('vertical')
        splitter.add_widget(w)
        splitter.add_widget(self.imdqlist)
        fr.set_widget(splitter)
        vbox.add_widget(fr, stretch=1)

        top.add_widget(sw, stretch=1)

        btns = Widgets.HBox()
        btns.set_border_width(4)
        btns.set_spacing(3)

        btn = Widgets.Button('Close')
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button('Help')
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)
        container.add_widget(top, stretch=1)

        self.gui_up = True

        # Populate fields based on active image
        self.redo()
Beispiel #19
0
    def build_gui(self, container):
        if not have_imexam:
            raise Exception("Please install 'imexam' to use this plugin")

        top = Widgets.VBox()
        top.set_border_width(4)

        fontsize = self.settings.get('fontsize', 12)

        msg_font = self.fv.get_font('sans', fontsize)
        tw = Widgets.TextArea(wrap=False, editable=False)
        tw.set_font(msg_font)
        self.tw = tw

        fr = Widgets.Expander("Instructions")
        fr.set_widget(tw)
        top.add_widget(fr, stretch=0)

        fr = Widgets.Frame("Imexam output:")

        if not self._plots_in_ws:
            splitter = Widgets.Splitter(orientation='vertical')

            self.nb = Widgets.TabWidget()
            splitter.add_widget(self.nb)

        # this holds the messages returned from imexamine
        tw = Widgets.TextArea(wrap=False, editable=False)
        font = self.settings.get('font', 'Courier')
        fixed_font = self.fv.get_font(font, fontsize)
        tw.set_font(fixed_font)
        self.msg_res = tw

        if not self._plots_in_ws:
            splitter.add_widget(tw)
            fr.set_widget(splitter)
        else:
            fr.set_widget(tw)

        top.add_widget(fr, stretch=1)

        hbox = Widgets.HBox()
        btn = Widgets.Button('Detach Plot')
        btn.add_callback('activated', self.detach_plot_cb)
        btn.set_tooltip("Detach current plot and start a new one")
        hbox.add_widget(btn, stretch=0)
        btn = Widgets.Button('Clear Text')
        btn.add_callback('activated', self.clear_text_cb)
        btn.set_tooltip("Clear the imexam output")
        hbox.add_widget(btn, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(hbox, stretch=0)

        top.add_widget(hbox, stretch=0)

        hbox = Widgets.HBox()
        lbl = Widgets.Label("Keys active:")
        hbox.add_widget(lbl)
        btn1 = Widgets.RadioButton("On")
        btn1.set_state(self.imexam_active)
        btn1.add_callback('activated',
                          lambda w, val: self.set_active_cb(True, val))
        btn1.set_tooltip("Enable imexam keys")
        self.w.btn_on = btn1
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Off", group=btn1)
        btn2.set_state(not self.imexam_active)
        btn2.add_callback('activated',
                          lambda w, val: self.set_active_cb(False, val))
        btn2.set_tooltip("Disable imexam keys")
        self.w.btn_off = btn2
        hbox.add_widget(btn2)

        hbox.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(hbox, stretch=0)

        btns = Widgets.HBox()
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(btns, stretch=0)

        self._plot = None
        self._plot_w = None
        self._plot_idx = 0
        self.make_new_figure()

        container.add_widget(top, stretch=1)
Beispiel #20
0
    def build_gui(self, container):

        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        vbox1 = Widgets.VBox()

        # Uncomment to debug; passing parent logger generates too
        # much noise in the main logger
        #zi = Viewers.CanvasView(logger=self.logger)
        zi = Viewers.CanvasView(logger=None)
        zi.set_desired_size(self._wd, self._ht)
        zi.enable_autozoom('once')
        zi.enable_autocuts('once')
        zi.enable_autocenter('once')
        zi.set_zoom_algorithm('step')
        zi.cut_levels(0, 255)
        zi.transform(False, True, False)
        #zi.set_scale_limits(0.001, 1000.0)
        settings = zi.get_settings()
        zi.set_bg(0.4, 0.4, 0.4)
        zi.set_color_map('gray')
        zi.set_intensity_map('ramp')
        # for debugging
        zi.set_name('scrnimage')
        self.scrnimage = zi

        bd = zi.get_bindings()
        bd.enable_zoom(True)
        bd.enable_pan(True)
        bd.enable_cmap(False)

        iw = Viewers.GingaViewerWidget(zi)
        iw.resize(self._wd, self._ht)
        vbox1.add_widget(iw, stretch=1)

        captions = (
            ('Type:', 'label', 'grtype', 'combobox', 'Snap', 'button'),
            ('Clear', 'button', 'Center', 'button', 'Fit', 'button'),
        )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w = b

        combobox = b.grtype
        for name in self.savetypes:
            combobox.append_text(name)
        index = self.savetypes.index(self.tosave_type)
        combobox.set_index(index)
        combobox.add_callback('activated', lambda w, idx: self.set_type(idx))
        combobox.set_tooltip("Set the format of the snap image")

        b.snap.set_tooltip(
            "Click to grab a snapshot of this channel viewer image")
        b.snap.add_callback('activated', self.snap_cb)
        b.clear.set_tooltip("Clear the snap image")
        b.clear.add_callback('activated', self.clear_cb)
        b.center.set_tooltip("Center the snap image")
        b.center.add_callback('activated', self.center_cb)
        b.fit.set_tooltip("Fit snap image to window")
        b.fit.add_callback('activated', self.fit_cb)

        vbox1.add_widget(w, stretch=0)

        fr = Widgets.Frame("Screenshot")
        fr.set_widget(vbox1)

        vpaned = Widgets.Splitter(orientation='vertical')
        vpaned.add_widget(fr)
        vpaned.add_widget(Widgets.Label(''))

        vbox2 = Widgets.VBox()

        fr = Widgets.Frame("Save File")

        captions = (
            ('Folder:', 'label', 'folder', 'entry'),
            ('Name:', 'label', 'name', 'entry'),
            ('Save', 'button'),
        )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w.update(b)

        b.folder.set_text(self.save_path)
        b.folder.set_tooltip("Set the folder path for the snap image")
        b.name.set_text(self.save_name)
        b.name.set_tooltip("Set the name for the snap image")
        b.save.set_tooltip("Click to save the last snap")
        b.save.add_callback('activated', self.save_cb)

        fr.set_widget(w)
        vbox2.add_widget(fr, stretch=0)

        # stretch
        spacer = Widgets.Label('')
        vbox2.add_widget(spacer, stretch=1)

        btns = Widgets.HBox()
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)

        vbox2.add_widget(btns, stretch=0)

        #vpaned.add_widget(vbox2)

        vbox.add_widget(vpaned, stretch=1)

        container.add_widget(vbox, stretch=1)
        container.add_widget(vbox2, stretch=0)
Beispiel #21
0
    def build_gui(self, container):

        vbox, sw, orientation = Widgets.get_oriented_box(container,
                                                         fill=True,
                                                         scrolled=False)
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        # Uncomment to debug; passing parent logger generates too
        # much noise in the main logger
        #zi = Viewers.CanvasView(logger=self.logger)
        zi = Viewers.CanvasView(logger=None)
        zi.set_desired_size(self._wd, self._ht)
        zi.enable_autozoom('off')
        zi.enable_autocuts('off')
        #zi.set_scale_limits(0.001, 1000.0)
        zi.zoom_to(self.default_zoom)
        settings = zi.get_settings()
        settings.getSetting('zoomlevel').add_callback('set',
                               self.zoomset, zi)
        zi.set_bg(0.4, 0.4, 0.4)
        zi.show_pan_mark(True)
        # for debugging
        zi.set_name('zoomimage')
        self.zoomimage = zi

        bd = zi.get_bindings()
        bd.enable_zoom(False)
        bd.enable_pan(False)
        bd.enable_cmap(False)

        iw = Viewers.GingaViewerWidget(zi)
        iw.resize(self._wd, self._ht)
        vpaned = Widgets.Splitter(orientation=orientation)
        vpaned.add_widget(iw)

        vbox2 = Widgets.VBox()
        captions = (("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'),
                    ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'),
                    )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)
        vbox2.add_widget(w, stretch=0)

        self.w.zoom_radius.set_limits(1, 300, incr_value=1)
        self.w.zoom_radius.set_value(self.zoom_radius)
        self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb)
        self.w.zoom_radius.set_tracking(True)

        self.w.zoom_amount.set_limits(-20, 30, incr_value=1)
        self.w.zoom_amount.set_value(self.zoom_amount)
        self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb)
        self.w.zoom_amount.set_tracking(True)

        captions = (("Zoom:", 'label', 'Zoom', 'label'),
                    ("Relative Zoom", 'checkbutton'),
                    ("Refresh Interval", 'label',
                     'Refresh Interval', 'spinbutton'),
                    ("Defaults", 'button'),
                    )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        b.zoom.set_text(self.fv.scale2text(zi.get_scale()))
        b.relative_zoom.set_state(not self.t_abszoom)
        b.relative_zoom.add_callback("activated", self.set_absrel_cb)
        b.defaults.add_callback("activated", lambda w: self.set_defaults())
        b.refresh_interval.set_limits(0, 200, incr_value=1)
        b.refresh_interval.set_value(int(self.refresh_interval * 1000))
        b.refresh_interval.add_callback('value-changed', self.set_refresh_cb)

        row = Widgets.HBox()
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        vbox2.add_widget(row, stretch=0)

        # stretch
        spacer = Widgets.Label('')
        vbox2.add_widget(spacer, stretch=1)

        vpaned.add_widget(vbox2)
        #vpaned.add_widget(Widgets.Label(''))

        vbox.add_widget(vpaned, stretch=1)

        #vbox.add_widget(Widgets.Label(''), stretch=1)

        container.add_widget(sw, stretch=1)
Beispiel #22
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

        box, sw, orientation = Widgets.get_oriented_box(container)
        box.set_border_width(4)
        box.set_spacing(2)

        paned = Widgets.Splitter(orientation=orientation)

        self.fwhm_plot = plots.FWHMPlot(logger=self.logger,
                                        width=400,
                                        height=400)

        if plots.MPL_GE_2_0:
            kwargs = {'facecolor': 'white'}
        else:
            kwargs = {'axisbg': 'white'}
        ax = self.fwhm_plot.add_axis(**kwargs)
        ax.grid(True)
        w = Plot.PlotWidget(self.fwhm_plot)
        w.resize(400, 400)
        paned.add_widget(Widgets.hadjust(w, orientation))

        captions = (("Load a Nires Image", 'label', "Load", 'button'),
                    ("Load an image and sky", 'label', "Load with sky",
                     'button'), ('Object_X', 'label', 'Object_X', 'llabel'),
                    ('Object_Y', 'label', 'Object_Y',
                     'llabel'), ('Box Size (50): ', 'label', 'Box Size',
                                 'entry', "Resize", 'button'))

        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w.update(b)

        self.wdetail = b

        b.load.add_callback('activated', lambda w: self.load_cb())

        b.load_with_sky.add_callback('activated',
                                     lambda w: self.load_with_sky_cb())

        b.box_size.add_callback('activated', lambda w: self.boxsize_cb())

        b.resize.add_callback('activated', lambda w: self.resize_cb())

        fr = Widgets.Frame("Pick Target Star")
        fr.set_widget(w)
        box.add_widget(fr, stretch=0)
        paned.add_widget(sw)

        paned.set_sizes([400, 500])

        top.add_widget(paned, stretch=5)

        btns = Widgets.HBox()
        btns.set_spacing(3)

        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(btns, stretch=0)

        container.add_widget(top, stretch=1)
        self.mfilesel = FileSelection(self.fv.w.root.get_widget())