예제 #1
0
    def build_colorbar(self):
        cbar = ColorBar.ColorBar(self.logger)
        cbar.set_cmap(self.cm)
        cbar.set_imap(self.im)
        cbar.show()
        self.colorbar = cbar
        self.add_callback('active-image', self.change_cbar, cbar)
        cbar.add_callback('motion', self.cbar_value_cb)

        fr = gtk.Frame()
        fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        fr.add(cbar)
        return fr
예제 #2
0
import sys
import gtk

from ginga.gtkw import ColorBar
from ginga import cmap, imap
import logging

logger = logging.getLogger('cbar')

root = gtk.Window(gtk.WINDOW_TOPLEVEL)
root.set_size_request(400, 150)
w = ColorBar.ColorBar(logger)
w.set_cmap(cmap.get_cmap('rainbow'))
w.set_imap(imap.get_imap('ramp'))
root.add(w)
root.show_all()

gtk.main()
예제 #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()
예제 #4
0
    def __init__(self, logger, container):
        self.logger = logger
        self.tag = None
        self.mycolor = 'skyblue'
        self.magmap = 'stairs8'

        self.mag_max = 25.0
        self.mag_min = 0.0

        # keys: are name, ra, dec, mag, flag, b_r, preference, priority, dst
        # TODO: automate this generation
        self.columns = [
            ('Name', 'name'),
            ('RA', 'ra'),
            ('DEC', 'dec'),
            ('Mag', 'mag'),
            ('Preference', 'preference'),
            ('Priority', 'priority'),
            ('Flag', 'flag'),
            ('b-r', 'b_r'),
            ('Dst', 'dst'),
            ('Description', 'description'),
        ]
        self.cell_sort_funcs = []
        for kwd, key in self.columns:
            self.cell_sort_funcs.append(self._mksrtfnN(key))

        self.catalog = None
        self.cursor = 0
        self.color_cursor = 'red'
        self.color_selected = 'skyblue'
        self.selection_mode = 'single'
        self.selected = []
        self.moving_cursor = False

        self.btn = Bunch.Bunch()

        self.mframe = container

        vbox = gtk.VBox()

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

        #self.font = pango.FontDescription('Monospace 10')

        # create the TreeView
        treeview = gtk.TreeView()
        self.treeview = treeview

        # create the TreeViewColumns to display the data
        tvcolumn = [None] * len(self.columns)
        for n in range(0, len(self.columns)):
            cell = gtk.CellRendererText()
            cell.set_padding(2, 0)
            header, kwd = self.columns[n]
            tvc = gtk.TreeViewColumn(header, cell)
            tvc.set_spacing(4)
            tvc.set_resizable(True)
            tvc.connect('clicked', self.sort_cb, n)
            tvc.set_clickable(True)
            tvcolumn[n] = tvc
            fn_data = self._mkcolfnN(kwd)
            tvcolumn[n].set_cell_data_func(cell, fn_data)
            treeview.append_column(tvcolumn[n])

        sw.add(treeview)
        self.treeview.connect('cursor-changed', self.select_star)
        sw.show_all()
        vbox.pack_start(sw, fill=True, expand=True)

        self.cbar = ColorBar.ColorBar(self.logger)
        self.cmap = cmap.get_cmap(self.magmap)
        self.imap = imap.get_imap('ramp')
        self.cbar.set_cmap(self.cmap)
        self.cbar.set_imap(self.imap)
        self.cbar.set_size_request(-1, 20)

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

        btns = gtk.HButtonBox()
        btns.set_layout(gtk.BUTTONBOX_CENTER)
        btns.set_spacing(5)

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

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

        self.mframe.pack_start(vbox, expand=True, fill=True)
        self.mframe.show_all()