def _create_info_window(self): sw = Widgets.ScrollArea() vbox = Widgets.VBox() captions = ( ("Name:", "label", "Name", "llabel"), ("Object:", "label", "Object", "llabel"), ("X:", "label", "X", "llabel"), ("Y:", "label", "Y", "llabel"), ("Value:", "label", "Value", "llabel"), ("RA:", "label", "RA", "llabel"), ("DEC:", "label", "DEC", "llabel"), ("Equinox:", "label", "Equinox", "llabel"), ("Dimensions:", "label", "Dimensions", "llabel"), ("Min:", "label", "Min", "llabel"), ("Max:", "label", "Max", "llabel"), ) w, b = Widgets.build_info(captions) col = Widgets.VBox() row = Widgets.HBox() row.set_spacing(0) row.set_border_width(0) row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(""), stretch=1) col.add_widget(row, stretch=1) col.add_widget(Widgets.Label(""), stretch=1) sw2 = Widgets.ScrollArea() sw2.set_widget(col) vbox.add_widget(sw2, stretch=2) captions = ( ("Zoom:", "label", "Zoom", "llabel"), ("Cut Low:", "label", "Cut Low Value", "llabel", "Cut Low", "entry"), ("Cut High:", "label", "Cut High Value", "llabel", "Cut High", "entry"), ("Auto Levels", "button", "spacer1", "spacer", "Cut Levels", "button"), ("Cut New:", "label", "Cut New", "llabel"), ("Zoom New:", "label", "Zoom New", "llabel"), ("Preferences", "button"), ) w, b2 = Widgets.build_info(captions) b.update(b2) # TODO: need a more general solution to gtk labels resizing their # parent window # b.object.set_length(12) 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.preferences.set_tooltip("Set preferences for this channel") row = Widgets.HBox() row.set_spacing(0) row.set_border_width(0) row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(""), stretch=1) vbox.add_widget(row, stretch=1) # stretcher vbox.add_widget(Widgets.Label(""), stretch=0) # Convenience navigation buttons btns = Widgets.HBox() btns.set_spacing(4) btns.set_border_width(4) bw = Bunch.Bunch() for tup in ( # ("Load", 'button', 'fits_open_48', "Open an image file"), ("Prev", "button", "prev_48", "Go to previous image"), ("Next", "button", "next_48", "Go to next image"), ("Zoom In", "button", "zoom_in_48", "Zoom in"), ("Zoom Out", "button", "zoom_out_48", "Zoom out"), ("Zoom Fit", "button", "zoom_fit_48", "Zoom to fit window size"), ("Zoom 1:1", "button", "zoom_100_48", "Zoom to 100% (1:1)"), # ("Quit", 'button', 'exit_48', "Quit the program"), ): btn = self.fv.make_button(*tup) name = tup[0] if tup[3]: btn.set_tooltip(tup[3]) bw[Widgets.name_mangle(name, pfx="btn_")] = btn btns.add_widget(btn, stretch=1) # self.w.btn_load.connect("clicked", lambda w: self.gui_load_file()) bw.btn_prev.add_callback("activated", lambda w: self.fv.prev_img()) bw.btn_next.add_callback("activated", lambda w: self.fv.next_img()) bw.btn_zoom_in.add_callback("activated", lambda w: self.fv.zoom_in()) bw.btn_zoom_out.add_callback("activated", lambda w: self.fv.zoom_out()) bw.btn_zoom_fit.add_callback("activated", lambda w: self.fv.zoom_fit()) bw.btn_zoom_1_1.add_callback("activated", lambda w: self.fv.zoom_1_to_1()) vbox.add_widget(btns, stretch=0) sw.set_widget(vbox) # sw.set_size_request(-1, 420) # sw.show_all() return sw, b
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(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 _create_info_window(self): sw = Widgets.ScrollArea() vbox = Widgets.VBox() captions = ( ('Name:', 'label', 'Name', 'llabel'), ('Object:', 'label', 'Object', 'llabel'), ('X:', 'label', 'X', 'llabel'), ('Y:', 'label', 'Y', 'llabel'), ('Value:', 'label', 'Value', 'llabel'), ('RA:', 'label', 'RA', 'llabel'), ('DEC:', 'label', 'DEC', 'llabel'), ('Equinox:', 'label', 'Equinox', 'llabel'), ('Dimensions:', 'label', 'Dimensions', 'llabel'), ('Min:', 'label', 'Min', 'llabel'), ('Max:', 'label', 'Max', 'llabel'), ) w, b = Widgets.build_info(captions) col = Widgets.VBox() row = Widgets.HBox() row.set_spacing(0) row.set_border_width(0) row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) col.add_widget(row, stretch=1) col.add_widget(Widgets.Label(''), stretch=1) sw2 = Widgets.ScrollArea() sw2.set_widget(col) vbox.add_widget(sw2, stretch=2) captions = ( ('Zoom:', 'label', 'Zoom', 'llabel'), ('Cut Low:', 'label', 'Cut Low Value', 'llabel', 'Cut Low', 'entry'), ('Cut High:', 'label', 'Cut High Value', 'llabel', 'Cut High', 'entry'), ('Auto Levels', 'button', 'spacer1', 'spacer', 'Cut Levels', 'button'), ('Cut New:', 'label', 'Cut New', 'llabel'), ('Zoom New:', 'label', 'Zoom New', 'llabel'), ('Preferences', 'button'), ) w, b2 = Widgets.build_info(captions) b.update(b2) # TODO: need a more general solution to gtk labels resizing their # parent window #b.object.set_length(12) 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.preferences.set_tooltip("Set preferences for this channel") row = Widgets.HBox() row.set_spacing(0) row.set_border_width(0) row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(row, stretch=1) # stretcher vbox.add_widget(Widgets.Label(''), stretch=0) # Convenience navigation buttons btns = Widgets.HBox() btns.set_spacing(4) btns.set_border_width(4) bw = Bunch.Bunch() for tup in ( #("Load", 'button', 'fits_open_48', "Open an image file"), ("Prev", 'button', 'prev_48', "Go to previous image"), ("Next", 'button', 'next_48', "Go to next image"), ("Zoom In", 'button', 'zoom_in_48', "Zoom in"), ("Zoom Out", 'button', 'zoom_out_48', "Zoom out"), ("Zoom Fit", 'button', 'zoom_fit_48', "Zoom to fit window size"), ("Zoom 1:1", 'button', 'zoom_100_48', "Zoom to 100% (1:1)"), #("Quit", 'button', 'exit_48', "Quit the program"), ): btn = self.fv.make_button(*tup) name = tup[0] if tup[3]: btn.set_tooltip(tup[3]) bw[Widgets.name_mangle(name, pfx='btn_')] = btn btns.add_widget(btn, stretch=1) #self.w.btn_load.connect("clicked", lambda w: self.gui_load_file()) bw.btn_prev.add_callback('activated', lambda w: self.fv.prev_img()) bw.btn_next.add_callback('activated', lambda w: self.fv.next_img()) bw.btn_zoom_in.add_callback('activated', lambda w: self.fv.zoom_in()) bw.btn_zoom_out.add_callback('activated', lambda w: self.fv.zoom_out()) bw.btn_zoom_fit.add_callback('activated', lambda w: self.fv.zoom_fit()) bw.btn_zoom_1_1.add_callback('activated', lambda w: self.fv.zoom_1_to_1()) vbox.add_widget(btns, stretch=0) sw.set_widget(vbox) #sw.set_size_request(-1, 420) #sw.show_all() return sw, b