Пример #1
0
    def build_gui(self, container):

        vbox = Widgets.VBox()

        self.msg_font = self.fv.get_font("fixedFont", 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

        ## sw = Widgets.ScrollArea()
        ## sw.set_widget(self.hist_w)
        ## vbox.add_widget(sw, stretch=1)
        vbox.add_widget(tw, stretch=1)

        vbox.add_widget(Widgets.Label("Type command here:"))
        self.cmd_w = Widgets.TextEntry()
        self.cmd_w.set_font(self.msg_font)
        vbox.add_widget(self.cmd_w, stretch=0)
        self.cmd_w.add_callback('activated', self.exec_cmd_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)
Пример #2
0
    def build_gui(self, container):

        self.w = Bunch.Bunch()
        self.w_track = dict()
        vbox = Widgets.VBox()

        sc = Widgets.ScrollArea()
        vbox2 = Widgets.VBox()
        fr = Widgets.Frame("Downloads")
        self.dlbox = Widgets.VBox()
        fr.set_widget(self.dlbox)
        vbox2.add_widget(fr, stretch=0)
        vbox2.add_widget(Widgets.Label(''), stretch=1)
        sc.set_widget(vbox2)
        vbox.add_widget(sc, stretch=1)
        self.w_scroll = sc

        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("Clear All")
        btn.add_callback('activated', lambda w: self.gui_clear_all())
        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
Пример #3
0
    def build_gui(self, container):
        vbox = Widgets.VBox()
        vbox.set_border_width(1)
        vbox.set_spacing(1)

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

        # create sort toggle
        hbox = Widgets.HBox()
        cb = Widgets.CheckBox("Sortable")
        cb.set_state(self.flg_sort)
        cb.add_callback('activated', lambda w, tf: self.set_sortable_cb(tf))
        hbox.add_widget(cb, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(hbox, 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)
        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
Пример #4
0
    def build_gui(self, container, future=None):
        vbox1 = Widgets.VBox()
        vbox = Widgets.VBox()

        fr = Widgets.Frame()
        fr.set_widget(vbox)

        self.lbl = Widgets.Label()
        vbox.add_widget(self.lbl, stretch=0)

        vbox2 = Widgets.VBox()
        self.entries = vbox2
        vbox.add_widget(vbox2, stretch=1)

        vbox1.add_widget(fr, stretch=0)

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

        btn = Widgets.Button("Ok")
        btn.add_callback('activated', lambda w: self.ok())
        btns.add_widget(btn)
        btn = Widgets.Button("Cancel")
        btn.add_callback('activated', lambda w: self.cancel())
        btns.add_widget(btn)
        vbox1.add_widget(btns, stretch=0)

        # stretch/spacer
        vbox1.add_widget(Widgets.Label(""), stretch=1)

        container.add_widget(vbox1, stretch=0)
Пример #5
0
    def build_axes(self):
        self.selected_axis = None

        if (not self.gui_up) or (self.hbox_axes is None):
            return
        self.hbox_axes.remove_all()
        self.clear_plot()

        image = self.fitsimage.get_image()
        if image is not None:
            # Add Checkbox widgets
            # `image.naxispath` returns only mdim axes
            nx = len(image.naxispath)
            maxi = nx + 2
            for i in range(1, maxi + 1):
                chkbox = Widgets.CheckBox('NAXIS{}'.format(i))
                self.hbox_axes.add_widget(chkbox)

                # Disable axes for 2D images
                if nx <= 0:
                    self.selected_axis = None
                    chkbox.set_enabled(False)
                    continue

                # Add callback
                self.axes_callback_handler(chkbox, i)

            # Add filler
            self.hbox_axes.add_widget(Widgets.Label(''), stretch=1)
        else:
            self.hbox_axes.add_widget(Widgets.Label('No NAXIS info'))
Пример #6
0
    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))
        hbox.add_widget(btn)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(hbox, stretch=0)
        # special hack for Qt
        vbox.cfg_expand(horizontal='minimum')

        self.msg_list.add_widget(vbox, stretch=0)
