Ejemplo n.º 1
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()
Ejemplo n.º 2
0
Archivo: View.py Proyecto: akirav/qplan
    def add_menus(self, holder):
        menubar = Widgets.Menubar()
        self.menubar = menubar

        holder.add_widget(menubar, stretch=1)

        # create a File pulldown menu, and add it to the menu bar
        filemenu = menubar.add_name("File")
        filemenu.add_separator()

        item = filemenu.add_name("Quit")
        item.add_callback('activated', lambda w: self.quit())
Ejemplo n.º 3
0
    def add_menus(self, holder):

        menubar = Widgets.Menubar()
        self.menubar = menubar

        # NOTE: Special hack for Mac OS X. From the Qt documentation:
        # "If you want all windows in a Mac application to share one
        #  menu bar, you must create a menu bar that does not have a
        #  parent."
        macos_ver = platform.mac_ver()[0]
        if len(macos_ver) > 0:
            pass
        else:
            holder.add_widget(menubar, stretch=1)

        # create a File pulldown menu, and add it to the menu bar
        filemenu = menubar.add_name("File")

        item = filemenu.add_name("Load Image")
        item.add_callback('activated', lambda *args: self.gui_load_file())

        item = filemenu.add_name("Remove Image")
        item.add_callback("activated",
                          lambda *args: self.remove_current_image())

        filemenu.add_separator()

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

        # create a Channel pulldown menu, and add it to the menu bar
        chmenu = menubar.add_name("Channel")

        item = chmenu.add_name("Add Channel")
        item.add_callback('activated', lambda *args: self.gui_add_channel())

        item = chmenu.add_name("Add Channels")
        item.add_callback('activated', lambda *args: self.gui_add_channels())

        item = chmenu.add_name("Delete Channel")
        item.add_callback('activated', lambda *args: self.gui_delete_channel())

        # create a Window pulldown menu, and add it to the menu bar
        wsmenu = menubar.add_name("Workspace")

        item = wsmenu.add_name("Add Workspace")
        item.add_callback('activated', lambda *args: self.gui_add_ws())

        # TODO: Make this an individual workspace menu in Desktop
        if self.ds.has_ws('channels'):
            mnb = self.ds.get_nb('channels')

            ## item = wsmenu.add_name("Take Tab")
            ## item.add_callback('activated',
            ##                   lambda *args: self.ds.take_tab_cb(mnb, args))

            if isinstance(mnb, Widgets.MDIWidget) and mnb.true_mdi:
                mnb.set_mode('tabs')

                item = wsmenu.add_name("Panes as Tabs", checkable=True)
                item.add_callback('activated',
                                  lambda w, tf: self.tabstoggle_cb(mnb, tf))
                is_tabs = (mnb.get_mode() == 'tabs')
                item.set_state(is_tabs)

                item = wsmenu.add_name("Tile Panes")
                item.add_callback('activated',
                                  lambda *args: self.tile_panes_cb(mnb))

                item = wsmenu.add_name("Cascade Panes")
                item.add_callback('activated',
                                  lambda *args: self.cascade_panes_cb(mnb))

        # # create a Option pulldown menu, and add it to the menu bar
        # optionmenu = menubar.add_name("Option")

        # create a Plugins pulldown menu, and add it to the menu bar
        plugmenu = menubar.add_name("Plugins")
        self.w.menu_plug = plugmenu

        # create a Help pulldown menu, and add it to the menu bar
        helpmenu = menubar.add_name("Help")

        item = helpmenu.add_name("About")
        item.add_callback('activated',
                          lambda *args: self.banner(raiseTab=True))

        item = helpmenu.add_name("Documentation")
        item.add_callback('activated', lambda *args: self.help())

        return menubar
