def build_gui(self, container): hbox = Widgets.HBox() hbox.set_border_width(0) hbox.set_spacing(2) cbox1 = Widgets.ComboBox() self.w.channel = cbox1 cbox1.set_tooltip("Select a channel") cbox1.add_callback('activated', self.channel_select_cb) if self.settings.get('show_channel_control', True): hbox.add_widget(cbox1, stretch=0) self.use_popup = self.settings.get('use_popup_menu', True) if self.use_popup: opmenu = Widgets.Menu() btn = Widgets.Button("Operation") else: opmenu = Widgets.ComboBox() opmenu.set_tooltip("Select an operation") hbox.add_widget(opmenu, stretch=0) btn = Widgets.Button("Go") self.w.operation = opmenu btn.add_callback('activated', self.invoke_op_cb) btn.set_tooltip("Invoke operation") self.w.opbtn = btn hbox.add_widget(btn, stretch=0) self.w.optray = Widgets.HBox() self.w.optray.set_border_width(0) self.w.optray.set_spacing(2) hbox.add_widget(self.w.optray, stretch=1) container.add_widget(hbox, stretch=0)
def __init__(self, name, wstype='tab', group=0, detachable=False, use_toolbar=False): super(Workspace, self).__init__() self.name = name self.wstype = wstype self.wstypes = ['tabs', 'mdi', 'stack', 'grid'] self.vbox = Widgets.VBox() self.vbox.set_spacing(0) self.vbox.set_border_width(0) # for now self.widget = self.vbox self.nb = None self.group = group self.detachable = detachable self.toolbar = None self.mdi_menu = None self.wstypes_c = ['Tabs', 'Grid', 'MDI', 'Stack'] self.wstypes_l = ['tabs', 'grid', 'mdi', 'stack'] self.extdata = Bunch.Bunch() if use_toolbar: self.toolbar = Widgets.Toolbar(orientation='horizontal') self.toolbar.set_border_width(0) self.vbox.add_widget(self.toolbar, stretch=0) ws_menu = self.toolbar.add_menu("Workspace") item = ws_menu.add_name("Close") item.add_callback('activated', self._close_menuitem_cb) self._set_wstype(wstype) self.vbox.add_widget(self.nb, stretch=1) if use_toolbar: cbox = Widgets.ComboBox() for _wstype in self.wstypes_c: cbox.append_text(_wstype) idx = self.wstypes_l.index(wstype) cbox.set_index(idx) cbox.add_callback('activated', self.config_wstype_cb) cbox.set_tooltip("Set workspace type") self.toolbar.add_widget(cbox) mdi_menu = self.toolbar.add_menu("MDI") item = mdi_menu.add_name("Tile Panes") item.add_callback('activated', lambda *args: self.tile_panes_cb()) item = mdi_menu.add_name("Cascade Panes") item.add_callback('activated', lambda *args: self.cascade_panes_cb()) self.mdi_menu = mdi_menu self._update_mdi_menu() for name in ('page-switch', 'page-detach', 'page-close', 'page-removed', 'page-added', 'ws-close'): self.enable_callback(name)
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)
def build_gui(self, container): hbox = Widgets.HBox() hbox.set_border_width(0) hbox.set_spacing(2) cbox1 = Widgets.ComboBox() self.w.channel = cbox1 cbox1.set_tooltip("Select a channel") cbox1.add_callback('activated', self.channel_select_cb) if self.settings.get('show_channel_control', True): hbox.add_widget(cbox1, stretch=0) self.use_popup = self.settings.get('use_popup_menu', True) opmenu = Widgets.Menu() btn = Widgets.Button("Operation") btn.set_tooltip("Invoke operation") btn.add_callback('activated', self.invoke_popup_cb) if not self.use_popup: hbox.add_widget(btn, stretch=0) self.w.opname = Widgets.Label('') hbox.add_widget(self.w.opname, stretch=0) btn = Widgets.Button("Go") btn.add_callback('activated', self.invoke_op_cb) self.w.operation = opmenu self.w.opbtn = btn hbox.add_widget(btn, stretch=0) self.w.optray = Widgets.HBox() self.w.optray.set_border_width(0) self.w.optray.set_spacing(2) # add a spacer to keep the icons aligned to the left self.spacer = Widgets.Label('') self.w.optray.add_widget(self.spacer, stretch=1) hbox.add_widget(self.w.optray, stretch=1) container.add_widget(hbox, stretch=0) self.gui_up = True
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() from ginga.gw import Widgets, Viewers, GwHelp self.app = Widgets.Application(logger=logger) self.app.add_callback('shutdown', self.quit) self.top = self.app.make_window("Ginga example2") self.top.add_callback('close', self.closed) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) fi = Viewers.CanvasView(logger=logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_zoom_algorithm('rate') fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback('drag-drop', self.drop_file) fi.set_callback('none-move', self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # add a color bar fi.private_canvas.add(self.dc.ColorBar(side='bottom', offset=10)) # add little mode indicator that shows modal states in # lower left hand corner fi.private_canvas.add(self.dc.ModeIndicator(corner='ur', fontsize=14)) # little hack necessary to get correct operation of the mode indicator # in all circumstances bm = fi.get_bindmap() bm.add_callback('mode-set', lambda *args: fi.redraw(whence=3)) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.enable_edit(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.setSurface(fi) self.canvas = canvas # add canvas to view fi.get_canvas().add(canvas) canvas.ui_setActive(True) canvas.register_for_cursor_drawing(fi) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() fi.set_desired_size(512, 512) iw = Viewers.GingaViewerWidget(viewer=fi) vbox.add_widget(iw, stretch=1) self.readout = Widgets.Label("") vbox.add_widget(self.readout, stretch=0) hbox = Widgets.HBox() hbox.set_border_width(2) wdrawtype = Widgets.ComboBox() for name in self.drawtypes: wdrawtype.append_text(name) index = self.drawtypes.index('rectangle') wdrawtype.set_index(index) wdrawtype.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawtype = wdrawtype wdrawcolor = Widgets.ComboBox() for name in self.drawcolors: wdrawcolor.append_text(name) index = self.drawcolors.index('lightblue') wdrawcolor.set_index(index) wdrawcolor.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawcolor = wdrawcolor wfill = Widgets.CheckBox("Fill") wfill.add_callback('activated', lambda w, tf: self.set_drawparams()) self.wfill = wfill walpha = Widgets.SpinBox(dtype=float) walpha.set_limits(0.0, 1.0, incr_value=0.1) walpha.set_value(1.0) walpha.set_decimals(2) walpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) self.walpha = walpha 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) hbox.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(hbox, stretch=0) self.top.set_widget(vbox) self.fs = None if hasattr(GwHelp, 'FileSelection'): self.fs = GwHelp.FileSelection(self.top.get_widget())
def _build_gui(self, container): self.mframe = container vbox = Widgets.VBox() # create the table table = Widgets.TreeView(selection='single', sortable=True, use_alt_row_color=False) self.table = table table.add_callback('selected', self.select_star_cb) vbox.add_widget(table, stretch=1) self.cbar = ColorBar.ColorBar(self.logger) self.cbar.set_cmap(self.cmap) self.cbar.set_imap(self.imap) rgbmap = self.cbar.get_rgbmap() rgbmap.add_callback('changed', lambda *args: self.replot_stars()) cbar_w = self.cbar.get_widget() vbox.add_widget(cbar_w, stretch=0) btns = Widgets.HBox() btns.set_spacing(5) combobox = Widgets.ComboBox() options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.append_text(name) index += 1 cmap_name = self.magcmap try: index = self.cmap_names.index(cmap_name) except Exception: index = self.cmap_names.index('gray') combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_cmap_cb(idx)) self.btn['cmap'] = combobox btns.add_widget(combobox, stretch=0) combobox = Widgets.ComboBox() options = [] index = 0 for name in self.imap_names: options.append(name) combobox.append_text(name) index += 1 imap_name = self.magimap try: index = self.imap_names.index(imap_name) except Exception: index = self.imap_names.index('ramp') combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_imap_cb(idx)) self.btn['imap'] = combobox btns.add_widget(combobox, stretch=0) combobox = Widgets.ComboBox() options = [] index = 0 for name, fn in self.operation_table: options.append(name) combobox.append_text(name) index += 1 combobox.set_index(0) combobox.add_callback('activated', lambda w, idx: self.do_operation_cb(idx)) self.btn['oprn'] = combobox btns.add_widget(combobox, stretch=0) btn = Widgets.Button("Do it") 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 = [] index = 0 for name in ['Mag']: options.append(name) combobox.append_text(name) index += 1 combobox.set_index(0) combobox.add_callback('activated', lambda w, idx: self.set_field_cb(idx)) self.btn['field'] = combobox btns.add_widget(combobox, stretch=0) vbox.add_widget(btns, stretch=0) # create the table info = Bunch.Bunch(columns=self.columns, color='Mag') self.build_table(info) self.mframe.add_widget(vbox, stretch=1)
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)
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() from ginga.gw import Widgets, Viewers self.app = Widgets.Application(logger=logger) #self.app.add_callback('shutdown', self.quit) self.top = self.app.make_window("Ginga example2") self.top.add_callback('close', self.closed) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) hbox = Widgets.HBox() hbox.set_border_width(2) hbox.set_spacing(4) v1 = Viewers.CanvasView(logger) v1.enable_autocuts('on') v1.set_autocut_params('zscale') v1.enable_autozoom('on') v1.set_zoom_algorithm('rate') v1.set_zoomrate(1.4) v1.show_pan_mark(True) v1.set_callback('drag-drop', self.drop_file) v1.set_callback('none-move', self.motion) v1.set_bg(0.2, 0.2, 0.2) v1.ui_setActive(True) v1.set_name('tweedledee') self.viewer1 = v1 self._mi1 = ModeIndicator(v1) bd = v1.get_bindings() bd.enable_all(True) # shared canvas between the two viewers canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.enable_edit(True) canvas.set_drawtype('rectangle', color='lightblue') self.canvas = canvas # Tell viewer1 to use this canvas v1.set_canvas(canvas) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() v1.set_desired_size(300, 300) iw = Viewers.GingaViewerWidget(viewer=v1) hbox.add_widget(iw, stretch=1) # Add a second viewer viewing the same canvas v2 = Viewers.CanvasView(logger) v2.enable_autocuts('on') v2.set_autocut_params('zscale') v2.enable_autozoom('on') v2.set_zoom_algorithm('rate') v2.set_zoomrate(1.4) v2.show_pan_mark(True) v2.set_callback('drag-drop', self.drop_file) v2.set_callback('none-move', self.motion) v2.set_bg(0.2, 0.2, 0.2) v2.ui_setActive(True) v1.set_name('tweedledum') self.viewer2 = v2 self._mi2 = ModeIndicator(v2) # Tell viewer2 to use this same canvas v2.set_canvas(canvas) bd = v2.get_bindings() bd.enable_all(True) v2.set_desired_size(300, 300) iw = Viewers.GingaViewerWidget(viewer=v2) hbox.add_widget(iw, stretch=1) vbox.add_widget(hbox, stretch=1) self.readout = Widgets.Label("") vbox.add_widget(self.readout, stretch=0) hbox = Widgets.HBox() hbox.set_border_width(2) wdrawtype = Widgets.ComboBox() for name in self.drawtypes: wdrawtype.append_text(name) index = self.drawtypes.index('rectangle') wdrawtype.set_index(index) wdrawtype.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawtype = wdrawtype wdrawcolor = Widgets.ComboBox() for name in self.drawcolors: wdrawcolor.append_text(name) index = self.drawcolors.index('lightblue') wdrawcolor.set_index(index) wdrawcolor.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawcolor = wdrawcolor wfill = Widgets.CheckBox("Fill") wfill.add_callback('activated', lambda w, tf: self.set_drawparams()) self.wfill = wfill walpha = Widgets.SpinBox(dtype=float) walpha.set_limits(0.0, 1.0, incr_value=0.1) walpha.set_value(1.0) walpha.set_decimals(2) walpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) self.walpha = walpha 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) self.top.set_widget(vbox)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container) box.set_border_width(4) box.set_spacing(2) fr = Widgets.Frame("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) pixview.set_desired_size(self._wd, self._ht) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) self.pixview = pixview self.pix_w = Viewers.GingaViewerWidget(pixview) fr.set_widget(self.pix_w) self.pix_w.resize(self._wd, self._ht) paned = Widgets.Splitter(orientation=orientation) paned.add_widget(fr) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in self.fontsizes: b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) vbox2.add_widget(Widgets.Label(''), stretch=1) box.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## box.add_widget(spacer, stretch=1) paned.add_widget(sw) # hack to set a reasonable starting position for the splitter _sz = max(self._wd, self._ht) paned.set_sizes([_sz, _sz]) top.add_widget(paned, 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) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container) vbox.set_margins(4, 4, 4, 4) vbox.set_spacing(2) self.plot = plots.Plot(logger=self.logger, width=400, height=300) ax = self.plot.add_axis() ax.grid(False) w = Plot.PlotWidget(self.plot) w.resize(400, 300) vbox.add_widget(w, stretch=0) fr = Widgets.Frame("Axes controls") self.hbox_axes = Widgets.HBox() self.hbox_axes.set_border_width(4) self.hbox_axes.set_spacing(1) fr.set_widget(self.hbox_axes) vbox.add_widget(fr, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") btns.add_widget(cbox2, stretch=0) btn1 = Widgets.CheckBox("Pan to mark") btn1.set_state(self.pan2mark) btn1.add_callback('activated', self.pan2mark_cb) btn1.set_tooltip("Pan follows selected mark") btns.add_widget(btn1) btns.add_widget(Widgets.Label(''), stretch=1) btn2 = Widgets.Button("Delete") self.del_btn = btn2 btn2.add_callback('activated', lambda w: self.clear_mark_cb()) btn2.set_tooltip("Delete selected mark") btn2.set_enabled(False) btns.add_widget(btn2, stretch=0) btn3 = Widgets.Button("Delete All") self.del_all_btn = btn3 btn3.add_callback('activated', lambda w: self.clear_all()) btn3.set_tooltip("Clear all marks") btn3.set_enabled(False) btns.add_widget(btn3, stretch=0) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) vbox2.add_widget(Widgets.Label(''), stretch=1) fr = Widgets.Frame("Mark controls") fr.set_widget(vbox2) vbox.add_widget(fr, 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) 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) top.add_widget(btns, stretch=0) # Add our GUI to the container container.add_widget(top, stretch=1) self.gui_up = True self.build_axes()
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container, fill=True) 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("Pixel Values") # Make the values table as a text widget msgFont = self.fv.getFont('fixedFont', 10) tw = Widgets.TextArea(wrap=False, editable=False) #tw.cfg_expand(1, 1) tw.set_font(msgFont) self.tw = tw ## sw1 = Widgets.ScrollArea() ## sw1.set_widget(tw) vbox2 = Widgets.VBox() vbox2.add_widget(tw) ## vbox2.add_widget(sw1) ## vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=1) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## vbox.add_widget(spacer, stretch=1) top.add_widget(sw, 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) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
elif wname == 'checkbox': w = Widgets.CheckBox("Check me") vbox.add_widget(w, stretch=1) elif wname == 'togglebutton': w = Widgets.ToggleButton("Toggle me") vbox.add_widget(w, stretch=1) elif wname == 'radiobutton': w = Widgets.RadioButton("Option 1") vbox.add_widget(w) vbox.add_widget(Widgets.RadioButton("Option 2", group=w)) vbox.add_widget(Widgets.RadioButton("Option 3", group=w)) elif wname == 'combobox': w = Widgets.ComboBox() for name in ["Larry", "Curly", "Moe"]: w.append_text(name) vbox.add_widget(w) elif wname == 'spinbox': w = Widgets.SpinBox(dtype=int) w.set_limits(-10, 10, incr_value=1) w.set_value(4) vbox.add_widget(w) elif wname == 'slider': w = Widgets.Slider(orientation='horizontal') w.set_limits(-10, 10, incr_value=1) w.set_value(4) vbox.add_widget(w)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container, fill=True) 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("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) width, height = 300, 300 pixview.set_desired_size(width, height) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() self.pixview = pixview self.pix_w = Viewers.ScrolledView(pixview) self.pix_w.resize(width, height) fr.set_widget(self.pix_w) vbox.add_widget(fr, stretch=1) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in (8, 9, 10, 11, 12, 14, 16): b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## vbox.add_widget(spacer, stretch=1) top.add_widget(sw, 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) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container) box.set_border_width(4) box.set_spacing(2) fr = Widgets.Frame("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) pixview.set_desired_size(self._wd, self._ht) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) self.pixview = pixview self.pix_w = Viewers.GingaViewerWidget(pixview) fr.set_widget(self.pix_w) self.pix_w.resize(self._wd, self._ht) paned = Widgets.Splitter(orientation=orientation) self.w.splitter = paned paned.add_widget(fr) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btn1.set_enabled(len(self.marks) > 1) self.w.btn_delete = btn1 btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btn2.set_enabled(len(self.marks) > 1) self.w.btn_delete_all = btn2 btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox', 'Caption:', 'label', 'Caption', 'entry'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in self.fontsizes: b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) b.caption.set_tooltip("Text to append to the marker") vbox2.add_widget(Widgets.Label(''), stretch=1) box.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## box.add_widget(spacer, stretch=1) paned.add_widget(sw) paned.set_sizes(self._split_sizes) top.add_widget(paned, stretch=1) mode = self.canvas.get_draw_mode() hbox = Widgets.HBox() btn1 = Widgets.RadioButton("Move") btn1.set_state(mode == 'move') btn1.add_callback('activated', lambda w, val: self.set_mode_cb('move', val)) btn1.set_tooltip("Choose this to add or move a mark") self.w.btn_move = btn1 hbox.add_widget(btn1) btn2 = Widgets.RadioButton("Draw", group=btn1) btn2.set_state(mode == 'draw') btn2.add_callback('activated', lambda w, val: self.set_mode_cb('draw', val)) btn2.set_tooltip("Choose this to draw a new or replacement mark") self.w.btn_draw = btn2 hbox.add_widget(btn2) btn3 = Widgets.RadioButton("Edit", group=btn1) btn3.set_state(mode == 'edit') btn3.add_callback('activated', lambda w, val: self.set_mode_cb('edit', val)) btn3.set_tooltip("Choose this to edit a mark") self.w.btn_edit = btn3 hbox.add_widget(btn3) hbox.add_widget(Widgets.Label(''), stretch=1) top.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) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1) self.gui_up = True