Пример #7
0
    def build_gui(self, container):
        """
        This method is called when the plugin is invoked.  It builds the
        GUI used by the plugin into the widget layout passed as
        ``container``.
        This method could be called several times if the plugin is opened
        and closed.  The method may be omitted if there is no GUI for the
        plugin.

        This specific example uses the GUI widget set agnostic wrappers
        to build the GUI, but you can also just as easily use explicit
        toolkit calls here if you only want to support one widget set.
        """
        top = Widgets.VBox()
        top.set_border_width(4)

        # this is a little trick for making plugins that work either in
        # a vertical or horizontal orientation.  It returns a box container,
        # a scroll widget and an orientation ('vertical', 'horizontal')
        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        # Take a text widget to show some instructions
        self.msgFont = self.fv.getFont("sansFont", 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msgFont)
        self.tw = tw

        # Frame for instructions and add the text widget with another
        # blank widget to stretch as needed to fill emp
        fr = Widgets.Frame("Status")
        vbox2 = Widgets.VBox()
        vbox2.add_widget(tw)
        vbox2.add_widget(Widgets.Label(''), stretch=1)
        fr.set_widget(vbox2)
        vbox.add_widget(fr, stretch=0)

        # Add a spacer to stretch the rest of the way to the end of the
        # plugin space
        spacer = Widgets.Label('')
        vbox.add_widget(spacer, stretch=1)

        # scroll bars will allow lots of content to be accessed
        top.add_widget(sw, stretch=1)

        # A button box that is always visible at the bottom
        btns = Widgets.HBox()
        btns.set_spacing(3)

        # Add a close button for the convenience of the user
        btn = Widgets.Button("Close")
        btn.add_callback('activated', lambda w: self.close())
        btns.add_widget(btn, stretch=0)
        btns.add_widget(Widgets.Label(''), stretch=1)
        top.add_widget(btns, stretch=0)

        # Add our GUI to the container
        container.add_widget(top, stretch=1)
Пример #8
0
    def __init__(self, logger, app, ev_quit):
        self.logger = logger
        self.app = app
        self.ev_quit = ev_quit

        self.histlimit = 5000
        self._plot_w = None

        self.zv = ZView.ZView(logger, self)

        from ginga.gw import Widgets, GwHelp

        self.top = self.app.make_window('GView')
        self.top.add_callback('close', lambda w: self.quit())

        vbox = Widgets.VBox()
        vbox.set_border_width(2)
        vbox.set_spacing(1)
        self.top.set_widget(vbox)
        self.top.resize(800, 600)

        mbar = Widgets.Menubar()
        vbox.add_widget(mbar, stretch=0)

        filemenu = mbar.add_name("File")
        filemenu.add_separator()

        item = filemenu.add_name("Quit")
        item.add_callback('activated', lambda *args: self.quit())

        nb = Widgets.TabWidget()
        vbox.add_widget(nb, stretch=1)

        sbar = Widgets.StatusBar()
        vbox.add_widget(sbar, stretch=0)

        vbox = Widgets.VBox()
        vbox.set_border_width(2)
        vbox.set_spacing(1)

        vbox.add_widget(Widgets.Label("Type command here:"))
        self.cmd_w = Widgets.TextEntry()
        # TODO: this is not fetching a fixed font
        font = GwHelp.get_font("fixed", 12)
        self.cmd_w.set_font(font)
        vbox.add_widget(self.cmd_w, stretch=0)
        self.cmd_w.add_callback('activated', self.exec_cmd_cb)

        vbox.add_widget(Widgets.Label("Output:"))
        self.hist_w = Widgets.TextArea(wrap=True, editable=True)
        self.hist_w.set_font(font)
        self.hist_w.set_limit(self.histlimit)
        vbox.add_widget(self.hist_w, stretch=1)

        nb.add_widget(vbox, "Command")

        self.top.show()
Пример #9
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)
	self.msg_font = self.fv.get_font("Courier", 12)
        vbox, sw, orientation = Widgets.get_oriented_box(container)
        vbox.set_border_width(4)
        vbox.set_spacing(2)
#Gui        

	fr = Widgets.Frame("Add or Subtract Two Images")
        vbox2 = Widgets.VBox()
        

	captions = (("Path to file 1:", 'label', 'First', 'entry'),
		    ("Path to file 2:", 'label', 'Second', 'entry'),
		    ("Add", 'button', "Subtract", 'button'),
                    )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w = b 
#Function callbacks
	b.first.set_text(str(self.first))
        b.first.add_callback('activated',
                                   lambda w: self.addimg())
        b.second.set_text(str(self.second))
	b.second.add_callback('activated',
                                   lambda w: self.addimg())	
        
	b.add.add_callback('activated',
                                   lambda w: self.addimg())
        b.first.add_callback('activated',
                                   lambda w: self.subimg())
        b.second.add_callback('activated',
                                   lambda w: self.subimg())     
        b.subtract.add_callback('activated',
                                   lambda w: self.subimg())

        vbox2.add_widget(w, stretch=0)

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

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

        top.add_widget(sw, stretch=1)

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

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

        container.add_widget(top, stretch=1)
