How to use the ginga.gw.Widgets function in ginga

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 / Info.py View on Github external
def build_gui(self, container):
        vbox = Widgets.VBox()
        vbox.set_border_width(2)
        vbox.set_spacing(2)

        nb = Widgets.StackWidget()
        self.nb = nb
        vbox.add_widget(nb, stretch=1)

        if self.settings.get('closeable', False):
            btns = Widgets.HBox()
            btns.set_border_width(4)
            btns.set_spacing(4)

            btn = Widgets.Button("Close")
            btn.add_callback('activated', lambda w: self.close())
            btns.add_widget(btn)
            btn = Widgets.Button("Help")
github ejeschke / ginga / experimental / plugins / Imexam.py View on Github external
def make_new_figure(self):
        chname = self.fv.get_channel_name(self.fitsimage)

        wd, ht = 400, 300
        self._plot_idx += 1
        self._plot = plots.Plot(logger=self.logger,
                                width=wd, height=ht)

        name = "%s: Fig %d" % (chname, self._plot_idx)
        group = 10

        pw = Plot.PlotWidget(self._plot)

        vbox = Widgets.VBox()
        vbox.add_widget(pw, stretch=1)
        hbox = Widgets.HBox()
        hbox.add_widget(Widgets.Label(''), stretch=1)
        btn = Widgets.Button('Close Plot')
        btn.add_callback('activated', lambda w: self.close_plot(name, vbox))
        hbox.add_widget(btn, stretch=0)
        vbox.add_widget(hbox, stretch=0)

        # vbox.resize(wd, ht)
        self._plot_w = vbox

        if self._plots_in_ws:
            ws = self.fv.get_current_workspace()
            tab = self.fv.ds.add_tab(ws.name, vbox, group, name, name,
                                     data=dict(plot=self._plot))
        else:
github ejeschke / ginga / ginga / rv / plugins / Errors.py View on Github external
def add_error(self, errmsg, ts=None):
        if ts is None:
            # Add the time the error occurred
            ts = time.strftime("%m/%d %H:%M:%S", time.localtime())

        if not self.gui_up:
            self.pending_errors.append((errmsg, ts))
            return

        vbox = Widgets.VBox()

        hbox = Widgets.HBox()
        # Add the time the error occurred
        ts = time.strftime("%m/%d %H:%M:%S", time.localtime())
        lbl = Widgets.Label(ts, halign='left')
        hbox.add_widget(lbl, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(hbox, stretch=0)

        tw = Widgets.TextArea(editable=False, wrap=False)
        tw.set_font(self.msg_font)

        tw.set_text(errmsg)
        vbox.add_widget(tw, stretch=1)

        hbox = Widgets.HBox()
        btn = Widgets.Button("Remove")
        btn.add_callback('activated', lambda w: self.remove_error(vbox))
github ejeschke / ginga / ginga / rv / plugins / MultiDim.py View on Github external
key = 'naxis%d' % (n + 1)
            title = key.upper()
            maxn = int(dims[n])
            self.logger.debug("NAXIS%d=%d" % (n + 1, maxn))
            if maxn <= 1:
                captions.append((title + ':', 'label', title, 'llabel'))
            else:
                captions.append((title + ':', 'label', title, 'llabel',
                                 "Choose %s" % (title), 'hscale'))

        # Remove old naxis widgets
        for key in self.w:
            if key.startswith('choose_'):
                self.w[key] = None

        hbox = Widgets.HBox()

        if ndims > 3:  # only add radiobuttons if we have more than 3 dim
            group = None
            for i in range(2, ndims):
                title = 'AXIS%d' % (i + 1)
                btn = Widgets.RadioButton(title, group=group)
                if group is None:
                    group = btn
                hbox.add_widget(btn)
                self.w[title.lower()] = btn

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

        vbox = Widgets.VBox()
        vbox.add_widget(w)
github ejeschke / ginga / ginga / rv / plugins / Catalogs.py View on Github external
index = 0
        for name, fn in self.operation_table:
            options.append(name)
            combobox.append_text(name)
            index += 1
        combobox.set_index(0)
        self.btn['oprn'] = combobox
        btns.add_widget(combobox, stretch=0)

        btn = Widgets.Button("Do it")
        btn.add_callback('activated', self.do_operation_cb, combobox)
        btns.add_widget(btn, stretch=0)

        vbox.add_widget(btns, stretch=0)

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

        for name in ('Plot', 'Clear'):  # 'Close'
            btn = Widgets.Button(name)
            btns.add_widget(btn, stretch=0)
            self.btn[name.lower()] = btn

        self.btn.plot.add_callback('activated',
                                   lambda w: self.replot_stars())
        self.btn.clear.add_callback('activated',
                                    lambda w: self.clear())
        #self.btn.close.add_callback('activated',
        #                            lambda w: self.close())

        combobox = Widgets.ComboBox()
        options = []
github ejeschke / ginga / ginga / rv / plugins / Header.py View on Github external
cb.set_state(self.flg_prihdr)
        cb.add_callback('activated', lambda w, tf: self.set_prihdr_cb(tf))
        self.w.chk_prihdr = cb
        hbox.add_widget(cb, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(hbox, stretch=0)

        if self.settings.get('closeable', False):
            btns = Widgets.HBox()
            btns.set_border_width(4)
            btns.set_spacing(4)

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

        container.add_widget(vbox, stretch=1)
        self.gui_up = True
github ejeschke / ginga / ginga / examples / gw / shared_canvas.py View on Github external
def open_file(self):
        from ginga.gw import Widgets

        res = Widgets.FileDialog.getOpenFileName(self, "Open FITS file",
                                                 ".", "FITS files (*.fits)")
        if isinstance(res, tuple):
            fileName = res[0]
        else:
            fileName = str(res)
        if len(fileName) != 0:
            self.load_file(self.viewer1, fileName)
github ejeschke / ginga / ginga / rv / plugins / WBrowser.py View on Github external
btn = tbar.add_action(
                None, iconpath=os.path.join(self.fv.iconpath, ico))
            btn.add_callback('activated', cb)
            btn.set_tooltip(tt)
        container.add_widget(tbar, stretch=0)

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

        self.gui_up = True
github ejeschke / ginga / ginga / gw / Desktop.py View on Github external
def dialog(params, rows, pack):
            if len(self.toplevels) == 0:
                raise ValueError("Need a top-level window to parent a dialog")

            # any old top-level will do, for now...
            top_w = self.toplevels[0]
            widget = Widgets.Dialog(parent=top_w)
            container = widget.get_content_area()

            res = []
            for dct in rows:
                if isinstance(dct, dict):
                    stretch = dct.get('stretch', 1)
                    row = dct.get('row', None)
                else:
                    # assume a list defining the row
                    stretch = 1
                    row = dct
                if row is not None:
                    r = make(row,
                             lambda w: container.add_widget(w,
                                                            stretch=stretch))
                    r = dict(row=r, stretch=stretch)