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): """ 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): 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("Blink") captions = (("Interval:", 'label', 'Interval', 'entry', "Start Blink", 'button', "Stop Blink", 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w = b b.interval.set_text(str(self.interval)) b.interval.add_callback('activated', lambda w: self._set_interval_cb()) b.interval.set_tooltip("Interval in seconds between changing images") b.start_blink.add_callback('activated', lambda w: self._start_blink_cb()) b.stop_blink.add_callback('activated', lambda w: self._stop_blink_cb()) fr.set_widget(w) vbox.add_widget(fr, stretch=0) spacer = Widgets.Label('') vbox.add_widget(spacer, stretch=1) top.add_widget(sw, stretch=1) btns = Widgets.HBox() btns.set_spacing(3) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
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): 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): 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, 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 build_gui(self, container): vbox, sw, orientation = Widgets.get_oriented_box(container, scrolled=False) vbox.set_border_width(4) vbox.set_spacing(2) width, height = 300, 300 # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = CanvasTypes.ImageViewCanvas(logger=self.logger) zi = CanvasTypes.ImageViewCanvas(logger=None) zi.set_desired_size(width, height) zi.enable_autozoom('off') zi.enable_autocuts('off') #zi.set_scale_limits(0.001, 1000.0) zi.zoom_to(self.default_zoom, redraw=False) settings = zi.get_settings() settings.getSetting('zoomlevel').add_callback('set', self.zoomset, zi) zi.set_bg(0.4, 0.4, 0.4) zi.show_pan_mark(True, redraw=False) # for debugging zi.set_name('zoomimage') self.zoomimage = zi bd = zi.get_bindings() bd.enable_zoom(False) bd.enable_pan(False) bd.enable_cmap(False) iw = Widgets.wrap(zi.get_widget()) vpaned = Widgets.Splitter(orientation=orientation) vpaned.add_widget(iw) vpaned.add_widget(Widgets.Label('')) vbox.add_widget(vpaned, stretch=1) vbox2 = Widgets.VBox() captions = (("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'), ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) vbox2.add_widget(w, stretch=0) self.w.zoom_radius.set_limits(1, 300, incr_value=1) self.w.zoom_radius.set_value(self.zoom_radius) self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb) self.w.zoom_radius.set_tracking(True) self.w.zoom_amount.set_limits(-20, 30, incr_value=1) self.w.zoom_amount.set_value(self.zoom_amount) self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb) self.w.zoom_amount.set_tracking(True) captions = (("Zoom:", 'label', 'Zoom', 'label'), ("Relative Zoom", 'checkbutton'), ("Refresh Interval", 'label', 'Refresh Interval', 'spinbutton'), ("Defaults", 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(zi.get_scale())) b.relative_zoom.set_state(not self.t_abszoom) b.relative_zoom.add_callback("activated", self.set_absrel_cb) b.defaults.add_callback("activated", lambda w: self.set_defaults()) b.refresh_interval.set_limits(0, 200, incr_value=1) b.refresh_interval.set_value(int(self.refresh_interval * 1000)) b.refresh_interval.add_callback('value-changed', self.set_refresh_cb) row = Widgets.HBox() row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(row, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) vbox.add_widget(vbox2, stretch=0) vbox.add_widget(Widgets.Label(''), stretch=1) container.add_widget(sw, stretch=1)
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 self.msgFont = self.fv.getFont("sansFont", 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(self.msgFont) self.tw = tw db_driver = Widgets.TextArea(wrap=True, editable=True) self.db_driver = db_driver db_name = Widgets.TextArea(wrap=True, editable=True) self.db_name = db_name db_user = Widgets.TextArea(wrap=True, editable=True) self.db_user = db_user db_pass = Widgets.TextArea(wrap=True, editable=True) self.db_pass = db_pass db_driver_label = Widgets.Label(text="Driver Name") self.db_driver_label = db_driver_label db_name_label = Widgets.Label(text="Database Name") self.db_name_label = db_name_label db_user_label = Widgets.Label(text="User Name") self.db_user_label = db_user_label db_pass_label = Widgets.Label(text="Password") self.db_pass_label = db_pass_label connect_button = Widgets.Button(text="Connect") self.connect_button = connect_button connect_button.add_callback('activated', lambda w: self.connectDB()) populate_button = Widgets.Button(text="Populate Database") self.populate_button = populate_button populate_button.add_callback('activated', lambda w: self.add_file_to_db()) status_label = Widgets.Label(text="Status:") self.status_label = status_label default_wavelength_label = Widgets.Label(text="Default Wavelength") self.default_wavelength_label = default_wavelength_label default_wavelength = Widgets.ComboBox() default_wavelength.insert_alpha('angstrom') default_wavelength.append_text('nm') self.default_wavelength = default_wavelength set_default_box = Widgets.CheckBox("Set Database as default") self.set_default_box = set_default_box view_button = Widgets.Button(text="View Database") self.view_button = view_button view_button.add_callback('activated', lambda w: self.view_database()) add_button = Widgets.Button(text="Add file to Database") self.add_button = add_button add_button.add_callback('activated', lambda w: self.add_file()) open_button = Widgets.Button(text="Open Database") self.open_button = open_button open_button.add_callback('activated', lambda w: self.open_sqlite_database()) commit_button = Widgets.Button(text="Commit changes to Database") self.commit_button = commit_button commit_button.add_callback('activated', lambda w: self.commit_database()) # 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(db_driver_label) vbox2.add_widget(db_driver) vbox2.add_widget(db_name_label) vbox2.add_widget(db_name) vbox2.add_widget(db_user_label) vbox2.add_widget(db_user) vbox2.add_widget(db_pass_label) vbox2.add_widget(db_pass) vbox2.add_widget(default_wavelength_label) vbox2.add_widget(default_wavelength) vbox2.add_widget(set_default_box) vbox2.add_widget(connect_button) vbox2.add_widget(populate_button) vbox2.add_widget(view_button) vbox2.add_widget(add_button) vbox2.add_widget(open_button) vbox2.add_widget(commit_button) vbox2.add_widget(status_label) 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): 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_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): 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): """ This method is called when the plugin is invoked. It builds the GUI used by the plugin into the widget layout passed as ``container``. This method could be called several times if the plugin is opened and closed. The method may be omitted if there is no GUI for the plugin. This specific example uses the GUI widget set agnostic wrappers to build the GUI, but you can also just as easily use explicit toolkit calls here if you only want to support one widget set. """ top = Widgets.VBox() top.set_border_width(4) # this is a little trick for making plugins that work either in # a vertical or horizontal orientation. It returns a box container, # a scroll widget and an orientation ('vertical', 'horizontal') vbox, sw, orientation = Widgets.get_oriented_box(container) vbox.set_border_width(4) vbox.set_spacing(2) # Take a text widget to show some instructions self.msgFont = self.fv.getFont("sansFont", 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(self.msgFont) self.tw = tw # Database Parameters db_parameters_frame = self.add_db_parameters_to_gui() vbox.add_widget(db_parameters_frame, stretch=0) # Database Default Values db_default_values_frame = self.add_db_default_values_to_gui() vbox.add_widget(db_default_values_frame, stretch=0) # Adding Buttons connect_db_button = Widgets.Button(text="Connect") self.connect_db_button = connect_db_button connect_db_button.add_callback("activated", lambda w: self.connect_db()) view_db_button = Widgets.Button(text="View Database") self.view_db_button = view_db_button view_db_button.add_callback("activated", lambda w: self.view_database()) add_file_to_db_button = Widgets.Button(text="Add file to Database") self.add_file_to_db_button = add_file_to_db_button add_file_to_db_button.add_callback("activated", lambda w: self.add_file()) open_db_button = Widgets.Button(text="Open Database") self.open_db_button = open_db_button open_db_button.add_callback("activated", lambda w: self.open_sqlite_database()) commit_db_button = Widgets.Button(text="Commit changes to Database") self.commit_db_button = commit_db_button commit_db_button.add_callback("activated", lambda w: self.commit_database()) vbox.add_widget(connect_db_button) vbox.add_widget(view_db_button) vbox.add_widget(add_file_to_db_button) vbox.add_widget(open_db_button) vbox.add_widget(commit_db_button) # Frame for instructions and add the text widget with another # blank widget to stretch as needed to fill emp fr = Widgets.Frame("Status") vbox2 = Widgets.VBox() vbox2.add_widget(tw) vbox2.add_widget(Widgets.Label(""), stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) # Add a spacer to stretch the rest of the way to the end of the # plugin space spacer = Widgets.Label("") vbox.add_widget(spacer, stretch=1) # scroll bars will allow lots of content to be accessed top.add_widget(sw, stretch=1) # A button box that is always visible at the bottom btns = Widgets.HBox() btns.set_spacing(3) # Add a close button for the convenience of the user btn = Widgets.Button("Close") btn.add_callback("activated", lambda w: self.close()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(""), stretch=1) top.add_widget(btns, stretch=0) # Add our GUI to the container container.add_widget(top, stretch=1)
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(0) vbox, sw, orientation = Widgets.get_oriented_box(container) self.orientation = orientation #vbox.set_border_width(2) vbox.set_spacing(2) tb = Widgets.Toolbar(orientation=orientation) for tup in ( #("Load", 'button', 'fits_open_48', "Open an image file", #None), ("FlipX", 'toggle', 'flipx_48', "Flip image in X axis", self.flipx_cb), ("FlipY", 'toggle', 'flipy_48', "Flip image in Y axis", self.flipy_cb), ("SwapXY", 'toggle', 'swapxy_48', "Swap X and Y axes", self.swapxy_cb), ("---",), ("Rot90", 'button', 'rot90ccw_48', "Rotate image 90 deg", self.rot90_cb), ("RotN90", 'button', 'rot90cw_48', "Rotate image -90 deg", self.rotn90_cb), ("OrientRH", 'button', 'orient_nw_48', "Orient image N=Up E=Right", self.orient_rh_cb), ("OrientLH", 'button', 'orient_ne_48', "Orient image N=Up E=Left", self.orient_lh_cb), ("---",), ("Prev", 'button', 'prev_48', "Go to previous image in channel", lambda w: self.fv.prev_img()), ("Next", 'button', 'next_48', "Go to next image in channel", lambda w: self.fv.next_img()), ("---",), ("Zoom In", 'button', 'zoom_in_48', "Zoom in", lambda w: self.fv.zoom_in()), ("Zoom Out", 'button', 'zoom_out_48', "Zoom out", lambda w: self.fv.zoom_out()), ("Zoom Fit", 'button', 'zoom_fit_48', "Zoom to fit window size", lambda w: self.fv.zoom_fit()), ("Zoom 1:1", 'button', 'zoom_100_48', "Zoom to 100% (1:1)", lambda w: self.fv.zoom_1_to_1()), ("---",), ("Pan", 'toggle', 'pan_48', "Pan with left, zoom with right", lambda w, tf: self.mode_cb(tf, 'pan')), ("FreePan", 'toggle', 'hand_48', "Free Panning", lambda w, tf: self.mode_cb(tf, 'freepan')), ("Rotate", 'toggle', 'rotate_48', "Interactive rotation", lambda w, tf: self.mode_cb(tf, 'rotate')), ("Cuts", 'toggle', 'cuts_48', "Left/right sets hi cut, up/down sets lo cut", lambda w, tf: self.mode_cb(tf, 'cuts')), ("Contrast", 'toggle', 'contrast_48', "Contrast/bias with left/right/up/down", lambda w, tf: self.mode_cb(tf, 'contrast')), ("ModeLock", 'toggle', 'lock_48', "Modes are oneshot or locked", self.set_locked_cb), ("---",), ("Center", 'button', 'center_image_48', "Center image", self.center_image_cb), ("Restore", 'button', 'reset_rotation_48', "Reset all transformations and rotations", self.reset_all_transforms_cb), ("AutoLevels", 'button', 'auto_cuts_48', "Auto cut levels", self.auto_levels_cb), ("ResetContrast", 'button', 'reset_contrast_48', "Reset contrast", self.reset_contrast_cb), ("---",), ("Preferences", 'button', 'settings_48', "Set channel preferences", lambda w: self.start_plugin_cb('Preferences')), ("FBrowser", 'button', 'open_48', "Open file", lambda w: self.start_plugin_cb('FBrowser')), ## ("Histogram", 'button', 'open_48', "Histogram and cut levels", ## lambda w: self.start_plugin_cb('Histogram')), #("Quit", 'button', 'exit_48', "Quit the program"), ): name = tup[0] if name == '---': tb.add_separator() continue #btn = self.fv.make_button(*tup[:4]) iconpath = os.path.join(self.fv.iconpath, "%s.png" % (tup[2])) btn = tb.add_action(None, toggle=(tup[1]=='toggle'), iconpath=iconpath) if tup[3]: btn.set_tooltip(tup[3]) if tup[4]: btn.add_callback('activated', tup[4]) # add to our widget dict self.w[Widgets.name_mangle(name, pfx='btn_')] = btn # add widget to toolbar #tb.add_widget(btn) # stretcher #tb.add_widget(Widgets.Label(''), stretch=1) #sw.set_widget(tb) #top.add_widget(sw, stretch=1) container.add_widget(tb, 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('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)
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'), ] 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) 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): 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): vbox, sw, orientation = Widgets.get_oriented_box(container, scrolled=False) vbox.set_border_width(4) vbox.set_spacing(2) width, height = 300, 300 # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = CanvasTypes.ImageViewCanvas(logger=self.logger) zi = CanvasTypes.ImageViewCanvas(logger=None) zi.set_desired_size(width, height) zi.enable_autozoom('off') zi.enable_autocuts('off') #zi.set_scale_limits(0.001, 1000.0) zi.zoom_to(self.default_zoom, redraw=False) settings = zi.get_settings() settings.getSetting('zoomlevel').add_callback('set', self.zoomset, zi) zi.set_bg(0.4, 0.4, 0.4) zi.show_pan_mark(True, redraw=False) # for debugging zi.set_name('zoomimage') self.zoomimage = zi bd = zi.get_bindings() bd.enable_zoom(False) bd.enable_pan(False) bd.enable_cmap(False) iw = Widgets.wrap(zi.get_widget()) vpaned = Widgets.Splitter(orientation=orientation) vpaned.add_widget(iw) vpaned.add_widget(Widgets.Label('')) vbox.add_widget(vpaned, stretch=1) vbox2 = Widgets.VBox() captions = ( ("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'), ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) vbox2.add_widget(w, stretch=0) self.w.zoom_radius.set_limits(1, 300, incr_value=1) self.w.zoom_radius.set_value(self.zoom_radius) self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb) self.w.zoom_radius.set_tracking(True) self.w.zoom_amount.set_limits(-20, 30, incr_value=1) self.w.zoom_amount.set_value(self.zoom_amount) self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb) self.w.zoom_amount.set_tracking(True) captions = ( ("Zoom:", 'label', 'Zoom', 'label'), ("Relative Zoom", 'checkbutton'), ("Refresh Interval", 'label', 'Refresh Interval', 'spinbutton'), ("Defaults", 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(zi.get_scale())) b.relative_zoom.set_state(not self.t_abszoom) b.relative_zoom.add_callback("activated", self.set_absrel_cb) b.defaults.add_callback("activated", lambda w: self.set_defaults()) b.refresh_interval.set_limits(0, 200, incr_value=1) b.refresh_interval.set_value(int(self.refresh_interval * 1000)) b.refresh_interval.add_callback('value-changed', self.set_refresh_cb) row = Widgets.HBox() row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(row, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) vbox.add_widget(vbox2, stretch=0) vbox.add_widget(Widgets.Label(''), stretch=1) container.add_widget(sw, 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_margins(4, 4, 4, 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") 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=4, dpi=100) ax = self.plot.add_axis() ax.grid(False) w = Widgets.wrap(self.plot.get_widget()) 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): 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) 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 is not 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 is not 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) 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): 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 (data cubes)") 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) b.next.set_enabled(False) b.prev.set_enabled(False) b.first.set_enabled(False) b.last.set_enabled(False) b.play.set_enabled(False) b.stop.set_enabled(False) b.interval.set_enabled(False) 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)
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) self.orientation = orientation #vbox.set_border_width(4) vbox.set_spacing(2) # COLOR DISTRIBUTION OPTIONS fr = Widgets.Frame("Color Distribution") captions = (('Algorithm:', 'label', 'Algorithm', 'combobox'), #('Table Size:', 'label', 'Table Size', 'entry'), ('Dist Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) self.w.calg_choice = b.algorithm #self.w.table_size = b.table_size b.algorithm.set_tooltip("Choose a color distribution algorithm") #b.table_size.set_tooltip("Set size of the distribution hash table") b.dist_defaults.set_tooltip("Restore color distribution defaults") b.dist_defaults.add_callback('activated', lambda w: self.set_default_distmaps()) combobox = b.algorithm options = [] index = 0 for name in self.calg_names: options.append(name) combobox.append_text(name) index += 1 index = self.calg_names.index(self.t_.get('color_algorithm', "linear")) combobox.set_index(index) combobox.add_callback('activated', self.set_calg_cb) ## entry = b.table_size ## entry.set_text(str(self.t_.get('color_hashsize', 65535))) ## entry.add_callback('activated', self.set_tablesize_cb) fr.set_widget(w) vbox.add_widget(fr) # COLOR MAPPING OPTIONS fr = Widgets.Frame("Color Mapping") captions = (('Colormap:', 'label', 'Colormap', 'combobox'), ('Intensity:', 'label', 'Intensity', 'combobox'), ('Color Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) self.w.cmap_choice = b.colormap self.w.imap_choice = b.intensity b.color_defaults.add_callback('activated', lambda w: self.set_default_cmaps()) b.colormap.set_tooltip("Choose a color map for this image") b.intensity.set_tooltip("Choose an intensity map for this image") b.color_defaults.set_tooltip("Restore default color and intensity maps") fr.set_widget(w) vbox.add_widget(fr) combobox = b.colormap options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.append_text(name) index += 1 cmap_name = self.t_.get('color_map', "gray") try: index = self.cmap_names.index(cmap_name) except Exception: index = self.cmap_names.index('gray') combobox.set_index(index) combobox.add_callback('activated', self.set_cmap_cb) combobox = b.intensity options = [] index = 0 for name in self.imap_names: options.append(name) combobox.append_text(name) index += 1 imap_name = self.t_.get('intensity_map', "ramp") try: index = self.imap_names.index(imap_name) except Exception: index = self.imap_names.index('ramp') combobox.set_index(index) combobox.add_callback('activated', self.set_imap_cb) # AUTOCUTS OPTIONS fr = Widgets.Frame("Auto Cuts") vbox2 = Widgets.VBox() fr.set_widget(vbox2) captions = (('Auto Method:', 'label', 'Auto Method', 'combobox'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) # Setup auto cuts method choice combobox = b.auto_method index = 0 method = self.t_.get('autocut_method', "histogram") for name in self.autocut_methods: combobox.append_text(name) index += 1 index = self.autocut_methods.index(method) combobox.set_index(index) combobox.add_callback('activated', self.set_autocut_method_cb) b.auto_method.set_tooltip("Choose algorithm for auto levels") vbox2.add_widget(w, stretch=0) self.w.acvbox = Widgets.VBox() vbox2.add_widget(self.w.acvbox, stretch=1) vbox.add_widget(fr, stretch=0) # TRANSFORM OPTIONS fr = Widgets.Frame("Transform") captions = (('Flip X', 'checkbutton', 'Flip Y', 'checkbutton', 'Swap XY', 'checkbutton'), ('Rotate:', 'label', 'Rotate', 'spinfloat'), ('Restore', 'button'),) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) for name in ('flip_x', 'flip_y', 'swap_xy'): btn = b[name] btn.set_state(self.t_.get(name, False)) btn.add_callback('activated', self.set_transforms_cb) b.flip_x.set_tooltip("Flip the image around the X axis") b.flip_y.set_tooltip("Flip the image around the Y axis") b.swap_xy.set_tooltip("Swap the X and Y axes in the image") b.rotate.set_tooltip("Rotate the image around the pan position") b.restore.set_tooltip("Clear any transforms and center image") b.restore.add_callback('activated', self.restore_cb) b.rotate.set_limits(0.00, 359.99999999, incr_value=10.0) b.rotate.set_value(0.00) b.rotate.set_decimals(8) b.rotate.add_callback('value-changed', self.rotate_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) # WCS OPTIONS fr = Widgets.Frame("WCS") captions = (('WCS Coords:', 'label', 'WCS Coords', 'combobox'), ('WCS Display:', 'label', 'WCS Display', 'combobox'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.wcs_coords.set_tooltip("Set WCS coordinate system") b.wcs_display.set_tooltip("Set WCS display format") # Setup WCS coords method choice combobox = b.wcs_coords index = 0 for name in wcsmod.coord_types: combobox.append_text(name) index += 1 method = self.t_.get('wcs_coords', "") try: index = wcsmod.coord_types.index(method) combobox.set_index(index) except ValueError: pass combobox.add_callback('activated', self.set_wcs_params_cb) # Setup WCS display format method choice combobox = b.wcs_display index = 0 for name in wcsmod.display_types: combobox.append_text(name) index += 1 method = self.t_.get('wcs_display', "sexagesimal") try: index = wcsmod.display_types.index(method) combobox.set_index(index) except ValueError: pass combobox.add_callback('activated', self.set_wcs_params_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) # ZOOM OPTIONS fr = Widgets.Frame("Zoom") captions = (('Zoom Alg:', 'label', 'Zoom Alg', 'combobox'), ('Zoom Rate:', 'label', 'Zoom Rate', 'spinfloat'), ('Stretch XY:', 'label', 'Stretch XY', 'combobox'), ('Stretch Factor:', 'label', 'Stretch Factor', 'spinfloat'), ('Scale X:', 'label', 'Scale X', 'entry'), ('Scale Y:', 'label', 'Scale Y', 'entry'), ('Scale Min:', 'label', 'Scale Min', 'spinfloat'), ('Scale Max:', 'label', 'Scale Max', 'spinfloat'), ('Zoom Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) index = 0 for name in self.zoomalg_names: b.zoom_alg.append_text(name.capitalize()) index += 1 zoomalg = self.t_.get('zoom_algorithm', "step") index = self.zoomalg_names.index(zoomalg) b.zoom_alg.set_index(index) b.zoom_alg.set_tooltip("Choose Zoom algorithm") b.zoom_alg.add_callback('activated', self.set_zoomalg_cb) index = 0 for name in ('X', 'Y'): b.stretch_xy.append_text(name) index += 1 b.stretch_xy.set_index(0) b.stretch_xy.set_tooltip("Stretch pixels in X or Y") b.stretch_xy.add_callback('activated', self.set_stretch_cb) b.stretch_factor.set_limits(1.0, 10.0, incr_value=0.10) b.stretch_factor.set_value(1.0) b.stretch_factor.set_decimals(8) b.stretch_factor.add_callback('value-changed', self.set_stretch_cb) b.stretch_factor.set_tooltip("Length of pixel relative to 1 on other side") b.stretch_factor.set_enabled(zoomalg != 'step') zoomrate = self.t_.get('zoom_rate', math.sqrt(2.0)) b.zoom_rate.set_limits(1.1, 3.0, incr_value=0.1) b.zoom_rate.set_value(zoomrate) b.zoom_rate.set_decimals(8) b.zoom_rate.set_enabled(zoomalg != 'step') b.zoom_rate.set_tooltip("Step rate of increase/decrease per zoom level") b.zoom_rate.add_callback('value-changed', self.set_zoomrate_cb) b.zoom_defaults.add_callback('activated', self.set_zoom_defaults_cb) scale_x, scale_y = self.fitsimage.get_scale_xy() b.scale_x.set_tooltip("Set the scale in X axis") b.scale_x.set_text(str(scale_x)) b.scale_x.add_callback('activated', self.set_scale_cb) b.scale_y.set_tooltip("Set the scale in Y axis") b.scale_y.set_text(str(scale_y)) b.scale_y.add_callback('activated', self.set_scale_cb) scale_min, scale_max = self.t_['scale_min'], self.t_['scale_max'] b.scale_min.set_limits(0.00001, 1.0, incr_value=1.0) b.scale_min.set_value(scale_min) b.scale_min.set_decimals(8) b.scale_min.add_callback('value-changed', self.set_scale_limit_cb) b.scale_min.set_tooltip("Set the minimum allowed scale in any axis") b.scale_max.set_limits(1.0, 10000.0, incr_value=1.0) b.scale_max.set_value(scale_max) b.scale_max.set_decimals(8) b.scale_max.add_callback('value-changed', self.set_scale_limit_cb) b.scale_min.set_tooltip("Set the maximum allowed scale in any axis") fr.set_widget(w) vbox.add_widget(fr, stretch=0) # PAN OPTIONS fr = Widgets.Frame("Panning") captions = (('Pan X:', 'label', 'Pan X', 'entry', 'WCS sexagesimal', 'checkbutton'), ('Pan Y:', 'label', 'Pan Y', 'entry', 'Apply Pan', 'button'), ('Pan Coord:', 'label', 'Pan Coord', 'combobox'), ('Center Image', 'button', 'Mark Center', 'checkbutton'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) pan_x, pan_y = self.fitsimage.get_pan() coord_offset = self.fv.settings.get('pixel_coords_offset', 0.0) b.pan_x.set_tooltip("Coordinate for the pan position in X axis") b.pan_x.set_text(str(pan_x + coord_offset)) #b.pan_x.add_callback('activated', self.set_pan_cb) b.pan_y.set_tooltip("Coordinate for the pan position in Y axis") b.pan_y.set_text(str(pan_y + coord_offset)) #b.pan_y.add_callback('activated', self.set_pan_cb) b.apply_pan.add_callback('activated', self.set_pan_cb) b.apply_pan.set_tooltip("Set the pan position") b.wcs_sexagesimal.set_tooltip("Display pan position in sexagesimal") index = 0 for name in self.pancoord_options: b.pan_coord.append_text(name) index += 1 pan_coord = self.t_.get('pan_coord', "data") index = self.pancoord_options.index(pan_coord) b.pan_coord.set_index(index) b.pan_coord.set_tooltip("Pan coordinates type") b.pan_coord.add_callback('activated', self.set_pan_coord_cb) b.center_image.set_tooltip("Set the pan position to center of the image") b.center_image.add_callback('activated', self.center_image_cb) b.mark_center.set_tooltip("Mark the center (pan locator)") b.mark_center.add_callback('activated', self.set_misc_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("New Images") captions = (('Cut New:', 'label', 'Cut New', 'combobox'), ('Zoom New:', 'label', 'Zoom New', 'combobox'), ('Center New:', 'label', 'Center New', 'combobox'), ('Follow New', 'checkbutton', 'Raise New', 'checkbutton'), ('Create thumbnail', 'checkbutton'), ('Num Images:', 'label', 'Num Images', 'entry'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) combobox = b.cut_new index = 0 for name in self.autocut_options: combobox.append_text(name) index += 1 option = self.t_.get('autocuts', "off") index = self.autocut_options.index(option) combobox.set_index(index) combobox.add_callback('activated', self.set_autocuts_cb) b.cut_new.set_tooltip("Automatically set cut levels for new images") combobox = b.zoom_new index = 0 for name in self.autozoom_options: combobox.append_text(name) index += 1 option = self.t_.get('autozoom', "off") index = self.autozoom_options.index(option) combobox.set_index(index) combobox.add_callback('activated', self.set_autozoom_cb) b.zoom_new.set_tooltip("Automatically fit new images to window") combobox = b.center_new index = 0 for name in self.autocenter_options: combobox.append_text(name) index += 1 option = self.t_.get('autocenter', "off") # Hack to convert old values that used to be T/F if isinstance(option, bool): choice = { True: 'on', False: 'off' } option = choice[option] index = self.autocenter_options.index(option) combobox.set_index(index) combobox.add_callback('activated', self.set_autocenter_cb) b.center_new.set_tooltip("Automatically center new images in window") b.follow_new.set_tooltip("View new images as they arrive") b.raise_new.set_tooltip("Raise and focus tab for new images") b.create_thumbnail.set_tooltip("Create thumbnail for new images") b.num_images.set_tooltip("Maximum number of in memory images in channel (0==unlimited)") self.w.follow_new.set_state(True) self.w.follow_new.add_callback('activated', self.set_chprefs_cb) self.w.raise_new.set_state(True) self.w.raise_new.add_callback('activated', self.set_chprefs_cb) self.w.create_thumbnail.set_state(True) self.w.create_thumbnail.add_callback('activated', self.set_chprefs_cb) self.w.num_images.set_text('0') self.w.num_images.add_callback('activated', self.set_buffer_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) top.add_widget(sw, stretch=1) btns = Widgets.HBox() btns.set_spacing(4) btns.set_border_width(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Save Settings") btn.add_callback('activated', lambda w: self.save_preferences()) btns.add_widget(btn) 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(0) vbox, sw, orientation = Widgets.get_oriented_box(container) self.orientation = orientation #vbox.set_border_width(2) vbox.set_spacing(2) tb = Widgets.Toolbar(orientation=orientation) for tup in ( #("Load", 'button', 'fits_open_48', "Open an image file", #None), ("FlipX", 'toggle', 'flipx_48', "Flip image in X axis", self.flipx_cb), ("FlipY", 'toggle', 'flipy_48', "Flip image in Y axis", self.flipy_cb), ("SwapXY", 'toggle', 'swapxy_48', "Swap X and Y axes", self.swapxy_cb), ("---", ), ("Rot90", 'button', 'rot90ccw_48', "Rotate image 90 deg", self.rot90_cb), ("RotN90", 'button', 'rot90cw_48', "Rotate image -90 deg", self.rotn90_cb), ("OrientRH", 'button', 'orient_nw_48', "Orient image N=Up E=Right", self.orient_rh_cb), ("OrientLH", 'button', 'orient_ne_48', "Orient image N=Up E=Left", self.orient_lh_cb), ("---", ), ("Prev", 'button', 'prev_48', "Go to previous image in channel", lambda w: self.fv.prev_img()), ("Next", 'button', 'next_48', "Go to next image in channel", lambda w: self.fv.next_img()), ("---", ), ("Zoom In", 'button', 'zoom_in_48', "Zoom in", lambda w: self.fv.zoom_in()), ("Zoom Out", 'button', 'zoom_out_48', "Zoom out", lambda w: self.fv.zoom_out()), ("Zoom Fit", 'button', 'zoom_fit_48', "Zoom to fit window size", lambda w: self.fv.zoom_fit()), ("Zoom 1:1", 'button', 'zoom_100_48', "Zoom to 100% (1:1)", lambda w: self.fv.zoom_1_to_1()), ("---", ), ("Pan", 'toggle', 'pan_48', "Pan with left, zoom with right", lambda w, tf: self.mode_cb(tf, 'pan')), ("FreePan", 'toggle', 'hand_48', "Free Panning", lambda w, tf: self.mode_cb(tf, 'freepan')), ("Rotate", 'toggle', 'rotate_48', "Interactive rotation", lambda w, tf: self.mode_cb(tf, 'rotate')), ("Cuts", 'toggle', 'cuts_48', "Left/right sets hi cut, up/down sets lo cut", lambda w, tf: self.mode_cb(tf, 'cuts')), ("Contrast", 'toggle', 'contrast_48', "Contrast/bias with left/right/up/down", lambda w, tf: self.mode_cb(tf, 'contrast')), ("ModeLock", 'toggle', 'lock_48', "Modes are oneshot or locked", self.set_locked_cb), ("---", ), ("Center", 'button', 'center_image_48', "Center image", self.center_image_cb), ("Restore", 'button', 'reset_rotation_48', "Reset all transformations and rotations", self.reset_all_transforms_cb), ("AutoLevels", 'button', 'auto_cuts_48', "Auto cut levels", self.auto_levels_cb), ("ResetContrast", 'button', 'reset_contrast_48', "Reset contrast", self.reset_contrast_cb), ("---", ), ("Preferences", 'button', 'settings_48', "Set channel preferences", lambda w: self.start_plugin_cb('Preferences')), ("FBrowser", 'button', 'open_48', "Open file", lambda w: self.start_plugin_cb('FBrowser')), ## ("Histogram", 'button', 'open_48', "Histogram and cut levels", ## lambda w: self.start_plugin_cb('Histogram')), #("Quit", 'button', 'exit_48', "Quit the program"), ): name = tup[0] if name == '---': tb.add_separator() continue #btn = self.fv.make_button(*tup[:4]) iconpath = os.path.join(self.fv.iconpath, "%s.png" % (tup[2])) btn = tb.add_action(None, toggle=(tup[1] == 'toggle'), iconpath=iconpath) if tup[3]: btn.set_tooltip(tup[3]) if tup[4]: btn.add_callback('activated', tup[4]) # add to our widget dict self.w[Widgets.name_mangle(name, pfx='btn_')] = btn # add widget to toolbar #tb.add_widget(btn) # stretcher #tb.add_widget(Widgets.Label(''), stretch=1) #sw.set_widget(tb) #top.add_widget(sw, stretch=1) container.add_widget(tb, 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 build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container) self.orientation = orientation #vbox.set_border_width(4) vbox.set_spacing(2) # COLOR DISTRIBUTION OPTIONS fr = Widgets.Frame("Color Distribution") captions = (('Algorithm:', 'label', 'Algorithm', 'combobox'), #('Table Size:', 'label', 'Table Size', 'entry'), ('Dist Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) self.w.calg_choice = b.algorithm #self.w.table_size = b.table_size b.algorithm.set_tooltip("Choose a color distribution algorithm") #b.table_size.set_tooltip("Set size of the distribution hash table") b.dist_defaults.set_tooltip("Restore color distribution defaults") b.dist_defaults.add_callback('activated', lambda w: self.set_default_distmaps()) combobox = b.algorithm options = [] index = 0 for name in self.calg_names: options.append(name) combobox.append_text(name) index += 1 index = self.calg_names.index(self.t_.get('color_algorithm', "linear")) combobox.set_index(index) combobox.add_callback('activated', self.set_calg_cb) ## entry = b.table_size ## entry.set_text(str(self.t_.get('color_hashsize', 65535))) ## entry.add_callback('activated', self.set_tablesize_cb) fr.set_widget(w) vbox.add_widget(fr) # COLOR MAPPING OPTIONS fr = Widgets.Frame("Color Mapping") captions = (('Colormap:', 'label', 'Colormap', 'combobox'), ('Intensity:', 'label', 'Intensity', 'combobox'), ('Color Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) self.w.cmap_choice = b.colormap self.w.imap_choice = b.intensity b.color_defaults.add_callback('activated', lambda w: self.set_default_cmaps()) b.colormap.set_tooltip("Choose a color map for this image") b.intensity.set_tooltip("Choose an intensity map for this image") b.color_defaults.set_tooltip("Restore default color and intensity maps") fr.set_widget(w) vbox.add_widget(fr) combobox = b.colormap options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.append_text(name) index += 1 cmap_name = self.t_.get('color_map', "ramp") try: index = self.cmap_names.index(cmap_name) except Exception: index = self.cmap_names.index('ramp') combobox.set_index(index) combobox.add_callback('activated', self.set_cmap_cb) combobox = b.intensity options = [] index = 0 for name in self.imap_names: options.append(name) combobox.append_text(name) index += 1 imap_name = self.t_.get('intensity_map', "ramp") try: index = self.imap_names.index(imap_name) except Exception: index = self.imap_names.index('ramp') combobox.set_index(index) combobox.add_callback('activated', self.set_imap_cb) # AUTOCUTS OPTIONS fr = Widgets.Frame("Auto Cuts") vbox2 = Widgets.VBox() fr.set_widget(vbox2) captions = (('Auto Method:', 'label', 'Auto Method', 'combobox'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) # Setup auto cuts method choice combobox = b.auto_method index = 0 method = self.t_.get('autocut_method', "histogram") for name in self.autocut_methods: combobox.append_text(name) index += 1 index = self.autocut_methods.index(method) combobox.set_index(index) combobox.add_callback('activated', self.set_autocut_method_cb) b.auto_method.set_tooltip("Choose algorithm for auto levels") vbox2.add_widget(w, stretch=0) self.w.acvbox = Widgets.VBox() vbox2.add_widget(self.w.acvbox, stretch=1) vbox.add_widget(fr, stretch=0) # TRANSFORM OPTIONS fr = Widgets.Frame("Transform") captions = (('Flip X', 'checkbutton', 'Flip Y', 'checkbutton', 'Swap XY', 'checkbutton'), ('Rotate:', 'label', 'Rotate', 'spinfloat'), ('Restore', 'button'),) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) for name in ('flip_x', 'flip_y', 'swap_xy'): btn = b[name] btn.set_state(self.t_.get(name, False)) btn.add_callback('activated', self.set_transforms_cb) b.flip_x.set_tooltip("Flip the image around the X axis") b.flip_y.set_tooltip("Flip the image around the Y axis") b.swap_xy.set_tooltip("Swap the X and Y axes in the image") b.rotate.set_tooltip("Rotate the image around the pan position") b.restore.set_tooltip("Clear any transforms and center image") b.restore.add_callback('activated', self.restore_cb) b.rotate.set_limits(0.00, 359.99999999, incr_value=10.0) b.rotate.set_value(0.00) b.rotate.set_decimals(8) b.rotate.add_callback('value-changed', self.rotate_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) # WCS OPTIONS fr = Widgets.Frame("WCS") captions = (('WCS Coords:', 'label', 'WCS Coords', 'combobox'), ('WCS Display:', 'label', 'WCS Display', 'combobox'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.wcs_coords.set_tooltip("Set WCS coordinate system") b.wcs_display.set_tooltip("Set WCS display format") # Setup WCS coords method choice combobox = b.wcs_coords index = 0 for name in wcsmod.coord_types: combobox.append_text(name) index += 1 method = self.t_.get('wcs_coords', "") try: index = wcsmod.coord_types.index(method) combobox.set_index(index) except ValueError: pass combobox.add_callback('activated', self.set_wcs_params_cb) # Setup WCS display format method choice combobox = b.wcs_display index = 0 for name in wcsmod.display_types: combobox.append_text(name) index += 1 method = self.t_.get('wcs_display', "sexagesimal") try: index = wcsmod.display_types.index(method) combobox.set_index(index) except ValueError: pass combobox.add_callback('activated', self.set_wcs_params_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) # ZOOM OPTIONS fr = Widgets.Frame("Zoom") captions = (('Zoom Alg:', 'label', 'Zoom Alg', 'combobox'), ('Zoom Rate:', 'label', 'Zoom Rate', 'spinfloat'), ('Stretch XY:', 'label', 'Stretch XY', 'combobox'), ('Stretch Factor:', 'label', 'Stretch Factor', 'spinfloat'), ('Scale X:', 'label', 'Scale X', 'entry'), ('Scale Y:', 'label', 'Scale Y', 'entry'), ('Scale Min:', 'label', 'Scale Min', 'spinfloat'), ('Scale Max:', 'label', 'Scale Max', 'spinfloat'), ('Zoom Defaults', 'button')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) index = 0 for name in self.zoomalg_names: b.zoom_alg.append_text(name.capitalize()) index += 1 zoomalg = self.t_.get('zoom_algorithm', "step") index = self.zoomalg_names.index(zoomalg) b.zoom_alg.set_index(index) b.zoom_alg.set_tooltip("Choose Zoom algorithm") b.zoom_alg.add_callback('activated', self.set_zoomalg_cb) index = 0 for name in ('X', 'Y'): b.stretch_xy.append_text(name) index += 1 b.stretch_xy.set_index(0) b.stretch_xy.set_tooltip("Stretch pixels in X or Y") b.stretch_xy.add_callback('activated', self.set_stretch_cb) b.stretch_factor.set_limits(1.0, 10.0, incr_value=0.10) b.stretch_factor.set_value(1.0) b.stretch_factor.set_decimals(8) b.stretch_factor.add_callback('value-changed', self.set_stretch_cb) b.stretch_factor.set_tooltip("Length of pixel relative to 1 on other side") b.stretch_factor.set_enabled(zoomalg != 'step') zoomrate = self.t_.get('zoom_rate', math.sqrt(2.0)) b.zoom_rate.set_limits(1.1, 3.0, incr_value=0.1) b.zoom_rate.set_value(zoomrate) b.zoom_rate.set_decimals(8) b.zoom_rate.set_enabled(zoomalg != 'step') b.zoom_rate.set_tooltip("Step rate of increase/decrease per zoom level") b.zoom_rate.add_callback('value-changed', self.set_zoomrate_cb) b.zoom_defaults.add_callback('activated', self.set_zoom_defaults_cb) scale_x, scale_y = self.fitsimage.get_scale_xy() b.scale_x.set_tooltip("Set the scale in X axis") b.scale_x.set_text(str(scale_x)) b.scale_x.add_callback('activated', self.set_scale_cb) b.scale_y.set_tooltip("Set the scale in Y axis") b.scale_y.set_text(str(scale_y)) b.scale_y.add_callback('activated', self.set_scale_cb) scale_min, scale_max = self.t_['scale_min'], self.t_['scale_max'] b.scale_min.set_limits(0.00001, 1.0, incr_value=1.0) b.scale_min.set_value(scale_min) b.scale_min.set_decimals(8) b.scale_min.add_callback('value-changed', self.set_scale_limit_cb) b.scale_min.set_tooltip("Set the minimum allowed scale in any axis") b.scale_max.set_limits(1.0, 10000.0, incr_value=1.0) b.scale_max.set_value(scale_max) b.scale_max.set_decimals(8) b.scale_max.add_callback('value-changed', self.set_scale_limit_cb) b.scale_min.set_tooltip("Set the maximum allowed scale in any axis") fr.set_widget(w) vbox.add_widget(fr, stretch=0) # PAN OPTIONS fr = Widgets.Frame("Panning") captions = (('Pan X:', 'label', 'Pan X', 'entry'), ('Pan Y:', 'label', 'Pan Y', 'entry'), ('Center Image', 'button'), ('Mark Center', 'checkbutton')) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) pan_x, pan_y = self.fitsimage.get_pan() b.pan_x.set_tooltip("Set the pan position in X axis") b.pan_x.set_text(str(pan_x+0.5)) b.pan_x.add_callback('activated', self.set_pan_cb) b.pan_y.set_tooltip("Set the pan position in Y axis") b.pan_y.set_text(str(pan_y+0.5)) b.pan_y.add_callback('activated', self.set_pan_cb) b.center_image.set_tooltip("Set the pan position to center of the image") b.center_image.add_callback('activated', self.center_image_cb) b.mark_center.set_tooltip("Mark the center (pan locator)") b.mark_center.add_callback('activated', self.set_misc_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("New Images") captions = (('Cut New:', 'label', 'Cut New', 'combobox'), ('Zoom New:', 'label', 'Zoom New', 'combobox'), ('Center New', 'checkbutton', 'Follow New', 'checkbutton'), ('Raise New', 'checkbutton', 'Create thumbnail', 'checkbutton'),) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) combobox = b.cut_new index = 0 for name in self.autocut_options: combobox.append_text(name) index += 1 option = self.t_.get('autocuts', "off") index = self.autocut_options.index(option) combobox.set_index(index) combobox.add_callback('activated', self.set_autocuts_cb) b.cut_new.set_tooltip("Automatically set cut levels for new images") combobox = b.zoom_new index = 0 for name in self.autozoom_options: combobox.append_text(name) index += 1 option = self.t_.get('autozoom', "off") index = self.autozoom_options.index(option) combobox.set_index(index) combobox.add_callback('activated', self.set_autozoom_cb) b.zoom_new.set_tooltip("Automatically fit new images to window") b.center_new.set_tooltip("Automatically center new images") b.follow_new.set_tooltip("View new images as they arrive") b.raise_new.set_tooltip("Raise and focus tab for new images") b.create_thumbnail.set_tooltip("Create thumbnail for new images") self.w.center_new.set_state(True) self.w.center_new.add_callback('activated', self.set_chprefs_cb) self.w.follow_new.set_state(True) self.w.follow_new.add_callback('activated', self.set_chprefs_cb) self.w.raise_new.set_state(True) self.w.raise_new.add_callback('activated', self.set_chprefs_cb) self.w.create_thumbnail.set_state(True) self.w.create_thumbnail.add_callback('activated', self.set_chprefs_cb) fr.set_widget(w) vbox.add_widget(fr, stretch=0) top.add_widget(sw, stretch=1) btns = Widgets.HBox() btns.set_spacing(4) btns.set_border_width(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Save Settings") btn.add_callback('activated', lambda w: self.save_preferences()) btns.add_widget(btn) 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) vbox, sw, orientation = Widgets.get_oriented_box(container) self.orientation = orientation 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'), ) w, b = Widgets.build_info(captions) self.w.update(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_cb()) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Attributes") vbox2 = Widgets.VBox() self.w.attrlbl = Widgets.Label() vbox2.add_widget(self.w.attrlbl, stretch=0) self.w.drawvbox = Widgets.VBox() vbox2.add_widget(self.w.drawvbox, stretch=1) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) captions = (("Rotate By:", 'label', 'Rotate By', 'entry', "Scale By:", 'label', 'Scale By', 'entry'), ("Delete Obj", 'button', "lbl1", 'label', "lbl2", 'label', "Clear canvas", 'button'), ) w, b = Widgets.build_info(captions) self.w.update(b) b.delete_obj.add_callback('activated', lambda w: self.delete_object()) b.delete_obj.set_tooltip("Delete selected object in edit mode") b.delete_obj.set_enabled(False) b.scale_by.add_callback('activated', self.scale_object) b.scale_by.set_text('0.9') b.scale_by.set_tooltip("Scale selected object in edit mode") b.scale_by.set_enabled(False) b.rotate_by.add_callback('activated', self.rotate_object) b.rotate_by.set_text('90.0') b.rotate_by.set_tooltip("Rotate selected object in edit mode") b.rotate_by.set_enabled(False) b.clear_canvas.add_callback('activated', lambda w: self.clear_canvas()) b.clear_canvas.set_tooltip("Delete all drawing objects") 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_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) # 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) 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): 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.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) fr = Widgets.Frame("Position") captions = ( ("RA:", "label", "RA", "entry", "DEC:", "label", "DEC", "entry"), ("Equinox:", "label", "Equinox", "entry", "Object:", "label", "Name", "entry"), ("Add Target", "button", "Clear All", "button"), ("Set Pointing", "button"), ("Pointing:", "label", "pra", "llabel", "pdec", "llabel"), ("FOV:", "label", "fov", "entry", "Create Blank", "button", "Get DSS", "button"), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w = b b.equinox.set_text("2000") # Currently assume J2000 targets--this will be fixed in future b.equinox.set_enabled(False) b.add_target.add_callback("activated", lambda w: self.add_target_cb()) b.clear_all.add_callback("activated", lambda w: self.clear_targets_cb()) b.fov.set_text(str(self.fov_deg)) b.set_pointing.add_callback("activated", lambda w: self.set_pointing_cb()) b.create_blank.add_callback("activated", lambda w: self.create_blank_image()) b.get_dss.add_callback("activated", lambda w: self.get_dss_image()) fr.set_widget(w) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Acquisition") vbox2 = Widgets.VBox() captions = ( ( "Dither Type:", "label", "Dither Type", "combobox", "Dither Steps:", "label", "Dither Steps", "spinbutton", ), ("INSROT_PA:", "label", "PA", "entry"), ("RA Offset:", "label", "RA Offset", "entry", "DEC Offset:", "label", "DEC Offset", "entry"), ("Dith1:", "label", "Dith1", "entry", "Dith2:", "label", "Dith2", "entry"), ("Skip:", "label", "Skip", "spinbutton", "Stop:", "label", "Stop", "spinbutton"), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) combobox = b.dither_type for name in self.dither_types: combobox.append_text(name) index = self.dither_types.index(self.dither_type) combobox.set_index(index) combobox.add_callback("activated", lambda w, idx: self.set_dither_type_cb()) b.pa.set_text(str(self.pa_deg)) b.dither_steps.set_limits(1, 20) b.dither_steps.add_callback("value-changed", lambda w, idx: self.set_dither_steps_cb(idx)) b.pa.set_tooltip("Angle of instrument rotator in deg") b.ra_offset.set_text(str(0.0)) b.dec_offset.set_text(str(0.0)) b.ra_offset.set_tooltip("RA offset from center of field in arcsec") b.dec_offset.set_tooltip("DEC offset from center of field in arcsec") b.skip.set_value(0) b.stop.set_value(1) vbox2.add_widget(w) captions = (("_x3", "spacer", "_x4", "spacer", "_x5", "spacer"), ("Update Image", "button")) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.update_image.add_callback("activated", lambda w: self.update_info_cb()) vbox2.add_widget(w) fr.set_widget(vbox2) vbox.add_widget(fr, stretch=0) captions = (("Show Step:", "label", "Show Step", "spinbutton"),) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.show_step.add_callback("value-changed", lambda w, idx: self.show_step_cb(idx)) 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_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) 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'), ) 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;}') vbox.add_widget(w, stretch=0) captions = (('Load Parameters', 'button', 'Save Parameters', 'button', 'Subtract', 'button'), ) w, b = Widgets.build_info(captions, orientation=self.orientation) self.w.update(b) b.load_parameters.set_tooltip('Load previously saved parameters') b.load_parameters.widget.clicked.connect(self.load_params) b.save_parameters.set_tooltip('Save background subtraction parameters') b.save_parameters.widget.clicked.connect(self.save_params) b.subtract.set_tooltip('Subtract background') b.subtract.widget.clicked.connect(self.sub_bg) b.subtract.widget.setEnabled(False) 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) 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, 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) 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