Пример #10
0
    def build_gui(self, container):
        if not have_samp:
            raise GingaPlugin.PluginError(
                "To run this plugin you need to install the astropy.vo.samp module"
            )

        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)

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

        fr = Widgets.Frame("Instructions")
        fr.set_widget(tw)
        vbox.add_widget(fr, stretch=0)

        fr = Widgets.Frame("SAMP")

        captions = [
            ('Start hub', 'checkbutton'),
            ('Connect client', 'checkbutton'),
        ]
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        b.start_hub.set_tooltip("Start a SAMP hub")
        b.start_hub.set_state(self.settings.get('start_hub', True))
        b.start_hub.add_callback('activated', self.start_hub_cb)
        b.connect_client.set_tooltip("Register with a SAMP hub")
        b.connect_client.set_state(self.settings.get('default_connect', True))
        b.connect_client.add_callback('activated', self.connect_client_cb)

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

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

        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)
Пример #11
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

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

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

        fr = Widgets.Expander("Instructions")
        fr.set_widget(tw)
        vbox.add_widget(fr, stretch=0)

        fr = Widgets.Frame("Blink")

        captions = (("Interval:", 'label', 'Interval', 'entry', "Start Blink",
                     'button', "Stop Blink", 'button'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w = b

        b.interval.set_text(str(self.interval))
        b.interval.add_callback('activated', lambda w: self._set_interval_cb())
        b.interval.set_tooltip("Interval in seconds between changing images")

        b.start_blink.add_callback('activated',
                                   lambda w: self._start_blink_cb())
        b.stop_blink.add_callback('activated', lambda w: self._stop_blink_cb())

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

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

        top.add_widget(sw, stretch=1)

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

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

        container.add_widget(top, stretch=1)
Пример #12
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

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

        self.msg_font = self.fv.get_font("sansFont", 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msg_font)
        self.tw = tw

        fr = Widgets.Expander("Instructions")
        fr.set_widget(tw)
        vbox.add_widget(fr, stretch=0)

        fr = Widgets.Frame("Crosshair")

        captions = (('Format:', 'label', 'Format', 'combobox'),
                    )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w = b

        combobox = b.format
        for name in self.formats:
            combobox.append_text(name)
        index = self.formats.index(self.format)
        combobox.set_index(index)
        combobox.add_callback('activated', lambda w, idx: self.set_format())

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

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

        top.add_widget(sw, stretch=1)

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

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

        container.add_widget(top, stretch=1)
Пример #13
0
    def build_gui(self, container):
        if not Widgets.has_webkit:
            self.browser = Widgets.Label(
                "Please install the python-webkit package to enable "
                "this plugin")
        else:
            self.browser = Widgets.WebView()

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

        container.add_widget(sw, stretch=1)
        sw.show()

        self.entry = Widgets.TextEntrySet()
        container.add_widget(self.entry, stretch=0)
        self.entry.add_callback('activated', lambda w: self.browse_cb())

        tbar = Widgets.Toolbar(orientation='horizontal')
        for tt, cb, ico in (('Go back', lambda w: self.back_cb(),
                             'prev_48.png'),
                            ('Go forward', lambda w: self.forward_cb(),
                             'next_48.png'), ('Reload page',
                                              lambda w: self.reload_cb(),
                                              'rotate_48.png'),
                            ('Stop loading', lambda w: self.stop_cb(),
                             'stop_48.png'), ('Go to top of documentation',
                                              lambda w: self.show_help(),
                                              'fits.png')):
            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
Пример #14
0
    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(self.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")
            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
Пример #15
0
    def activate_plugin_cb(self, pl_mgr, bnch):
        lname = bnch.pInfo.name.lower()
        menu = Widgets.Menu()
        item = menu.add_name("Focus")
        item.add_callback('activated', lambda *args: pl_mgr.set_focus(lname))
        item = menu.add_name("Unfocus")
        item.add_callback('activated', lambda *args: pl_mgr.clear_focus(lname))
        item = menu.add_name("Stop")
        item.add_callback('activated', lambda *args: pl_mgr.deactivate(lname))

        lblname = bnch.lblname
        lbl = Widgets.Label(lblname,
                            halign='center',
                            style='clickable',
                            menu=menu)
        lbl.set_tooltip("Right click for menu")
        # don't let this widget expand to fill the bar
        lbl.cfg_expand(0x0, 0x4)
        self.w.optray.remove(self.spacer)
        self.w.optray.add_widget(lbl, stretch=0)
        self.w.optray.add_widget(self.spacer, stretch=1)

        lbl.add_callback('activated', lambda w: pl_mgr.set_focus(lname))

        bnch.setvals(widget=lbl, label=lbl, menu=menu)
Пример #16
0
        def seq(params, cols, pack):
            def mypack(w):
                w_top = self.app.make_window()
                #w_top.cfg_expand(8, 8)
                # Ask the size of the widget that wants to get packed
                # and resize the top-level to fit
                wd, ht = w.get_size()
                w_top.resize(wd, ht)
                w_top.set_widget(w)
                self.toplevels.append(w_top)
                w_top.show()

            for dct in cols:
                if isinstance(dct, dict):
                    stretch = dct.get('stretch', 0)
                    col = dct.get('col', None)
                else:
                    # assume a list defining the col
                    stretch = 0
                    col = dct
                if col is not None:
                    make(col, mypack)

            widget = Widgets.Label("Placeholder")
            pack(widget)
Пример #17
0
    def build_gui(self, container):
        self.msg_font = self.fv.get_font('fixed', 10)

        vbox = Widgets.VBox()

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

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

        vbox.add_widget(sw, stretch=1)

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

        if self.settings.get('closeable', False):
            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)

        btn = Widgets.Button("Remove All")
        btn.add_callback('activated', lambda w: self.remove_all())
        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
Пример #18
0
    def gui_add_track(self, track):
        vbox = Widgets.VBox()
        fname = Widgets.TextEntry()
        fname.set_text(track.info.url)
        vbox.add_widget(fname, stretch=0)
        hbox = Widgets.HBox()
        hbox.set_spacing(2)
        time_lbl = Widgets.Label(track.elapsed)
        prog_bar = Widgets.ProgressBar()
        prog_bar.set_value(track.progress)
        hbox.add_widget(time_lbl)
        hbox.add_widget(prog_bar)
        rmv = Widgets.Button('Clear')

        def _clear_download(w):
            self.gui_rm_track(track)

        rmv.add_callback('activated', _clear_download)
        hbox.add_widget(rmv)
        vbox.add_widget(hbox, stretch=0)
        self.dlbox.add_widget(vbox)
        w_track = Bunch.Bunch(container=vbox,
                              time_lbl=time_lbl,
                              prog_bar=prog_bar,
                              track=track)
        self.w_track[track.key] = w_track
        self.w_scroll.scroll_to_end(vertical=True)
Пример #19
0
def popup_dialog(parent):
    dia = Widgets.Dialog(title="Dialog Title",
                         buttons=[('ok', 0), ('cancel', 1)],
                         parent=parent, modal=True)
    cntr = dia.get_content_area()
    cntr.add_widget(Widgets.Label("My Dialog Content"))
    dia.show()
Пример #20
0
        def seq(params, cols, pack):
            def mypack(w):
                w_top = self.app.make_window()
                # Ask the size of the widget that wants to get packed
                # and resize the top-level to fit
                wd, ht = w.get_size()
                w_top.resize(wd, ht)
                w_top.set_widget(w)
                self.toplevels.append(w_top)
                w_top.show()
                process_common_params('top', w_top, params)

            res = []
            for dct in cols:
                if isinstance(dct, dict):
                    col = dct.get('col', None)
                else:
                    # assume a list defining the col
                    col = dct
                if col is not None:
                    res.append(make(col, mypack))

            # presumably, the passed-in pack is a no-op, so this
            # should do nothing
            widget = Widgets.Label("Placeholder")
            pack(widget)
            return ['seq', params] + res
Пример #21
0
    def build_gui(self, container):

        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)
        self.vbox = vbox

        tw = Widgets.TextArea(wrap=False, editable=False)
        self.font = self.view.get_font('Courier', 12)
        tw.set_font(self.font)
        self.tw = tw

        vbox.add_widget(self.tw, stretch=1)

        container.add_widget(vbox, stretch=1)

        hbox = Widgets.HBox()
        btn = Widgets.Button('Make OPE')
        hbox.add_widget(btn)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        btn.add_callback('activated', self.make_ope_cb)

        self.vbox.add_widget(hbox, stretch=0)

        self.gui_up = True
Пример #22
0
    def build_gui(self, container):
        self.msg_font = 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)

        self.gui_up = True

        pending = self.pending_errors
        self.pending_errors = []

        for errmsg, ts in pending:
            self.add_error(errmsg, ts=ts)
