Ejemplo n.º 1
0
    def build_gui(self, container):
        self.msgFont = pango.FontDescription("Fixed 10")
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_NONE)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.set_editable(False)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.modify_font(self.msgFont)
        self.tw = tw
        self.buf = self.tw.get_buffer()
         
        sw = gtk.ScrolledWindow()
        sw.set_border_width(2)
        sw.set_policy(gtk.POLICY_AUTOMATIC,
                      gtk.POLICY_AUTOMATIC)
        sw.add(self.tw)

        container.pack_start(sw, fill=True, expand=True)

        hbox = gtk.HBox()

        lbl = gtk.Label('Level:')
        hbox.pack_start(lbl, fill=False, expand=False)
        combobox = GtkHelp.combo_box_new_text()
        for (name, level) in self.levels:
            combobox.append_text(name)
        combobox.set_active(1)
        combobox.sconnect('changed', self.set_loglevel_cb)
        hbox.pack_start(combobox, fill=False, expand=False,
                        padding=4)
        
        lbl = gtk.Label('History:')
        hbox.pack_start(lbl, fill=False, expand=False)
        spinbox = GtkHelp.SpinButton()
        adj = spinbox.get_adjustment()
        adj.configure(self.histlimit, 100, self.histmax, 10, 100, 0)
        spinbox.sconnect('value-changed', self.set_history_cb)
        hbox.pack_start(spinbox, fill=False, expand=False,
                        padding=4)
        
        btn = gtk.Button("Clear")
        btn.connect('clicked', lambda w: self.clear())
        hbox.pack_end(btn, fill=False, expand=False)
        container.pack_end(hbox, fill=False, expand=False)
Ejemplo n.º 2
0
    def __init__(self, logger):

        self.logger = logger
        self.drawcolors = colors.get_colors()
        self.dc = get_canvas_types()

        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_title("Gtk2 CanvasView Example")
        root.set_border_width(2)
        root.connect("delete_event", lambda w, e: quit(w))
        self.root = root
        self.select = GtkHelp.FileSelection(root)

        vbox = gtk.VBox(spacing=2)

        fi = CanvasView(logger)
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.set_zoom_algorithm('rate')
        fi.set_zoomrate(1.4)
        fi.show_pan_mark(True)
        fi.set_callback('drag-drop', self.drop_file_cb)
        fi.set_callback('cursor-changed', self.cursor_cb)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_set_active(True)
        self.fitsimage = fi

        bd = fi.get_bindings()
        bd.enable_all(True)

        # canvas that we will draw on
        canvas = self.dc.DrawingCanvas()
        canvas.enable_draw(True)
        canvas.set_drawtype('rectangle', color='lightblue')
        canvas.set_surface(fi)
        self.canvas = canvas
        # add canvas to view
        private_canvas = fi.get_canvas()
        private_canvas.register_for_cursor_drawing(fi)
        private_canvas.add(canvas)
        canvas.ui_set_active(True)
        self.drawtypes = canvas.get_drawtypes()
        self.drawtypes.sort()

        # add a color bar
        #fi.show_color_bar(True)

        fi.show_focus_indicator(True)

        # add little mode indicator that shows keyboard modal states
        fi.show_mode_indicator(True, corner='ur')

        w = fi.get_widget()
        w.set_size_request(512, 512)

        vbox.pack_start(w, fill=True, expand=True)

        self.readout = gtk.Label("")
        vbox.pack_start(self.readout, fill=True, expand=False)

        hbox = gtk.HBox(spacing=5)

        wdrawtype = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawtypes:
            wdrawtype.insert_text(index, name)
            index += 1
        index = self.drawtypes.index('rectangle')
        wdrawtype.set_active(index)
        wdrawtype.connect('changed', self.set_drawparams)
        self.wdrawtype = wdrawtype

        wdrawcolor = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawcolors:
            wdrawcolor.insert_text(index, name)
            index += 1
        index = self.drawcolors.index('lightblue')
        wdrawcolor.set_active(index)
        wdrawcolor.connect('changed', self.set_drawparams)
        self.wdrawcolor = wdrawcolor

        wfill = GtkHelp.CheckButton("Fill")
        wfill.sconnect('toggled', self.set_drawparams)
        self.wfill = wfill

        walpha = GtkHelp.SpinButton()
        adj = walpha.get_adjustment()
        adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0)
        walpha.set_value(1.0)
        walpha.set_digits(1)
        walpha.sconnect('value-changed', self.set_drawparams)
        self.walpha = walpha

        wclear = gtk.Button("Clear Canvas")
        wclear.connect('clicked', self.clear_canvas)

        wopen = gtk.Button("Open File")
        wopen.connect('clicked', self.open_file)
        wquit = gtk.Button("Quit")
        wquit.connect('clicked', quit)

        for w in (wquit, wclear, walpha, gtk.Label("Alpha:"),
                  wfill, wdrawcolor, wdrawtype, wopen):
            hbox.pack_end(w, fill=False, expand=False)

        vbox.pack_start(hbox, fill=False, expand=False)

        root.add(vbox)
