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))
w.add_callback('activated', lambda w, val: logger.info("value is %d" % val)) vbox.add_widget(w) elif wname == 'progressbar': w = Widgets.ProgressBar() w.set_value(0.6) vbox.add_widget(w) elif wname == 'statusbar': w = Widgets.StatusBar() w.set_message("Hello, World! is my status") vbox.add_widget(w) elif wname == 'image': w = Widgets.Image() w.load_file(os.path.join(icondir, 'ginga-512x512.png')) vbox.add_widget(w) elif wname == 'treeview': w = Widgets.TreeView(selection='single', sortable=True, use_alt_row_color=True) columns = [("Meal", 'meal'), ("Critic 1", 'review1'), ("Critic 2", 'review2'), ("Critic 3", 'review3')] w.setup_table(columns, 1, 'meal') tree = dict(Breakfast=dict(meal='Breakfast', review1="Delish!", review2="Ugh!", review3="Meh"), Lunch=dict(meal='Lunch',
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")