Пример #23
0
    def build_gui(self, container):

        container.set_margins(2, 2, 2, 2)
        container.set_spacing(4)

        self.tabWidget = Widgets.TabWidget()

        for name in self.tabs:
            modName = self.tabInfo[name]['mod']
            self.mm.load_module(modName)
            module = self.mm.get_module(modName)
            klass = getattr(module, modName)
            self.tabInfo[name]['obj'] = klass(self.controller)

            widget = Widgets.VBox()
            self.tabInfo[name]['obj'].build_gui(widget)
            self.tabInfo[name]['obj'].setProposal(self.proposal)
            self.tabWidget.add_widget(widget, title=name)
            self.tabInfo[name]['obj'].populate_cb(
                self.model, self.tabInfo[name]['inputDataDict'][self.proposal])

        container.add_widget(self.tabWidget)

        # Create a "Close" button so the user can easily close the
        # ProposalTab
        hbox = Widgets.HBox()
        closeTabButton = Widgets.Button('Close %s' % self.proposal)
        closeTabButton.add_callback('activated', self.close_tab_cb)
        closeTabButton.set_tooltip("Close proposal %s tab" % self.proposal)
        hbox.add_widget(closeTabButton)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        container.add_widget(hbox)
Пример #24
0
    def _create_header_window(self, info):
        vbox = Widgets.VBox()
        vbox.set_margins(2, 2, 2, 2)

        color_alternate = self.settings.get('color_alternate_rows', True)
        table = Widgets.TreeView(auto_expand=True,
                                 use_alt_row_color=color_alternate)
        self.table = table
        table.setup_table(self.columns, 1, 'key')

        vbox.add_widget(table, stretch=1)

        # create sort toggle
        cb = Widgets.CheckBox("Sortable")
        cb.add_callback('activated', lambda w, tf: self.set_sortable_cb(info))
        hbox = Widgets.HBox()
        hbox.add_widget(cb, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)
        vbox.add_widget(hbox, stretch=0)

        # toggle sort
        if self.settings.get('sortable', False):
            cb.set_state(True)

        info.setvals(widget=vbox, table=table, sortw=cb)
        return vbox