Ejemplo n.º 3
0
    def _build_gui(self, container):
        self.mframe = container

        vbox = gtk.VBox()

        sw = gtk.ScrolledWindow()
        sw.set_border_width(2)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.sw = sw

        vbox.pack_start(sw, fill=True, expand=True)

        self.cbar = ColorBar.ColorBar(self.logger)
        self.cbar.set_cmap(self.cmap)
        self.cbar.set_imap(self.imap)

        vbox.pack_start(self.cbar, padding=4, fill=True, expand=False)

        btns = gtk.HBox()
        btns.set_spacing(2)

        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in self.cmap_names:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        cmap_name = self.magcmap
        try:
            index = self.cmap_names.index(cmap_name)
        except Exception:
            index = self.cmap_names.index('ramp')
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_cmap_cb)
        self.btn['cmap'] = combobox
        btns.add(combobox)

        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in self.imap_names:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        imap_name = self.magimap
        try:
            index = self.imap_names.index(imap_name)
        except Exception:
            index = self.imap_names.index('ramp')
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_imap_cb)
        self.btn['imap'] = combobox
        btns.add(combobox)

        vbox.pack_start(btns, padding=4, fill=True, expand=False)

        btns = gtk.HBox()
        btns.set_spacing(2)

        for name in ('Plot', 'Clear', #'Close'
                     ):
            btn = gtk.Button(name)
            btns.add(btn)
            self.btn[name.lower()] = btn
            
        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in ['Mag']:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        combobox.set_active(0)
        combobox.sconnect('changed', self.set_field_cb)
        self.btn['field'] = combobox
        btns.add(combobox)

        self.btn.plot.connect('clicked', lambda w: self.replot_stars())
        self.btn.clear.connect('clicked', lambda w: self.clear())
        #self.btn.close.connect('clicked', lambda w: self.close())

        vbox.pack_start(btns, padding=4, fill=True, expand=False)
        vbox.show_all()
        
        # create the table
        info = Bunch.Bunch(columns=self.columns, color='Mag')
        self.build_table(info)

        self.mframe.pack_start(vbox, expand=True, fill=True)
        self.mframe.show_all()
Ejemplo n.º 4
0
    def build_gui(self, container):
        # Paned container is just to provide a way to size the graph
        # to a reasonable size
        box = gtk.VPaned()
        container.pack_start(box, expand=True, fill=True)

        # Make the cuts plot
        vbox = gtk.VBox()

        self.msgFont = pango.FontDescription("Sans 14")
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_WORD)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.set_editable(False)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.modify_font(self.msgFont)
        self.tw = tw

        fr = gtk.Frame(" Instructions ")
        fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        fr.set_label_align(0.1, 0.5)
        fr.add(tw)
        vbox.pack_start(fr, padding=4, fill=True, expand=False)

        self.plot = Plot.Cuts(self.logger)
        w = self.plot.get_widget()
        vbox.pack_start(w, padding=4, fill=True, expand=True)

        hbox = gtk.HBox(spacing=4)

        # control for selecting a cut
        combobox = GtkHelp.combo_box_new_text()
        for tag in self.tags:
            combobox.append_text(tag)
        if self.cutstag == None:
            combobox.set_active(0)
        else:
            combobox.show_text(self.cutstag)
        combobox.sconnect("changed", self.cut_select_cb)
        self.w.cuts = combobox
        self.w.tooltips.set_tip(combobox, "Select a cut")
        hbox.pack_start(combobox, fill=False, expand=False)

        btn = gtk.Button("Delete")
        btn.connect('clicked', lambda w: self.delete_cut_cb())
        self.w.tooltips.set_tip(btn, "Delete selected cut")
        hbox.pack_start(btn, fill=False, expand=False)

        btn = gtk.Button("Delete All")
        btn.connect('clicked', lambda w: self.delete_all())
        self.w.tooltips.set_tip(btn, "Clear all cuts")
        hbox.pack_start(btn, fill=False, expand=False)

        ## btn = GtkHelp.CheckButton("Move together")
        ## btn.set_active(self.move_together)
        ## #btn.sconnect('toggled', self.movetogether_cb)
        ## self.w.tooltips.set_tip(btn, "Move cuts as a group")
        ## hbox.pack_start(btn, fill=False, expand=False)

        vbox.pack_start(hbox, fill=True, expand=False)

        box.pack1(vbox, resize=True, shrink=True)
        box.pack2(gtk.Label(), resize=True, shrink=True)

        btns = gtk.HButtonBox()
        btns.set_layout(gtk.BUTTONBOX_START)
        btns.set_spacing(3)
        btns.set_child_size(15, -1)

        btn = gtk.Button("Close")
        btn.connect('clicked', lambda w: self.close())
        btns.add(btn)
        container.pack_start(btns, padding=4, fill=True, expand=False)
