How to use ginga - 10 common examples

To help you get started, we’ve selected a few ginga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ejeschke / ginga / ginga / rv / plugins / Thumbs.py View on Github external
def _insert_lazy_thumb(self, thumbkey, chname, info, thumbpath):
        """This function gets called to create an initial entry for a
        thumb.
        """
        thumbname = info.name
        self.logger.debug("inserting an empty thumb %s" % (thumbname))

        # Make an initial entry for the thumbs in the tracking dict.
        # Nothing is actually plotted, because the thumb may be in a region
        # that is not visible.
        n = len(self.thumb_list)
        row = n // self.thumb_num_cols
        col = n % self.thumb_num_cols

        extras = info.setdefault('thumb_extras', Bunch.Bunch())
        bnch = Bunch.Bunch(info=info, extras=extras,
                           thumbname=thumbname, chname=chname,
                           thumbpath=thumbpath, row=row, col=col)

        self.thumb_dict[thumbkey] = bnch
        if thumbkey not in self.thumb_list:
            sort_order = self.settings.get('sort_order', None)
            if sort_order is not None:
                bisect.insort(self.thumb_list, thumbkey)
            else:
                self.thumb_list.append(thumbkey)

        self._latest_thumb = thumbkey

        self.timer_update.cond_set(self.update_interval)
        #self.timer_update.set(self.update_interval)
github ejeschke / ginga / ginga / qtw / Widgets.py View on Github external
def build_info(captions, orientation='vertical'):
    # numrows = len(captions)
    numcols = reduce(lambda acc, tup: max(acc, len(tup)), captions, 0)
    if (numcols % 2) != 0:
        raise ValueError("Column spec is not an even number")
    numcols = int(numcols // 2)

    widget = QtGui.QWidget()
    table = QtGui.QGridLayout()
    widget.setLayout(table)
    table.setVerticalSpacing(2)
    table.setHorizontalSpacing(4)
    table.setContentsMargins(2, 2, 2, 2)

    wb = Bunch.Bunch()
    row = 0
    for tup in captions:
        col = 0
        while col < numcols:
            idx = col * 2
            if idx < len(tup):
                title, wtype = tup[idx:idx + 2]
                if not title.endswith(':'):
                    name = name_mangle(title)
github ejeschke / ginga / ginga / rv / plugins / Command.py View on Github external
self.msg_font = self.fv.get_font('fixed', 12)

        vbox.add_widget(Widgets.Label("Output:"))
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msg_font)
        tw.set_limit(self.histlimit)
        self.hist_w = tw

        vbox2 = Widgets.VBox()
        vbox2.add_widget(tw, stretch=1)
        vbox2.add_widget(Widgets.Label(''), stretch=0)

        vbox.add_widget(vbox2, stretch=1)

        vbox2 = Widgets.VBox()
        vbox2.add_widget(Widgets.Label("Type command here:"))
        self.cmd_w = Widgets.TextEntry()
        self.cmd_w.set_font(self.msg_font)
        vbox2.add_widget(self.cmd_w, stretch=0)
        self.cmd_w.add_callback('activated', self.exec_cmd_cb)
        vbox.add_widget(vbox2, stretch=0)

        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)
        btn = Widgets.Button("Help")
        btn.add_callback('activated', lambda w: self.help())
        btns.add_widget(btn, stretch=0)
github ejeschke / ginga / ginga / examples / gw / clocks.py View on Github external
vbox = Widgets.VBox()

        menubar = Widgets.Menubar()
        clockmenu = menubar.add_name('Clock')
        item = clockmenu.add_name("Quit")
        item.add_callback('activated', lambda *args: self.quit())
        vbox.add_widget(menubar, stretch=0)

        self.grid = Widgets.GridBox()
        self.grid.set_border_width(1)
        self.grid.set_spacing(2)
        vbox.add_widget(self.grid, stretch=1)

        hbox = Widgets.HBox()

        self.timezone_label = Widgets.Label('TimeZone')
        self.county_timezone = Widgets.ComboBox(editable=True)

        # make a giant list of time zones
        zones = [timezone for timezones in pytz.country_timezones.values()
                 for timezone in timezones]
        zones.sort()
        for timezone in zones:
            self.county_timezone.append_text(timezone)

        # also let user set timezone by UTC offset
        self.location_label = Widgets.Label('Location')
        self.location = Widgets.TextEntry()
        self.location.set_tooltip("Type a label to denote this UTC offset")
        #self.location.set_length(10)
        self.timeoffset_label = Widgets.Label('UTC Offset(hour)')
        self.time_offset = Widgets.SpinBox(dtype=float)
github ejeschke / ginga / ginga / rv / plugins / Command.py View on Github external
def build_gui(self, container):

        vbox = Widgets.VBox()

        self.msg_font = self.fv.get_font('fixed', 12)

        vbox.add_widget(Widgets.Label("Output:"))
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msg_font)
        tw.set_limit(self.histlimit)
        self.hist_w = tw

        vbox2 = Widgets.VBox()
        vbox2.add_widget(tw, stretch=1)
        vbox2.add_widget(Widgets.Label(''), stretch=0)

        vbox.add_widget(vbox2, stretch=1)

        vbox2 = Widgets.VBox()
        vbox2.add_widget(Widgets.Label("Type command here:"))
        self.cmd_w = Widgets.TextEntry()
        self.cmd_w.set_font(self.msg_font)
        vbox2.add_widget(self.cmd_w, stretch=0)
        self.cmd_w.add_callback('activated', self.exec_cmd_cb)
        vbox.add_widget(vbox2, stretch=0)

        btns = Widgets.HBox()
        btns.set_spacing(4)
        btns.set_border_width(4)
