def __init__(self, logger=None, rgbmap=None, settings=None): ImageViewCairo.ImageViewCairo.__init__(self, logger=logger, rgbmap=rgbmap, settings=settings) imgwin = gtk.DrawingArea() imgwin.connect("expose_event", self.expose_event) imgwin.connect("configure-event", self.configure_event) imgwin.connect("size-request", self.size_request) imgwin.set_events(gtk.gdk.EXPOSURE_MASK) # prevents some flickering imgwin.set_double_buffered(True) imgwin.set_app_paintable(True) # prevents extra redraws, because we manually redraw on a size # change imgwin.set_redraw_on_allocate(False) self.imgwin = imgwin self.imgwin.show_all() # see reschedule_redraw() method self._defer_task = GtkHelp.Timer() self._defer_task.add_callback('expired', lambda timer: self.delayed_redraw()) self.msgtask = GtkHelp.Timer() self.msgtask.add_callback('expired', lambda timer: self.onscreen_message(None))
def gui_add_channels(self): captions = (('Prefix', 'entry'), ('Number', 'spinbutton'), ('Workspace', 'combobox'), #('Base on Channel', 'combobox'), #('Copy Settings', 'button'), #'Share Settings', 'button'), #('Cancel', 'button', 'Ok', 'button') ) w, b = GtkHelp.build_info(captions) b.prefix.set_text("Image") adj = b.number.get_adjustment() lower = 1 upper = 12 adj.configure(lower, lower, upper, 1, 1, 0) adj.set_value(lower) cbox = b.workspace names = self.ds.get_wsnames() try: idx = names.index('channels') except: idx = 0 for name in names: cbox.append_text(name) cbox.set_active(idx) ## cbox = b.base_on_channel ## names = self.get_channelNames() ## for name in names: ## cbox.append_text(name) ## prefs = self.prefs.getSettings('channel_Image') ## d = prefs.getDict() ## cbox = b.copy_settings ## for name in d.keys(): ## cbox.append_text(name) ## cbox = b.share_settings ## for name in d.keys(): ## cbox.append_text(name) dialog = GtkHelp.Dialog("Add Channels", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.add_channels_cb(w, rsp, b, names)) box = dialog.get_content_area() box.pack_start(w, True, True, 0) dialog.show_all()
def __init__(self, text=''): super(CheckBox, self).__init__() self.widget = GtkHelp.CheckButton(text) self.widget.sconnect('toggled', self._cb_redirect) self.enable_callback('activated')
def get_plain_image_as_pixbuf(self): arr = self.getwin_array(order='RGB') try: pixbuf = GtkHelp.pixbuf_new_from_array(arr, gtk.gdk.COLORSPACE_RGB, 8) except Exception as e: self.logger.warning("Error making pixbuf: %s" % (str(e))) # pygtk might have been compiled without numpy support daht, dawd, depth = arr.shape rgb_buf = self._get_rgbbuf(arr) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, gtk.gdk.COLORSPACE_RGB, False, 8, dawd, daht, dawd*3) return pixbuf
def gui_add_channel(self, chname=None): if not chname: self.chncnt += 1 chname = "Image%d" % self.chncnt lbl = gtk.Label('New channel name:') ent = gtk.Entry() ent.set_text(chname) ent.set_activates_default(True) lbl2 = gtk.Label('Workspace:') cbox = gtk.combo_box_new_text() names = self.ds.get_wsnames() try: idx = names.index(self._lastwsname) except: idx = 0 for name in names: cbox.append_text(name) cbox.set_active(idx) dialog = GtkHelp.Dialog("Add Channel", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.add_channel_cb(w, rsp, ent, cbox, names)) box = dialog.get_content_area() box.pack_start(lbl, True, False, 0) box.pack_start(ent, True, True, 0) box.pack_start(lbl2, True, False, 0) box.pack_start(cbox, True, True, 0) dialog.show_all()
def get_rgb_image_as_pixbuf(self): dawd = self.surface.get_width() daht = self.surface.get_height() rgb_buf = bytes(self.surface.get_data()) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, gtk.gdk.COLORSPACE_RGB, False, 8, dawd, daht, dawd * 3) return pixbuf
def build_gui(self, container): self.msgFont = pango.FontDescription("Fixed 10") tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_NONE) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw self.buf = self.tw.get_buffer() sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.tw) container.pack_start(sw, fill=True, expand=True) hbox = gtk.HBox() lbl = gtk.Label('Level:') hbox.pack_start(lbl, fill=False, expand=False) combobox = GtkHelp.combo_box_new_text() for (name, level) in self.levels: combobox.append_text(name) combobox.set_active(1) combobox.sconnect('changed', self.set_loglevel_cb) hbox.pack_start(combobox, fill=False, expand=False, padding=4) lbl = gtk.Label('History:') hbox.pack_start(lbl, fill=False, expand=False) spinbox = GtkHelp.SpinButton() adj = spinbox.get_adjustment() adj.configure(self.histlimit, 100, self.histmax, 10, 100, 0) spinbox.sconnect('value-changed', self.set_history_cb) hbox.pack_start(spinbox, fill=False, expand=False, padding=4) btn = gtk.Button("Clear") btn.connect('clicked', lambda w: self.clear()) hbox.pack_end(btn, fill=False, expand=False) container.pack_end(hbox, fill=False, expand=False)
def get_rgb_image_as_pixbuf(self): arr8 = self.renderer.get_surface_as_array(order='RGB') daht, dawd = arr8.shape[:2] rgb_buf = arr8.tobytes(order='C') pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, gtk.gdk.COLORSPACE_RGB, False, 8, dawd, daht, dawd * 3) return pixbuf
def get_plain_image_as_pixbuf(self): #arr = self.getwin_array(order=self._rgb_order) arr = self.getwin_array(order='RGB') try: pixbuf = GtkHelp.pixbuf_new_from_array(arr, gtk.gdk.COLORSPACE_RGB, 8) except Exception as e: self.logger.warning("Error making pixbuf: %s" % (str(e))) # pygtk might have been compiled without numpy support daht, dawd, depth = arr.shape rgb_buf = self._get_rgbbuf(arr) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, gtk.gdk.COLORSPACE_RGB, False, 8, dawd, daht, dawd*3) return pixbuf
def get_rgb_image_as_pixbuf(self): dawd = self.surface.get_width() daht = self.surface.get_height() rgb_buf = bytes(self.surface.get_data()) pixbuf = GtkHelp.pixbuf_new_from_data(rgb_buf, gtk.gdk.COLORSPACE_RGB, False, 8, dawd, daht, dawd*3) return pixbuf
def build_gui(self, container): canvas = CanvasTypes.DrawingCanvas() canvas.enable_draw(False) #canvas.set_callback('button-press', self.btndown) canvas.set_callback('motion', self.cursormotion) #canvas.set_callback('button-release', self.update) canvas.add_callback('key-press', self.window_key_press) canvas.add_callback('key-release', self.window_key_release) self.canvas = canvas vbox1 = gtk.VBox() fr = gtk.Frame("IRAF") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = [ ("Control", 'hbox'), ("Channel", 'label'), ] w, b = GtkHelp.build_info(captions) fr.add(w) self.w = b self.w.mode_d = {} btn = GtkHelp.RadioButton(group=None, label="Ginga") btn.sconnect('toggled', lambda w: self.switchMode('ginga')) self.w.mode_d['ginga'] = btn self.w.control.pack_start(btn, padding=4, fill=False, expand=False) btn = GtkHelp.RadioButton(group=btn, label="IRAF") btn.sconnect('toggled', lambda w: self.switchMode('iraf')) self.w.mode_d['iraf'] = btn self.w.control.pack_start(btn, padding=4, fill=False, expand=False) vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("Frame/Channel") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) lbl = gtk.Label("") self.w.frch = lbl fr.add(lbl) vbox1.pack_start(fr, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def __init__(self, dtype=int): super(SpinBox, self).__init__() self.widget = GtkHelp.SpinButton() # if not gtksel.have_gtk3: # self.widget.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.widget.sconnect('value-changed', self._cb_redirect) self.enable_callback('value-changed')
def __init__(self, orientation='horizontal', track=False): super(Slider, self).__init__() if orientation == 'horizontal': w = GtkHelp.HScale() # TEMP: hack because scales don't seem to expand as expected w.set_size_request(200, -1) else: w = GtkHelp.VScale() w.set_size_request(-1, 200) self.widget = w w.set_draw_value(True) w.set_value_pos(gtk.POS_BOTTOM) self.set_tracking(track) w.sconnect('value-changed', self._cb_redirect) self.enable_callback('value-changed')
def __init__(self, text=''): super(ToggleButton, self).__init__() w = GtkHelp.ToggleButton(text) w.set_mode(True) self.widget = w self.widget.sconnect('toggled', self._cb_redirect) self.enable_callback('activated')
def __init__(self, text='', group=None): super(RadioButton, self).__init__() if group != None: group = group.get_widget() self.widget = GtkHelp.RadioButton(group, text) self.widget.connect('toggled', self._cb_redirect) self.enable_callback('activated')
def build_gui(self, container): vbox1 = gtk.VBox() self.msgFont = self.fv.getFont("sansFont", 14) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(label=" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) fr.show_all() vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame(label="HDU") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = [("Num HDUs", 'label'), ("Choose HDU", 'spinbutton')] w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.numhdu = b.num_hdus self.w.hdu = b.choose_hdu self.w.hdu.set_tooltip_text("Choose which HDU to view") if not gtksel.have_gtk3: self.w.hdu.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.w.hdu.connect('value-changed', self.set_hdu_cb) fr.add(w) vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame(label="NAXIS") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) self.naxisfr = fr vbox1.pack_start(fr, padding=4, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox1.pack_start(btns, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def gui_add_ws(self): captions = (('Workspace name', 'entry'), ('Workspace type', 'combobox'), ('In workspace', 'combobox'), ('Channel prefix', 'entry'), ('Number of channels', 'spinbutton')) w, b = GtkHelp.build_info(captions) self.wscount += 1 wsname = "ws%d" % (self.wscount) b.workspace_name.set_text(wsname) cbox = b.workspace_type cbox.append_text("Tabs") cbox.append_text("Grid") #cbox.append_text("MDI") cbox.set_active(0) cbox = b.in_workspace names = self.ds.get_wsnames() names.insert(0, 'top level') try: idx = names.index('top level') except: idx = 0 for name in names: cbox.append_text(name) cbox.set_active(idx) b.channel_prefix.set_text("Image") adj = b.number_of_channels.get_adjustment() lower = 0 upper = 12 adj.configure(lower, lower, upper, 1, 1, 0) adj.set_value(1) dialog = GtkHelp.Dialog("Add Workspace", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.new_ws_cb(w, rsp, b, names)) box = dialog.get_content_area() box.pack_start(w, expand=True, fill=True) dialog.show_all()
def build_gui(self, container): vbox1 = gtk.VBox() self.msgFont = pango.FontDescription("Sans 14") tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) fr.show_all() vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("HDU") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = [("Num HDUs", 'label'), ("Choose HDU", 'spinbutton')] w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.numhdu = b.num_hdus self.w.hdu = b.choose_hdu self.w.hdu.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.w.hdu.connect('value-changed', self.set_hdu_cb) fr.add(w) vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("NAXIS") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) self.naxisfr = fr vbox1.pack_start(fr, padding=4, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox1.pack_start(btns, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def gui_delete_channel(self): chinfo = self.get_channelInfo() chname = chinfo.name lbl = gtk.Label("Really delete channel '%s' ?" % (chname)) dialog = GtkHelp.Dialog("Delete Channel", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.delete_channel_cb(w, rsp, chname)) box = dialog.get_content_area() box.pack_start(lbl, True, False, 0) dialog.show_all()
def build_gui(self, container): nb = GtkHelp.Notebook() nb.set_group_id(-30) nb.set_tab_pos(gtk.POS_BOTTOM) nb.set_scrollable(False) nb.set_show_tabs(False) nb.set_show_border(False) nb.show() self.nb = nb cw = container.get_widget() cw.pack_start(self.nb, fill=True, expand=True)
def _make_spin(self, lower, upper): #adj = gtk.Adjustment(lower=lower, upper=upper) adj = gtk.Adjustment() adj.configure(lower, lower, upper, 1, 1, 1) adj.set_value(lower) scale = GtkHelp.SpinButton(adj) scale.set_digits(0) scale.set_wrap(True) scale.set_snap_to_ticks(True) #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS) return scale
def build_gui(self, container): vbox1 = gtk.VBox() self.msgFont = self.fv.getFont("sansFont", 14) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) fr.show_all() vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("Ruler") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (("Units", "combobox"),) w, b = GtkHelp.build_info(captions) self.w = b combobox = b.units index = 0 for name in self.unittypes: combobox.insert_text(index, name) index += 1 index = self.unittypes.index(self.units) combobox.set_active(index) combobox.sconnect("changed", lambda w: self.set_units()) fr.add(w) vbox1.pack_start(fr, padding=4, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect("clicked", lambda w: self.close()) btns.add(btn) vbox1.pack_start(btns, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def build_gui(self, container): vbox1 = gtk.VBox() self.msgFont = pango.FontDescription("Sans 14") tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) fr.show_all() vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("Ruler") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Units', 'combobox'), ) w, b = GtkHelp.build_info(captions) self.w = b combobox = b.units index = 0 for name in self.unittypes: combobox.insert_text(index, name) index += 1 index = self.unittypes.index(self.units) combobox.set_active(index) combobox.sconnect('changed', lambda w: self.set_units()) fr.add(w) vbox1.pack_start(fr, padding=4, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox1.pack_start(btns, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def gui_add_channels(self): captions = (('Prefix', 'entry'), ('Number', 'spinbutton'), ('Workspace', 'combobox'), #('Base on Channel', 'combobox'), #('Copy Settings', 'button'), #'Share Settings', 'button'), #('Cancel', 'button', 'Ok', 'button') ) w, b = GtkHelp.build_info(captions) b.prefix.set_text("Image") adj = b.number.get_adjustment() lower = 1 upper = 12 adj.configure(lower, lower, upper, 1, 1, 0) adj.set_value(lower) cbox = b.workspace names = self.ds.get_wsnames() try: idx = names.index('channels') except: idx = 0 for name in names: cbox.append_text(name) cbox.set_active(idx) ## cbox = b.base_on_channel ## names = self.get_channelNames() ## for name in names: ## cbox.append_text(name) ## prefs = self.prefs.getSettings('channel_Image') ## d = prefs.getDict() ## cbox = b.copy_settings ## for name in d.keys(): ## cbox.append_text(name) ## cbox = b.share_settings ## for name in d.keys(): ## cbox.append_text(name) dialog = GtkHelp.Dialog("Add Channels", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.add_channels_cb(w, rsp, b, names)) box = dialog.get_content_area() box.pack_start(w, True, True, 0) dialog.show_all() self._cur_dialogs.append(dialog)
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x; y = event.y degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % ( degrees, direction)) data_x, data_y = self.get_data_xy(x, y) self.last_data_x, self.last_data_y = data_x, data_y return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def __init__(self): super(ComboBox, self).__init__() cb = GtkHelp.ComboBox() liststore = gtk.ListStore(gobject.TYPE_STRING) cb.set_model(liststore) cell = gtk.CellRendererText() cb.pack_start(cell, True) cb.add_attribute(cell, 'text', 0) self.widget = cb self.widget.sconnect('changed', self._cb_redirect) self.enable_callback('activated')
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x y = event.y self.last_win_x, self.last_win_y = x, y degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % (degrees, direction)) data_x, data_y = self.check_cursor_location() return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def scroll_event(self, widget, event): # event.button, event.x, event.y x = event.x y = event.y self.last_win_x, self.last_win_y = x, y degrees, direction = GtkHelp.get_scroll_info(event) self.logger.debug("scroll deg=%f direction=%f" % ( degrees, direction)) data_x, data_y = self.check_cursor_location() return self.make_ui_callback('scroll', direction, degrees, data_x, data_y)
def __init__(self, logger): self.logger = logger root = gtk.Window(gtk.WINDOW_TOPLEVEL) root.set_title("ImageViewZoom Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: self.quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = gtk.VBox(spacing=2) # create the ginga viewer and configure it fi = ImageViewCanvas(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi # enable some user interaction bd = fi.get_bindings() bd.enable_all(True) w = fi.get_widget() w.set_size_request(512, 512) # add scrollbar interface around this viewer si = ScrolledView(fi) si.scroll_bars(horizontal='on', vertical='on') vbox.pack_start(si, fill=True, expand=True) hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_END) wopen = gtk.Button("Open File") wopen.connect('clicked', self.open_file) wquit = gtk.Button("Quit") wquit.connect('clicked', self.quit) for w in (wopen, wquit): hbox.add(w) vbox.pack_start(hbox, fill=False, expand=False) root.add(vbox)
def gui_add_ws(self): captions = (('Workspace name', 'entry'), ('Workspace type', 'combobox'), ('In workspace', 'combobox'), ('Channel prefix', 'entry'), ('Number of channels', 'spinbutton'), ('Share settings', 'entry'), ) w, b = GtkHelp.build_info(captions) self.wscount += 1 wsname = "ws%d" % (self.wscount) b.workspace_name.set_text(wsname) b.share_settings.set_width_chars(60) cbox = b.workspace_type cbox.append_text("Tabs") cbox.append_text("Grid") #cbox.append_text("MDI") cbox.set_active(1) cbox = b.in_workspace names = self.ds.get_wsnames() names.insert(0, 'top level') try: idx = names.index('channels') except: idx = 0 for name in names: cbox.append_text(name) cbox.set_active(idx) b.channel_prefix.set_text("Image") adj = b.number_of_channels.get_adjustment() lower = 0 upper = 12 adj.configure(lower, lower, upper, 1, 1, 0) adj.set_value(4) dialog = GtkHelp.Dialog("Add Workspace", gtk.DIALOG_DESTROY_WITH_PARENT, [['Cancel', 0], ['Ok', 1]], lambda w, rsp: self.new_ws_cb(w, rsp, b, names)) box = dialog.get_content_area() box.pack_start(w, expand=True, fill=True) dialog.show_all() self._cur_dialogs.append(dialog)
def build_naxis(self, dims): # build a vbox of NAXIS controls captions = [("NAXIS1", 'label'), ("NAXIS2", 'label')] self.naxispath = [] for n in xrange(2, len(dims)): self.naxispath.append(0) key = 'naxis%d' % (n+1) title = key.upper() maxn = int(dims[n]) self.logger.debug("NAXIS%d=%d" % (n+1, maxn)) if maxn <= 1: captions.append((title, 'label')) else: captions.append((title, 'label', "Choose %s" % (title), 'spinbutton')) w, b = GtkHelp.build_info(captions) for n in xrange(0, len(dims)): key = 'naxis%d' % (n+1) lbl = b[key] maxn = int(dims[n]) lbl.set_text("%d" % maxn) slkey = 'choose_'+key if b.has_key(slkey): slider = b[slkey] adj = slider.get_adjustment() lower = 1 upper = maxn adj.configure(lower, lower, upper, 1, 1, 0) adj.set_value(lower) slider.set_digits(0) slider.set_wrap(True) slider.set_snap_to_ticks(True) slider.connect('value-changed', self.set_naxis_cb, n) if not gtksel.have_gtk3: slider.set_update_policy(gtk.UPDATE_DISCONTINUOUS) # Add vbox of naxis controls to gui try: oldv = self.naxisfr.get_child() self.naxisfr.remove(oldv) except: pass self.naxisfr.add(w) self.naxisfr.show_all()
def build_gui(self, container): canvas = CanvasTypes.DrawingCanvas() canvas.enable_draw(False) #canvas.set_callback('button-press', self.btndown) canvas.set_callback('motion', self.cursormotion) #canvas.set_callback('button-release', self.update) canvas.add_callback('key-press', self.window_key_press) canvas.add_callback('key-release', self.window_key_release) self.canvas = canvas vbox1 = gtk.VBox() fr = gtk.Frame("IRAF") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = [("Control", 'hbox'), ("Channel", 'label'), ] w, b = GtkHelp.build_info(captions) fr.add(w) self.w = b self.w.mode_d = {} btn = GtkHelp.RadioButton(group=None, label="Ginga") btn.sconnect('toggled', lambda w: self.switchMode('ginga')) self.w.mode_d['ginga'] = btn self.w.control.pack_start(btn, padding=4, fill=False, expand=False) btn = GtkHelp.RadioButton(group=btn, label="IRAF") btn.sconnect('toggled', lambda w: self.switchMode('iraf')) self.w.mode_d['iraf'] = btn self.w.control.pack_start(btn, padding=4, fill=False, expand=False) vbox1.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame("Frame/Channel") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) lbl = gtk.Label("") self.w.frch = lbl fr.add(lbl) vbox1.pack_start(fr, padding=4, fill=True, expand=False) vbox1.show_all() container.pack_start(vbox1, padding=0, fill=True, expand=False)
def build_naxis(self, dims): # build a vbox of NAXIS controls captions = [("NAXIS1", 'label'), ("NAXIS2", 'label')] self.naxispath = [] for n in xrange(2, len(dims)): self.naxispath.append(0) key = 'naxis%d' % (n + 1) title = key.upper() maxn = int(dims[n]) self.logger.debug("NAXIS%d=%d" % (n + 1, maxn)) if maxn <= 1: captions.append((title, 'label')) else: captions.append( (title, 'label', "Choose %s" % (title), 'spinbutton')) w, b = GtkHelp.build_info(captions) for n in xrange(0, len(dims)): key = 'naxis%d' % (n + 1) lbl = b[key] maxn = int(dims[n]) lbl.set_text("%d" % maxn) slkey = 'choose_' + key if b.has_key(slkey): slider = b[slkey] adj = slider.get_adjustment() lower = 1 upper = maxn adj.configure(lower, lower, upper, 1, 1, 1) adj.set_value(lower) slider.set_digits(0) slider.set_wrap(True) slider.set_snap_to_ticks(True) slider.connect('value-changed', self.set_naxis_cb, n) slider.set_update_policy(gtk.UPDATE_DISCONTINUOUS) # Add vbox of naxis controls to gui try: oldv = self.naxisfr.get_child() self.naxisfr.remove(oldv) except: pass self.naxisfr.add(w) self.naxisfr.show_all()
def __init__(self, logger): self.logger = logger root = gtk.Window(gtk.WINDOW_TOPLEVEL) root.set_title("ImageViewZoom Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: self.quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = gtk.VBox(spacing=2) fi = ImageViewCanvas(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_pan(True) bd.enable_zoom(True) bd.enable_cuts(True) bd.enable_flip(True) w = fi.get_widget() w.set_size_request(512, 512) vbox.pack_start(w, fill=True, expand=True) hbox = gtk.HButtonBox() hbox.set_layout(gtk.BUTTONBOX_END) wopen = gtk.Button("Open File") wopen.connect('clicked', self.open_file) wquit = gtk.Button("Quit") wquit.connect('clicked', self.quit) for w in (wopen, wquit): hbox.add(w) vbox.pack_start(hbox, fill=False, expand=False) root.add(vbox)
def build_gui(self, container): self.msgFont = self.fv.getFont("fixedFont", 10) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_NONE) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.modify_font(self.msgFont) self.tw = tw self.buf = self.tw.get_buffer() sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.tw) container.pack_start(sw, fill=True, expand=True) captions = (('Level', 'combobox', 'History', 'spinbutton'), ('Auto scroll', 'checkbutton', 'Clear', 'button') ) w, b = GtkHelp.build_info(captions) self.w.update(b) combobox = b.level for (name, level) in self.levels: combobox.append_text(name) combobox.set_active(1) combobox.sconnect('changed', self.set_loglevel_cb) combobox.set_tooltip_text("Set the logging level") spinbox = b.history adj = spinbox.get_adjustment() adj.configure(self.histlimit, 100, self.histmax, 10, 100, 0) spinbox.sconnect('value-changed', self.set_history_cb) spinbox.set_tooltip_text("Set the logging history line limit") btn = b.auto_scroll btn.set_tooltip_text("Scroll the log window automatically") btn = b.clear btn.connect('clicked', lambda w: self.clear()) btn.set_tooltip_text("Clear the log history") container.pack_end(w, fill=False, expand=False)
def build_gui(self, container): width, height = 300, 300 cm, im = self.fv.cm, self.fv.im tg = ImageViewCanvasGtk.ImageViewCanvas(logger=self.logger) tg.configure(200, 200) tg.enable_autozoom('on') tg.enable_autocuts('override') tg.enable_auto_orient(True) tg.set_bg(0.7, 0.7, 0.7) tg.defer_redraw = False self.thumb_generator = tg sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # Create thumbnails pane vbox = gtk.VBox(spacing=14) vbox.set_border_width(4) self.w.thumbs = vbox sw.add_with_viewport(vbox) sw.show_all() self.w.thumbs_scroll = sw self.w.thumbs_scroll.connect("size_allocate", self.thumbpane_resized_cb) #nb.connect("size_allocate", self.thumbpane_resized_cb) # TODO: should this even have it's own scrolled window? cw = container.get_widget() cw.pack_start(sw, fill=True, expand=True) captions = (('Auto scroll', 'checkbutton', 'Clear', 'button'),) w, b = GtkHelp.build_info(captions) self.w.update(b) b.auto_scroll.set_tooltip_text( "Scroll the thumbs window when new images arrive") b.clear.set_tooltip_text("Remove all current thumbnails") b.clear.connect("clicked", lambda w: self.clear()) auto_scroll = self.settings.get('auto_scroll', True) b.auto_scroll.set_active(auto_scroll) cw.pack_start(w, fill=True, expand=False) self.gui_up = True
def build_gui(self, container): width, height = 300, 300 cm, im = self.fv.cm, self.fv.im tg = ImageViewGtk.ImageViewGtk(logger=self.logger) tg.configure(200, 200) tg.enable_autozoom('on') tg.enable_autocuts('on') tg.enable_auto_orient(True) tg.set_makebg(False) tg.enable_overlays(False) self.thumb_generator = tg sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # Create thumbnails pane vbox = gtk.VBox(spacing=14) vbox.set_border_width(4) self.w.thumbs = vbox sw.add_with_viewport(vbox) sw.show_all() self.w.thumbs_scroll = sw self.w.thumbs_scroll.connect("size_allocate", self.thumbpane_resized_cb) #nb.connect("size_allocate", self.thumbpane_resized_cb) # TODO: should this even have it's own scrolled window? cw = container.get_widget() cw.pack_start(sw, fill=True, expand=True) captions = (('Auto scroll', 'checkbutton', 'Clear', 'button'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) b.auto_scroll.set_tooltip_text( "Scroll the thumbs window when new images arrive") b.clear.set_tooltip_text("Remove all current thumbnails") b.clear.connect("clicked", lambda w: self.clear()) autoScroll = self.settings.get('autoScroll', True) b.auto_scroll.set_active(autoScroll) cw.pack_start(w, fill=True, expand=False)
def _setup_params(self, obj, container): params = obj.getParams() captions = [] for key, bnch in params.items(): text = key if bnch.has_key('label'): text = bnch.label captions.append((text, 'entry')) # TODO: put RA/DEC first, and other stuff not in random orders w, b = GtkHelp.build_info(captions) # remove old widgets children = container.get_children() for child in children: container.remove(child) # add new widgets container.pack_start(w, fill=False, expand=False) container.show_all() return b
def build_gui(self, container): width, height = 300, 300 cm, im = self.fv.cm, self.fv.im tg = FitsImageGtk.FitsImageGtk(logger=self.logger) tg.configure(200, 200) tg.enable_autozoom('on') tg.enable_autocuts('on') tg.enable_auto_orient(True) tg.set_makebg(False) self.thumb_generator = tg sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # Create thumbnails pane vbox = gtk.VBox(spacing=14) vbox.set_border_width(4) self.w.thumbs = vbox sw.add_with_viewport(vbox) sw.show_all() self.w.thumbs_scroll = sw self.w.thumbs_scroll.connect("size_allocate", self.thumbpane_resized) #nb.connect("size_allocate", self.thumbpane_resized) # TODO: should this even have it's own scrolled window? container.pack_start(sw, fill=True, expand=True) captions = (('Auto scroll', 'checkbutton'),) w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.tooltips.set_tip(b.auto_scroll, "Scroll the thumbs window when new images arrive") autoScroll = self.settings.get('autoScroll', True) b.auto_scroll.set_active(autoScroll) container.pack_start(w, fill=True, expand=False)
def _create_header_window(self, info): width, height = 300, -1 vbox = gtk.VBox() sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # create the TreeView treeview = gtk.TreeView() # create the TreeViewColumns to display the data tvcolumn = [None] * len(self.columns) for n in range(0, len(self.columns)): cell = gtk.CellRendererText() cell.set_padding(2, 0) header, kwd = self.columns[n] tvc = gtk.TreeViewColumn(header, cell) tvc.set_resizable(True) tvc.connect('clicked', self.sort_cb, n) tvc.set_clickable(True) tvcolumn[n] = tvc fn_data = self._mkcolfnN(kwd) tvcolumn[n].set_cell_data_func(cell, fn_data) treeview.append_column(tvcolumn[n]) sw.add(treeview) vbox.pack_start(sw, fill=True, expand=True) # create sort toggle cb = GtkHelp.CheckButton("Sortable") cb.sconnect('toggled', lambda w: self.set_sortable_cb(info)) hbox = gtk.HBox() hbox.pack_start(cb, fill=True, expand=False) vbox.pack_start(hbox, fill=True, expand=False) vbox.show_all() info.setvals(widget=vbox, treeview=treeview, sortw=cb) return vbox
def _setup_params(self, obj, container): params = obj.getParams() captions = [] paramList = sorted(params.values(), key=lambda b: b.order) for bnch in paramList: text = bnch.name if bnch.has_key('label'): text = bnch.label #captions.append((text, 'entry')) captions.append((text, 'xlabel', '@'+bnch.name, 'entry')) # TODO: put RA/DEC first, and other stuff not in random orders w, b = GtkHelp.build_info(captions) # remove old widgets children = container.get_children() for child in children: container.remove(child) # add new widgets container.pack_start(w, fill=False, expand=False) container.show_all() return b
def _setup_params(self, obj, container): params = obj.getParams() captions = [] paramList = sorted(params.values(), key=lambda b: b.order) for bnch in paramList: text = bnch.name if 'label' in bnch: text = bnch.label #captions.append((text, 'entry')) captions.append((text, 'xlabel', '@' + bnch.name, 'entry')) # TODO: put RA/DEC first, and other stuff not in random orders w, b = GtkHelp.build_info(captions) # remove old widgets children = container.get_children() for child in children: container.remove(child) # add new widgets container.pack_start(w, fill=False, expand=False) container.show_all() return b
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() root = gtk.Window(gtk.WINDOW_TOPLEVEL) root.set_title("Gtk2 CanvasView Example") root.set_border_width(2) root.connect("delete_event", lambda w, e: quit(w)) self.root = root self.select = GtkHelp.FileSelection(root) vbox = gtk.VBox(spacing=2) fi = CanvasView(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_zoom_algorithm('rate') fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback('drag-drop', self.drop_file_cb) fi.set_callback('cursor-changed', self.cursor_cb) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.set_surface(fi) self.canvas = canvas # add canvas to view private_canvas = fi.get_canvas() private_canvas.register_for_cursor_drawing(fi) private_canvas.add(canvas) canvas.ui_set_active(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar #fi.show_color_bar(True) fi.show_focus_indicator(True) # add little mode indicator that shows keyboard modal states fi.show_mode_indicator(True, corner='ur') w = fi.get_widget() w.set_size_request(512, 512) vbox.pack_start(w, fill=True, expand=True) self.readout = gtk.Label("") vbox.pack_start(self.readout, fill=True, expand=False) hbox = gtk.HBox(spacing=5) wdrawtype = GtkHelp.combo_box_new_text() index = 0 for name in self.drawtypes: wdrawtype.insert_text(index, name) index += 1 index = self.drawtypes.index('rectangle') wdrawtype.set_active(index) wdrawtype.connect('changed', self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = GtkHelp.combo_box_new_text() index = 0 for name in self.drawcolors: wdrawcolor.insert_text(index, name) index += 1 index = self.drawcolors.index('lightblue') wdrawcolor.set_active(index) wdrawcolor.connect('changed', self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = GtkHelp.CheckButton("Fill") wfill.sconnect('toggled', self.set_drawparams) self.wfill = wfill walpha = GtkHelp.SpinButton() adj = walpha.get_adjustment() adj.configure(0.0, 0.0, 1.0, 0.1, 0.1, 0) walpha.set_value(1.0) walpha.set_digits(1) walpha.sconnect('value-changed', self.set_drawparams) self.walpha = walpha wclear = gtk.Button("Clear Canvas") wclear.connect('clicked', self.clear_canvas) wopen = gtk.Button("Open File") wopen.connect('clicked', self.open_file) wquit = gtk.Button("Quit") wquit.connect('clicked', quit) for w in (wquit, wclear, walpha, gtk.Label("Alpha:"), wfill, wdrawcolor, wdrawtype, wopen): hbox.pack_end(w, fill=False, expand=False) vbox.pack_start(hbox, fill=False, expand=False) root.add(vbox)
def build_gui(self, container): assert iqcalc.have_scipy == True, \ Exception("Please install python-scipy to use this plugin") self.pickcenter = None vpaned = gtk.VPaned() nb = gtk.Notebook() #nb.set_group_id(group) #nb.connect("create-window", self.detach_page, group) nb.set_tab_pos(gtk.POS_RIGHT) nb.set_scrollable(True) nb.set_show_tabs(True) nb.set_show_border(False) self.w.nb1 = nb vpaned.pack1(nb, resize=True, shrink=True) cm, im = self.fv.cm, self.fv.im di = FitsImageCanvasGtk.FitsImageCanvas(logger=self.logger) di.enable_autozoom('off') di.enable_autocuts('off') di.enable_zoom(True) di.enable_cuts(True) di.zoom_to(3, redraw=False) di.set_callback('zoom-set', self.zoomset) di.set_cmap(cm, redraw=False) di.set_imap(im, redraw=False) di.set_callback('motion', self.detailxy) di.set_bg(0.4, 0.4, 0.4) self.pickimage = di iw = di.get_widget() width, height = 200, 200 iw.set_size_request(width, height) label = gtk.Label('Image') label.show() nb.append_page(iw, label) nb.set_tab_reorderable(iw, True) #nb.set_tab_detachable(iw, True) if have_mpl: self.w.fig = matplotlib.figure.Figure() 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 = FigureCanvas(self.w.fig) #canvas.set_size_request(width, height) self.w.canvas = canvas self.w.canvas.show_all() canvas.connect("scroll_event", self.plot_scroll) #canvas.connect("key_press_event", self.pan_plot) canvas.connect("motion_notify_event", self.plot_motion_notify) canvas.connect("button_press_event", self.plot_button_press) canvas.connect("button_release_event", self.plot_button_release) label = gtk.Label('Contour') label.show() nb.append_page(canvas, label) nb.set_tab_reorderable(canvas, True) #nb.set_tab_detachable(canvas, True) self.w.fig2 = matplotlib.figure.Figure() 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 = FigureCanvas(self.w.fig2) #canvas.set_size_request(width, height) self.w.canvas2 = canvas self.w.canvas2.show_all() label = gtk.Label('FWHM') label.show() nb.append_page(canvas, label) nb.set_tab_reorderable(canvas, True) #nb.set_tab_detachable(canvas, True) sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox = gtk.VBox() sw.add_with_viewport(vbox) self.msgFont = pango.FontDescription("Sans 14") tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) vbox.pack_start(fr, padding=4, fill=True, expand=False) fr = gtk.Frame(" Pick ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) nb = gtk.Notebook() #nb.set_group_id(group) #nb.connect("create-window", self.detach_page, group) nb.set_tab_pos(gtk.POS_BOTTOM) nb.set_scrollable(True) nb.set_show_tabs(True) nb.set_show_border(False) self.w.nb2 = nb fr.add(nb) vbox.pack_start(fr, padding=4, fill=True, expand=False) # Build report panel captions = (('Zoom', 'label', 'Contour Zoom', 'label'), ('Object_X', 'label', 'Object_Y', 'label'), ('RA', 'label', 'DEC', 'label'), ('Equinox', 'label', 'Background', 'label'), ('Sky Level', 'label', 'Brightness', 'label'), ('FWHM X', 'label', 'FWHM Y', 'label'), ('FWHM', 'label', 'Star Size', 'label'), ('Sample Area', 'label', 'Default Region', 'button'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) b.zoom.set_text(self.fv.scale2text(di.get_scale())) self.wdetail = b b.default_region.connect('clicked', lambda w: self.reset_region()) self.w.tooltips.set_tip(b.default_region, "Reset region size to default") # Pick field evaluation status label = gtk.Label() label.set_alignment(0.05, 0.5) self.w.eval_status = label w.pack_start(self.w.eval_status, fill=False, expand=False, padding=2) # Pick field evaluation progress bar and stop button hbox = gtk.HBox() btn = gtk.Button("Stop") btn.connect('clicked', lambda w: self.eval_intr()) btn.set_sensitive(False) self.w.btn_intr_eval = btn hbox.pack_end(btn, fill=False, expand=False, padding=2) self.w.eval_pgs = gtk.ProgressBar() # GTK3 #self.w.eval_pgs.set_orientation(gtk.ORIENTATION_HORIZONTAL) #self.w.eval_pgs.set_inverted(False) hbox.pack_start(self.w.eval_pgs, fill=True, expand=True, padding=4) w.pack_start(hbox, fill=False, expand=False, padding=2) label = gtk.Label("Report") label.show() nb.append_page(w, label) nb.set_tab_reorderable(w, True) #nb.set_tab_detachable(w, True) # Build settings panel captions = (('Show Candidates', 'checkbutton'), ('Radius', 'xlabel', '@Radius', 'spinbutton'), ('Threshold', 'xlabel', '@Threshold', 'entry'), ('Min FWHM', 'xlabel', '@Min FWHM', 'spinbutton'), ('Max FWHM', 'xlabel', '@Max FWHM', 'spinbutton'), ('Ellipticity', 'xlabel', '@Ellipticity', 'entry'), ('Edge', 'xlabel', '@Edge', 'entry'), ('Max side', 'xlabel', '@Max side', 'spinbutton'), ('Redo Pick', 'button'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.tooltips.set_tip(b.radius, "Radius for peak detection") self.w.tooltips.set_tip(b.threshold, "Threshold for peak detection (blank=default)") self.w.tooltips.set_tip(b.min_fwhm, "Minimum FWHM for selection") self.w.tooltips.set_tip(b.max_fwhm, "Maximum FWHM for selection") self.w.tooltips.set_tip(b.ellipticity, "Minimum ellipticity for selection") self.w.tooltips.set_tip(b.edge, "Minimum edge distance for selection") self.w.tooltips.set_tip(b.show_candidates, "Show all peak candidates") # radius control adj = b.radius.get_adjustment() b.radius.set_digits(2) b.radius.set_numeric(True) adj.configure(self.radius, 5.0, 200.0, 1.0, 10.0, 0) def chg_radius(w): self.radius = float(w.get_text()) self.w.lbl_radius.set_text(str(self.radius)) return True b.lbl_radius.set_text(str(self.radius)) b.radius.connect('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.lbl_threshold.set_text(str(self.threshold)) return True b.lbl_threshold.set_text(str(self.threshold)) b.threshold.connect('activate', chg_threshold) # min fwhm adj = b.min_fwhm.get_adjustment() b.min_fwhm.set_digits(2) b.min_fwhm.set_numeric(True) adj.configure(self.min_fwhm, 0.1, 200.0, 0.1, 1, 0) def chg_min(w): self.min_fwhm = w.get_value() self.w.lbl_min_fwhm.set_text(str(self.min_fwhm)) return True b.lbl_min_fwhm.set_text(str(self.min_fwhm)) b.min_fwhm.connect('value-changed', chg_min) # max fwhm adj = b.max_fwhm.get_adjustment() b.max_fwhm.set_digits(2) b.max_fwhm.set_numeric(True) adj.configure(self.max_fwhm, 0.1, 200.0, 0.1, 1, 0) def chg_max(w): self.max_fwhm = w.get_value() self.w.lbl_max_fwhm.set_text(str(self.max_fwhm)) return True b.lbl_max_fwhm.set_text(str(self.max_fwhm)) b.max_fwhm.connect('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.lbl_ellipticity.set_text(str(self.min_ellipse)) return True b.lbl_ellipticity.set_text(str(self.min_ellipse)) b.ellipticity.connect('activate', 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.lbl_edge.set_text(str(self.edgew)) return True b.lbl_edge.set_text(str(self.edgew)) b.edge.connect('activate', chg_edgew) adj = b.max_side.get_adjustment() b.max_side.set_digits(0) b.max_side.set_numeric(True) adj.configure(self.max_side, 5, 10000, 10, 100, 0) def chg_max_side(w): self.max_side = int(w.get_value()) self.w.lbl_max_side.set_text(str(self.max_side)) return True b.lbl_max_side.set_text(str(self.max_side)) b.max_side.connect('value-changed', chg_max_side) b.redo_pick.connect('clicked', lambda w: self.redo()) b.show_candidates.set_active(self.show_candidates) b.show_candidates.connect('toggled', self.show_candidates_cb) label = gtk.Label("Settings") label.show() nb.append_page(w, label) nb.set_tab_reorderable(w, True) #nb.set_tab_detachable(w, True) # Build controls panel captions = ( ('Sky cut', 'button', 'Delta sky', 'xlabel', '@Delta sky', 'entry'), ('Bright cut', 'button', 'Delta bright', 'xlabel', '@Delta bright', 'entry'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.tooltips.set_tip(b.sky_cut, "Set image low cut to Sky Level") self.w.tooltips.set_tip(b.delta_sky, "Delta to apply to low cut") self.w.tooltips.set_tip(b.bright_cut, "Set image high cut to Sky Level+Brightness") self.w.tooltips.set_tip(b.delta_bright, "Delta to apply to high cut") b.sky_cut.set_sensitive(False) self.w.btn_sky_cut = b.sky_cut self.w.btn_sky_cut.connect('clicked', lambda w: self.sky_cut()) self.w.sky_cut_delta = b.delta_sky b.lbl_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.lbl_delta_sky.set_text(str(self.delta_sky)) return True b.delta_sky.connect('activate', chg_delta_sky) b.bright_cut.set_sensitive(False) self.w.btn_bright_cut = b.bright_cut self.w.btn_bright_cut.connect('clicked', lambda w: self.bright_cut()) self.w.bright_cut_delta = b.delta_bright b.lbl_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.lbl_delta_bright.set_text(str(self.delta_bright)) return True b.delta_bright.connect('activate', chg_delta_bright) label = gtk.Label("Controls") label.show() nb.append_page(w, label) nb.set_tab_reorderable(w, True) #nb.set_tab_detachable(w, True) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox.pack_start(btns, padding=4, fill=True, expand=False) vpaned.pack2(sw, resize=True, shrink=True) vpaned.set_position(280) vpaned.show_all() container.pack_start(vpaned, padding=0, fill=True, expand=True)
def _build_gui(self, container): self.mframe = container vbox = gtk.VBox() sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.sw = sw vbox.pack_start(sw, fill=True, expand=True) self.cbar = ColorBar.ColorBar(self.logger) self.cbar.set_cmap(self.cmap) self.cbar.set_imap(self.imap) vbox.pack_start(self.cbar, padding=4, fill=True, expand=False) btns = gtk.HBox() btns.set_spacing(2) combobox = GtkHelp.combo_box_new_text() options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.insert_text(index, name) index += 1 cmap_name = self.magcmap try: index = self.cmap_names.index(cmap_name) except Exception: index = self.cmap_names.index('ramp') combobox.set_active(index) combobox.sconnect('changed', self.set_cmap_cb) self.btn['cmap'] = combobox btns.add(combobox) combobox = GtkHelp.combo_box_new_text() options = [] index = 0 for name in self.imap_names: options.append(name) combobox.insert_text(index, name) index += 1 imap_name = self.magimap try: index = self.imap_names.index(imap_name) except Exception: index = self.imap_names.index('ramp') combobox.set_active(index) combobox.sconnect('changed', self.set_imap_cb) self.btn['imap'] = combobox btns.add(combobox) vbox.pack_start(btns, padding=4, fill=True, expand=False) btns = gtk.HBox() btns.set_spacing(2) for name in ('Plot', 'Clear', #'Close' ): btn = gtk.Button(name) btns.add(btn) self.btn[name.lower()] = btn combobox = GtkHelp.combo_box_new_text() options = [] index = 0 for name in ['Mag']: options.append(name) combobox.insert_text(index, name) index += 1 combobox.set_active(0) combobox.sconnect('changed', self.set_field_cb) self.btn['field'] = combobox btns.add(combobox) self.btn.plot.connect('clicked', lambda w: self.replot_stars()) self.btn.clear.connect('clicked', lambda w: self.clear()) #self.btn.close.connect('clicked', lambda w: self.close()) vbox.pack_start(btns, padding=4, fill=True, expand=False) vbox.show_all() # create the table info = Bunch.Bunch(columns=self.columns, color='Mag') self.build_table(info) self.mframe.pack_start(vbox, expand=True, fill=True) self.mframe.show_all()
def build_gui(self, container, future=None): vbox1 = gtk.VBox() self.msgFont = self.fv.getFont('sansFont', 12) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(label=" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) vbox1.pack_start(fr, padding=4, fill=True, expand=False) nb = gtk.Notebook() #nb.set_group_id(group) #nb.connect("create-window", self.detach_page, group) nb.set_tab_pos(gtk.POS_BOTTOM) nb.set_scrollable(True) nb.set_show_tabs(True) nb.set_show_border(False) vbox1.pack_start(nb, padding=4, fill=True, expand=True) vbox0 = gtk.VBox() hbox = gtk.HBox(spacing=4) vbox = gtk.VBox() fr = gtk.Frame(label=" Image Server ") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) fr.add(vbox) captions = (('Server', 'xlabel'), ('@Server', 'combobox'), ('Use DSS channel', 'checkbutton'), ('Get Image', 'button')) w, self.w = GtkHelp.build_info(captions) self.w.nb = nb self.w.get_image.connect('clicked', lambda w: self.getimage_cb()) self.w.use_dss_channel.set_active(self.use_dss_channel) self.w.use_dss_channel.connect('toggled', self.use_dss_channel_cb) vbox.pack_start(w, padding=4, fill=True, expand=False) self.w.img_params = gtk.VBox() vbox.pack_start(self.w.img_params, padding=4, fill=True, expand=False) combobox = self.w.server index = 0 self.image_server_options = self.fv.imgsrv.getServerNames(kind='image') for name in self.image_server_options: combobox.insert_text(index, name) index += 1 index = 0 combobox.set_active(index) combobox.sconnect('changed', self.setup_params_image) if len(self.image_server_options) > 0: self.setup_params_image(combobox, redo=False) hbox.pack_start(fr, fill=True, expand=True) vbox = gtk.VBox() fr = gtk.Frame(label=" Catalog Server ") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) fr.add(vbox) captions = (('Server', 'xlabel'), ('@Server', 'combobox'), ('Limit stars to area', 'checkbutton'), ('Search', 'button')) w, self.w2 = GtkHelp.build_info(captions) self.w2.search.connect('clicked', lambda w: self.getcatalog_cb()) self.w2.limit_stars_to_area.set_active(self.limit_stars_to_area) self.w2.limit_stars_to_area.connect('toggled', self.limit_area_cb) vbox.pack_start(w, padding=4, fill=True, expand=False) self.w2.cat_params = gtk.VBox() vbox.pack_start(self.w2.cat_params, padding=4, fill=True, expand=False) combobox = self.w2.server index = 0 self.catalog_server_options = self.fv.imgsrv.getServerNames(kind='catalog') for name in self.catalog_server_options: combobox.insert_text(index, name) index += 1 index = 0 combobox.set_active(index) combobox.sconnect('changed', self.setup_params_catalog) if len(self.catalog_server_options) > 0: self.setup_params_catalog(combobox, redo=False) hbox.pack_start(fr, fill=True, expand=True) vbox0.pack_start(hbox, fill=True, expand=True) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(4) btn = gtk.RadioButton(None, "Rectangle") if self.drawtype == 'rectangle': btn.set_active(True) btn.connect('toggled', self.set_drawtype_cb, 'rectangle') btns.add(btn) btn = gtk.RadioButton(btn, "Circle") if self.drawtype == 'circle': btn.set_active(True) btn.connect('toggled', self.set_drawtype_cb, 'circle') btns.add(btn) btn = gtk.Button("Entire image") btn.connect('clicked', lambda w: self.setfromimage()) btns.add(btn) vbox0.pack_start(btns, padding=4, fill=True, expand=False) sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(vbox0) lbl = gtk.Label("Params") self.w.params = sw nb.append_page(sw, lbl) vbox = gtk.VBox() self.table = CatalogListing(self.logger, vbox) hbox = gtk.HBox() scale = gtk.HScrollbar() adj = scale.get_adjustment() #adj.configure(0, 0, 0, 1, 10, self.plot_limit) adj.configure(0, 0, 0, 1, 10, 0) #scale.set_size_request(200, -1) scale.set_tooltip_text("Choose subset of stars plotted") if not gtksel.have_gtk3: #scale.set_update_policy(gtk.UPDATE_DELAYED) scale.set_update_policy(gtk.UPDATE_CONTINUOUS) self.w.plotgrp = scale scale.connect('value-changed', self.plot_pct_cb) hbox.pack_start(scale, padding=2, fill=True, expand=True) sb = GtkHelp.SpinButton() adj = sb.get_adjustment() adj.configure(self.plot_limit, 10, self.plot_max, 10, 100, 0) self.w.plotnum = sb sb.set_tooltip_text("Adjust size of subset of stars plotted") sb.connect('value-changed', self.plot_limit_cb) hbox.pack_start(sb, padding=2, fill=False, expand=False) vbox.pack_start(hbox, padding=0, fill=False, expand=False) #vbox1.pack_start(vbox, padding=4, fill=True, expand=True) lbl = gtk.Label("Listing") self.w.listing = vbox nb.append_page(vbox, lbl) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) #btns.set_child_size(15, -1) self.w.buttons = btns btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) if future: btn = gtk.Button('Ok') btn.connect('clicked', lambda w: self.ok()) btns.add(btn) btn = gtk.Button('Cancel') btn.connect('clicked', lambda w: self.cancel()) btns.add(btn) vbox1.pack_start(btns, padding=4, fill=True, expand=False) vbox1.show_all() cw = container.get_widget() cw.pack_start(vbox1, padding=0, fill=True, expand=True)
def build_gui(self, container): # Paned container is just to provide a way to size the graph # to a reasonable size box = gtk.VPaned() container.pack_start(box, expand=True, fill=True) # Make the cuts plot vbox = gtk.VBox() self.msgFont = pango.FontDescription("Sans 14") tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) vbox.pack_start(fr, padding=4, fill=True, expand=False) self.plot = Plot.Cuts(self.logger) w = self.plot.get_widget() vbox.pack_start(w, padding=4, fill=True, expand=True) hbox = gtk.HBox(spacing=4) # control for selecting a cut combobox = GtkHelp.combo_box_new_text() for tag in self.tags: combobox.append_text(tag) if self.cutstag == None: combobox.set_active(0) else: combobox.show_text(self.cutstag) combobox.sconnect("changed", self.cut_select_cb) self.w.cuts = combobox self.w.tooltips.set_tip(combobox, "Select a cut") hbox.pack_start(combobox, fill=False, expand=False) btn = gtk.Button("Delete") btn.connect('clicked', lambda w: self.delete_cut_cb()) self.w.tooltips.set_tip(btn, "Delete selected cut") hbox.pack_start(btn, fill=False, expand=False) btn = gtk.Button("Delete All") btn.connect('clicked', lambda w: self.delete_all()) self.w.tooltips.set_tip(btn, "Clear all cuts") hbox.pack_start(btn, fill=False, expand=False) ## btn = GtkHelp.CheckButton("Move together") ## btn.set_active(self.move_together) ## #btn.sconnect('toggled', self.movetogether_cb) ## self.w.tooltips.set_tip(btn, "Move cuts as a group") ## hbox.pack_start(btn, fill=False, expand=False) vbox.pack_start(hbox, fill=True, expand=False) box.pack1(vbox, resize=True, shrink=True) box.pack2(gtk.Label(), resize=True, shrink=True) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) container.pack_start(btns, padding=4, fill=True, expand=False)
def build_toplevel(self): self.font = self.getFont('fixedFont', 12) self.font11 = self.getFont('fixedFont', 11) # Hack to enable images in Buttons in recent versions of gnome. # Why did they change the default? Grrr.... s = gtk.settings_get_default() try: s.set_property("gtk-button-images", True) except: pass self.ds = GtkHelp.Desktop() self.ds.make_desktop(self.layout, widgetDict=self.w) # TEMP: FIX ME! self.gpmon.ds = self.ds for root in self.ds.toplevels: # Create root window and add delete/destroy callbacks root.set_title("Ginga") root.set_border_width(2) root.connect("destroy", self.quit) root.connect("delete_event", self.delete_event) root.connect('window-state-event', self.window_state_change) self.w.root = root menuholder = self.w['menu'] self.add_menus(menuholder) # Create main (center) FITS image pane self.w.vbox = self.w['main'] #bnch = self.ds.make_ws(name='main', group=1, wstype='nb') #bnch = self.ds.make_ws(name='main', group=1, wstype='grid') self.ds.add_callback("page-select", self.page_switch_cb) # readout if self.settings.get('shareReadout', True): self.readout = self.build_readout() self.add_callback('field-info', self.readout_cb, self.readout, None) rw = self.readout.get_widget() self.w.vbox.pack_start(rw, padding=0, fill=True, expand=False) # bottom buttons hbox = gtk.HBox() cbox = GtkHelp.combo_box_new_text() self.w.channel = cbox cbox.set_tooltip_text("Select a channel") cbox.connect("changed", self.channel_select_cb) hbox.pack_start(cbox, fill=False, expand=False, padding=4) opmenu = gtk.Menu() self.w.operation = opmenu btn = gtk.Button("Operation") btn.connect('button-press-event', self.invoke_op_cb) btn.set_tooltip_text("Invoke operation") hbox.pack_start(btn, fill=False, expand=False, padding=2) self.w.optray = gtk.HBox() hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2) self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False) # Add colormap bar cbar = self.build_colorbar() self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False) self.w.vbox.show_all() self.add_dialogs() statusholder = self.w['status'] self.add_statusbar(statusholder) self.w.root.show_all()
def build_gui(self, container): # Paned container is just to provide a way to size the graph # to a reasonable size box = gtk.VPaned() container.pack_start(box, expand=True, fill=True) # Make the histogram plot vbox = gtk.VBox() self.msgFont = self.fv.getFont('fixedFont', 10) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_NONE) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Pixel Values ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) fr.show_all() vbox.pack_start(fr, padding=4, fill=True, expand=False) box.pack1(vbox, resize=True, shrink=True) hbox = gtk.HBox(spacing=4) combobox = GtkHelp.combo_box_new_text() index = 0 for i in self.sizes: j = 1 + i*2 name = "%dx%d" % (j, j) combobox.insert_text(index, name) index += 1 index = self.sizes.index(self.pixtbl_radius) combobox.set_active(index) combobox.sconnect('changed', self.set_cutout_size) self.w.tooltips.set_tip(combobox, "Select size of pixel table") hbox.pack_start(combobox, fill=False, expand=False) # control for selecting a mark combobox = GtkHelp.combo_box_new_text() for tag in self.marks: combobox.append_text(tag) if self.mark_selected == None: combobox.set_active(0) else: combobox.show_text(self.mark_selected) combobox.sconnect("changed", self.mark_select_cb) self.w.marks = combobox self.w.tooltips.set_tip(combobox, "Select a mark") hbox.pack_start(combobox, fill=False, expand=False) btn = gtk.Button("Delete") btn.connect('clicked', lambda w: self.clear_mark_cb()) self.w.tooltips.set_tip(btn, "Delete selected mark") hbox.pack_start(btn, fill=False, expand=False) btn = gtk.Button("Delete All") btn.connect('clicked', lambda w: self.clear_all()) self.w.tooltips.set_tip(btn, "Clear all marks") hbox.pack_start(btn, fill=False, expand=False) btn = GtkHelp.CheckButton("Pan to mark") btn.set_active(self.pan2mark) btn.sconnect('toggled', self.pan2mark_cb) self.w.tooltips.set_tip(btn, "Pan follows selected mark") hbox.pack_start(btn, fill=False, expand=False) vbox.pack_start(hbox, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox.pack_start(btns, padding=4, fill=True, expand=False) box.pack2(gtk.Label(), resize=True, shrink=True)
def build_gui(self, container): vpaned = gtk.VPaned() width, height = 200, 200 # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = FitsImageCanvasGtk.FitsImageCanvas(logger=self.logger) zi = FitsImageCanvasGtk.FitsImageCanvas(logger=None) zi.enable_autozoom('off') zi.enable_autocuts('off') zi.enable_zoom(False) #zi.set_scale_limits(0.001, 1000.0) zi.zoom_to(self.default_zoom, redraw=False) zi.add_callback('zoom-set', self.zoomset) #zi.add_callback('motion', self.showxy) zi.set_bg(0.4, 0.4, 0.4) zi.show_pan_mark(True, redraw=False) self.zoomimage = zi iw = zi.get_widget() iw.set_size_request(width, height) vpaned.pack1(iw, resize=True, shrink=True) vbox = gtk.VBox() vbox.pack_start(gtk.Label("Zoom Radius:"), padding=2, fill=True, expand=False) adj = gtk.Adjustment(lower=1, upper=100) adj.set_value(self.zoom_radius) scale = GtkHelp.HScale(adj) scale.set_size_request(200, -1) scale.set_digits(0) scale.set_draw_value(True) scale.set_value_pos(gtk.POS_BOTTOM) #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.w_radius = scale scale.connect('value-changed', self.set_radius_cb) vbox.pack_start(scale, padding=0, fill=True, expand=False) vbox.pack_start(gtk.Label("Zoom Amount:"), padding=2, fill=True, expand=False) adj = gtk.Adjustment(lower=-20, upper=30) adj.set_value(self.zoom_amount) scale = GtkHelp.HScale(adj) scale.set_size_request(200, -1) scale.set_digits(0) scale.set_draw_value(True) scale.set_value_pos(gtk.POS_BOTTOM) #scale.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.w_amount = scale scale.connect('value-changed', self.set_amount_cb) vbox.pack_start(scale, padding=0, fill=True, expand=False) captions = (('Zoom', 'label'), ("Relative Zoom", 'checkbutton'), ("Lag Time", 'spinbutton'), ('Defaults', 'button'), ) w, b = GtkHelp.build_info(captions) b.zoom.set_text(self.fv.scale2text(zi.get_scale())) self.wzoom = b b.relative_zoom.set_active(not self.t_abszoom) b.relative_zoom.sconnect("toggled", self.set_absrel_cb) b.defaults.connect("clicked", lambda w: self.set_defaults()) adj = b.lag_time.get_adjustment() adj.configure(0, 0, 20, 1, 1, 1) adj.set_value(self.lagtime) b.lag_time.set_digits(0) b.lag_time.set_wrap(True) b.lag_time.connect('value-changed', self.setlag_cb) vbox.pack_start(w, padding=4, fill=True, expand=False) sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(vbox) vpaned.pack2(sw, resize=True, shrink=True) vpaned.show_all() vpaned.set_position(height) container.pack_start(vpaned, padding=0, fill=True, expand=True)
def build_gui(self, container): sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox = gtk.VBox(spacing=2) vbox.set_border_width(4) sw.add_with_viewport(vbox) # COLOR MAPPING OPTIONS fr = gtk.Frame(label="Colors") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Colormap', 'combobox', 'Intensity', 'combobox'), ('Algorithm', 'combobox', 'Table Size', 'entry'), ('Color Defaults', 'button')) w, b = GtkHelp.build_info(captions) self.w.cmap_choice = b.colormap self.w.imap_choice = b.intensity self.w.calg_choice = b.algorithm self.w.table_size = b.table_size b.color_defaults.connect('clicked', lambda w: self.set_default_maps()) b.colormap.set_tooltip_text("Choose a color map for this image") b.intensity.set_tooltip_text("Choose an intensity map for this image") b.algorithm.set_tooltip_text("Choose a color mapping algorithm") b.table_size.set_tooltip_text("Set size of the color mapping table") b.color_defaults.set_tooltip_text("Restore default color and intensity maps") fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) combobox = b.colormap options = [] index = 0 for name in self.cmap_names: options.append(name) combobox.insert_text(index, 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_active(index) combobox.sconnect('changed', self.set_cmap_cb) combobox = b.intensity options = [] index = 0 for name in self.imap_names: options.append(name) combobox.insert_text(index, 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_active(index) combobox.sconnect('changed', self.set_imap_cb) combobox = b.algorithm options = [] index = 0 for name in self.calg_names: options.append(name) combobox.insert_text(index, name) index += 1 index = self.calg_names.index(self.t_.get('color_algorithm', "linear")) combobox.set_active(index) combobox.sconnect('changed', self.set_calg_cb) entry = b.table_size entry.set_text(str(self.t_.get('color_hashsize', 65535))) entry.connect('activate', self.set_tablesize_cb) # ZOOM OPTIONS fr = gtk.Frame(label="Zoom") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Zoom Alg', 'combobox', 'Zoom Rate', 'spinbutton'), ('Stretch XY', 'combobox', 'Stretch Factor', 'spinbutton'), ('Scale X', 'entry', 'Scale Y', 'entry'), ('Scale Min', 'spinbutton', 'Scale Max', 'spinbutton'), ('Zoom Defaults', 'button')) w, b = GtkHelp.build_info(captions) self.w.update(b) index = 0 for name in self.zoomalg_names: b.zoom_alg.insert_text(index, name.capitalize()) index += 1 zoomalg = self.t_.get('zoom_algorithm', "step") index = self.zoomalg_names.index(zoomalg) b.zoom_alg.set_active(index) b.zoom_alg.set_tooltip_text("Choose Zoom algorithm") b.zoom_alg.sconnect('changed', lambda w: self.set_zoomalg_cb()) index = 0 for name in ('X', 'Y'): b.stretch_xy.insert_text(index, name) index += 1 b.stretch_xy.set_active(0) b.stretch_xy.set_tooltip_text("Stretch pixels in X or Y") b.stretch_xy.sconnect('changed', lambda w: self.set_stretch_cb()) b.stretch_factor.set_range(1.0, 10.0) b.stretch_factor.set_value(1.0) b.stretch_factor.set_increments(0.1, 0.25) b.stretch_factor.set_digits(5) b.stretch_factor.set_numeric(True) b.stretch_factor.sconnect('value-changed', lambda w: self.set_stretch_cb()) b.stretch_factor.set_tooltip_text("Length of pixel relative to 1 on other side") b.stretch_factor.set_sensitive(zoomalg!='step') zoomrate = self.t_.get('zoom_rate', math.sqrt(2.0)) b.zoom_rate.set_range(1.1, 3.0) b.zoom_rate.set_value(zoomrate) b.zoom_rate.set_increments(0.1, 0.5) b.zoom_rate.set_digits(5) b.zoom_rate.set_numeric(True) b.zoom_rate.set_sensitive(zoomalg!='step') b.zoom_rate.set_tooltip_text("Step rate of increase/decrease per zoom level") b.zoom_rate.sconnect('value-changed', self.set_zoomrate_cb) b.zoom_defaults.connect('clicked', self.set_zoom_defaults_cb) scale_x, scale_y = self.fitsimage.get_scale_xy() b.scale_x.set_tooltip_text("Set the scale in X axis") b.scale_x.set_text(str(scale_x)) b.scale_x.connect("activate", lambda w: self.set_scale_cb()) b.scale_y.set_tooltip_text("Set the scale in Y axis") b.scale_y.set_text(str(scale_y)) b.scale_y.connect("activate", lambda w: self.set_scale_cb()) scale_min, scale_max = self.t_['scale_min'], self.t_['scale_max'] b.scale_min.set_range(0.00001, 1.0) b.scale_min.set_value(scale_min) b.scale_min.set_increments(1.0, 10.0) b.scale_min.set_digits(5) b.scale_min.set_numeric(True) b.scale_min.sconnect('value-changed', lambda w: self.set_scale_limit_cb()) b.scale_min.set_tooltip_text("Set the minimum allowed scale in any axis") b.scale_max.set_range(1.0, 10000.0) b.scale_max.set_value(scale_max) b.scale_max.set_increments(1.0, 10.0) b.scale_max.set_digits(5) b.scale_max.set_numeric(True) b.scale_max.sconnect('value-changed', lambda w: self.set_scale_limit_cb()) b.scale_min.set_tooltip_text("Set the maximum allowed scale in any axis") fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) # PAN OPTIONS fr = gtk.Frame(label="Panning") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Pan X', 'entry'), ('Pan Y', 'entry', 'Center Image', 'button'), ('Reverse Pan', 'checkbutton', 'Mark Center', 'checkbutton')) w, b = GtkHelp.build_info(captions) self.w.update(b) pan_x, pan_y = self.fitsimage.get_pan() b.pan_x.set_tooltip_text("Set the pan position in X axis") b.pan_x.set_text(str(pan_x+0.5)) b.pan_x.connect("activate", lambda w: self.set_pan_cb()) b.pan_y.set_tooltip_text("Set the pan position in Y axis") b.pan_y.set_text(str(pan_y+0.5)) b.pan_y.connect("activate", lambda w: self.set_pan_cb()) b.center_image.set_tooltip_text("Set the pan position to center of the image") b.center_image.connect("clicked", lambda w: self.center_image_cb()) b.reverse_pan.set_tooltip_text("Reverse the pan direction") b.reverse_pan.sconnect("toggled", lambda w: self.set_misc_cb()) b.mark_center.set_tooltip_text("Mark the center (pan locator)") b.mark_center.sconnect("toggled", lambda w: self.set_misc_cb()) fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) # TRANSFORM OPTIONS fr = gtk.Frame(label="Transform") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Flip X', 'checkbutton', 'Flip Y', 'checkbutton', 'Swap XY', 'checkbutton'), ('Rotate', 'spinbutton'), ('Restore', 'button'),) w, b = GtkHelp.build_info(captions) self.w.update(b) for name in ('flip_x', 'flip_y', 'swap_xy'): btn = b[name] btn.set_active(self.t_.get(name, False)) btn.sconnect("toggled", lambda w: self.set_transforms_cb()) btn.set_mode(True) b.flip_x.set_tooltip_text("Flip the image around the X axis") b.flip_y.set_tooltip_text("Flip the image around the Y axis") b.swap_xy.set_tooltip_text("Swap the X and Y axes in the image") b.rotate.set_range(0.00, 359.99999999) b.rotate.set_value(self.t_.get('rot_deg', 0.00)) b.rotate.set_increments(10.0, 30.0) b.rotate.set_digits(5) b.rotate.set_numeric(True) b.rotate.set_wrap(True) b.rotate.sconnect('value-changed', lambda w: self.rotate_cb()) b.rotate.set_tooltip_text("Rotate image around the pan position") b.restore.set_tooltip_text("Clear any transforms and center image") b.restore.connect("clicked", lambda w: self.restore_cb()) fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) # AUTOCUTS OPTIONS fr = gtk.Frame(label="Auto Cuts") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Auto Method', 'combobox'), ) w, b = GtkHelp.build_info(captions) 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.insert_text(index, name) index += 1 index = self.autocut_methods.index(method) combobox.set_active(index) combobox.sconnect('changed', lambda w: self.set_autocut_method_cb()) b.auto_method.set_tooltip_text("Choose algorithm for auto levels") self.w.acvbox = gtk.VBox() w.pack_end(self.w.acvbox, fill=True, expand=True) fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) # WCS OPTIONS fr = gtk.Frame(label="WCS") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('WCS Coords', 'combobox', 'WCS Display', 'combobox'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) b.wcs_coords.set_tooltip_text("Set WCS coordinate system") b.wcs_display.set_tooltip_text("Set WCS display format") # Setup WCS coords method choice combobox = b.wcs_coords index = 0 for name in wcs.coord_types: combobox.insert_text(index, name) index += 1 method = self.t_.get('wcs_coords', "") try: index = wcs.coord_types.index(method) combobox.set_active(index) except ValueError: pass combobox.sconnect('changed', lambda w: self.set_wcs_params_cb()) # Setup WCS display format method choice combobox = b.wcs_display index = 0 for name in wcs.display_types: combobox.insert_text(index, name) index += 1 method = self.t_.get('wcs_display', "sexagesimal") try: index = wcs.display_types.index(method) combobox.set_active(index) except ValueError: pass combobox.sconnect('changed', lambda w: self.set_wcs_params_cb()) fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) # NEW IMAGES OPTIONS fr = gtk.Frame(label="New Images") fr.set_shadow_type(gtk.SHADOW_ETCHED_IN) fr.set_label_align(0.5, 0.5) captions = (('Cut New', 'combobox', 'Zoom New', 'combobox'), ('Center New', 'checkbutton', 'Follow New', 'checkbutton'), ('Raise New', 'checkbutton', 'Create thumbnail', 'checkbutton'),) w, b = GtkHelp.build_info(captions) self.w.update(b) combobox = b.cut_new index = 0 for name in self.autocut_options: combobox.insert_text(index, name) index += 1 option = self.t_.get('autocuts', "off") index = self.autocut_options.index(option) combobox.set_active(index) combobox.sconnect('changed', self.set_autocuts_cb) combobox = b.zoom_new index = 0 for name in self.autozoom_options: combobox.insert_text(index, name) index += 1 option = self.t_.get('autozoom', "off") index = self.autozoom_options.index(option) combobox.set_active(index) combobox.sconnect('changed', self.set_autozoom_cb) b.zoom_new.set_tooltip_text("Automatically fit new images to window") b.cut_new.set_tooltip_text("Automatically set cut levels for new images") b.center_new.set_tooltip_text("Automatically center new images") b.follow_new.set_tooltip_text("View new images as they arrive") b.raise_new.set_tooltip_text("Raise and focus tab for new images") b.create_thumbnail.set_tooltip_text("Create thumbnail for new images") self.w.center_new.set_active(True) self.w.center_new.sconnect("toggled", lambda w: self.set_chprefs_cb()) self.w.follow_new.set_active(True) self.w.follow_new.sconnect("toggled", lambda w: self.set_chprefs_cb()) self.w.raise_new.set_active(True) self.w.raise_new.sconnect("toggled", lambda w: self.set_chprefs_cb()) self.w.create_thumbnail.set_active(True) self.w.create_thumbnail.sconnect("toggled", lambda w: self.set_chprefs_cb()) fr.add(w) vbox.pack_start(fr, padding=4, fill=True, expand=False) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btn = gtk.Button("Save Settings") btn.connect('clicked', lambda w: self.save_preferences()) btns.add(btn) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) vbox.pack_start(btns, padding=4, fill=True, expand=False) vbox.show_all() container.pack_start(sw, padding=0, fill=True, expand=True) self.gui_up = True
def _create_info_window(self): sw = gtk.ScrolledWindow() sw.set_border_width(2) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vbox = gtk.VBox() captions = (('Name', 'label'), ('Object', 'label'), ('X', 'label'), ('Y', 'label'), ('Value', 'label'), ('RA', 'label'), ('DEC', 'label'), ('Equinox', 'label'), ('Dimensions', 'label'), #('Slices', 'label', 'MultiDim', 'button'), ('Min', 'label'), ('Max', 'label'), ('Zoom', 'label'), ('Cut Low', 'xlabel', '@Cut Low', 'entry'), ('Cut High', 'xlabel', '@Cut High', 'entry'), ('Auto Levels', 'button', 'Cut Levels', 'button'), ('Cut New', 'label'), ('Zoom New', 'label'), ('Preferences', 'button'), ) w, b = GtkHelp.build_info(captions) # TODO: need a more general solution to gtk labels resizing their # parent window b.object.set_width_chars(12) b.cut_levels.set_tooltip_text("Set cut levels manually") b.auto_levels.set_tooltip_text("Set cut levels by algorithm") b.cut_low.set_tooltip_text("Set low cut level (press Enter)") b.cut_high.set_tooltip_text("Set high cut level (press Enter)") b.preferences.set_tooltip_text("Set preferences for this channel") #b.multidim.set_tooltip_text("View other HDUs or slices") vbox.pack_start(w, padding=0, fill=True, expand=True) # Convenience navigation buttons btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_CENTER) btns.set_spacing(3) if not gtksel.have_gtk3: btns.set_child_size(15, -1) 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_text(tup[3]) bw[GtkHelp._name_mangle(name, pfx='btn_')] = btn btns.pack_end(btn, padding=4) #self.w.btn_load.connect("clicked", lambda w: self.gui_load_file()) bw.btn_prev.connect("clicked", lambda w: self.fv.prev_img()) bw.btn_next.connect("clicked", lambda w: self.fv.next_img()) bw.btn_zoom_in.connect("clicked", lambda w: self.fv.zoom_in()) bw.btn_zoom_out.connect("clicked", lambda w: self.fv.zoom_out()) bw.btn_zoom_fit.connect("clicked", lambda w: self.fv.zoom_fit()) bw.btn_zoom_1_1.connect("clicked", lambda w: self.fv.zoom_1_to_1()) vbox.pack_start(btns, padding=4, fill=True, expand=False) vbox.show_all() sw.add_with_viewport(vbox) #sw.set_size_request(-1, 420) sw.show_all() return sw, b
def build_gui(self, container): # Paned container is just to provide a way to size the graph # to a reasonable size box = gtk.VPaned() container.pack_start(box, expand=True, fill=True) # Make the histogram plot vbox = gtk.VBox() self.msgFont = self.fv.getFont("sansFont", 14) tw = gtk.TextView() tw.set_wrap_mode(gtk.WRAP_WORD) tw.set_left_margin(4) tw.set_right_margin(4) tw.set_editable(False) tw.set_left_margin(4) tw.set_right_margin(4) tw.modify_font(self.msgFont) self.tw = tw fr = gtk.Frame(" Instructions ") fr.set_shadow_type(gtk.SHADOW_ETCHED_OUT) fr.set_label_align(0.1, 0.5) fr.add(tw) vbox.pack_start(fr, padding=4, fill=True, expand=False) self.plot = Plot.Plot(self.logger) w = self.plot.get_widget() vbox.pack_start(w, padding=4, fill=True, expand=True) captions = (('Cut Low', 'xlabel', '@Cut Low', 'entry'), ('Cut High', 'xlabel', '@Cut High', 'entry', 'Cut Levels', 'button'), ('Auto Levels', 'button'), ) w, b = GtkHelp.build_info(captions) self.w.update(b) self.w.tooltips.set_tip(b.cut_levels, "Set cut levels manually") self.w.tooltips.set_tip(b.auto_levels, "Set cut levels by algorithm") self.w.tooltips.set_tip(b.cut_low, "Set low cut level (press Enter)") self.w.tooltips.set_tip(b.cut_high, "Set high cut level (press Enter)") b.cut_low.connect('activate', lambda w: self.cut_levels()) b.cut_high.connect('activate', lambda w: self.cut_levels()) b.cut_levels.connect('clicked', lambda w: self.cut_levels()) b.auto_levels.connect('clicked', lambda w: self.auto_levels()) vbox.pack_start(w, padding=4, fill=True, expand=False) box.pack1(vbox, resize=True, shrink=True) box.pack2(gtk.Label(), resize=True, shrink=True) #self.plot.set_callback('close', lambda x: self.stop()) btns = gtk.HButtonBox() btns.set_layout(gtk.BUTTONBOX_START) btns.set_spacing(3) btns.set_child_size(15, -1) btn = gtk.Button("Close") btn.connect('clicked', lambda w: self.close()) btns.add(btn) btn = gtk.Button("Full Image") btn.connect('clicked', lambda w: self.full_image()) btns.add(btn) container.pack_start(btns, padding=4, fill=True, expand=False) self.gui_up = True
def make_cursor(self, iconpath, x, y): cursor = GtkHelp.make_cursor(self.imgwin, iconpath, x, y) return cursor
def build_toplevel(self, layout): self.w.tooltips = gtk.Tooltips() self.font = self.getFont('fixedFont', 12) self.font11 = self.getFont('fixedFont', 11) # Hack to enable images in Buttons in recent versions of gnome. # Why did they change the default? Grrr.... s = gtk.settings_get_default() try: s.set_property("gtk-button-images", True) except: pass # Create root window and add delete/destroy callbacks root = gtk.Window(gtk.WINDOW_TOPLEVEL) root.set_size_request(self.default_width, self.default_height) root.set_title("Ginga") root.set_border_width(2) root.connect("destroy", self.quit) root.connect("delete_event", self.delete_event) root.connect('window-state-event', self.window_state_change) self.w.root = root self.ds = GtkHelp.Desktop() # create main frame self.w.mframe = gtk.VBox(spacing=2) root.add(self.w.mframe) self.add_menus() self.w.mvbox = self.ds.make_desktop(layout, widgetDict=self.w) self.w.mvbox.show_all() self.w.mframe.pack_start(self.w.mvbox, expand=True) # Create main (center) FITS image pane self.w.vbox = self.w['main'] bnch = self.ds.make_ws(name='main', group=1, wstype='nb') #bnch = self.ds.make_ws(name='main', group=1, wstype='grid') self.w.mnb = bnch.nb self.ds.add_callback("page-select", self.page_switch_cb) #self.w.mnb.connect("switch-page", self.page_switch_cb) self.w.vbox.pack_start(bnch.widget, expand=True, fill=True) # readout if self.settings.get('shareReadout', True): self.readout = self.build_readout() self.add_callback('field-info', self.readout_cb, self.readout, None) rw = self.readout.get_widget() self.w.vbox.pack_start(rw, padding=0, fill=True, expand=False) # bottom buttons hbox = gtk.HBox() cbox = GtkHelp.combo_box_new_text() self.w.channel = cbox self.w.tooltips.set_tip(cbox, "Select a channel") cbox.connect("changed", self.channel_select_cb) hbox.pack_start(cbox, fill=False, expand=False, padding=4) opmenu = gtk.Menu() self.w.operation = opmenu btn = gtk.Button("Operation") btn.connect('button-press-event', self.invoke_op_cb) self.w.tooltips.set_tip(btn, "Invoke operation") hbox.pack_start(btn, fill=False, expand=False, padding=2) self.w.optray = gtk.HBox() hbox.pack_start(self.w.optray, fill=True, expand=True, padding=2) self.w.vbox.pack_start(hbox, padding=0, fill=True, expand=False) # Add colormap bar cbar = self.build_colorbar() self.w.vbox.pack_start(cbar, padding=0, fill=True, expand=False) self.add_dialogs() self.add_statusbar() self.w.root.show_all()
def __init__(self, logger=None, rgbmap=None, settings=None): ImageViewGtk.__init__(self, logger=logger, rgbmap=rgbmap, settings=settings) imgwin = self.imgwin imgwin.set_can_focus(True) imgwin.connect("map_event", self.map_event) imgwin.connect("focus_in_event", self.focus_event, True) imgwin.connect("focus_out_event", self.focus_event, False) imgwin.connect("enter_notify_event", self.enter_notify_event) imgwin.connect("leave_notify_event", self.leave_notify_event) imgwin.connect("motion_notify_event", self.motion_notify_event) imgwin.connect("button_press_event", self.button_press_event) imgwin.connect("button_release_event", self.button_release_event) imgwin.connect("key_press_event", self.key_press_event) imgwin.connect("key_release_event", self.key_release_event) imgwin.connect("scroll_event", self.scroll_event) mask = imgwin.get_events() imgwin.set_events(mask | gtk.gdk.ENTER_NOTIFY_MASK | gtk.gdk.LEAVE_NOTIFY_MASK | gtk.gdk.FOCUS_CHANGE_MASK | gtk.gdk.STRUCTURE_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.SCROLL_MASK) # Set up widget as a drag and drop destination imgwin.connect("drag-data-received", self.drop_event) imgwin.connect("drag-motion", self.drag_motion_cb) imgwin.connect("drag-drop", self.drag_drop_cb) self.TARGET_TYPE_TEXT = 0 self.TARGET_TYPE_THUMB = 1 toImage = [ ( "text/plain", 0, self.TARGET_TYPE_TEXT ), #( "text/uri-list", 0, self.TARGET_TYPE_TEXT ), ( "text/thumb", gtk.TARGET_SAME_APP, self.TARGET_TYPE_THUMB ), ] imgwin.drag_dest_set(gtk.DEST_DEFAULT_ALL, toImage, gtk.gdk.ACTION_COPY) # last known window mouse position self.last_win_x = 0 self.last_win_y = 0 # last known data mouse position self.last_data_x = 0 self.last_data_y = 0 # Does widget accept focus when mouse enters window self.enter_focus = self.t_.get('enter_focus', True) # @$%&^(_)*&^ gnome!! self._keytbl = { 'shift_l': 'shift_l', 'shift_r': 'shift_r', 'control_l': 'control_l', 'control_r': 'control_r', 'alt_l': 'alt_l', 'alt_r': 'alt_r', 'super_l': 'super_l', 'super_r': 'super_r', 'meta_right': 'meta_right', 'asciitilde': '~', 'grave': 'backquote', 'exclam': '!', 'at': '@', 'numbersign': '#', 'percent': '%', 'asciicircum': '^', 'ampersand': '&', 'asterisk': '*', 'dollar': '$', 'parenleft': '(', 'parenright': ')', 'underscore': '_', 'minus': '-', 'plus': '+', 'equal': '=', 'braceleft': '{', 'braceright': '}', 'bracketleft': '[', 'bracketright': ']', 'bar': '|', 'colon': ':', 'semicolon': ';', 'quotedbl': 'doublequote', 'apostrophe': 'singlequote', 'backslash': 'backslash', 'less': '<', 'greater': '>', 'comma': ',', 'period': '.', 'question': '?', 'slash': '/', 'space': 'space', 'escape': 'escape', 'return': 'return', 'tab': 'tab', 'f1': 'f1', 'f2': 'f2', 'f3': 'f3', 'f4': 'f4', 'f5': 'f5', 'f6': 'f6', 'f7': 'f7', 'f8': 'f8', 'f9': 'f9', 'f10': 'f10', 'f11': 'f11', 'f12': 'f12', 'right': 'right', 'left': 'left', 'up': 'up', 'down': 'down', } # Define cursors for curname, filename in (('pan', 'openHandCursor.png'), ('pick', 'thinCrossCursor.png')): path = os.path.join(icon_dir, filename) cur = GtkHelp.make_cursor(self.imgwin, path, 8, 8) self.define_cursor(curname, cur) for name in ('motion', 'button-press', 'button-release', 'key-press', 'key-release', 'drag-drop', 'scroll', 'map', 'focus', 'enter', 'leave', ): self.enable_callback(name)