Ejemplo n.º 5
0
    def build_toplevel(self):

        self.font = self.getFont('fixedFont', 12)
        self.font11 = self.getFont('fixedFont', 11)

        # Hack to enable images in Buttons in recent versions of gnome.
        # Why did they change the default?  Grrr....
        s = gtk.settings_get_default()
        try:
            s.set_property("gtk-button-images", True)
        except:
            pass

        self.ds = GtkHelp.Desktop()
        self.ds.make_desktop(self.layout, widgetDict=self.w)
        # TEMP: FIX ME!
        self.gpmon.ds = self.ds

        for root in self.ds.toplevels:
            # Create root window and add delete/destroy callbacks
            root.set_title("Ginga")
            root.set_border_width(2)
            root.connect("destroy", self.quit)
            root.connect("delete_event", self.delete_event)
            root.connect('window-state-event', self.window_state_change)
        
        self.w.root = root

        menuholder = self.w['menu']
        self.add_menus(menuholder)

        # Create main (center) FITS image pane
        self.w.vbox = self.w['main']
        #bnch = self.ds.make_ws(name='main', group=1, wstype='nb')
        #bnch = self.ds.make_ws(name='main', group=1, wstype='grid')
        self.ds.add_callback("page-select", self.page_switch_cb)

        # readout
        if self.settings.get('shareReadout', True):
            self.readout = self.build_readout()
            self.add_callback('field-info', self.readout_cb, self.readout, None)
            rw = self.readout.get_widget()
            self.w.vbox.pack_start(rw, padding=0, fill=True, expand=False)
            
        # bottom buttons
        hbox = gtk.HBox()

        cbox = GtkHelp.combo_box_new_text()
        self.w.channel = cbox
        cbox.set_tooltip_text("Select a channel")
        cbox.connect("changed", self.channel_select_cb)
        hbox.pack_start(cbox, fill=False, expand=False, padding=4)

        opmenu = gtk.Menu()
        self.w.operation = opmenu
        btn = gtk.Button("Operation")
        btn.connect('button-press-event', self.invoke_op_cb)
        btn.set_tooltip_text("Invoke operation")
        hbox.pack_start(btn, fill=False, expand=False, padding=2)

        self.w.optray = gtk.HBox()
        hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2)
        
        self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False)

        # Add colormap bar
        cbar = self.build_colorbar()
        self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False)

        self.w.vbox.show_all()

        self.add_dialogs()
        statusholder = self.w['status']
        self.add_statusbar(statusholder)

        self.w.root.show_all()
Ejemplo n.º 6
0
    def build_gui(self, container):
        # Paned container is just to provide a way to size the graph
        # to a reasonable size
        box = gtk.VPaned()
        container.pack_start(box, expand=True, fill=True)
        
        # Make the histogram plot
        vbox = gtk.VBox()

        self.msgFont = self.fv.getFont('fixedFont', 10)
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_NONE)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.set_editable(False)
        tw.modify_font(self.msgFont)
        self.tw = tw

        fr = gtk.Frame(" Pixel Values ")
        fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        fr.set_label_align(0.1, 0.5)
        fr.add(tw)
        fr.show_all()
        vbox.pack_start(fr, padding=4, fill=True, expand=False)
        
        box.pack1(vbox, resize=True, shrink=True)

        hbox = gtk.HBox(spacing=4)
        combobox = GtkHelp.combo_box_new_text()
        index = 0
        for i in self.sizes:
            j = 1 + i*2
            name = "%dx%d" % (j, j)
            combobox.insert_text(index, name)
            index += 1
        index = self.sizes.index(self.pixtbl_radius)
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_cutout_size)
        self.w.tooltips.set_tip(combobox, "Select size of pixel table")
        hbox.pack_start(combobox, fill=False, expand=False)

        # control for selecting a mark
        combobox = GtkHelp.combo_box_new_text()
        for tag in self.marks:
            combobox.append_text(tag)
        if self.mark_selected == None:
            combobox.set_active(0)
        else:
            combobox.show_text(self.mark_selected)
        combobox.sconnect("changed", self.mark_select_cb)
        self.w.marks = combobox
        self.w.tooltips.set_tip(combobox, "Select a mark")
        hbox.pack_start(combobox, fill=False, expand=False)

        btn = gtk.Button("Delete")
        btn.connect('clicked', lambda w: self.clear_mark_cb())
        self.w.tooltips.set_tip(btn, "Delete selected mark")
        hbox.pack_start(btn, fill=False, expand=False)
        
        btn = gtk.Button("Delete All")
        btn.connect('clicked', lambda w: self.clear_all())
        self.w.tooltips.set_tip(btn, "Clear all marks")
        hbox.pack_start(btn, fill=False, expand=False)
        
        btn = GtkHelp.CheckButton("Pan to mark")
        btn.set_active(self.pan2mark)
        btn.sconnect('toggled', self.pan2mark_cb)
        self.w.tooltips.set_tip(btn, "Pan follows selected mark")
        hbox.pack_start(btn, fill=False, expand=False)
        
        vbox.pack_start(hbox, fill=True, expand=False)
        
        btns = gtk.HButtonBox()
        btns.set_layout(gtk.BUTTONBOX_START)
        btns.set_spacing(3)
        btns.set_child_size(15, -1)

        btn = gtk.Button("Close")
        btn.connect('clicked', lambda w: self.close())
        btns.add(btn)
        vbox.pack_start(btns, padding=4, fill=True, expand=False)

        box.pack2(gtk.Label(), resize=True, shrink=True)