github ejeschke / ginga / ginga / examples / gw / clocks.py View on Github external
if options.num_cols is not None:
            cols = options.num_cols

        self.settings.add_defaults(columns=cols, zones=['UTC'],
                                   colors=colors)
        self.colors = self.settings.get('colors', colors)

        # now import our items
        from ginga.gw import Widgets, GwHelp

        self.app = Widgets.Application(logger=logger)
        self.app.add_callback('shutdown', self.quit)
        self.top = self.app.make_window("Clocks")
        self.top.add_callback('close', self.closed)

        vbox = Widgets.VBox()

        menubar = Widgets.Menubar()
        clockmenu = menubar.add_name('Clock')
        item = clockmenu.add_name("Quit")
        item.add_callback('activated', lambda *args: self.quit())
        vbox.add_widget(menubar, stretch=0)

        self.grid = Widgets.GridBox()
        self.grid.set_border_width(1)
        self.grid.set_spacing(2)
        vbox.add_widget(self.grid, stretch=1)

        hbox = Widgets.HBox()

        self.timezone_label = Widgets.Label('TimeZone')
        self.county_timezone = Widgets.ComboBox(editable=True)
github ejeschke / ginga / ginga / examples / gw / example1_video.py View on Github external
# Clip cuts assumes data does not need to be scaled in cut levels--
            # only clipped
            fi.set_autocuts(AutoCuts.Clip(logger=self.logger))

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

        fi.set_desired_size(512, 512)
        iw = Viewers.GingaViewerWidget(viewer=fi)
        vbox.add_widget(iw, stretch=1)

        hbox = Widgets.HBox()
        hbox.set_margins(4, 2, 4, 2)

        wopen = Widgets.Button("Open File")
        #wopen.clicked.connect(self.open_file)
        wquit = Widgets.Button("Quit")
        wquit.add_callback('activated', lambda *args: self.quit())

        for w in (wopen, wquit):
            hbox.add_widget(w, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        vbox.add_widget(hbox, stretch=0)

        self.top.set_widget(vbox)
        self.top.set_title("Video Example Viewer")
github ejeschke / ginga / ginga / examples / gw / clocks.py View on Github external
self.top.add_callback('close', self.closed)

        vbox = Widgets.VBox()

        menubar = Widgets.Menubar()
        clockmenu = menubar.add_name('Clock')
        item = clockmenu.add_name("Quit")
        item.add_callback('activated', lambda *args: self.quit())
        vbox.add_widget(menubar, stretch=0)

        self.grid = Widgets.GridBox()
        self.grid.set_border_width(1)
        self.grid.set_spacing(2)
        vbox.add_widget(self.grid, stretch=1)

        hbox = Widgets.HBox()

        self.timezone_label = Widgets.Label('TimeZone')
        self.county_timezone = Widgets.ComboBox(editable=True)

        # make a giant list of time zones
        zones = [timezone for timezones in pytz.country_timezones.values()
                 for timezone in timezones]
        zones.sort()
        for timezone in zones:
            self.county_timezone.append_text(timezone)

        # also let user set timezone by UTC offset
        self.location_label = Widgets.Label('Location')
        self.location = Widgets.TextEntry()
        self.location.set_tooltip("Type a label to denote this UTC offset")
        #self.location.set_length(10)
github ejeschke / ginga / ginga / examples / gw / shared_canvas.py View on Github external
wclear = Widgets.Button("Clear Canvas")
        wclear.add_callback('activated', lambda w: self.clear_canvas())
        wopen = Widgets.Button("Open File")
        wopen.add_callback('activated', lambda w: self.open_file())
        wquit = Widgets.Button("Quit")
        wquit.add_callback('activated', lambda w: self.quit())

        hbox.add_widget(Widgets.Label(''), stretch=1)
        for w in (wopen, wdrawtype, wdrawcolor, wfill,
                  Widgets.Label('Alpha:'), walpha, wclear, wquit):
            hbox.add_widget(w, stretch=0)

        vbox.add_widget(hbox, stretch=0)

        mode = self.canvas.get_draw_mode()
        hbox = Widgets.HBox()
        btn1 = Widgets.RadioButton("Draw")
        btn1.set_state(mode == 'draw')
        btn1.add_callback('activated', lambda w, val: self.set_mode_cb('draw', val))
        btn1.set_tooltip("Choose this to draw on the canvas")
        hbox.add_widget(btn1)

        btn2 = Widgets.RadioButton("Edit", group=btn1)
        btn2.set_state(mode == 'edit')
        btn2.add_callback('activated', lambda w, val: self.set_mode_cb('edit', val))
        btn2.set_tooltip("Choose this to edit things on the canvas")
        hbox.add_widget(btn2)

        ## btn3 = Widgets.CheckBox("I'm using a trackpad")
        ## btn3.add_callback('activated', lambda w, tf: self.use_trackpad_cb(tf))
        ## hbox.add_widget(btn3)
github crawfordsm / specidentify / specreduce / gingatools.py View on Github external
def __init__(self):
        """Default constructor."""

        #logger = log.get_logger(log_stderr=True, level=20)
        logger = log.get_logger(null=True)
        
        # Initialize base class
        GingaCanvas.__init__(self, logger=logger)

        # Keep track of all patches
        self.patches={}
        #self.zorder=10

        self.get_bindings().enable_all(True)
        self.enable_draw(True)
        self.enable_edit(True)

        self.set_drawtype('line', color='green', cap='ball',
                          linewidth=2)
        #self.add_callback('draw-event', self.draw_cb)
        #self.add_callback('edit-event', self.edit_cb)