Beispiel #1
0
    def build_gui(self, container):
        vbox = Widgets.VBox()

        self.msgFont = self.fv.getFont("fixedFont", 12)
        tw = Widgets.TextArea(wrap=False, editable=False)
        tw.set_font(self.msgFont)
        tw.set_limit(self.histlimit)
        self.tw = tw

        sw = Widgets.ScrollArea()
        sw.set_widget(self.tw)

        vbox.add_widget(sw, stretch=1)

        captions = (('Level', 'combobox', 'History', 'spinbutton'),
                    ('Auto scroll', 'checkbutton', 'Clear', 'button'))
        w, b = Widgets.build_info(captions)
        self.w.update(b)

        combobox = b.level
        for (name, level) in self.levels:
            combobox.append_text(name)
        combobox.set_index(1)
        combobox.add_callback('activated', self.set_loglevel_cb)
        combobox.set_tooltip("Set the logging level")

        spinbox = b.history
        spinbox.set_limits(100, self.histmax, incr_value=10)
        spinbox.set_value(self.histlimit)
        spinbox.add_callback('value-changed', self.set_history_cb)
        spinbox.set_tooltip("Set the logging history line limit")

        btn = b.auto_scroll
        btn.set_state(self.autoscroll)
        btn.set_tooltip("Scroll the log window automatically")
        btn.add_callback('activated', self.set_autoscroll_cb)

        btn = b.clear
        btn.add_callback('activated', lambda w: self.clear())
        btn.set_tooltip("Clear the log history")
        vbox.add_widget(w, 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)
        btns.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(btns, stretch=0)

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

        vbox = Widgets.VBox()

        self.msgFont = self.fv.getFont("fixedFont", 12)
        tw = Widgets.TextArea(wrap=False, editable=False)
        tw.set_font(self.msgFont)
        self.tw = tw
        self.history = []
        self.histmax = 10

        sw = Widgets.ScrollArea()
        sw.set_widget(self.tw)

        vbox.add_widget(sw, stretch=1)

        captions = (
            ('Local plugin:', 'label', 'Local plugin', 'entry', 'Reload',
             'button'),
            ('Global plugin:', 'label', 'Global plugin', 'entry', 'ReloadG',
             'button'),
        )
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        b.local_plugin.set_tooltip("Name of a local plugin to reload")
        b.local_plugin.set_length(14)
        b.reload.add_callback('activated', self.reload_local_cb)
        b.global_plugin.set_tooltip("Name of a global plugin to reload")
        b.global_plugin.set_length(14)
        b.reloadg.add_callback('activated', self.reload_global_cb)
        vbox.add_widget(w, stretch=1)

        self.entry = Widgets.TextEntry()
        vbox.add_widget(self.entry, stretch=0)
        self.entry.add_callback('activated', self.command_cb)

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

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

        container.add_widget(vbox, stretch=1)