Ejemplo n.º 7
0
    def __init__(self, logger):

        self.logger = logger
        self.drawcolors = colors.get_colors()
        self.dc = get_canvas_types()

        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_title("Gtk2 CanvasView Example")
        root.set_border_width(2)
        root.connect("delete_event", lambda w, e: quit(w))
        self.root = root
        self.select = GtkHelp.FileSelection(root)

        vbox = gtk.VBox(spacing=2)

        fi = CanvasView(logger)
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.set_zoom_algorithm('rate')
        fi.set_zoomrate(1.4)
        fi.show_pan_mark(True)
        fi.set_callback('drag-drop', self.drop_file)
        fi.set_callback('none-move', self.motion)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_setActive(True)
        self.fitsimage = fi

        bd = fi.get_bindings()
        bd.enable_all(True)

        # canvas that we will draw on
        canvas = self.dc.DrawingCanvas()
        canvas.enable_draw(True)
        canvas.set_drawtype('rectangle', color='lightblue')
        canvas.setSurface(fi)
        self.canvas = canvas
        # add canvas to view
        private_canvas = fi.get_canvas()
        private_canvas.register_for_cursor_drawing(fi)
        private_canvas.add(canvas)
        canvas.ui_setActive(True)
        self.drawtypes = canvas.get_drawtypes()
        self.drawtypes.sort()

        # add a color bar
        #fi.show_color_bar(True)

        # add little mode indicator that shows keyboard modal states
        fi.show_mode_indicator(True, corner='ur')

        w = fi.get_widget()
        w.set_size_request(512, 512)

        vbox.pack_start(w, fill=True, expand=True)

        self.readout = gtk.Label("")
        vbox.pack_start(self.readout, fill=True, expand=False)

        hbox = gtk.HBox(spacing=5)

        wdrawtype = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawtypes:
            wdrawtype.insert_text(index, name)
            index += 1
        index = self.drawtypes.index('rectangle')
        wdrawtype.set_active(index)
        wdrawtype.connect('changed', self.set_drawparams)
        self.wdrawtype = wdrawtype

        wdrawcolor = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawcolors:
            wdrawcolor.insert_text(index, name)
            index += 1
        index = self.drawcolors.index('lightblue')
        wdrawcolor.set_active(index)
        wdrawcolor.connect('changed', self.set_drawparams)
        self.wdrawcolor = wdrawcolor

        wfill = GtkHelp.CheckButton("Fill")
        wfill.sconnect('toggled', self.set_drawparams)
        self.wfill = wfill

        walpha = GtkHelp.SpinButton()
        adj = walpha.get_adjustment()
        adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0)
        walpha.set_value(1.0)
        walpha.set_digits(1)
        walpha.sconnect('value-changed', self.set_drawparams)
        self.walpha = walpha

        wclear = gtk.Button("Clear Canvas")
        wclear.connect('clicked', self.clear_canvas)

        wopen = gtk.Button("Open File")
        wopen.connect('clicked', self.open_file)
        wquit = gtk.Button("Quit")
        wquit.connect('clicked', quit)

        for w in (wquit, wclear, walpha, gtk.Label("Alpha:"), wfill,
                  wdrawcolor, wdrawtype, wopen):
            hbox.pack_end(w, fill=False, expand=False)

        vbox.pack_start(hbox, fill=False, expand=False)

        root.add(vbox)
Ejemplo n.º 8
0
    def build_toplevel(self, layout):

        self.w.tooltips = gtk.Tooltips()
        
        self.font = self.getFont('fixedFont', 12)
        self.font11 = self.getFont('fixedFont', 11)

        # Hack to enable images in Buttons in recent versions of gnome.
        # Why did they change the default?  Grrr....
        s = gtk.settings_get_default()
        try:
            s.set_property("gtk-button-images", True)
        except:
            pass

        # Create root window and add delete/destroy callbacks
        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_size_request(self.default_width, self.default_height)
        root.set_title("Ginga")
        root.set_border_width(2)
        root.connect("destroy", self.quit)
        root.connect("delete_event", self.delete_event)
        root.connect('window-state-event', self.window_state_change)
        
        self.w.root = root

        self.ds = GtkHelp.Desktop()
        
        # create main frame
        self.w.mframe = gtk.VBox(spacing=2)
        root.add(self.w.mframe)

        self.add_menus()

        self.w.mvbox = self.ds.make_desktop(layout, widgetDict=self.w)
        self.w.mvbox.show_all()
        self.w.mframe.pack_start(self.w.mvbox, expand=True)

        # Create main (center) FITS image pane
        self.w.vbox = self.w['main']
        bnch = self.ds.make_ws(name='main', group=1, wstype='nb')
        #bnch = self.ds.make_ws(name='main', group=1, wstype='grid')
        self.w.mnb = bnch.nb
        self.ds.add_callback("page-select", self.page_switch_cb)
        #self.w.mnb.connect("switch-page", self.page_switch_cb)
        self.w.vbox.pack_start(bnch.widget, expand=True, fill=True)

        # readout
        if self.settings.get('shareReadout', True):
            self.readout = self.build_readout()
            self.add_callback('field-info', self.readout_cb, self.readout, None)
            rw = self.readout.get_widget()
            self.w.vbox.pack_start(rw, padding=0, fill=True, expand=False)
            
        # bottom buttons
        hbox = gtk.HBox()

        cbox = GtkHelp.combo_box_new_text()
        self.w.channel = cbox
        self.w.tooltips.set_tip(cbox, "Select a channel")
        cbox.connect("changed", self.channel_select_cb)
        hbox.pack_start(cbox, fill=False, expand=False, padding=4)

        opmenu = gtk.Menu()
        self.w.operation = opmenu
        btn = gtk.Button("Operation")
        btn.connect('button-press-event', self.invoke_op_cb)
        self.w.tooltips.set_tip(btn, "Invoke operation")
        hbox.pack_start(btn, fill=False, expand=False, padding=2)

        self.w.optray = gtk.HBox()
        hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2)
        
        self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False)

        # Add colormap bar
        cbar = self.build_colorbar()
        self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False)

        self.add_dialogs()
        self.add_statusbar()

        self.w.root.show_all()