Пример #25
0
    def start(self, future=None):
        self.callerInfo = future
        # Gather parameters
        p = future.get_data()

        self.lbl.set_text(p.title)

        # Remove previous entries
        self.entries.remove_all()

        p.resDict = {}

        tbl = Widgets.GridBox(rows=len(p.itemlist), columns=2)
        tbl.set_row_spacing(2)
        tbl.set_column_spacing(2)

        row = 0
        for name, val in p.itemlist:
            lbl = Widgets.Label(name)
            #lbl.set_alignment(1.0, 0.5)
            ent = Widgets.TextEntry()
            #ent.set_length(100)
            val_s = str(val)
            ent.set_text(val_s)
            p.resDict[name] = ent

            tbl.add_widget(lbl, 0, row, stretch=0)
            tbl.add_widget(ent, 1, row, stretch=1)
            row += 1

        self.entries.add_widget(tbl, stretch=0)
Пример #26
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

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

        # Take a text widget to show version info
        msgFont = self.fv.getFont('sansFont', 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(msgFont)
        tw.set_text(self.info_string())

        vbox.add_widget(tw, stretch=0)
        top.add_widget(sw, stretch=1)

        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)
        btns.add_widget(Widgets.Label(''), stretch=1)

        top.add_widget(btns, stretch=0)
        container.add_widget(top, stretch=1)
Пример #27
0
    def build_gui(self, container):
        top = Widgets.VBox()
        top.set_border_width(4)

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

        self.msg_font = self.fv.get_font("sansFont", 12)
        tw = Widgets.TextArea(wrap=True, editable=False)
        tw.set_font(self.msg_font)
        self.tw = tw

        fr = Widgets.Expander("Instructions")
        fr.set_widget(tw)
        vbox.add_widget(fr, stretch=0)

        fr = Widgets.Frame("WCS Match")

        captions = ((' Reference Channel:', 'label', 'ref channel',
                     'combobox'), )
        w, b = Widgets.build_info(captions, orientation=orientation)
        self.w = b

        b.ref_channel.add_callback('activated', self.set_reference_channel_cb)

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

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

        top.add_widget(sw, stretch=1)

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

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

        container.add_widget(top, stretch=1)

        self.gui_up = True
        self._reset_channels_gui()
