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 may be called many times as the plugin is opened and closed for modal operations. 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("Instructions") 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)
def build_gui(self, container): vbox = Widgets.VBox() self.msgFont = self.fv.getFont("fixedFont", 12) tw = Widgets.TextArea(wrap=False, editable=False) tw.set_font(self.msgFont) tw.set_limit(self.histlimit) self.tw = tw sw = Widgets.ScrollArea() sw.set_widget(self.tw) vbox.add_widget(sw, stretch=1) captions = (('Level', 'combobox', 'History', 'spinbutton'), ('Auto scroll', 'checkbutton', 'Clear', 'button')) w, b = Widgets.build_info(captions) self.w.update(b) combobox = b.level for (name, level) in self.levels: combobox.append_text(name) combobox.set_index(1) combobox.add_callback('activated', self.set_loglevel_cb) combobox.set_tooltip("Set the logging level") spinbox = b.history spinbox.set_limits(100, self.histmax, incr_value=10) spinbox.set_value(self.histlimit) spinbox.add_callback('value-changed', self.set_history_cb) spinbox.set_tooltip("Set the logging history line limit") btn = b.auto_scroll btn.set_state(self.autoscroll) btn.set_tooltip("Scroll the log window automatically") btn.add_callback('activated', self.set_autoscroll_cb) btn = b.clear btn.add_callback('activated', lambda w: self.clear()) btn.set_tooltip("Clear the log history") vbox.add_widget(w, 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) btns.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(btns, stretch=0) container.add_widget(vbox, 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_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.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Ruler") captions = (('Units:', 'label', 'Units', 'combobox'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w = b combobox = b.units for name in self.unittypes: combobox.append_text(name) index = self.unittypes.index(self.units) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_units()) 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)
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)
def build_gui(self, container): vbox = Widgets.VBox() self.msgFont = self.fv.getFont("fixedFont", 12) tw = Widgets.TextArea(wrap=False, editable=False) tw.set_font(self.msgFont) self.tw = tw self.history = [] self.histmax = 10 sw = Widgets.ScrollArea() sw.set_widget(self.tw) vbox.add_widget(sw, stretch=1) captions = ( ('Local plugin:', 'label', 'Local plugin', 'entry', 'Reload', 'button'), ('Global plugin:', 'label', 'Global plugin', 'entry', 'ReloadG', 'button'), ) w, b = Widgets.build_info(captions) self.w.update(b) b.local_plugin.set_tooltip("Name of a local plugin to reload") b.local_plugin.set_length(14) b.reload.add_callback('activated', self.reload_local_cb) b.global_plugin.set_tooltip("Name of a global plugin to reload") b.global_plugin.set_length(14) b.reloadg.add_callback('activated', self.reload_global_cb) vbox.add_widget(w, stretch=1) self.entry = Widgets.TextEntry() vbox.add_widget(self.entry, stretch=0) self.entry.add_callback('activated', self.command_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)
def add_error(self, errmsg): 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) hbox.add_widget(lbl, stretch=1) vbox.add_widget(hbox, stretch=0) tw = Widgets.TextArea(editable=False, wrap=False) tw.set_font(self.msgFont) tw.set_text(errmsg) vbox.add_widget(tw, stretch=0) 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) self.msgList.add_widget(vbox, stretch=0)
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.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") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) 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) 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): assert iqcalc.have_scipy == True, \ Exception("Please install python-scipy to use this plugin") self.pickcenter = None vtop = Widgets.VBox() vtop.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container) vbox.set_border_width(4) vbox.set_spacing(2) vpaned = Widgets.Splitter(orientation=orientation) nb = Widgets.TabWidget(tabpos='bottom') #nb.set_scrollable(True) self.w.nb1 = nb vpaned.add_widget(nb) cm, im = self.fv.cm, self.fv.im di = CanvasTypes.ImageViewCanvas(logger=self.logger) width, height = 200, 200 di.set_desired_size(width, height) di.enable_autozoom('off') di.enable_autocuts('off') di.zoom_to(3, redraw=False) settings = di.get_settings() settings.getSetting('zoomlevel').add_callback('set', self.zoomset, di) di.set_cmap(cm, redraw=False) di.set_imap(im, redraw=False) di.set_callback('none-move', self.detailxy) di.set_bg(0.4, 0.4, 0.4) # for debugging di.set_name('pickimage') self.pickimage = di bd = di.get_bindings() bd.enable_pan(True) bd.enable_zoom(True) bd.enable_cuts(True) iw = Widgets.wrap(di.get_widget()) nb.add_widget(iw, title="Image") if have_mpl: self.plot1 = Plot.Plot(logger=self.logger, width=2, height=3, dpi=72) self.w.canvas = self.plot1.canvas self.w.fig = self.plot1.fig self.w.ax = self.w.fig.add_subplot(111, axisbg='black') self.w.ax.set_aspect('equal', adjustable='box') self.w.ax.set_title('Contours') #self.w.ax.grid(True) canvas = self.w.canvas connect = canvas.mpl_connect # These are not ready for prime time... # connect("motion_notify_event", self.plot_motion_notify) # connect("button_press_event", self.plot_button_press) connect("scroll_event", self.plot_scroll) nb.add_widget(Widgets.wrap(canvas), title="Contour") self.plot2 = Plot.Plot(logger=self.logger, width=2, height=3, dpi=72) self.w.canvas2 = self.plot2.canvas self.w.fig2 = self.plot2.fig self.w.ax2 = self.w.fig2.add_subplot(111, axisbg='white') #self.w.ax2.set_aspect('equal', adjustable='box') self.w.ax2.set_ylabel('brightness') self.w.ax2.set_xlabel('pixels') self.w.ax2.set_title('FWHM') self.w.ax.grid(True) canvas = self.w.canvas2 nb.add_widget(Widgets.wrap(canvas), title="FWHM") ## self.msgFont = self.fv.getFont("sansFont", 12) ## tw = Widgets.TextArea(wrap=True, editable=False) ## tw.set_font(self.msgFont) ## self.tw = tw ## fr = Widgets.Frame("Instructions") ## vbox2 = Widgets.VBox() ## vbox2.add_widget(tw) ## vbox2.add_widget(Widgets.Label(''), stretch=1) ## fr.set_widget(vbox2) ## vbox.add_widget(fr, stretch=0) vpaned.add_widget(Widgets.Label('')) vbox.add_widget(vpaned, stretch=1) fr = Widgets.Frame("Pick") nb = Widgets.TabWidget(tabpos='bottom') self.w.nb2 = nb # Build report panel captions = ( ('Zoom:', 'label', 'Zoom', 'llabel', 'Contour Zoom:', 'label', 'Contour Zoom', 'llabel'), ('Object_X', 'label', 'Object_X', 'llabel', 'Object_Y', 'label', 'Object_Y', 'llabel'), ('RA:', 'label', 'RA', 'llabel', 'DEC:', 'label', 'DEC', 'llabel'), ('Equinox:', 'label', 'Equinox', 'llabel', 'Background:', 'label', 'Background', 'llabel'), ('Sky Level:', 'label', 'Sky Level', 'llabel', 'Brightness:', 'label', 'Brightness', 'llabel'), ('FWHM X:', 'label', 'FWHM X', 'llabel', 'FWHM Y:', 'label', 'FWHM Y', 'llabel'), ('FWHM:', 'label', 'FWHM', 'llabel', 'Star Size:', 'label', 'Star Size', 'llabel'), ('Sample Area:', 'label', 'Sample Area', 'llabel', 'Default Region', 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(di.get_scale())) self.wdetail = b b.default_region.add_callback('activated', lambda w: self.reset_region()) b.default_region.set_tooltip("Reset region size to default") vbox1 = Widgets.VBox() vbox1.add_widget(w, stretch=0) # spacer vbox1.add_widget(Widgets.Label(''), stretch=0) # Pick field evaluation status hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) label = Widgets.Label() #label.set_alignment(0.05, 0.5) self.w.eval_status = label hbox.add_widget(self.w.eval_status, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox1.add_widget(hbox, stretch=0) # Pick field evaluation progress bar and stop button hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) btn = Widgets.Button("Stop") btn.add_callback('activated', lambda w: self.eval_intr()) btn.set_enabled(False) self.w.btn_intr_eval = btn hbox.add_widget(btn, stretch=0) self.w.eval_pgs = Widgets.ProgressBar() hbox.add_widget(self.w.eval_pgs, stretch=1) vbox1.add_widget(hbox, stretch=0) nb.add_widget(vbox1, title="Readout") # Build settings panel captions = ( ('Show Candidates', 'checkbutton'), ('Radius:', 'label', 'xlbl_radius', 'label', 'Radius', 'spinbutton'), ('Threshold:', 'label', 'xlbl_threshold', 'label', 'Threshold', 'entry'), ('Min FWHM:', 'label', 'xlbl_min_fwhm', 'label', 'Min FWHM', 'spinbutton'), ('Max FWHM:', 'label', 'xlbl_max_fwhm', 'label', 'Max FWHM', 'spinbutton'), ('Ellipticity:', 'label', 'xlbl_ellipticity', 'label', 'Ellipticity', 'entry'), ('Edge:', 'label', 'xlbl_edge', 'label', 'Edge', 'entry'), ('Max side:', 'label', 'xlbl_max_side', 'label', 'Max side', 'spinbutton'), ('Redo Pick', 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.radius.set_tooltip("Radius for peak detection") b.threshold.set_tooltip("Threshold for peak detection (blank=default)") b.min_fwhm.set_tooltip("Minimum FWHM for selection") b.max_fwhm.set_tooltip("Maximum FWHM for selection") b.ellipticity.set_tooltip("Minimum ellipticity for selection") b.edge.set_tooltip("Minimum edge distance for selection") b.show_candidates.set_tooltip("Show all peak candidates") # radius control #b.radius.set_digits(2) #b.radius.set_numeric(True) b.radius.set_limits(5.0, 200.0, incr_value=1.0) b.radius.set_value(self.radius) def chg_radius(w, val): self.radius = float(val) self.w.xlbl_radius.set_text(str(self.radius)) return True b.xlbl_radius.set_text(str(self.radius)) b.radius.add_callback('value-changed', chg_radius) # threshold control def chg_threshold(w): threshold = None ths = w.get_text().strip() if len(ths) > 0: threshold = float(ths) self.threshold = threshold self.w.xlbl_threshold.set_text(str(self.threshold)) return True b.xlbl_threshold.set_text(str(self.threshold)) b.threshold.add_callback('activated', chg_threshold) # min fwhm #b.min_fwhm.set_digits(2) #b.min_fwhm.set_numeric(True) b.min_fwhm.set_limits(0.1, 200.0, incr_value=0.1) b.min_fwhm.set_value(self.min_fwhm) def chg_min(w, val): self.min_fwhm = float(val) self.w.xlbl_min_fwhm.set_text(str(self.min_fwhm)) return True b.xlbl_min_fwhm.set_text(str(self.min_fwhm)) b.min_fwhm.add_callback('value-changed', chg_min) # max fwhm #b.max_fwhm.set_digits(2) #b.max_fwhm.set_numeric(True) b.max_fwhm.set_limits(0.1, 200.0, incr_value=0.1) b.max_fwhm.set_value(self.max_fwhm) def chg_max(w, val): self.max_fwhm = float(val) self.w.xlbl_max_fwhm.set_text(str(self.max_fwhm)) return True b.xlbl_max_fwhm.set_text(str(self.max_fwhm)) b.max_fwhm.add_callback('value-changed', chg_max) # Ellipticity control def chg_ellipticity(w): minellipse = None val = w.get_text().strip() if len(val) > 0: minellipse = float(val) self.min_ellipse = minellipse self.w.xlbl_ellipticity.set_text(str(self.min_ellipse)) return True b.xlbl_ellipticity.set_text(str(self.min_ellipse)) b.ellipticity.add_callback('activated', chg_ellipticity) # Edge control def chg_edgew(w): edgew = None val = w.get_text().strip() if len(val) > 0: edgew = float(val) self.edgew = edgew self.w.xlbl_edge.set_text(str(self.edgew)) return True b.xlbl_edge.set_text(str(self.edgew)) b.edge.add_callback('activated', chg_edgew) #b.max_side.set_digits(0) #b.max_side.set_numeric(True) b.max_side.set_limits(5, 10000, incr_value=10) b.max_side.set_value(self.max_side) def chg_max_side(w, val): self.max_side = int(val) self.w.xlbl_max_side.set_text(str(self.max_side)) return True b.xlbl_max_side.set_text(str(self.max_side)) b.max_side.add_callback('value-changed', chg_max_side) b.redo_pick.add_callback('activated', lambda w: self.redo()) b.show_candidates.set_state(self.show_candidates) b.show_candidates.add_callback('activated', self.show_candidates_cb) nb.add_widget(w, title="Settings") # Build controls panel captions = ( ('Sky cut', 'button', 'Delta sky:', 'label', 'xlbl_delta_sky', 'label', 'Delta sky', 'entry'), ('Bright cut', 'button', 'Delta bright:', 'label', 'xlbl_delta_bright', 'label', 'Delta bright', 'entry'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.sky_cut.set_tooltip("Set image low cut to Sky Level") b.delta_sky.set_tooltip("Delta to apply to low cut") b.bright_cut.set_tooltip("Set image high cut to Sky Level+Brightness") b.delta_bright.set_tooltip("Delta to apply to high cut") b.sky_cut.set_enabled(False) self.w.btn_sky_cut = b.sky_cut self.w.btn_sky_cut.add_callback('activated', lambda w: self.sky_cut()) self.w.sky_cut_delta = b.delta_sky b.xlbl_delta_sky.set_text(str(self.delta_sky)) b.delta_sky.set_text(str(self.delta_sky)) def chg_delta_sky(w): delta_sky = 0.0 val = w.get_text().strip() if len(val) > 0: delta_sky = float(val) self.delta_sky = delta_sky self.w.xlbl_delta_sky.set_text(str(self.delta_sky)) return True b.delta_sky.add_callback('activated', chg_delta_sky) b.bright_cut.set_enabled(False) self.w.btn_bright_cut = b.bright_cut self.w.btn_bright_cut.add_callback('activated', lambda w: self.bright_cut()) self.w.bright_cut_delta = b.delta_bright b.xlbl_delta_bright.set_text(str(self.delta_bright)) b.delta_bright.set_text(str(self.delta_bright)) def chg_delta_bright(w): delta_bright = 0.0 val = w.get_text().strip() if len(val) > 0: delta_bright = float(val) self.delta_bright = delta_bright self.w.xlbl_delta_bright.set_text(str(self.delta_bright)) return True b.delta_bright.add_callback('activated', chg_delta_bright) nb.add_widget(w, title="Controls") vbox3 = Widgets.VBox() msgFont = self.fv.getFont("fixedFont", 10) tw = Widgets.TextArea(wrap=False, editable=True) tw.set_font(msgFont) self.w.report = tw sw1 = Widgets.ScrollArea() sw1.set_widget(tw) vbox3.add_widget(sw1, stretch=1) tw.append_text(self._mkreport_header()) btns = Widgets.HBox() btns.set_spacing(4) btn = Widgets.Button("Add Pick") btn.add_callback('activated', lambda w: self.add_pick_cb()) btns.add_widget(btn) btn = Widgets.CheckBox("Record Picks") btn.set_state(self.do_record) btn.add_callback('activated', self.record_cb) btns.add_widget(btn) btns.add_widget(Widgets.Label(''), stretch=1) vbox3.add_widget(btns, stretch=0) nb.add_widget(vbox3, title="Report") ## vbox4 = Widgets.VBox() ## tw = Widgets.TextArea(wrap=False, editable=True) ## tw.set_font(msgFont) ## self.w.correct = tw ## sw1 = Widgets.ScrollArea() ## sw1.set_widget(tw) ## vbox4.add_widget(sw1, stretch=1) ## tw.append_text("# paste a reference report here") ## btns = Widgets.HBox() ## btns.set_spacing(4) ## btn = Widgets.Button("Correct WCS") ## btn.add_callback('activated', lambda w: self.correct_wcs()) ## btns.add_widget(btn) ## vbox4.add_widget(btns, stretch=0) ## nb.add_widget(vbox4, title="Correct") fr.set_widget(nb) vbox.add_widget(fr, stretch=0) ## spacer = Widgets.Label('') ## vbox.add_widget(spacer, stretch=1) vtop.add_widget(sw, stretch=1) btns = Widgets.HBox() 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) vtop.add_widget(btns, stretch=0) container.add_widget(vtop, stretch=1)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, self.orientation = Widgets.get_oriented_box(container) 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') vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame('Background Selection') captions = (('Type:', 'label', 'BG type', 'combobox'), ) w, b = Widgets.build_info(captions) self.w.update(b) combobox = b.bg_type for name in self._bgtype_options: combobox.append_text(name) b.bg_type.set_index(self._bgtype_options.index(self.bgtype)) b.bg_type.widget.activated[str].connect(self.set_bgtype) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame('Attributes') vbox2 = Widgets.VBox() self.w.bgtype_attr_vbox = Widgets.VBox() vbox2.add_widget(self.w.bgtype_attr_vbox, stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) captions = (('Background Value:', 'label', 'Background Value', 'entry'), ('Subtract', 'button', 'Save Parameters', 'button')) w, b = Widgets.build_info(captions, orientation=self.orientation) self.w.update(b) b.background_value.set_tooltip('Background value') b.background_value.set_text(str(self.bgval)) b.background_value.widget.editingFinished.connect(self.set_constant_bg) b.background_value.widget.setReadOnly(True) b.background_value.widget.setEnabled(True) b.background_value.widget.setStyleSheet( 'QLineEdit{background: white;}') b.subtract.set_tooltip('Subtract background') b.subtract.widget.clicked.connect(self.sub_bg) b.subtract.widget.setEnabled(False) b.save_parameters.set_tooltip('Save background subtraction parameters') b.save_parameters.widget.clicked.connect(self.save_params) vbox.add_widget(w, 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) # Populate default attributes frame self.set_bgtype(self.bgtype) self.gui_up = True
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) # Make the cuts plot vbox, sw, orientation = Widgets.get_oriented_box(container) vbox.set_margins(4, 4, 4, 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") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) self.plot = Plot.Cuts(self.logger, width=2, height=3, dpi=100) ax = self.plot.add_axis() ax.grid(True) # for now we need to wrap this native widget w = Widgets.wrap(self.plot.get_widget()) vbox.add_widget(w, stretch=1) hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) # control for selecting a cut combobox = Widgets.ComboBox() for tag in self.tags: combobox.append_text(tag) if self.cutstag == None: combobox.set_index(0) else: combobox.show_text(self.cutstag) combobox.add_callback('activated', self.cut_select_cb) self.w.cuts = combobox combobox.set_tooltip("Select a cut") hbox.add_widget(combobox) btn = Widgets.Button("Delete") btn.add_callback('activated', self.delete_cut_cb) btn.set_tooltip("Delete selected cut") hbox.add_widget(btn) btn = Widgets.Button("Delete All") btn.add_callback('activated', self.delete_all_cb) btn.set_tooltip("Clear all cuts") hbox.add_widget(btn) combobox = Widgets.ComboBox() for cuttype in self.cuttypes: combobox.append_text(cuttype) self.w.cuts_type = combobox index = self.cuttypes.index(self.cuttype) combobox.set_index(index) combobox.add_callback('activated', self.set_cutsdrawtype_cb) combobox.set_tooltip("Choose the cut type") hbox.add_widget(combobox) vbox2 = Widgets.VBox() vbox2.add_widget(hbox, stretch=0) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(vbox2, 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) self.gui_up = True
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) # Make the cuts plot vbox, sw, orientation = Widgets.get_oriented_box(container) 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") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) self.plot = Plot.Plot(self.logger, width=2, height=3, dpi=100) ax = self.plot.add_axis() ax.grid(True) # for now we need to wrap this native widget w = Widgets.wrap(self.plot.get_widget()) vbox.add_widget(w, stretch=1) captions = ( ('Cut Low:', 'label', 'Cut Low', 'entry'), ('Cut High:', 'label', 'Cut High', 'entry', 'Cut Levels', 'button'), ('Auto Levels', 'button'), ('Log Histogram', 'checkbutton', 'Plot By Cuts', 'checkbutton'), ('NumBins:', 'label', 'NumBins', 'entry'), ('Full Image', 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.cut_levels.set_tooltip("Set cut levels manually") b.auto_levels.set_tooltip("Set cut levels by algorithm") b.cut_low.set_tooltip("Set low cut level (press Enter)") b.cut_high.set_tooltip("Set high cut level (press Enter)") b.log_histogram.set_tooltip( "Use the log of the pixel values for the histogram (empty bins map to 10^-1)" ) b.plot_by_cuts.set_tooltip( "Only show the part of the histogram between the cuts") b.numbins.set_tooltip("Number of bins for the histogram") b.full_image.set_tooltip( "Use the full image for calculating the histogram") b.numbins.set_text(str(self.numbins)) b.cut_low.add_callback('activated', lambda w: self.cut_levels()) b.cut_high.add_callback('activated', lambda w: self.cut_levels()) b.cut_levels.add_callback('activated', lambda w: self.cut_levels()) b.auto_levels.add_callback('activated', lambda w: self.auto_levels()) b.log_histogram.set_state(self.plot.logy) b.log_histogram.add_callback('activated', self.log_histogram_cb) b.plot_by_cuts.set_state(self.xlimbycuts) b.plot_by_cuts.add_callback('activated', self.plot_by_cuts_cb) b.numbins.add_callback('activated', lambda w: self.set_numbins_cb()) b.full_image.add_callback('activated', lambda w: self.full_image_cb()) vbox.add_widget(w, stretch=0) ## 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(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
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.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Mosaic") captions = [ ("FOV (deg):", 'label', 'Fov', 'llabel', 'set_fov', 'entry'), ("New Mosaic", 'button'), ("Label images", 'checkbutton', "Match bg", 'checkbutton'), ("Trim Pixels:", 'label', 'Trim Px', 'llabel', 'trim_pixels', 'entry'), ("Num Threads:", 'label', 'Num Threads', 'llabel', 'set_num_threads', 'entry'), ("Merge data", 'checkbutton', "Drop new", 'checkbutton'), ("Mosaic HDUs", 'checkbutton'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) fov_deg = self.settings.get('fov_deg', 1.0) b.fov.set_text(str(fov_deg)) b.set_fov.set_length(8) b.set_fov.set_text(str(fov_deg)) b.set_fov.add_callback('activated', self.set_fov_cb) b.set_fov.set_tooltip("Set size of mosaic FOV (deg)") b.new_mosaic.add_callback('activated', lambda w: self.new_mosaic_cb()) labelem = self.settings.get('annotate_images', False) b.label_images.set_state(labelem) b.label_images.set_tooltip("Label tiles with their names") b.label_images.add_callback('activated', self.annotate_cb) trim_px = self.settings.get('trim_px', 0) match_bg = self.settings.get('match_bg', False) b.match_bg.set_tooltip("Try to match background levels") b.match_bg.set_state(match_bg) b.match_bg.add_callback('activated', self.match_bg_cb) b.trim_pixels.set_tooltip("Set number of pixels to trim from each edge") b.trim_px.set_text(str(trim_px)) b.trim_pixels.add_callback('activated', self.trim_pixels_cb) b.trim_pixels.set_length(8) b.trim_pixels.set_text(str(trim_px)) num_threads = self.settings.get('num_threads', 4) b.num_threads.set_text(str(num_threads)) b.set_num_threads.set_length(8) b.set_num_threads.set_text(str(num_threads)) b.set_num_threads.set_tooltip("Number of threads to use for mosaicing") b.set_num_threads.add_callback('activated', self.set_num_threads_cb) merge = self.settings.get('merge', False) b.merge_data.set_tooltip("Merge data instead of overlay") b.merge_data.set_state(merge) b.merge_data.add_callback('activated', self.merge_cb) drop_new = self.settings.get('drop_creates_new_mosaic', False) b.drop_new.set_tooltip("Dropping files on image starts a new mosaic") b.drop_new.set_state(drop_new) b.drop_new.add_callback('activated', self.drop_new_cb) mosaic_hdus = self.settings.get('mosaic_hdus', False) b.mosaic_hdus.set_tooltip("Mosaic data HDUs in each file") b.mosaic_hdus.set_state(mosaic_hdus) b.mosaic_hdus.add_callback('activated', self.mosaic_hdus_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) vbox2 = Widgets.VBox() # Mosaic evaluation status hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) label = Widgets.Label() self.w.eval_status = label hbox.add_widget(self.w.eval_status, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(hbox, stretch=0) # Mosaic evaluation progress bar and stop button hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) btn = Widgets.Button("Stop") btn.add_callback('activated', lambda w: self.eval_intr()) btn.set_enabled(False) self.w.btn_intr_eval = btn hbox.add_widget(btn, stretch=0) self.w.eval_pgs = Widgets.ProgressBar() hbox.add_widget(self.w.eval_pgs, stretch=1) vbox2.add_widget(hbox, stretch=0) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(vbox2, stretch=1) self.w.vbox = Widgets.VBox() vbox.add_widget(self.w.vbox, 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
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.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Limits") captions = (('Opacity:', 'label', 'Opacity', 'spinfloat'), ('Hi color:', 'label', 'Hi color', 'combobox'), ('Hi limit:', 'label', 'Hi value', 'entry'), ('Lo color:', 'label', 'Lo color', 'combobox'), ('Lo limit:', 'label', 'Lo value', 'entry'), ('Redo', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.opacity.set_decimals(2) b.opacity.set_limits(0.0, 1.0, incr_value=0.1) b.opacity.set_value(self.opacity) b.opacity.add_callback('value-changed', lambda *args: self.redo()) combobox = b.hi_color for name in self.colornames: combobox.append_text(name) index = self.colornames.index(self.hi_color) combobox.set_index(index) combobox.add_callback('activated', lambda *args: self.redo()) b.hi_value.set_length(22) if self.hi_value != None: b.hi_value.set_text(str(self.hi_value)) b.hi_value.add_callback('activated', lambda *args: self.redo()) combobox = b.lo_color for name in self.colornames: combobox.append_text(name) index = self.colornames.index(self.lo_color) combobox.set_index(index) combobox.add_callback('activated', lambda *args: self.redo()) b.lo_value.set_length(22) if self.lo_value != None: b.lo_value.set_text(str(self.lo_value)) b.lo_value.add_callback('activated', lambda *args: self.redo()) b.redo.add_callback('activated', lambda *args: self.redo()) 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)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox1, sw, orientation = Widgets.get_oriented_box(container) vbox1.set_border_width(4) vbox1.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.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox1.add_widget(fr, stretch=0) # Main pipeline control area captions = [ ("Subtract Bias", 'button', "Bias Image:", 'label', 'bias_image', 'llabel'), ("Apply Flat Field", 'button', "Flat Image:", 'label', 'flat_image', 'llabel'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) fr = Widgets.Frame("Pipeline") fr.set_widget(w) vbox1.add_widget(fr, stretch=0) b.subtract_bias.add_callback('activated', self.subtract_bias_cb) b.subtract_bias.set_tooltip("Subtract a bias image") bias_name = 'None' if self.bias != None: bias_name = self.bias.get('name', "NoName") b.bias_image.set_text(bias_name) b.apply_flat_field.add_callback('activated', self.apply_flat_cb) b.apply_flat_field.set_tooltip("Apply a flat field correction") flat_name = 'None' if self.flat != None: flat_name = self.flat.get('name', "NoName") b.flat_image.set_text(flat_name) vbox2 = Widgets.VBox() # Pipeline status hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) label = Widgets.Label() self.w.eval_status = label hbox.add_widget(self.w.eval_status, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(hbox, stretch=0) # progress bar and stop button hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) btn = Widgets.Button("Stop") btn.add_callback('activated', lambda w: self.eval_intr()) btn.set_enabled(False) self.w.btn_intr_eval = btn hbox.add_widget(btn, stretch=0) self.w.eval_pgs = Widgets.ProgressBar() hbox.add_widget(self.w.eval_pgs, stretch=1) vbox2.add_widget(hbox, stretch=0) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox1.add_widget(vbox2, stretch=0) # Image list captions = [ ("Append", 'button', "Prepend", 'button', "Clear", 'button'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) fr = Widgets.Frame("Image Stack") vbox = Widgets.VBox() hbox = Widgets.HBox() self.w.stack = Widgets.Label('') hbox.add_widget(self.w.stack, stretch=0) vbox.add_widget(hbox, stretch=0) vbox.add_widget(w, stretch=0) fr.set_widget(vbox) vbox1.add_widget(fr, stretch=0) self.update_stack_gui() b.append.add_callback('activated', self.append_image_cb) b.append.set_tooltip("Append an individual image to the stack") b.prepend.add_callback('activated', self.prepend_image_cb) b.prepend.set_tooltip("Prepend an individual image to the stack") b.clear.add_callback('activated', self.clear_stack_cb) b.clear.set_tooltip("Clear the stack of images") # Bias captions = [ ("Make Bias", 'button', "Set Bias", 'button'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) fr = Widgets.Frame("Bias Subtraction") fr.set_widget(w) vbox1.add_widget(fr, stretch=0) b.make_bias.add_callback('activated', self.make_bias_cb) b.make_bias.set_tooltip("Makes a bias image from a stack of individual images") b.set_bias.add_callback('activated', self.set_bias_cb) b.set_bias.set_tooltip("Set the currently loaded image as the bias image") # Flat fielding captions = [ ("Make Flat Field", 'button', "Set Flat Field", 'button'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) fr = Widgets.Frame("Flat Fielding") fr.set_widget(w) vbox1.add_widget(fr, stretch=0) b.make_flat_field.add_callback('activated', self.make_flat_cb) b.make_flat_field.set_tooltip("Makes a flat field from a stack of individual flats") b.set_flat_field.add_callback('activated', self.set_flat_cb) b.set_flat_field.set_tooltip("Set the currently loaded image as the flat field") spacer = Widgets.Label('') vbox1.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
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) msgFont = self.fv.getFont("sansFont", 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(msgFont) self.tw = tw fr = Widgets.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Drawing") captions = (("Draw type:", 'label', "Draw type", 'combobox'), ("Draw color:", 'label', "Draw color", 'combobox'), ("Line width:", 'label', "Line width", 'spinbutton'), ("Line style:", 'label', "Line style", 'combobox'), ("Alpha:", 'label', "Alpha", 'spinfloat'), ("Fill", 'checkbutton', "Fill color", 'combobox'), ("Fill Alpha:", 'label', "Fill Alpha", 'spinfloat'), ("Text:", 'label', "Text", 'entry'), ("Clear canvas", 'button')) w, b = Widgets.build_info(captions) self.w = b combobox = b.draw_type for name in self.drawtypes: combobox.append_text(name) index = self.drawtypes.index(default_drawtype) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) combobox = b.draw_color self.drawcolors = draw_colors for name in self.drawcolors: combobox.append_text(name) index = self.drawcolors.index(default_drawcolor) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) combobox = b.fill_color for name in self.drawcolors: combobox.append_text(name) index = self.drawcolors.index(default_drawcolor) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) b.line_width.set_limits(0, 10, 1) #b.line_width.set_decimals(0) b.line_width.set_value(1) b.line_width.add_callback('value-changed', lambda w, val: self.set_drawparams()) combobox = b.line_style for name in self.linestyles: combobox.append_text(name) combobox.set_index(0) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) b.fill.add_callback('activated', lambda w, tf: self.set_drawparams()) b.fill.set_state(False) b.alpha.set_limits(0.0, 1.0, 0.1) b.alpha.set_decimals(2) b.alpha.set_value(1.0) b.alpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) b.fill_alpha.set_limits(0.0, 1.0, 0.1) b.fill_alpha.set_decimals(2) b.fill_alpha.set_value(0.3) b.fill_alpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) b.text.add_callback('activated', lambda w: self.set_drawparams()) b.text.set_text('EDIT ME') b.text.set_length(60) b.clear_canvas.add_callback('activated', lambda w: self.clear_canvas()) 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(4) 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)
def plugin_build_error(self, box, text): textw = Widgets.TextArea(editable=False, wrap=True) textw.append_text(text) box.add_widget(textw, 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_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") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Drawing") captions = (('Draw type:', 'label', 'Draw type', 'combobox'), ('Draw color:', 'label', 'Draw color', 'combobox'), ('Clear canvas', 'button')) w, b = Widgets.build_info(captions) self.w = b combobox = b.draw_type options = [] index = 0 for name in self.drawtypes: options.append(name) combobox.append_text(name) index += 1 index = self.drawtypes.index(default_drawtype) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) self.w.draw_color = b.draw_color combobox = b.draw_color options = [] index = 0 self.drawcolors = draw_colors for name in self.drawcolors: options.append(name) combobox.append_text(name) index += 1 index = self.drawcolors.index(default_drawcolor) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_drawparams()) b.clear_canvas.add_callback('activated', lambda w: self.clear_canvas()) 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(4) 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)
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) 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.set_font(msgFont) self.tw = tw vbox2 = Widgets.VBox() vbox2.add_widget(tw) 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 == 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)
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) msgFont = self.fv.getFont('sansFont', 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(msgFont) self.tw = tw fr = Widgets.Frame('Instructions') vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame('Single Pixel') captions = [('X:', 'label', 'X', 'entry'), ('Y:', 'label', 'Y', 'entry'), ('DQ Flag:', 'label', 'DQ', 'llabel')] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.x.set_tooltip('X of pixel') b.x.set_text(str(self.xcen)) b.x.widget.editingFinished.connect(self.set_xcen) b.y.set_tooltip('Y of pixel') b.y.set_text(str(self.ycen)) b.y.widget.editingFinished.connect(self.set_ycen) b.dq.set_tooltip('DQ value of pixel') b.dq.set_text(self._no_keyword) b.dq.widget.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.pxdqlist = QtGui.QListWidget() splitter = Widgets.Splitter('vertical') splitter.add_widget(w) splitter.widget.addWidget(self.pxdqlist) fr.set_widget(splitter) vbox.add_widget(fr, stretch=1) fr = Widgets.Frame('Whole Image') captions = [('Number of pixels:', 'llabel', 'npix', 'llabel', 'spacer1', 'spacer')] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.npix.set_tooltip('Number of affected pixels') b.npix.set_text(self._no_keyword) b.npix.widget.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.imdqlist = QtGui.QListWidget() self.imdqlist.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.imdqlist.itemSelectionChanged.connect(self.mark_dqs) splitter = Widgets.Splitter('vertical') splitter.add_widget(w) splitter.widget.addWidget(self.imdqlist) fr.set_widget(splitter) vbox.add_widget(fr, stretch=1) 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) self.gui_up = True # Populate fields based on active image self.redo()
def build_gui(self, container): assert have_pyfits == True, \ Exception("Please install astropy/pyfits to use this plugin") top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container, scrolled=False) self.orientation = orientation 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.Frame("Instructions") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(''), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("HDU") captions = [ ("Num HDUs:", 'label', "Num HDUs", 'llabel'), ("Choose HDU", 'combobox'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) self.w.numhdu = b.num_hdus self.w.hdu = b.choose_hdu self.w.hdu.set_tooltip("Choose which HDU to view") self.w.hdu.add_callback('activated', self.set_hdu_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("NAXIS") self.naxisfr = fr vbox.add_widget(fr, stretch=0) captions = [ ("First", 'button', "Prev", 'button', "Stop", 'button'), ("Last", 'button', "Next", 'button', "Play", 'button'), ("Interval:", 'label', "Interval", 'spinfloat'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.next.add_callback('activated', lambda w: six.advance_iterator(self)) b.prev.add_callback('activated', lambda w: self.prev()) b.first.add_callback('activated', lambda w: self.first()) b.last.add_callback('activated', lambda w: self.last()) b.play.add_callback('activated', lambda w: self.play_start()) b.stop.add_callback('activated', lambda w: self.play_stop()) lower, upper = 0.1, 8.0 b.interval.set_limits(lower, upper, incr_value=0.1) b.interval.set_value(lower) b.interval.set_decimals(2) b.interval.add_callback('value-changed', self.play_int_cb) vbox.add_widget(w, stretch=0) captions = [ ("Slice:", 'label', "Slice", 'llabel', "Value:", 'label', "Value", 'llabel'), ] w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) vbox.add_widget(w, stretch=0) spacer = Widgets.Label('') vbox.add_widget(spacer, stretch=1) top.add_widget(sw, stretch=0) btns = Widgets.HBox() 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=0)