Ejemplo n.º 9
0
    def build_toplevel(self):

        self.font = self.getFont('fixedFont', 12)
        self.font11 = self.getFont('fixedFont', 11)

        # Hack to enable images in Buttons in recent versions of gnome.
        # Why did they change the default?  Grrr....
        s = gtk.settings_get_default()
        try:
            s.set_property("gtk-button-images", True)
        except:
            pass

        self.ds = GtkHelp.Desktop()
        self.ds.make_desktop(self.layout, widgetDict=self.w)
        # TEMP: FIX ME!
        self.gpmon.ds = self.ds

        for root in self.ds.toplevels:
            # Create root window and add delete/destroy callbacks
            root.set_title("Ginga")
            root.set_border_width(2)
            root.connect("destroy", self.quit)
            root.connect("delete_event", self.delete_event)
            root.connect('window-state-event', self.window_state_change)
        
        self.w.root = root

        menuholder = self.w['menu']
        self.add_menus(menuholder)

        # Create main (center) FITS image pane
        self.w.vbox = self.w['main']
        self.ds.add_callback("page-select", self.page_switch_cb)

        # readout
        if self.settings.get('shareReadout', True):
            self.readout = self.build_readout()
            self.add_callback('field-info', self.readout_cb, self.readout, None)
            rw = self.readout.get_widget()
            self.w.vbox.pack_start(rw, padding=0, fill=True, expand=False)
            
        # bottom buttons
        hbox = gtk.HBox()

        cbox = GtkHelp.combo_box_new_text()
        self.w.channel = cbox
        cbox.set_tooltip_text("Select a channel")
        cbox.connect("changed", self.channel_select_cb)
        hbox.pack_start(cbox, fill=False, expand=False, padding=4)

        opmenu = gtk.Menu()
        self.w.operation = opmenu
        btn = gtk.Button("Operation")
        btn.connect('button-press-event', self.invoke_op_cb)
        btn.set_tooltip_text("Invoke operation")
        hbox.pack_start(btn, fill=False, expand=False, padding=2)

        self.w.optray = gtk.HBox()
        hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2)
        
        self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False)

        # Add colormap bar
        cbar = self.build_colorbar()
        self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False)

        self.w.vbox.show_all()

        self.add_dialogs()
        statusholder = self.w['status']
        self.add_statusbar(statusholder)

        self.w.root.show_all()
Ejemplo n.º 10
0
    def __init__(self, logger):

        self.logger = logger
        self.drawcolors = colors.get_colors()
        self.select = FileSelection.FileSelection()

        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_title("ImageViewCanvas Example")
        root.set_border_width(2)
        root.connect("delete_event", lambda w, e: quit(w))
        self.root = root

        vbox = gtk.VBox(spacing=2)

        fi = ImageViewCanvas(logger)
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.enable_draw(True)
        fi.set_drawtype('ruler')
        fi.set_drawcolor('blue')
        fi.set_callback('drag-drop', self.drop_file)
        fi.set_callback('none-move', self.motion)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_setActive(True)
        self.fitsimage = fi

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

        w = fi.get_widget()
        w.set_size_request(512, 512)

        vbox.pack_start(w, fill=True, expand=True)

        self.readout = gtk.Label("")
        vbox.pack_start(self.readout, fill=True, expand=False)
        
        hbox = gtk.HBox(spacing=5)

        wdrawtype = GtkHelp.combo_box_new_text()
        self.drawtypes = fi.get_drawtypes()
        index = 0
        for name in self.drawtypes:
            wdrawtype.insert_text(index, name)
            index += 1
        index = self.drawtypes.index('ruler')
        wdrawtype.set_active(index)
        wdrawtype.connect('changed', self.set_drawparams)
        self.wdrawtype = wdrawtype

        wdrawcolor = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawcolors:
            wdrawcolor.insert_text(index, name)
            index += 1
        index = self.drawcolors.index('blue')
        wdrawcolor.set_active(index)
        wdrawcolor.connect('changed', self.set_drawparams)
        self.wdrawcolor = wdrawcolor

        wclear = gtk.Button("Clear Canvas")
        wclear.connect('clicked', self.clear_canvas)

        wopen = gtk.Button("Open File")
        wopen.connect('clicked', self.open_file)
        wquit = gtk.Button("Quit")
        wquit.connect('clicked', quit)

        for w in (wquit, wclear, wdrawcolor, wdrawtype, wopen):
            hbox.pack_end(w, fill=False, expand=False)

        vbox.pack_start(hbox, fill=False, expand=False)

        root.add(vbox)