Beispiel #3
0
    def build_gui(self, container):
        self.msgFont = self.fv.getFont("fixedFont", 10)

        vbox = Widgets.VBox()

        mlst = Widgets.VBox()
        mlst.set_spacing(2)
        self.msgList = mlst

        sw = Widgets.ScrollArea()
        sw.set_widget(self.msgList)

        vbox.add_widget(sw, stretch=1)

        hbox = Widgets.HBox()
        btn = Widgets.Button("Remove All")
        btn.add_callback('activated', lambda w: self.remove_all())
        hbox.add_widget(btn, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        vbox.add_widget(hbox, stretch=0)
        container.add_widget(vbox, stretch=1)
Beispiel #4
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)

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

        vpaned = Widgets.Splitter(orientation=orientation)

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

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

        di = CanvasTypes.ImageViewCanvas(logger=self.logger)
        width, height = 200, 200
        di.set_desired_size(width, height)
        di.enable_autozoom('off')
        di.enable_autocuts('off')
        di.zoom_to(3, redraw=False)
        settings = di.get_settings()
        settings.getSetting('zoomlevel').add_callback('set', self.zoomset, di)
        di.set_cmap(cm, redraw=False)
        di.set_imap(im, redraw=False)
        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)

        iw = Widgets.wrap(di.get_widget())
        nb.add_widget(iw, title="Image")

        if have_mpl:
            self.plot1 = Plot.Plot(logger=self.logger,
                                   width=2,
                                   height=3,
                                   dpi=72)
            self.w.canvas = self.plot1.canvas
            self.w.fig = self.plot1.fig
            self.w.ax = self.w.fig.add_subplot(111, axisbg='black')
            self.w.ax.set_aspect('equal', adjustable='box')
            self.w.ax.set_title('Contours')
            #self.w.ax.grid(True)

            canvas = self.w.canvas
            connect = canvas.mpl_connect
            # These are not ready for prime time...
            # connect("motion_notify_event", self.plot_motion_notify)
            # connect("button_press_event", self.plot_button_press)
            connect("scroll_event", self.plot_scroll)
            nb.add_widget(Widgets.wrap(canvas), title="Contour")

            self.plot2 = Plot.Plot(logger=self.logger,
                                   width=2,
                                   height=3,
                                   dpi=72)
            self.w.canvas2 = self.plot2.canvas
            self.w.fig2 = self.plot2.fig
            self.w.ax2 = self.w.fig2.add_subplot(111, axisbg='white')
            #self.w.ax2.set_aspect('equal', adjustable='box')
            self.w.ax2.set_ylabel('brightness')
            self.w.ax2.set_xlabel('pixels')
            self.w.ax2.set_title('FWHM')
            self.w.ax.grid(True)
            canvas = self.w.canvas2
            nb.add_widget(Widgets.wrap(canvas), title="FWHM")

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

        ## fr = Widgets.Frame("Instructions")
        ## vbox2 = Widgets.VBox()
        ## vbox2.add_widget(tw)
        ## vbox2.add_widget(Widgets.Label(''), stretch=1)
        ## fr.set_widget(vbox2)
        ## vbox.add_widget(fr, stretch=0)

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

        fr = Widgets.Frame("Pick")

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

        # Build report panel
        captions = (
            ('Zoom:', 'label', 'Zoom', 'llabel', 'Contour Zoom:', 'label',
             'Contour 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'),
        )

        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")

        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'),
            ('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")
        # radius control
        #b.radius.set_digits(2)
        #b.radius.set_numeric(True)
        b.radius.set_limits(5.0, 200.0, incr_value=1.0)
        b.radius.set_value(self.radius)

        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)

        nb.add_widget(w, title="Settings")

        # Build controls panel
        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)

        nb.add_widget(w, title="Controls")

        vbox3 = Widgets.VBox()
        msgFont = self.fv.getFont("fixedFont", 10)
        tw = Widgets.TextArea(wrap=False, editable=True)
        tw.set_font(msgFont)
        self.w.report = tw
        sw1 = Widgets.ScrollArea()
        sw1.set_widget(tw)
        vbox3.add_widget(sw1, stretch=1)
        tw.append_text(self._mkreport_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")
        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)

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

        ## vbox4 = Widgets.VBox()
        ## tw = Widgets.TextArea(wrap=False, editable=True)
        ## tw.set_font(msgFont)
        ## self.w.correct = tw
        ## sw1 = Widgets.ScrollArea()
        ## sw1.set_widget(tw)
        ## vbox4.add_widget(sw1, stretch=1)
        ## tw.append_text("# paste a reference report here")

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

        ## btn = Widgets.Button("Correct WCS")
        ## btn.add_callback('activated', lambda w: self.correct_wcs())
        ## btns.add_widget(btn)
        ## vbox4.add_widget(btns, stretch=0)

        ## nb.add_widget(vbox4, title="Correct")

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

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

        vtop.add_widget(sw, stretch=1)

        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=1)
Beispiel #5
0
    def _create_info_window(self):
        sw = Widgets.ScrollArea()

        vbox = Widgets.VBox()
        captions = (('Name:', 'label', 'Name', 'llabel'),
                    ('Object:', 'label', 'Object', 'llabel'),
                    ('X:', 'label', 'X', 'llabel'),
                    ('Y:', 'label', 'Y', 'llabel'),
                    ('Value:', 'label', 'Value', 'llabel'),
                    ('RA:', 'label', 'RA', 'llabel'),
                    ('DEC:', 'label', 'DEC', 'llabel'),
                    ('Equinox:', 'label', 'Equinox', 'llabel'),
                    ('Dimensions:', 'label', 'Dimensions', 'llabel'),
                    ('Min:', 'label', 'Min', 'llabel'),
                    ('Max:', 'label', 'Max', 'llabel'),
                    )
        w, b = Widgets.build_info(captions)

        col = Widgets.VBox()
        row = Widgets.HBox()
        row.set_spacing(0)
        row.set_border_width(0)
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        col.add_widget(row, stretch=1)
        col.add_widget(Widgets.Label(''), stretch=1)
        sw2 = Widgets.ScrollArea()
        sw2.set_widget(col)
        vbox.add_widget(sw2, stretch=2)
        
        captions = (('Zoom:', 'label', 'Zoom', 'llabel'), 
                    ('Cut Low:', 'label', 'Cut Low Value', 'llabel',
                     'Cut Low', 'entry'),
                    ('Cut High:', 'label', 'Cut High Value', 'llabel',
                     'Cut High', 'entry'),
                    ('Auto Levels', 'button', 'spacer1', 'spacer',
                     'Cut Levels', 'button'), 
                    ('Cut New:', 'label', 'Cut New', 'llabel'),
                    ('Zoom New:', 'label', 'Zoom New', 'llabel'), 
                    ('Center New:', 'label', 'Center New', 'llabel'), 
                    )

        w, b2 = Widgets.build_info(captions)
        b.update(b2)
        # TODO: need a more general solution to gtk labels resizing their
        # parent window
        #b.object.set_length(12)
        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)")

        row = Widgets.HBox()
        row.set_spacing(0)
        row.set_border_width(0)
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(row, stretch=1)

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

        sw.set_widget(vbox)
        return sw, b
