def add_cls_item(self, clr, sym, scl, rng, lbl, delete_button=True): """add a single row to the classification list. Optionally add a delete button that will delete that row from the classification. """ class_box = gtk.HBox() #explicitly size the first 5, let the last one fill the rest of the #space. h = 24 clr.set_size_request(48, h) rng.set_size_request(130, h) lbl.set_size_request(130, h) class_box.pack_start(clr, expand=False) if sym: sym.set_size_request(50, h) class_box.pack_start(sym, expand=False, fill=False) if scl: scl.set_size_request(50, h) class_box.pack_start(scl, expand=False, fill=False) class_box.pack_start(rng, expand=False) class_box.pack_start(lbl, expand=False) if delete_button: del_btn = create_stock_button(gtk.STOCK_DELETE, self.delete_item, class_box) del_btn.set_size_request(h, h) class_box.pack_start(del_btn, expand=False) class_box.pack_start( gtk.Label() ) self.class_list.pack_start(class_box, expand=False)
def __init__(self, viewwin): """Initialize the Layers list. Takes a single parameter, viewwin, which is the view window for which this is a layer list. Its only purpose is to access the viewarea because we don't want to reference it directly """ gtk.Frame.__init__(self) scrlwin = gtk.ScrolledWindow() scrlwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrlwin.set_shadow_type(gtk.SHADOW_NONE) self.viewwin = viewwin #setup connection to view area self.viewwin.viewarea.connect('active-changed', self.active_layer_changed) self.UImgr = gtk.UIManager() self.setup_actions() self.make_popup_menu() self.updating = True icons = ('ly_r','ly_p','ly_l','ly_a','ly_t') # layer on icon set self.layer_on = [create_pixbuf(icon+'_on') for icon in icons] # layer off icon set self.layer_off = [create_pixbuf(icon+'_off') for icon in icons] #the main layout widget shell = gtk.VBox() self.add(shell) shell.pack_start(scrlwin) tree_view = self.make_tree_view() scrlwin.add(tree_view) tree_view.connect('button-press-event', self.list_clicked) tree_view.connect('select-row', self.row_selected) # Option buttons opts = ((gtk.STOCK_GO_UP, _("Move Up"), self.raise_layer), (gtk.STOCK_GO_DOWN, _("Move Down"), self.lower_layer), (gtk.STOCK_REMOVE, _("Remove All Layers"), self.remove_all), (gtk.STOCK_DELETE, _("Remove Layer"), self.delete_layer)) self.butbox = gtk.HBox(spacing=1, homogeneous=True) shell.pack_start(self.butbox, expand=False) for stock,tip,cb in opts: but = create_stock_button(stock, cb) self.butbox.pack_start(but) but.set_tooltip_text(tip) self.connect('realize', self.realize) self.publish('deleted-layer') shell.show_all() self.tree_view = tree_view self.updating = False
def __init__(self, spacing=10): gtk.VBox.__init__(self, spacing=spacing) self.updating = False self.sel_manager = gview.app.sel_manager self.sel_manager.subscribe('active-layer-changed', self.update_gui) self.sel_manager.subscribe('selection-changed', self.update_gui) self.sel_manager.subscribe('subselection-changed', self.update_gui) hbox = gtk.HBox(spacing=3) self.pack_start(hbox, expand=False) self.hbox = hbox hbox.pack_start(gtk.Label('Shape:'), expand=False) self.oid_tb = gtk.Entry(max=7) self.oid_tb.connect('activate', self.oid_cb) self.oid_tb.connect('focus-out-event', self.oid_cb) hbox.pack_start(self.oid_tb) left_button = create_stock_button(gtk.STOCK_GO_BACK, self.cycle_down) hbox.pack_start(left_button, expand=False) left_button.set_tooltip_text('Cycle Selection Down') self.n_of_n_label = gtk.Label('XXXX of XXXX') hbox.pack_start(self.n_of_n_label) right_button = create_stock_button(gtk.STOCK_GO_FORWARD, self.cycle_up) right_button.set_tooltip_text('Cycle Selection Up') hbox.pack_start(right_button, expand=False) hbox = gtk.HBox(spacing=3) self.pack_start(hbox) self.layer_label = gtk.Label('XXXXXXXXXXXXXXXXXXXXXXXXXXX') self.layer_label.set_alignment(0,0.5) hbox.pack_start(self.layer_label, expand=False) self.connect('unrealize', self.close) self.update_gui() self.show_all()
def createGUI(self): mainbox = gtk.VBox(spacing=5) mainbox.set_border_width(5) self.add(mainbox) frame = gtk.Frame("Input") mainbox.pack_start(frame, expand=False) table = gtk.Table() table.set_border_width(5) table.set_row_spacings(5) table.set_col_spacings(5) frame.add(table) # Input layers row = 0 # RGB source label = pgu.Label("RGB:") table.attach(label, 0, 1, row, row+1) self.rgbCB = pgu.ComboText(strings=self.rgbDict.keys()) table.attach(self.rgbCB, 1, 2, row, row+1) row += 1 # Pan source label = pgu.Label("Pan:") table.attach(label, 0, 1, row, row+1) self.panCB = pgu.ComboText(strings=self.panDict.keys()) table.attach(self.panCB, 1, 2, row, row+1) # output frame = gtk.Frame("Output") mainbox.pack_start(frame, expand=False) table = gtk.Table() table.set_border_width(5) table.set_row_spacings(5) table.set_col_spacings(5) frame.add(table) row = 0 label = pgu.Label("Format:") table.attach(label, 0, 1, row, row+1) wDrvs = filter(lambda drv: 'DCAP_CREATE' in drv.GetMetadata(), GetDriverList()) drivers = map(lambda d: d.ShortName, wDrvs) drivers.sort() self.formatCB = pgu.ComboText(strings=drivers) self.formatCB.set_active_text('GTiff') self.formatCB.set_tooltip_text("Output formats. Some may not work.") table.attach(self.formatCB, 1, 2, row, row+1) row += 1 label = pgu.Label("Output file:") table.attach(label, 0, 1, row, row+1) self.outTE = gtk.Entry() table.attach(self.outTE, 1, 2, row, row+1) row += 1 label = pgu.Label("Create options:") table.attach(label, 0, 1, row, row+1) self.coptTE = gtk.Entry() self.coptTE.set_text("tiled=yes") table.attach(self.coptTE, 1, 2, row, row+1) # resampling options frame = gtk.Frame("Resampling") mainbox.pack_start(frame, expand=False) table = gtk.Table() table.set_border_width(5) table.set_row_spacings(5) table.set_col_spacings(5) frame.add(table) row = 0 # warp options label = pgu.Label("Algorithm") table.attach(label, 0, 1, row, row+1) self.algCB = pgu.ComboText(strings=("Nearest Neighbor","Bilinear","Cubic","Cubic Spline")) table.attach(self.algCB, 1, 2, row, row+1) self.algCB.set_tooltip_text("Resampling algorithm. Cubic Spline is recommended for best results") row += 1 label = pgu.Label("Resize:") table.attach(label, 0, 1, row, row+1) box = gtk.HBox(spacing=5) table.attach(box, 1, 2, row, row+1) self.reszFn0CB = gtk.RadioButton(label="Gdalwarp") box.pack_start(self.reszFn0CB, expand=False) self.reszFn1CB = gtk.RadioButton(label="gdal.py", group=self.reszFn0CB) box.pack_end(self.reszFn1CB, expand=False) row += 1 label = pgu.Label("Datatype:") table.attach(label, 0, 1, row, row+1) box = gtk.HBox(spacing=5) table.attach(box, 1, 2, row, row+1) row += 1 self.swapTO = gtk.CheckButton(label="Swap R-B") table.attach(self.swapTO, 0, 2, row, row+1) self.swapTO.set_tooltip_text("Swap Red and Blue bands. Used for Quickbird.") self.sat0RB = gtk.RadioButton(label="Byte") box.pack_start(self.sat0RB, expand=False) self.sat1RB = gtk.RadioButton(label="UInt16", group=self.sat0RB) box.pack_end(self.sat1RB, expand=False) # window options frame = gtk.Frame("Window") mainbox.pack_start(frame, expand=False) table = gtk.Table() table.set_border_width(5) table.set_row_spacings(5) table.set_col_spacings(5) frame.add(table) row = 0 self.xoffTE = pgu.LabelEntry("Pixel:", width=50) table.attach(self.xoffTE, 0, 1, row, row+1) self.yoffTE = pgu.LabelEntry("Line:", width=50) table.attach(self.yoffTE, 1, 2, row, row+1) row += 1 self.widthTE = pgu.LabelEntry("Width:", width=50) table.attach(self.widthTE, 0, 1, row, row+1) self.heightTE = pgu.LabelEntry("Height:", width=50) table.attach(self.heightTE, 1, 2, row, row+1) row += 1 self.panXoffTE = pgu.LabelEntry("X offset:", width=50) self.panXoffTE.set_text("0") table.attach(self.panXoffTE, 0, 1, row, row+1) self.panXoffTE.set_tooltip_text("Pan X offset") self.panYoffTE = pgu.LabelEntry("Y offset:", width=50) self.panYoffTE.set_text("0") table.attach(self.panYoffTE, 1, 2, row, row+1) self.panYoffTE.set_tooltip_text("Pan Y offset") # Params frame = gtk.Frame("Fusion Method") mainbox.pack_start(frame, expand=False) vbox = gtk.VBox(spacing=3) vbox.set_border_width(5) frame.add(vbox) box = gtk.HBox(spacing=5) vbox.add(box) self.met0RB = gtk.RadioButton(label="IHS") tipTxt = "Standard Intensity-Hue-Saturation merging. " tipTxt += "Sharpness setting has no effect. " self.met0RB.set_tooltip_text(tipTxt) box.add(self.met0RB) self.met1RB = gtk.RadioButton(label="Kernel",group=self.met0RB) tipTxt = "Pan is run through a convolution kernel and added to RGB. " tipTxt += "Recommended sharpness: 0.15-0.25 for Ikonos and Quickbird, " tipTxt += "0.3-0.5 for Landsat and SPOT. " tipTxt += "Can be set higher if imagery is enhanced." self.met1RB.set_tooltip_text(tipTxt) box.add(self.met1RB) # params vbox2 = gtk.VBox(spacing=5) vbox2.set_border_width(5) vbox.add(vbox2) box = gtk.HBox(spacing=5) vbox2.add(box) box.pack_start(gtk.Label("Sharpness:"), expand=False) self.adjSharp = gtk.Adjustment(0.15,0.0,1.0,0.01,0.1) slider = gtk.HScale(self.adjSharp) slider.set_digits(2) box.add(slider) # Buttons box = gtk.HBox(homogeneous=1, spacing=5) mainbox.pack_start(box, expand=False) mergeBT = gtk.Button("Merge") mergeBT.connect('clicked', self.compute, 'merge') mergeBT.set_tooltip_text("Proceed with merging") box.add(mergeBT) pviewBT = gvutils.create_stock_button('eye', self.compute, 'pview') pviewBT.set_tooltip_text("Preview merging") box.add(pviewBT) closeBT = gtk.Button(stock=gtk.STOCK_CLOSE) closeBT.connect('clicked',self.close) box.add(closeBT) # do the connects last so events are not fired during init self.panCB.connect(cb=self.panChanged) self.rgbCB.connect(cb=self.rgbChanged) self.formatCB.connect(cb=self.formatChanged)
def createGUI(self): vbox = gtk.VBox(spacing=5) vbox.set_border_width(5) self.add(vbox) histoBox = gtk.VBox(spacing=3) vbox.add(histoBox) histoList = [] hisdir,f = os.path.split(self.layer.name) name,ext = os.path.splitext(f) self.set_title(name+" Histogram") hisfile = os.path.join(hisdir, name+'.his') if os.path.exists(hisfile): # histofile is in same dir histoList = self.loadHistos(hisfile) elif hisDir is not None: hisfile = os.path.join(hisDir, name+'.his') if os.path.exists(hisfile): # histofile is in histos dir histoList = self.loadHistos(self.hisFile) self.hisFile = hisfile if self.layer.get_mode() == gview.RLM_RGBA: if not histoList: for isrc in range(3): histoList.append(self.buildHisto(isrc)) self.pixCnt = self.getPixCount(histoList) histoDisp = HistogramFrame("Red", 0, histoList[0], self) histoBox.pack_start(histoDisp, expand=False) self.histoDisplays.append(histoDisp) histoDisp = HistogramFrame("Green", 1, histoList[1], self) histoBox.pack_start(histoDisp, expand=False) self.histoDisplays.append(histoDisp) histoDisp = HistogramFrame("Blue", 2, histoList[2], self) histoBox.pack_start(histoDisp, expand=False) self.histoDisplays.append(histoDisp) else: if not histoList: histoList.append(self.buildHisto(0)) self.pixCnt = self.getPixCount(histoList) histoDisp = HistogramFrame("Raster", 0, histoList[0], self) histoBox.pack_start(histoDisp, expand=False) self.histoDisplays.append(histoDisp) ctrlbox = gtk.HBox(homogeneous=1, spacing=5) vbox.pack_start(ctrlbox, expand=False) button = create_stock_button('refresh', self.refresh) ctrlbox.pack_start(button, expand=False) button.set_tooltip_text("rebuilds the histogram from layer") button = create_stock_button(gtk.STOCK_ZOOM_IN, self.zoom, 'in') ctrlbox.pack_start(button, expand=False) button.set_tooltip_text("zoom in") button = create_stock_button(gtk.STOCK_ZOOM_OUT, self.zoom, 'out') ctrlbox.pack_start(button, expand=False) button.set_tooltip_text("zoom out") button = create_stock_button(gtk.STOCK_OPEN, self.load) ctrlbox.pack_start(button, expand=False) button.set_tooltip_text("load histogram") button = create_stock_button(gtk.STOCK_SAVE, self.save) ctrlbox.pack_start(button, expand=False) button.set_tooltip_text("save histogram") frame = gtk.Frame("Autoscale") vbox.pack_start(frame, expand=False) scalebox = gtk.VBox(spacing=5) scalebox.set_border_width(5) frame.add(scalebox) box = gtk.HBox(spacing=5) scalebox.pack_start(box, expand=False) box.pack_start(gtk.Label("Remove: "), expand=False) blackCK = gtk.CheckButton("Black") blackCK.set_active(True) blackCK.connect('toggled', self.setLimits, 'lo') box.pack_start(blackCK, expand=False) whiteCK = gtk.CheckButton("White") whiteCK.set_active(True) whiteCK.connect('toggled', self.setLimits, 'hi') box.pack_start(whiteCK, expand=False) box = gtk.HBox(spacing=5) scalebox.pack_start(box, expand=False) box.pack_start(gtk.Label("Min tail:"), expand=False) minAdj = gtk.Adjustment(self.mintail, 0.0, 99.9, 0.01, 0.1) self.minSpin = gtk.SpinButton(minAdj, 0.1, 2) self.minSpin.set_size_request(55, -1) self.minSpin.connect('changed', self.adjustMin) box.pack_start(self.minSpin, expand=False) maxAdj = gtk.Adjustment(self.maxtail, 0.0, 99.9, 0.01, 0.1) self.maxSpin = gtk.SpinButton(maxAdj, 0.1, 2) self.maxSpin.set_size_request(55, -1) self.maxSpin.connect('changed', self.adjustMax) box.pack_end(self.maxSpin, expand=False) box.pack_end(gtk.Label("Max tail:"), expand=False) algCB = ComboText(strings=("None","linear","log","root","square"), action=self.setAlg) algCB.set_size_request(70,-1) scalebox.pack_start(algCB, expand=False)