Ejemplo n.º 11
0
    def build_toplevel(self, layout):
        # Hack to enable images in Buttons in recent versions of gnome.
        # Why did they change the default?  Grrr....
        s = gtk.settings_get_default()
        try:
            s.set_property("gtk-button-images", True)
        except:
            pass

        # Create root window and add delete/destroy callbacks
        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_size_request(self.default_width, self.default_height)
        root.set_title("Ginga")
        root.set_border_width(2)
        root.connect("destroy", self.quit)
        root.connect("delete_event", self.delete_event)
        root.connect('window-state-event', self.window_state_change)

        self.w.root = root

        self.ds = GtkHelp.Desktop()

        # create main frame
        self.w.mframe = gtk.VBox(spacing=2)
        root.add(self.w.mframe)

        self.add_menus()

        self.w.mvbox = self.ds.make_desktop(layout, widgetDict=self.w)
        self.w.mvbox.show_all()
        self.w.mframe.pack_start(self.w.mvbox, expand=True)

        # Create main (center) FITS image pane
        self.w.vbox = self.w['main']
        bnch = self.ds.make_nb(name='main', group=1, wstype='nb')
        self.w.mnb = bnch.nb
        self.ds.add_callback("page-select", self.page_switch_cb)
        #self.w.mnb.connect("switch-page", self.page_switch_cb)
        self.w.vbox.pack_start(bnch.widget, expand=True, fill=True)

        # bottom buttons
        hbox = gtk.HBox()

        cbox = GtkHelp.combo_box_new_text()
        self.w.channel = cbox
        self.w.tooltips.set_tip(cbox, "Select a channel")
        cbox.connect("changed", self.channel_select_cb)
        hbox.pack_start(cbox, fill=False, expand=False, padding=4)

        opmenu = gtk.Menu()
        self.w.operation = opmenu
        btn = gtk.Button("Operation")
        btn.connect('button-press-event', self.invoke_op_cb)
        self.w.tooltips.set_tip(btn, "Invoke operation")
        hbox.pack_start(btn, fill=False, expand=False, padding=2)

        self.w.optray = gtk.HBox()
        hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2)

        self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False)

        # Add colormap bar
        cbar = self.build_colorbar()
        self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False)

        self.add_dialogs()
        self.add_statusbar()

        self.w.root.show_all()
Ejemplo n.º 12
0
    def _build_gui(self, container):
        self.mframe = container

        vbox = gtk.VBox()

        sw = gtk.ScrolledWindow()
        sw.set_border_width(2)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.sw = sw

        vbox.pack_start(sw, fill=True, expand=True)

        self.cbar = ColorBar.ColorBar(self.logger)
        self.cbar.set_cmap(self.cmap)
        self.cbar.set_imap(self.imap)

        vbox.pack_start(self.cbar, padding=4, fill=True, expand=False)

        btns = gtk.HBox()
        btns.set_spacing(2)

        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in self.cmap_names:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        cmap_name = self.magcmap
        try:
            index = self.cmap_names.index(cmap_name)
        except Exception:
            index = self.cmap_names.index('ramp')
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_cmap_cb)
        self.btn['cmap'] = combobox
        btns.add(combobox)

        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in self.imap_names:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        imap_name = self.magimap
        try:
            index = self.imap_names.index(imap_name)
        except Exception:
            index = self.imap_names.index('ramp')
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_imap_cb)
        self.btn['imap'] = combobox
        btns.add(combobox)

        vbox.pack_start(btns, padding=4, fill=True, expand=False)

        btns = gtk.HBox()
        btns.set_spacing(2)

        for name in (
                'Plot',
                'Clear',  #'Close'
        ):
            btn = gtk.Button(name)
            btns.add(btn)
            self.btn[name.lower()] = btn

        combobox = GtkHelp.combo_box_new_text()
        options = []
        index = 0
        for name in ['Mag']:
            options.append(name)
            combobox.insert_text(index, name)
            index += 1
        combobox.set_active(0)
        combobox.sconnect('changed', self.set_field_cb)
        self.btn['field'] = combobox
        btns.add(combobox)

        self.btn.plot.connect('clicked', lambda w: self.replot_stars())
        self.btn.clear.connect('clicked', lambda w: self.clear())
        #self.btn.close.connect('clicked', lambda w: self.close())

        vbox.pack_start(btns, padding=4, fill=True, expand=False)
        vbox.show_all()

        # create the table
        info = Bunch.Bunch(columns=self.columns, color='Mag')
        self.build_table(info)

        self.mframe.pack_start(vbox, expand=True, fill=True)
        self.mframe.show_all()