Пример #28
0
    def insert_thumbnail(self, imgwin, thumbkey, thumbname, chname, name, path,
                         thumbpath, metadata, image_future):

        # make a context menu
        menu = self._mk_context_menu(thumbkey, chname, name, path,
                                     image_future)

        thumbw = Widgets.Image(native_image=imgwin,
                               menu=menu,
                               style='clickable')
        wd, ht = self.thumb_generator.get_window_size()
        thumbw.resize(wd, ht)

        # set the load callback
        thumbw.add_callback(
            'activated', lambda w: self.load_file(thumbkey, chname, name, path,
                                                  image_future))

        # make a tool tip
        text = self.query_thumb(thumbkey, name, metadata)
        thumbw.set_tooltip(text)

        vbox = Widgets.VBox()
        vbox.set_margins(0, 0, 0, 0)
        vbox.set_spacing(0)
        namelbl = Widgets.Label(text=thumbname, halign='left')
        vbox.add_widget(namelbl, stretch=0)
        vbox.add_widget(thumbw, stretch=0)
        # special hack for Qt widgets
        vbox.cfg_expand(0, 0)

        bnch = Bunch.Bunch(widget=vbox,
                           image=thumbw,
                           name=name,
                           imname=name,
                           namelbl=namelbl,
                           chname=chname,
                           path=path,
                           thumbpath=thumbpath,
                           image_future=image_future)

        with self.thmblock:
            self.thumbDict[thumbkey] = bnch
            self.thumbList.append(thumbkey)

            sort_order = self.settings.get('sort_order', None)
            if sort_order:
                self.thumbList.sort()
                self.reorder_thumbs()
                return

            self.w.thumbs.add_widget(vbox, self.thumbRowCount,
                                     self.thumbColCount)
            self.thumbColCount = (self.thumbColCount + 1) % self.thumbNumCols
            if self.thumbColCount == 0:
                self.thumbRowCount += 1

        self._auto_scroll()
        self.logger.debug("added thumb for %s" % (name))
Пример #29
0
    def build_gui(self, container):
        if not have_samp:
            raise GingaPlugin.PluginError(
                "To run this plugin you need to install the "
                "astropy package")

        vbox = Widgets.VBox()
        vbox.set_border_width(4)
        vbox.set_spacing(2)

        fr = Widgets.Frame("SAMP")

        captions = [
            ('Start hub', 'checkbutton'),
            ('Connect client', 'checkbutton'),
        ]
        w, b = Widgets.build_info(captions)
        self.w.update(b)
        b.start_hub.set_tooltip("Start a SAMP hub")
        b.start_hub.set_state(self.settings.get('start_hub', True))
        b.start_hub.add_callback('activated', self.start_hub_cb)
        b.connect_client.set_tooltip("Register with a SAMP hub")
        b.connect_client.set_state(self.settings.get('default_connect', True))
        b.connect_client.add_callback('activated', self.connect_client_cb)

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

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

        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
Пример #30
0
    def ask_action_images(self, action):

        images = self.get_selected()
        if len(images) == 0:
            self.fv.show_error("Please select some images first")
            return

        l_img = list(map(lambda tup: "%s/%s" % (tup[0], tup[1].imname),
                         images))

        verb = action.capitalize()
        l_img.insert(0, "%s images\n" % (verb))

        # build dialog
        dialog = Widgets.Dialog(title="%s Images" % (verb),
                                flags=0,
                                buttons=[['Cancel', 0], ['Ok', 1]],
                                parent=self.treeview)
        box = dialog.get_content_area()
        box.set_border_width(6)
        if len(l_img) < 12:
            text = Widgets.Label("\n".join(l_img))
        else:
            text = Widgets.TextArea(wrap=None)
            text.set_text("\n".join(l_img))
        box.add_widget(text, stretch=1)

        if action != 'remove':
            hbox = Widgets.HBox()
            hbox.add_widget(Widgets.Label("To channel: "))
            chnl = Widgets.ComboBox()
            for chname in self.chnames:
                chnl.append_text(chname)
            hbox.add_widget(chnl)
            hbox.add_widget(Widgets.Label(''), stretch=1)
            box.add_widget(hbox)
        else:
            chnl = None

        dialog.add_callback('activated',
                            lambda w, rsp: self.action_images_cb(w, rsp,
                                                                 chnl,
                                                                 images,
                                                                 action))

        self.fv.ds.show_dialog(dialog)