Beispiel #6
0
    def _create_info_window(self):
        sw = Widgets.ScrollArea()

        vbox = Widgets.VBox()
        captions = (
            ('Name:', 'label', 'Name', 'llabel'),
            ('Object:', 'label', 'Object', 'llabel'),
            ('X:', 'label', 'X', 'llabel'),
            ('Y:', 'label', 'Y', 'llabel'),
            ('Value:', 'label', 'Value', 'llabel'),
            ('RA:', 'label', 'RA', 'llabel'),
            ('DEC:', 'label', 'DEC', 'llabel'),
            ('Equinox:', 'label', 'Equinox', 'llabel'),
            ('Dimensions:', 'label', 'Dimensions', 'llabel'),
            ('Min:', 'label', 'Min', 'llabel'),
            ('Max:', 'label', 'Max', 'llabel'),
        )
        w, b = Widgets.build_info(captions)

        col = Widgets.VBox()
        row = Widgets.HBox()
        row.set_spacing(0)
        row.set_border_width(0)
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        col.add_widget(row, stretch=1)
        col.add_widget(Widgets.Label(''), stretch=1)
        sw2 = Widgets.ScrollArea()
        sw2.set_widget(col)
        vbox.add_widget(sw2, stretch=2)

        captions = (
            ('Zoom:', 'label', 'Zoom', 'llabel'),
            ('Cut Low:', 'label', 'Cut Low Value', 'llabel', 'Cut Low',
             'entry'),
            ('Cut High:', 'label', 'Cut High Value', 'llabel', 'Cut High',
             'entry'),
            ('Auto Levels', 'button', 'spacer1', 'spacer', 'Cut Levels',
             'button'),
            ('Cut New:', 'label', 'Cut New', 'llabel'),
            ('Zoom New:', 'label', 'Zoom New', 'llabel'),
            ('Preferences', 'button'),
        )

        w, b2 = Widgets.build_info(captions)
        b.update(b2)
        # TODO: need a more general solution to gtk labels resizing their
        # parent window
        #b.object.set_length(12)
        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.preferences.set_tooltip("Set preferences for this channel")

        row = Widgets.HBox()
        row.set_spacing(0)
        row.set_border_width(0)
        row.add_widget(w, stretch=0)
        row.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(row, stretch=1)

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

        # Convenience navigation buttons
        btns = Widgets.HBox()
        btns.set_spacing(4)
        btns.set_border_width(4)

        bw = Bunch.Bunch()
        for tup in (
                #("Load", 'button', 'fits_open_48', "Open an image file"),
            ("Prev", 'button', 'prev_48', "Go to previous image"),
            ("Next", 'button', 'next_48', "Go to next image"),
            ("Zoom In", 'button', 'zoom_in_48', "Zoom in"),
            ("Zoom Out", 'button', 'zoom_out_48', "Zoom out"),
            ("Zoom Fit", 'button', 'zoom_fit_48', "Zoom to fit window size"),
            ("Zoom 1:1", 'button', 'zoom_100_48', "Zoom to 100% (1:1)"),
                #("Quit", 'button', 'exit_48', "Quit the program"),
        ):

            btn = self.fv.make_button(*tup)
            name = tup[0]
            if tup[3]:
                btn.set_tooltip(tup[3])

            bw[Widgets.name_mangle(name, pfx='btn_')] = btn
            btns.add_widget(btn, stretch=1)

        #self.w.btn_load.connect("clicked", lambda w: self.gui_load_file())
        bw.btn_prev.add_callback('activated', lambda w: self.fv.prev_img())
        bw.btn_next.add_callback('activated', lambda w: self.fv.next_img())
        bw.btn_zoom_in.add_callback('activated', lambda w: self.fv.zoom_in())
        bw.btn_zoom_out.add_callback('activated', lambda w: self.fv.zoom_out())
        bw.btn_zoom_fit.add_callback('activated', lambda w: self.fv.zoom_fit())
        bw.btn_zoom_1_1.add_callback('activated',
                                     lambda w: self.fv.zoom_1_to_1())

        vbox.add_widget(btns, stretch=0)

        sw.set_widget(vbox)
        #sw.set_size_request(-1, 420)
        #sw.show_all()
        return sw, b