Ejemplo n.º 13
0
    def __init__(self, logger):

        self.logger = logger
        self.drawcolors = colors.get_colors()
        self.select = FileSelection.FileSelection()

        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_title("ImageViewCanvas Example")
        root.set_border_width(2)
        root.connect("delete_event", lambda w, e: quit(w))
        self.root = root

        vbox = gtk.VBox(spacing=2)

        fi = ImageViewCanvas(logger)
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.enable_draw(False)
        fi.set_callback('drag-drop', self.drop_file)
        fi.set_callback('none-move', self.motion)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_setActive(True)
        self.fitsimage = fi

        bd = fi.get_bindings()
        bd.enable_all(True)

        # canvas that we will draw on
        canvas = DrawingCanvas()
        canvas.enable_draw(True)
        canvas.set_drawtype('rectangle', color='lightblue')
        canvas.setSurface(fi)
        self.canvas = canvas
        # add canvas to view
        fi.add(canvas)
        canvas.ui_setActive(True)

        w = fi.get_widget()
        w.set_size_request(512, 512)

        vbox.pack_start(w, fill=True, expand=True)

        self.readout = gtk.Label("")
        vbox.pack_start(self.readout, fill=True, expand=False)

        hbox = gtk.HBox(spacing=5)

        wdrawtype = GtkHelp.combo_box_new_text()
        self.drawtypes = fi.get_drawtypes()
        index = 0
        for name in self.drawtypes:
            wdrawtype.insert_text(index, name)
            index += 1
        index = self.drawtypes.index('rectangle')
        wdrawtype.set_active(index)
        wdrawtype.connect('changed', self.set_drawparams)
        self.wdrawtype = wdrawtype

        wdrawcolor = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawcolors:
            wdrawcolor.insert_text(index, name)
            index += 1
        index = self.drawcolors.index('lightblue')
        wdrawcolor.set_active(index)
        wdrawcolor.connect('changed', self.set_drawparams)
        self.wdrawcolor = wdrawcolor

        wfill = GtkHelp.CheckButton("Fill")
        wfill.sconnect('toggled', self.set_drawparams)
        self.wfill = wfill

        walpha = GtkHelp.SpinButton()
        adj = walpha.get_adjustment()
        adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0)
        walpha.set_value(1.0)
        walpha.set_digits(1)
        walpha.sconnect('value-changed', self.set_drawparams)
        self.walpha = walpha

        wclear = gtk.Button("Clear Canvas")
        wclear.connect('clicked', self.clear_canvas)

        wopen = gtk.Button("Open File")
        wopen.connect('clicked', self.open_file)
        wquit = gtk.Button("Quit")
        wquit.connect('clicked', quit)

        for w in (wquit, wclear, walpha, gtk.Label("Alpha:"),
                  wfill, wdrawcolor, wdrawtype, wopen):
            hbox.pack_end(w, fill=False, expand=False)

        vbox.pack_start(hbox, fill=False, expand=False)

        root.add(vbox)
Ejemplo n.º 14
0
Archivo: Cuts.py Proyecto: adrn/ginga
    def build_gui(self, container):
        # Paned container is just to provide a way to size the graph
        # to a reasonable size
        box = gtk.VPaned()
        container.pack_start(box, expand=True, fill=True)
        
        # Make the cuts plot
        vbox = gtk.VBox()

        self.msgFont = pango.FontDescription("Sans 14")
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_WORD)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.set_editable(False)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.modify_font(self.msgFont)
        self.tw = tw

        fr = gtk.Frame(" Instructions ")
        fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        fr.set_label_align(0.1, 0.5)
        fr.add(tw)
        vbox.pack_start(fr, padding=4, fill=True, expand=False)
        
        self.plot = Plot.Cuts(self.logger)
        w = self.plot.get_widget()
        vbox.pack_start(w, padding=4, fill=True, expand=True)

        hbox = gtk.HBox(spacing=4)

        # control for selecting a cut
        combobox = GtkHelp.combo_box_new_text()
        for tag in self.tags:
            combobox.append_text(tag)
        if self.cutstag == None:
            combobox.set_active(0)
        else:
            combobox.show_text(self.cutstag)
        combobox.sconnect("changed", self.cut_select_cb)
        self.w.cuts = combobox
        self.w.tooltips.set_tip(combobox, "Select a cut")
        hbox.pack_start(combobox, fill=False, expand=False)

        btn = gtk.Button("Delete")
        btn.connect('clicked', lambda w: self.delete_cut_cb())
        self.w.tooltips.set_tip(btn, "Delete selected cut")
        hbox.pack_start(btn, fill=False, expand=False)
        
        btn = gtk.Button("Delete All")
        btn.connect('clicked', lambda w: self.delete_all())
        self.w.tooltips.set_tip(btn, "Clear all cuts")
        hbox.pack_start(btn, fill=False, expand=False)
        
        ## btn = GtkHelp.CheckButton("Move together")
        ## btn.set_active(self.move_together)
        ## #btn.sconnect('toggled', self.movetogether_cb)
        ## self.w.tooltips.set_tip(btn, "Move cuts as a group")
        ## hbox.pack_start(btn, fill=False, expand=False)
        
        vbox.pack_start(hbox, fill=True, expand=False)
        
        box.pack1(vbox, resize=True, shrink=True)
        box.pack2(gtk.Label(), resize=True, shrink=True)

        btns = gtk.HButtonBox()
        btns.set_layout(gtk.BUTTONBOX_START)
        btns.set_spacing(3)
        btns.set_child_size(15, -1)

        btn = gtk.Button("Close")
        btn.connect('clicked', lambda w: self.close())
        btns.add(btn)
        container.pack_start(btns, padding=4, fill=True, expand=False)