Ejemplo n.º 4
0
    def __init__(self, logger, settings, options):
        self.logger = logger
        self.options = options
        self.settings = settings

        colors = [
            'lightgreen', 'orange', 'cyan', 'pink', 'slateblue', 'yellow',
            'maroon', 'brown'
        ]
        self.color_index = 0

        cols = 3
        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)

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

        self.top.set_widget(menubar)

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

        hbox = Widgets.HBox()

        self.timezone_label = Widgets.Label('TimeZone')
        self.county_timezone = Widgets.ComboBox()
        self.county_timezone.widget.setEditable(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)
        self.time_offset.set_decimals(2)
        self.time_offset.set_limits(-12, 12)
        self.time_offset.set_tooltip("Time offset from UTC")
        self.timezone_button = Widgets.Button('Add by Timezone')
        self.offset_button = Widgets.Button('Add by Offset')

        self.timezone_button.widget.clicked.connect(
            self.more_clock_by_timezone)
        self.offset_button.widget.clicked.connect(self.more_clock_by_offset)

        hbox.add_widget(self.timezone_label, stretch=0)
        hbox.add_widget(self.county_timezone, stretch=0)
        hbox.add_widget(self.timezone_button, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        hbox.add_widget(self.location_label, stretch=0)
        hbox.add_widget(self.location, stretch=0)

        hbox.add_widget(self.timeoffset_label, stretch=0)
        hbox.add_widget(self.time_offset, stretch=0)
        hbox.add_widget(self.offset_button, stretch=0)
        hbox.add_widget(Widgets.Label(''), stretch=1)

        self.top.set_widget(hbox)

        self.clocks = {}
        self.timer = GwHelp.Timer(1.0)
        self.timer.add_callback('expired', self.timer_cb)
        self.timer.start(1.0)
Ejemplo n.º 5
0
elif wname == 'mdiwidget':
    w = Widgets.MDIWidget()
    w.add_widget(Widgets.Label('Content of MDI Area 1'))
    w.add_widget(Widgets.Label('Content of MDI Area 2'))
    vbox.add_widget(w, stretch=1)

elif wname == 'gridbox':
    w = Widgets.GridBox(rows=2, columns=2)
    w.add_widget(Widgets.Label('Content of Grid Area 1'), 0, 0)
    w.add_widget(Widgets.Label('Content of Grid Area 2'), 0, 1)
    w.add_widget(Widgets.Label('Content of Grid Area 3'), 1, 0)
    w.add_widget(Widgets.Label('Content of Grid Area 4'), 1, 1)
    vbox.add_widget(w, stretch=1)

elif wname == 'menubar':
    w = Widgets.Menubar()
    menu = w.add_name('Menu 1')
    menu.add_name('Larry').add_callback('activated',
                                        lambda *args: print("chose Larry"))
    menu.add_name('Curly').add_callback(
        'activated', lambda *args: logger.info("chose Curly"))
    menu.add_name('Moe').add_callback('activated',
                                      lambda *args: logger.info("chose Moe"))
    vbox.add_widget(w)
    vbox.add_widget(Widgets.Label("App content"), stretch=1)

elif wname == 'toolbar':
    w = Widgets.Toolbar()
    menu = w.add_menu('Menu Type 1', mtype='tool')
    menu.add_name('Larry').add_callback('activated',
                                        lambda w: logger.info("chose Larry"))
Ejemplo n.º 6
0
    def add_menus(self, holder):

        menubar = Widgets.Menubar()
        self.menubar = menubar

        # NOTE: Special hack for Mac OS X. From the Qt documentation:
        # "If you want all windows in a Mac application to share one
        #  menu bar, you must create a menu bar that does not have a
        #  parent."
        macos_ver = platform.mac_ver()[0]
        if len(macos_ver) > 0:
            pass
        else:
            holder.add_widget(menubar, stretch=1)

        # create a File pulldown menu, and add it to the menu bar
        filemenu = menubar.add_name("File")

        item = filemenu.add_name("Load Image")
        item.add_callback('activated', lambda *args: self.gui_load_file())

        item = filemenu.add_name("Remove Image")
        item.add_callback("activated",
                          lambda *args: self.remove_current_image())

        filemenu.add_separator()

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

        # create a Channel pulldown menu, and add it to the menu bar
        chmenu = menubar.add_name("Channel")

        item = chmenu.add_name("Add Channel")
        item.add_callback('activated', lambda *args: self.gui_add_channel())

        item = chmenu.add_name("Add Channels")
        item.add_callback('activated', lambda *args: self.gui_add_channels())

        item = chmenu.add_name("Delete Channel")
        item.add_callback('activated', lambda *args: self.gui_delete_channel())

        # create a Window pulldown menu, and add it to the menu bar
        wsmenu = menubar.add_name("Workspace")

        item = wsmenu.add_name("Add Workspace")
        item.add_callback('activated', lambda *args: self.gui_add_ws())

        # # create a Option pulldown menu, and add it to the menu bar
        # optionmenu = menubar.add_name("Option")

        # create a Plugins pulldown menu, and add it to the menu bar
        plugmenu = menubar.add_name("Plugins")
        self.w.menu_plug = plugmenu

        # create a Help pulldown menu, and add it to the menu bar
        helpmenu = menubar.add_name("Help")

        item = helpmenu.add_name("About")
        item.add_callback('activated',
                          lambda *args: self.banner(raiseTab=True))

        item = helpmenu.add_name("Documentation")
        item.add_callback('activated', lambda *args: self.help())

        return menubar
Ejemplo n.º 7
0
    def setup_ui(self):

        self.logger.debug("setting up ana menu gui")
        vbox = Widgets.VBox()

        menubar = Widgets.Menubar()
        menu = menubar.add_name('File')
        menu.add_separator()
        item = menu.add_name('Quit')
        item.add_callback('activated', lambda w: self.quit())
        vbox.add_widget(menubar, stretch=0)

        hbox = Widgets.HBox()
        hbox.set_spacing(2)
        icn = Widgets.Image()
        icn.load_file(os.path.join(icondir, 'sumo.png'))
        hbox.add_widget(icn, stretch=0)

        lbl = Widgets.Label("ANA " + self.title_suffix)
        lbl.set_font('sans', 24)
        hbox.add_widget(lbl, stretch=1)
        vbox.add_widget(hbox, stretch=0)
        self.w.title = lbl

        tb0 = Widgets.Toolbar(orientation='horizontal')
        fr = Widgets.Frame('PropID:')
        fr.set_widget(tb0)
        entry = Widgets.TextEntry()
        self.w.propid = entry
        if self.propid is not None:
            entry.set_text(self.propid)
        tb0.add_widget(entry)
        a = tb0.add_action('Set')
        a.add_callback('activated', self.set_propid_cb)
        vbox.add_widget(fr)

        # buttons for Gen2 application
        tb1 = Widgets.Toolbar(orientation='horizontal')
        fr = Widgets.Frame('Viewers:')
        fr.set_widget(tb1)
        vbox.add_widget(fr)

        tb2 = Widgets.Toolbar(orientation='horizontal')
        fr = Widgets.Frame('Instrument:')
        fr.set_widget(tb2)
        vbox.add_widget(fr)

        tb3 = Widgets.Toolbar(orientation='horizontal')
        fr = Widgets.Frame('Etc:')
        fr.set_widget(tb3)
        vbox.add_widget(fr)

        status = Widgets.StatusBar()
        vbox.add_widget(status)
        self.w.msgbar = status

        # Add some buttons to the tool bars.
        a = tb1.add_action('Ginga',
                           toggle=False,
                           iconpath=os.path.join(icondir, 'view-file.png'),
                           iconsize=(24, 24))
        a.add_callback('activated', lambda w: self.launch_fits_viewer())
        a.set_tooltip("Start ginga FITS viewer")
        a = tb1.add_action('Ds9',
                           toggle=False,
                           iconpath=os.path.join(icondir, 'view-file.png'),
                           iconsize=(24, 24))
        a.add_callback('activated', lambda w: self.launch_ds9())
        a.set_tooltip("Start ds9 FITS viewer")

        for name, action in self.action_list:
            a = tb2.add_action(name,
                               toggle=False,
                               iconpath=os.path.join(icondir, 'camera.png'),
                               iconsize=(24, 24))
            a.add_callback('activated', action)
            a.set_tooltip("Start data analysis package for %s" % (name))

        a = tb3.add_action('Terminal',
                           toggle=False,
                           iconpath=os.path.join(icondir, 'terminal.png'),
                           iconsize=(24, 24))
        a.add_callback('activated', lambda w: self.launch_terminal())
        a.set_tooltip("Start a terminal on analysis server")
        a = tb3.add_action('StatMon',
                           toggle=False,
                           iconpath=os.path.join(icondir, 'statmon.png'),
                           iconsize=(28, 24))
        a.add_callback('activated', lambda w: self.launch_statmon())
        a.set_tooltip("Start Gen2 status monitor")

        self.w.root.set_widget(vbox)
        self.w.root.add_callback('close', lambda w: self.quit())

        self.__init_propid_entry()
        #self.__set_propfile()
        self.logger.debug("ana menu gui done")