Beispiel #7
0
    def build_gui(self, container):
        # Create a scrollable area
        sw = Widgets.ScrollArea()

        # Create a vertical box into which our widgets will be placed
        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        # Place the vertical box inside the scrollable area
        sw.set_widget(vbox)

        # Create a frame for the program name and the OB ID.
        prog_ob_frame = Widgets.Frame()
        # Create some label widgets to display the program and the OB
        # ID
        captions = (('Program:', 'label', 'Program', 'label', 'OB ID:',
                     'label', 'OB ID', 'label', 'Dup All OB', 'checkbutton'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_prog_ob = b
        # Set the inital text for the program and OB ID to N/A
        b.program.set_text('N/A')
        b.ob_id.set_text('N/A')
        b.dup_all_ob.set_state(False)

        # Place the label widgets into the frame
        prog_ob_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(prog_ob_frame, stretch=0)

        # Create a frame for the resolution comments
        comment_frame = Widgets.Frame('OB Comments')

        # Create a text area into which comments can be entered
        captions = (('Comment entry', 'textarea'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_comments = b

        # Place the text area into the frame
        comment_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(comment_frame, stretch=0)

        # Create a frame for the data quality buttons
        data_button_frame = Widgets.Frame()
        # Create some radio buttons to describe the data quality
        buttonList = []
        self.qualityButtonVals = {}
        for i, name in enumerate(self.qualityButtons):
            buttonList.append(name)
            buttonList.append('radiobutton')
            self.qualityButtonVals[name] = len(self.qualityButtons) - i
        captions = (('Data Quality:', 'label'), buttonList)
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_data_buttons = b

        # Set the callback method for the data quality radio buttons
        for name in self.qualityButtons:
            b[name.lower()].add_callback('activated', self.rate_cb,
                                         self.qualityButtonVals[name])

        # Put the quality buttons into a QButtonGroup so that we set
        # up the buttons as "exclusive", i.e., only one button can be
        # selected at a time.
        self.data_bg = QtGui.QButtonGroup()
        for name in self.qualityButtons:
            self.data_bg.addButton(
                self.w_data_buttons[name.lower()].get_widget())

        # Place the radio buttons into the frame
        data_button_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(data_button_frame, stretch=0)

        # Create a frame for the clear button
        clear_button_frame = Widgets.Frame()
        # Create the Clear button
        captions = (('Clear', 'button'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_clear = b

        # Connect the button-click event to the callback method
        b.clear.add_callback('activated', self.clear_cb)

        # Place the radio buttons into the frame
        clear_button_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(clear_button_frame, stretch=0)

        # Create a frame for the slider bar
        slider_frame = Widgets.Frame()
        captions = (('ob list index', 'hscale'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_slider = b
        b.ob_list_index.set_limits(0, 1)
        b.ob_list_index.set_tracking(True)
        b.ob_list_index.add_callback('value-changed', self.ob_list_index_cb)
        # Place the slider bar into the frame
        slider_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(slider_frame, stretch=0)

        # Create a frame for the first/prev/next/last buttons
        prev_next_button_frame = Widgets.Frame()
        # Create the First, Prev, Next, and Last buttons
        captions = (('First', 'button', 'Prev', 'button', 'Next', 'button',
                     'Last', 'button'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_prev_next = b

        # Connect the button-click event to the callback method
        b.first.add_callback('activated', self.first_cb)
        b.next.add_callback('activated', self.next_cb)
        b.prev.add_callback('activated', self.prev_cb)
        b.last.add_callback('activated', self.last_cb)

        # Place the radio buttons into the frame
        prev_next_button_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(prev_next_button_frame, stretch=0)

        # Create a frame for the save buttons
        save_button_frame = Widgets.Frame()
        # Create the Save button
        captions = (('Save', 'button'), )
        w, b = Widgets.build_info(captions, orientation='vertical')
        self.w_save_button = b

        # Connect the button-click event to the callback method
        b.save.add_callback('activated', self.save_cb)

        # Place the button into the frame
        save_button_frame.set_widget(w)
        # Add the frame to the vertical box
        vbox.add_widget(save_button_frame, stretch=0)

        # Create a layout for the container that was supplied to us
        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(4)
        # Set the supplied container to have the layout we just
        # created
        container.setLayout(layout)

        # Get the widget for the scrollable area
        top_w = sw.get_widget()

        # Add the widget for the scrollable area to the layout we just
        # created for the supplied container
        layout.addWidget(top_w, stretch=1)