Ejemplo n.º 15
0
    def build_gui(self, container):
        # Paned container is just to provide a way to size the graph
        # to a reasonable size
        box = gtk.VPaned()
        container.pack_start(box, expand=True, fill=True)

        # Make the histogram plot
        vbox = gtk.VBox()

        self.msgFont = pango.FontDescription("Monospace 10")
        tw = gtk.TextView()
        tw.set_wrap_mode(gtk.WRAP_NONE)
        tw.set_left_margin(4)
        tw.set_right_margin(4)
        tw.set_editable(False)
        tw.modify_font(self.msgFont)
        self.tw = tw

        fr = gtk.Frame(" Pixel Values ")
        fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        fr.set_label_align(0.1, 0.5)
        fr.add(tw)
        fr.show_all()
        vbox.pack_start(fr, padding=4, fill=True, expand=False)

        box.pack1(vbox, resize=True, shrink=True)

        hbox = gtk.HBox(spacing=4)
        combobox = GtkHelp.combo_box_new_text()
        index = 0
        for i in self.sizes:
            j = 1 + i * 2
            name = "%dx%d" % (j, j)
            combobox.insert_text(index, name)
            index += 1
        index = self.sizes.index(self.pixtbl_radius)
        combobox.set_active(index)
        combobox.sconnect('changed', self.set_cutout_size)
        self.w.tooltips.set_tip(combobox, "Select size of pixel table")
        hbox.pack_start(combobox, fill=False, expand=False)

        # control for selecting a mark
        combobox = GtkHelp.combo_box_new_text()
        for tag in self.marks:
            combobox.append_text(tag)
        if self.mark_selected == None:
            combobox.set_active(0)
        else:
            combobox.show_text(self.mark_selected)
        combobox.sconnect("changed", self.mark_select_cb)
        self.w.marks = combobox
        self.w.tooltips.set_tip(combobox, "Select a mark")
        hbox.pack_start(combobox, fill=False, expand=False)

        btn = gtk.Button("Delete")
        btn.connect('clicked', lambda w: self.clear_mark_cb())
        self.w.tooltips.set_tip(btn, "Delete selected mark")
        hbox.pack_start(btn, fill=False, expand=False)

        btn = gtk.Button("Delete All")
        btn.connect('clicked', lambda w: self.clear_all())
        self.w.tooltips.set_tip(btn, "Clear all marks")
        hbox.pack_start(btn, fill=False, expand=False)

        btn = GtkHelp.CheckButton("Pan to mark")
        btn.set_active(self.pan2mark)
        btn.sconnect('toggled', self.pan2mark_cb)
        self.w.tooltips.set_tip(btn, "Pan follows selected mark")
        hbox.pack_start(btn, fill=False, expand=False)

        vbox.pack_start(hbox, fill=True, expand=False)

        btns = gtk.HButtonBox()
        btns.set_layout(gtk.BUTTONBOX_START)
        btns.set_spacing(3)
        btns.set_child_size(15, -1)

        btn = gtk.Button("Close")
        btn.connect('clicked', lambda w: self.close())
        btns.add(btn)
        vbox.pack_start(btns, padding=4, fill=True, expand=False)

        box.pack2(gtk.Label(), resize=True, shrink=True)
Ejemplo n.º 16
0
    def __init__(self, logger):

        self.logger = logger
        self.drawcolors = colors.get_colors()
        self.select = FileSelection.FileSelection()

        root = gtk.Window(gtk.WINDOW_TOPLEVEL)
        root.set_title("ImageViewCanvas Example")
        root.set_border_width(2)
        root.connect("delete_event", lambda w, e: quit(w))
        self.root = root

        vbox = gtk.VBox(spacing=2)

        fi = ImageViewCanvas(logger)
        fi.enable_autocuts('on')
        fi.set_autocut_params('zscale')
        fi.enable_autozoom('on')
        fi.enable_draw(True)
        fi.set_drawtype('ruler')
        fi.set_drawcolor('blue')
        fi.set_callback('drag-drop', self.drop_file)
        fi.set_callback('none-move', self.motion)
        fi.set_bg(0.2, 0.2, 0.2)
        fi.ui_setActive(True)
        self.fitsimage = fi

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

        w = fi.get_widget()
        w.set_size_request(512, 512)

        vbox.pack_start(w, fill=True, expand=True)

        self.readout = gtk.Label("")
        vbox.pack_start(self.readout, fill=True, expand=False)

        hbox = gtk.HBox(spacing=5)

        wdrawtype = GtkHelp.combo_box_new_text()
        self.drawtypes = fi.get_drawtypes()
        index = 0
        for name in self.drawtypes:
            wdrawtype.insert_text(index, name)
            index += 1
        index = self.drawtypes.index('ruler')
        wdrawtype.set_active(index)
        wdrawtype.connect('changed', self.set_drawparams)
        self.wdrawtype = wdrawtype

        wdrawcolor = GtkHelp.combo_box_new_text()
        index = 0
        for name in self.drawcolors:
            wdrawcolor.insert_text(index, name)
            index += 1
        index = self.drawcolors.index('blue')
        wdrawcolor.set_active(index)
        wdrawcolor.connect('changed', self.set_drawparams)
        self.wdrawcolor = wdrawcolor

        wclear = gtk.Button("Clear Canvas")
        wclear.connect('clicked', self.clear_canvas)

        wopen = gtk.Button("Open File")
        wopen.connect('clicked', self.open_file)
        wquit = gtk.Button("Quit")
        wquit.connect('clicked', quit)

        for w in (wquit, wclear, wdrawcolor, wdrawtype, wopen):
            hbox.pack_end(w, fill=False, expand=False)

        vbox.pack_start(hbox, fill=False, expand=False)

        root.add(vbox)