def __init__(self, tips): gtk.GtkVBox.__init__(self) self.frames = {} self.tips = tips hbox = gtk.GtkHBox() hbox.set_border_width(spc) self.pack_start(hbox) label = gtk.GtkLabel("Input Geocoding: ") label.set_alignment(0, 0.5) hbox.pack_start(label) self.geocode_menu_list = ['Default', 'GCPs', 'Geotransform'] self.geocode_menu = gvutils.GvOptionMenu(self.geocode_menu_list, self.geotype_toggled_cb) self.tips.set_tip( self.geocode_menu, 'Default: Derive geocoding from input bands\n' + 'GCPs: Define new ground control points\n' + 'Geotransform: Define a new affine transformation') hbox.pack_start(self.geocode_menu) hbox.show_all() self.create_default_frame() self.create_gcp_frame() self.create_geotransform_frame() self.geocode_menu.set_history(0) self.geotype_toggled_cb() self.default_fname = None # dataset to use for default info self.default_geotransform = None self.default_gcps = None self.default_prj = ''
def __init__(self, shapes, shapesgridtool=None): gtk.GtkWindow.__init__(self) self.set_title('Schema') shell = gtk.GtkVBox(spacing=5) shell.set_border_width(10) self.add(shell) self.grid = pgugrid.pguGrid(config=(2, 0, 0, 1, 4, 0, 0, 0)) self.grid.subscribe("cell-changed", self.changed_field) self.shapes = shapes self.shapesgridtool = shapesgridtool shell.pack_start(self.grid) # New field box3 = gtk.GtkTable(rows=5, cols=3) box3.set_row_spacings(5) box3.set_col_spacings(5) box3.set_border_width(10) nf_frame = gtk.GtkFrame('Add Field') nf_frame.add(box3) self.new_field_name_entry = gtk.GtkEntry(10) self.new_field_name_entry.set_text('') self.new_field_name_entry.set_editable(gtk.TRUE) self.new_field_width_entry = gtk.GtkEntry(2) self.new_field_width_entry.set_text('20') self.new_field_width_entry.set_editable(gtk.TRUE) self.new_field_precision_entry = gtk.GtkEntry(2) self.new_field_precision_entry.set_text('0') self.new_field_precision_entry.set_editable(gtk.FALSE) self.new_field_precision_entry.set_sensitive(gtk.FALSE) self.new_field_types = ('string', 'integer', 'float') self.new_field_type_menu = gvutils.GvOptionMenu( self.new_field_types, self.new_field_precision_cb) self.new_field_type_menu.set_history(0) box3.attach(gtk.GtkLabel('Name'), 0, 1, 0, 1) box3.attach(self.new_field_name_entry, 1, 2, 0, 1) box3.attach(gtk.GtkLabel('Type'), 0, 1, 1, 2) box3.attach(self.new_field_type_menu, 1, 2, 1, 2) box3.attach(gtk.GtkLabel('Width'), 0, 1, 2, 3) box3.attach(self.new_field_width_entry, 1, 2, 2, 3) box3.attach(gtk.GtkLabel('Precision'), 0, 1, 3, 4) box3.attach(self.new_field_precision_entry, 1, 2, 3, 4) button = gtk.GtkButton("Add") box3.attach(button, 0, 2, 4, 5) button.connect("clicked", self.add_field) shell.pack_start(nf_frame) nf_frame.show_all() # Ability to delete fields? self.fill_grid() self.grid.resize_to_default() self.show_all()
def create_lutprop(self): self.lut_pane = GtkVBox(spacing=10) self.lut_pane.set_border_width(10) self.notebook.append_page(self.lut_pane, GtkLabel('LUT')) self.lut_preview = GtkPreview() self.lut_preview.size(256, 32) self.lut_pane.pack_start(self.lut_preview) self.complex_lut_om = \ gvutils.GvOptionMenu(('Magnitude', 'Phase', 'Magnitude & Phase', 'Real','Imaginary'), self.complex_lut_cb) self.lut_pane.pack_start(self.complex_lut_om, expand=FALSE)
def create_openglprop(self): oglpane = GtkVBox(spacing=10) oglpane.set_border_width(10) self.notebook.append_page(oglpane, GtkLabel('Draw Style')) # Create Modulation Color box = GtkHBox(spacing=5) oglpane.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Modulation Color:'), expand=FALSE) self.mod_color = pgucolorsel.ColorControl('Modulation Color', self.color_cb, None) box.pack_start(self.mod_color) # Create Interpolation Control box = GtkHBox(spacing=5) oglpane.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Subpixel Interpolation:'), expand=FALSE) self.interp_om = gvutils.GvOptionMenu(('Linear','Off (Nearest)'), \ self.set_interp_cb) box.pack_start(self.interp_om, expand=FALSE)
def create_gui(self): self.dict_of_bands = get_list_of_bands_as_dict() if self.dict_of_bands is None: raise TypeError self.list_of_bands = self.dict_of_bands.keys() self.list_of_bands.sort() title_width = 120 box1 = GtkVBox(spacing=10) box1.set_border_width(10) self.add(box1) box1.show() box2 = GtkVBox(spacing=5) box2.set_border_width(5) box1.pack_start(box2) box2.show() self.expression_unit = GtkEntry() self.expression_unit.set_text(self.expression) self.expression_unit.connect("changed", self.expression_edit_cb) box2.pack_start(self.expression_unit) self.expression_unit.show() box3 = GtkHBox(spacing=5) box1.pack_start(box3) box3.show() ##### funcbox = GtkVBox(spacing=5) funcbox.set_border_width(10) box3.pack_start(funcbox) funcbox.show() fg_list = ["Mathematics", "Bit Operations", "Trigionometry", "Special"] self.fun_group_list = gvutils.GvOptionMenu(fg_list, self.group_changed) funcbox.pack_start(self.fun_group_list, expand=FALSE) self.mathematics_group(funcbox) self.bit_operations_group(funcbox) self.trigonometry_group(funcbox) self.special_funcs_group(funcbox) ##### digitbox = GtkVBox(spacing=10) digitbox.set_border_width(10) box3.pack_start(digitbox) digitbox.show() digit_table = GtkTable(5, 5) digit_table.set_border_width(5) digit_table.set_row_spacings(5) digit_table.set_col_spacings(5) digitbox.pack_start(digit_table) digit_table.show() btn = GtkButton("Back") btn.connect("clicked", self.back_button_pressed) digit_table.attach(btn, 1, 3, 0, 1) btn = GtkButton("C") btn.connect("clicked", self.clear_button_pressed) digit_table.attach(btn, 3, 5, 0, 1) btn = GtkButton("7") btn.connect("clicked", self.button_pressed, "7") digit_table.attach(btn, 0, 1, 1, 2) btn = GtkButton("8") btn.connect("clicked", self.button_pressed, "8") digit_table.attach(btn, 1, 2, 1, 2) btn = GtkButton("9") btn.connect("clicked", self.button_pressed, "9") digit_table.attach(btn, 2, 3, 1, 2) btn = GtkButton(" / ") btn.connect("clicked", self.button_pressed, "/") digit_table.attach(btn, 3, 4, 1, 2) btn = GtkButton("(") btn.connect("clicked", self.button_pressed, "(") digit_table.attach(btn, 4, 5, 1, 2) btn = GtkButton("4") btn.connect("clicked", self.button_pressed, "4") digit_table.attach(btn, 0, 1, 2, 3) btn = GtkButton("5") btn.connect("clicked", self.button_pressed, "5") digit_table.attach(btn, 1, 2, 2, 3) btn = GtkButton("6") btn.connect("clicked", self.button_pressed, "6") digit_table.attach(btn, 2, 3, 2, 3) btn = GtkButton("*") btn.connect("clicked", self.button_pressed, "*") digit_table.attach(btn, 3, 4, 2, 3) btn = GtkButton(")") btn.connect("clicked", self.button_pressed, ")") digit_table.attach(btn, 4, 5, 2, 3) btn = GtkButton("1") btn.connect("clicked", self.button_pressed, "1") digit_table.attach(btn, 0, 1, 3, 4) btn = GtkButton("2") btn.connect("clicked", self.button_pressed, "2") digit_table.attach(btn, 1, 2, 3, 4) btn = GtkButton("3") btn.connect("clicked", self.button_pressed, "3") digit_table.attach(btn, 2, 3, 3, 4) btn = GtkButton("-") btn.connect("clicked", self.button_pressed, "-") digit_table.attach(btn, 3, 4, 3, 4) btn = GtkButton("End") btn.connect("clicked", self.end_button_pressed) digit_table.attach(btn, 4, 5, 3, 4) btn = GtkButton("0") btn.connect("clicked", self.button_pressed, "0") digit_table.attach(btn, 0, 1, 4, 5) btn = GtkButton(",") btn.connect("clicked", self.button_pressed, ",") digit_table.attach(btn, 1, 2, 4, 5) btn = GtkButton(".") btn.connect("clicked", self.button_pressed, ".") digit_table.attach(btn, 2, 3, 4, 5) btn = GtkButton("+") btn.connect("clicked", self.button_pressed, "+") digit_table.attach(btn, 3, 4, 4, 5) btn = GtkButton("=") btn.connect("clicked", self.compute) digit_table.attach(btn, 4, 5, 4, 5) ##### rastersbox = GtkVBox(spacing=5) box1.pack_start(rastersbox) rastersbox.show() ### source list ############################################################# frame1 = GtkFrame("Select Image Bands To Compute") frame1.show() box1.pack_start(frame1, expand=FALSE) box2r = GtkVBox(spacing=10) box2r.set_border_width(10) frame1.add(box2r) box2r.show() self.s1_list = \ gvutils.GvOptionMenu(self.list_of_bands, self.raster_selected_cb) box2r.pack_start(self.s1_list) self.s1_list.set_history(-1) self.s1_list.show() ##### OUT TYPES ######################################################### box_types = GtkHBox(spacing=10) box2r.pack_start(box_types) box_types.show() types_label = GtkLabel('Image Data Type:') types_label.set_alignment(0, 0.5) box_types.pack_start(types_label, expand=FALSE) self.types_list = [] i = GDT_Byte while i < GDT_TypeCount: self.types_list.append(gdal.GetDataTypeName(i)) i += 1 self.types = gvutils.GvOptionMenu(self.types_list) box_types.pack_start(self.types) self.types.show() #### NEW VIEW ########################################################## self.switch_new_view = GtkCheckButton("Create New View") box1.pack_start(self.switch_new_view) self.switch_new_view.show() return TRUE
def create_gui(self): self.dict_of_bands = get_list_of_bands_as_dict() if self.dict_of_bands is None: raise self.list_of_bands = self.dict_of_bands.keys() title_width = 120 box1 = GtkVBox(spacing=5) self.add(box1) box1.show() #### OPERATIONS #################################################### box_op = GtkHBox(spacing=10) box1.set_border_width(10) box1.pack_start(box_op, expand=FALSE) box_op.show() op_label = GtkLabel('Operation:') op_label.set_alignment(0, 0.5) box_op.pack_start(op_label, expand=FALSE) # The item <operations_dict> is the dictionary, that contains # the list of calculator operation names as keys and the set # of corresponding functions. self.operations_dict = {} self.operations_dict['Add [Res = A * X + B * Y + C]'] = \ (3,self.add_bands) self.operations_dict['Multiply [Res = X * Y]'] = \ (0,self.multiply_bands) self.operations_dict['Divide [Res = A * X / (Y + B) + C]'] = \ (3,self.divide_bands) self.operations_dict[ 'Vegetation Index [Res = A * (X - Y) / ( X + Y) + B]'] = ( 2, self.veg_index) self.operations_list = self.operations_dict.keys() self.operation = \ gvutils.GvOptionMenu(self.operations_list,self.update_gui) box_op.pack_start(self.operation) self.operation.show() ### COEFFICIENTS ###################################################### self.box_coeffs = GtkHBox(spacing=10) box1.pack_start(self.box_coeffs, expand=FALSE) self.box_coeffs.show() self.box_coeff_a = GtkHBox(spacing=5) self.box_coeffs.pack_start(self.box_coeff_a, expand=FALSE) self.box_coeff_a.show() a_label = GtkLabel('A =') a_label.set_alignment(0, 0.5) self.box_coeff_a.pack_start(a_label) self.a_const = GtkEntry() self.a_const.set_usize(80, 30) self.a_const.set_text('1') self.box_coeff_a.pack_start(self.a_const, expand=FALSE) self.a_const.show() self.box_coeff_b = GtkHBox(spacing=5) self.box_coeffs.pack_start(self.box_coeff_b, expand=FALSE) self.box_coeff_b.show() b_label = GtkLabel('B =') b_label.set_alignment(0, 0.5) self.box_coeff_b.pack_start(b_label) self.b_const = GtkEntry() self.b_const.set_usize(80, 30) self.b_const.set_text('1') self.box_coeff_b.pack_start(self.b_const, expand=FALSE) self.b_const.show() self.box_coeff_c = GtkHBox(spacing=5) self.box_coeffs.pack_start(self.box_coeff_c, expand=FALSE) self.box_coeff_c.show() c_label = GtkLabel('C =') c_label.set_alignment(0, 0.5) self.box_coeff_c.pack_start(c_label) self.c_const = GtkEntry() self.c_const.set_usize(80, 30) self.c_const.set_text('1') self.box_coeff_c.pack_start(self.c_const, expand=FALSE) self.c_const.show() self.coeffs_vis = [ self.box_coeff_a, self.box_coeff_b, self.box_coeff_c ] ### source1 ############################################################# frame1 = GtkFrame("Select Image Bands To Compute") frame1.show() box1.pack_start(frame1, expand=FALSE) box2 = GtkVBox(spacing=10) box2.set_border_width(10) frame1.add(box2) box2.show() box_s1 = GtkHBox(spacing=10) box2.pack_start(box_s1, expand=FALSE) box_s1.show() source1_label = GtkLabel('Source 1 < X >:') source1_label.set_alignment(0, 0.5) box_s1.pack_start(source1_label, expand=FALSE) self.s1_list = gvutils.GvOptionMenu(self.list_of_bands) box_s1.pack_start(self.s1_list) self.s1_list.show() ## source2 ############################################################## box_s2 = GtkHBox(spacing=10) box2.pack_start(box_s2, expand=FALSE) box_s2.show() source2_label = GtkLabel('Source 2 < Y >:') source2_label.set_alignment(0, 0.5) box_s2.pack_start(source2_label, expand=FALSE) self.s2_list = gvutils.GvOptionMenu(self.list_of_bands) box_s2.pack_start(self.s2_list) self.s2_list.show() #####OUT TYPES######################################################### box_types = GtkHBox(spacing=10) box2.pack_start(box_types, expand=FALSE) box_types.show() types_label = GtkLabel('Image data type:') types_label.set_alignment(0, 0.5) box_types.pack_start(types_label, expand=FALSE) self.types_list = [] i = GDT_Byte while i < GDT_TypeCount: self.types_list.append(gdal.GetDataTypeName(i)) i += 1 self.types = gvutils.GvOptionMenu(self.types_list) box_types.pack_start(self.types) self.types.show() #### NEW VIEW ########################################################## self.switch_new_view = GtkCheckButton("Create New View") box1.pack_start(self.switch_new_view) self.switch_new_view.show() #### BUTTONS ########################################################### box_buttons = GtkHBox(spacing=15) box1.pack_start(box_buttons, expand=FALSE) box_buttons.show() self.ok_btn = GtkButton("Ok") self.ok_btn.connect("clicked", self.compute) box_buttons.pack_start(self.ok_btn) self.cancel_btn = GtkButton("Cancel") self.cancel_btn.connect("clicked", self.close) box_buttons.pack_start(self.cancel_btn) return TRUE
def create_gui(self): self.dict_of_bands = get_list_of_bands_as_dict() self.list_of_bands = self.dict_of_bands.keys() self.list_of_bands.sort() title_width = 120 self.metric_num = 0 box1 = GtkVBox(spacing=5) self.add(box1) box1.show() rastersbox = GtkVBox(spacing=5) box1.pack_start(rastersbox) rastersbox.show() ### source list ############################################################# frame1 = GtkFrame("Raster Specifications") frame1.show() rastersbox.pack_start(frame1, expand=FALSE) box2r = GtkHBox(spacing=10) box2r.set_border_width(10) frame1.add(box2r) box2r.show() box2r1 = GtkVBox(spacing=5) box2r.add(box2r1) box2r1.show() self.src_list = GtkCList(cols=1) self.src_list.set_selection_mode(SELECTION_SINGLE) self.src_list.set_column_width(0, 120) self.src_list.connect('button-press-event', self.src_band_selected_cb) self.src_list.freeze() self.src_list.clear() for name in self.list_of_bands: self.src_list.append([name]) self.src_list.thaw() box2r1.pack_start(self.src_list) self.src_list.show() box2r2 = GtkVBox(spacing=5) box2r.add(box2r2) box2r2.show() button_copy = GtkButton(">>") box2r2.pack_start(button_copy) button_copy.connect("clicked", self.copy_band_cb) button_remove = GtkButton("<<") box2r2.pack_start(button_remove) button_remove.connect("clicked", self.remove_band_cb) box2r3 = GtkVBox(spacing=5) box2r.add(box2r3) box2r3.show() self.sel_list = GtkCList(cols=1) self.sel_list.set_selection_mode(SELECTION_SINGLE) self.sel_list.connect('button-press-event', self.sel_band_selected_cb) self.sel_list.set_column_width(0, 120) box2r3.pack_start(self.sel_list) self.sel_list.show() self.src_row_to_copy = -1 self.sel_row_to_delete = -1 #### Entries ########################################################### entries_table = GtkTable(3, 4) entries_table.set_border_width(5) box1.pack_start(entries_table) label = GtkLabel("Desirable Number of Clusters") entries_table.attach(label, 0, 2, 0, 1) self.clusters = GtkEntry() self.clusters.set_text("8") entries_table.attach(self.clusters, 2, 3, 0, 1) label = GtkLabel("Maximal Number of Iterations") entries_table.attach(label, 0, 2, 1, 2) self.maxiter = GtkEntry() self.maxiter.set_text("20") entries_table.attach(self.maxiter, 2, 3, 1, 2) label = GtkLabel("Minimal Cluster Volume") entries_table.attach(label, 0, 2, 2, 3) self.min_volume = GtkEntry() self.min_volume.set_text("1000") entries_table.attach(self.min_volume, 2, 3, 2, 3) label = GtkLabel("Movement Classes Treshold") entries_table.attach(label, 0, 2, 3, 4) self.mov_treshold = GtkEntry() self.mov_treshold.set_text("0.1") entries_table.attach(self.mov_treshold, 2, 3, 3, 4) ####################################################################### metric_box = GtkHBox(spacing=10) box1.pack_start(metric_box) metric_list = [ "Manhattan Metric", "Euclidian Metric", "Chebyshev Metric" ] self.metric_menu = gvutils.GvOptionMenu(metric_list, self.metrics_selected_cb) metric_box.pack_start(self.metric_menu) #### Buttons ########################################################### button_box = GtkHBox(spacing=10) button_box.set_border_width(10) box1.pack_start(button_box) button_ok = GtkButton("Classify") button_ok.connect("clicked", self.classify_cb) button_box.pack_start(button_ok) button_cancel = GtkButton("Cancel") button_cancel.connect("clicked", self.close) button_box.pack_start(button_cancel) return TRUE
def create_gui(self): box1 = GtkVBox() self.add(box1) box1.show() self.selbrowser = gvselbrowser.GvSelBrowser() self.selbrowser.set_border_width(10) box1.pack_start(self.selbrowser, expand=FALSE) box2 = GtkVBox(spacing=10) box2.set_border_width(10) box1.pack_start(box2) box2.show() table = GtkTable(2, 2) table.set_row_spacing(0, 2) table.set_col_spacing(0, 2) box2.pack_start(table) table.show() text = GtkText() text.set_usize(400, 100) text.set_line_wrap(FALSE) text.set_word_wrap(FALSE) text.set_editable(TRUE) table.attach(text, 0, 1, 0, 1) text.show() self.text = text self.text.connect('activate', self.att_update_cb) self.text.connect('leave-notify-event', self.att_update_cb) vscrollbar = GtkVScrollbar(text.get_vadjustment()) table.attach(vscrollbar, 1, 2, 0, 1, xoptions=FILL) vscrollbar.show() separator = GtkHSeparator() box1.pack_start(separator, expand=FALSE) separator.show() box2 = GtkVBox(spacing=10) box2.set_border_width(10) box1.pack_start(box2, expand=FALSE) box2.show() # new field options box3 = GtkHBox(spacing=10) box3.set_border_width(10) nf_frame = GtkFrame('New field properties: type/width/precision') nf_frame.add(box3) self.new_field_width_entry = GtkEntry(2) self.new_field_width_entry.set_text('20') self.new_field_width_entry.set_editable(TRUE) self.new_field_precision_entry = GtkEntry(2) self.new_field_precision_entry.set_text('0') self.new_field_precision_entry.set_editable(FALSE) self.new_field_precision_entry.set_sensitive(FALSE) self.new_field_types = ('string', 'integer', 'float') self.new_field_type_menu = gvutils.GvOptionMenu( self.new_field_types, self.new_field_precision_cb) self.new_field_type_menu.set_history(0) box3.pack_start(self.new_field_type_menu) box3.pack_start(self.new_field_width_entry, expand=FALSE, fill=FALSE) box3.pack_start(self.new_field_precision_entry, expand=FALSE, fill=FALSE) box2.pack_start(nf_frame) nf_frame.show_all() button = GtkButton("close") button.connect("clicked", self.close) box2.pack_start(button) button.set_flags(CAN_DEFAULT) button.grab_default() button.show()
def create_gui(self): box1 = GtkVBox(spacing=10) box1.set_border_width(10) self.add(box1) box1.show() box2 = GtkHBox(spacing=10) box1.pack_start(box2, expand=TRUE) box2.show() # Input WKT frame inproj_frame = GtkFrame('Input Well Known Text') inproj_frame.show() box2.pack_start(inproj_frame, expand=TRUE) inproj_text = GtkText() inproj_text.set_line_wrap(TRUE) inproj_text.set_word_wrap(FALSE) inproj_text.set_editable(FALSE) inproj_text.show() inproj_text.insert_defaults(self.proj_full) proj_scrollwin = GtkScrolledWindow() proj_scrollwin.add(inproj_text) proj_scrollwin.set_usize(300, 300) inproj_frame.add(proj_scrollwin) # Separation label box2.pack_start(GtkLabel('-->'), expand=FALSE) # Output projection box box3 = GtkVBox(spacing=10) box2.pack_start(box3, expand=FALSE) box3.show() # Projection frame proj_frame = GtkFrame('Output Projection') proj_frame.show() box3.pack_start(proj_frame, expand=FALSE) self.proj_vbox = GtkVBox(spacing=5) # Create projection switch proj_hbox = GtkHBox(spacing=5) proj_hbox.pack_start(GtkLabel('Projection Name:'), \ expand=FALSE, padding=5) proj_methods = osr.GetProjectionMethods() self.projs = map(lambda x: x.__getitem__(0), proj_methods) self.projs.insert(0, '') proj_names = map(lambda x: x.__getitem__(1), proj_methods) proj_names.insert(0, 'None') self.proj_parms = map(lambda x: x.__getitem__(2), proj_methods) self.proj_parms.insert(0, []) self.proj_index = self.projs.index(self.proj_name) self.proj_table = None self.proj_om = gvutils.GvOptionMenu(proj_names, self.set_proj_cb) self.create_projparms() self.proj_om.set_history(self.proj_index) proj_hbox.pack_start(self.proj_om, padding=5) self.proj_vbox.pack_start(proj_hbox, expand=FALSE) proj_frame.add(self.proj_vbox) # Datum frame datum_frame = GtkFrame('Output Datum') datum_frame.show() box3.pack_start(datum_frame, expand=FALSE) datum_hbox = GtkHBox(spacing=5) datum_hbox.pack_start(GtkLabel('Datum Name:'), expand=FALSE, padding=5) try: self.datum_name = self.sr.GetAttrValue("DATUM") except: self.datum_name = None self.datum_names = {None:"None", osr.SRS_DN_NAD27:"NAD27", \ osr.SRS_DN_NAD83:"NAD83", osr.SRS_DN_WGS72:"WGS72", \ osr.SRS_DN_WGS84:"WGS84"} try: self.datum_index = self.datum_names.keys().index(self.datum_name) except ValueError: self.datum_index = self.datum_names.keys().index(None) self.datum_om = gvutils.GvOptionMenu(self.datum_names.values(), \ self.set_datum_cb) self.datum_om.set_history(self.datum_index) datum_hbox.pack_start(self.datum_om, expand=FALSE, padding=5) datum_frame.add(datum_hbox) # Reprojection parameters frame rparmsframe = GtkFrame('Reprojection parameters') rparmsframe.show() box3.pack_start(rparmsframe, expand=FALSE) rparmstable = GtkTable(2, 3, FALSE) rparmstable.set_border_width(5) rparmstable.set_row_spacings(5) rparmstable.set_col_spacings(5) rparmsframe.add(rparmstable) rparmstable.show() label = GtkLabel('Interpolation Method:') label.set_alignment(0, 0.5) rparmstable.attach(label, 0, 1, 0, 1) self.interp_methods = [ 'Nearest Neighbour', \ 'Bilinear', \ 'Cubic Convolution', \ 'Cubic Spline' \ ] self.interp_menu = gvutils.GvOptionMenu(self.interp_methods) self.interp_menu.set_history(0) rparmstable.attach(self.interp_menu, 1, 2, 0, 1) # Output file frame fileframe = GtkFrame('Select output file') fileframe.show() box3.pack_start(fileframe, expand=FALSE) filetable = GtkTable(2, 3, FALSE) filetable.set_border_width(5) filetable.set_row_spacings(5) filetable.set_col_spacings(5) fileframe.add(filetable) filetable.show() open_btn = GtkButton('Open...') open_btn.connect("clicked", self.open_cb) filetable.attach(open_btn, 0, 1, 0, 1) self.open_entry = GtkEntry() self.open_entry.set_editable(TRUE) self.open_entry.set_text('') filetable.attach(self.open_entry, 1, 2, 0, 1) fileframe.add(filetable) label = GtkLabel('Output Format:') label.set_alignment(0, 0.5) filetable.attach(label, 0, 1, 1, 2) self.format_list = [] hist_idx = 0 for driver in gdal.GetDriverList(): create = None try: create = driver.GetMetadata()["DCAP_CREATE"] except KeyError: pass if create == "YES": if driver.ShortName == 'DTED': # DTED is a special case that needs certain # conditions to be valid. Skip it. continue self.format_list.append(driver.ShortName) self.format_list.sort() # Default to GTiff if possible try: hist_idx = self.format_list.index('GTiff') except ValueError: pass self.format_menu = gvutils.GvOptionMenu(self.format_list) self.format_menu.set_history(hist_idx) filetable.attach(self.format_menu, 1, 2, 1, 2) optlabel = GtkLabel('Create Options:') optlabel.set_alignment(0, 0.5) filetable.attach(optlabel, 0, 1, 2, 3) self.optentry = GtkEntry() self.optentry.set_editable(editable=TRUE) self.optentry.set_text('') filetable.attach(self.optentry, 1, 2, 2, 3) # WKT frame proj_text_frame = GtkFrame('Output Well Known Text') proj_text_frame.show() box2.pack_start(proj_text_frame, expand=TRUE) self.proj_text = GtkText() self.proj_text.set_line_wrap(TRUE) self.proj_text.set_word_wrap(FALSE) self.proj_text.set_editable(FALSE) self.proj_text.show() self.proj_text.insert_defaults(self.proj_full) proj_scrollwin = GtkScrolledWindow() proj_scrollwin.set_usize(300, 300) proj_scrollwin.add(self.proj_text) proj_text_frame.add(proj_scrollwin) self.switch_new_view = GtkCheckButton("Create new view") box1.pack_start(self.switch_new_view, expand=FALSE) self.switch_new_view.show() separator = GtkHSeparator() box1.pack_start(separator, expand=FALSE) box4 = GtkHBox(spacing=10) box1.pack_end(box4, expand=FALSE) box4.show() execute_btn = GtkButton("Ok") execute_btn.connect("clicked", self.execute_cb) box4.pack_start(execute_btn) close_btn = GtkButton("Cancel") close_btn.connect("clicked", self.close) box4.pack_start(close_btn)
def showgui_cb(self, *args): if self.dialog is None: self.dialog = gtk.GtkWindow() self.dialog.connect('delete-event', self.close) table = gtk.GtkTable(9, 4) table.set_border_width(10) table.set_row_spacings(10) table.set_col_spacings(10) vbox = gtk.GtkVBox() self.dialog.add(vbox) vbox.pack_start(table) iconbar = gtk.GtkToolbar(gtk.ORIENTATION_HORIZONTAL, gtk.TOOLBAR_ICONS) arrows = [] atypes = [ gtk.ARROW_LEFT, gtk.ARROW_UP, gtk.ARROW_DOWN, gtk.ARROW_RIGHT ] cbs = [ self.rewind_cb, self.speed_up_cb, self.speed_down_cb, self.play_cb ] for atype, cb in map(None, atypes, cbs): arr = gtk.GtkButton() arr.set_border_width(0) arr.set_relief(gtk.RELIEF_NONE) arr.add(gtk.GtkArrow(atype)) arr.connect('clicked', cb) arrows.append(arr) vbox = gtk.GtkVBox(spacing=0, homogeneous=gtk.FALSE) vbox.pack_start(arrows[1], expand=gtk.FALSE) vbox.pack_start(arrows[2], expand=gtk.FALSE) # Now put them in the toolbar iconbar.append_widget(arrows[0], 'Rewind', 'Rewind') iconbar.append_widget(vbox, 'Adjust speed', 'Adjust speed') iconbar.append_widget(arrows[3], 'Play', 'Play') table.attach(iconbar, 0, 1, 0, 1) but = gtk.GtkButton('Stop') table.attach(but, 1, 2, 0, 1) but.connect('clicked', self.stop_pan_cb) but = gtk.GtkButton('Pause') table.attach(but, 2, 3, 0, 1) but.connect('clicked', self.pause_pan_cb) label = gtk.GtkLabel('Block Size Mode:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 1, 2) self.block_size_menu = gvutils.GvOptionMenu( ('Relative to Pan Extents', 'View Coordinates', 'Constant Resolution'), self.block_mode_changed) table.attach(self.block_size_menu, 1, 3, 1, 2) self.block_label_list = [ 'Block x size (0-1):', 'Block x size:', 'View units/Pixel:' ] self.block_label = gtk.GtkLabel(self.block_label_list[0]) self.block_label.set_alignment(0, 0.5) table.attach(self.block_label, 0, 1, 2, 3) self.block_entry = gtk.GtkEntry() self.block_entry.set_editable(gtk.TRUE) self.block_entry.set_text('0.125') self.block_entry.connect('leave-notify-event', self.block_size_changed) table.attach(self.block_entry, 1, 3, 2, 3) label = gtk.GtkLabel('Overlap (0-1):') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 3, 4) self.overlap_entry = gtk.GtkEntry() self.overlap_entry.set_editable(gtk.TRUE) self.overlap_entry.set_text('0.1') self.overlap_entry.connect('leave-notify-event', self.overlap_changed) table.attach(self.overlap_entry, 1, 3, 3, 4) label = gtk.GtkLabel('Path type:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 4, 5) self.path_menu = gvutils.GvOptionMenu(('0', '1', '2', '3', '4'), self.path_changed) table.attach(self.path_menu, 1, 3, 4, 5) label = gtk.GtkLabel('Show trail:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 5, 6) self.trail_menu = gvutils.GvOptionMenu(('No', 'Yes'), self.trail_changed) table.attach(self.trail_menu, 1, 2, 5, 6) button = gtk.GtkButton('Clear Trail') table.attach(button, 2, 3, 5, 6) button.connect('clicked', self.clear_trail) label = gtk.GtkLabel('Trail Color:') label.set_alignment(0, 0.5) table.attach(label, 0, 1, 6, 7) self.trail_color = pgucolorsel.ColorControl( 'Trail Color', self.trail_color_cb) table.attach(self.trail_color, 1, 3, 6, 7) self.trail_color.set_color((1.0, 0.75, 0.0, 0.5)) self.second_view = gview.GvViewArea() self.second_view.set_usize(300, 300) table.attach(self.second_view, 0, 3, 7, 8) self.dialog.show_all() self.dialog.connect('delete-event', self.close) self.viewtitle = args[1] self.dialog.show() self.dialog.get_window()._raise()
def init_dialog(self): self.dialog = gtk.GtkWindow() self.dialog.set_title('GDAL Export Tool') self.dialog.set_border_width(10) self.tips = gtk.GtkTooltips() #self.dialog.set_default_size(500,400) self.dialog.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE) # main shell mainshell = gtk.GtkHBox(spacing=1, homogeneous=gtk.FALSE) self.dialog.add(mainshell) self.show_list = [] self.adv_show_list = [] # advanced show list self.show_list.append(mainshell) #navigation shell navshell = gtk.GtkVBox(spacing=1, homogeneous=gtk.FALSE) mainshell.pack_start(navshell) self.show_list.append(navshell) self.frame_dict = {} self.button_dict = {} self.frame_dict['Files'] = gvutils.GvDataFilesFrame( 'Data Files', sel_list=('Input', 'Output')) self.frame_dict['Files'].set_border_width(5) self.frame_dict['Files'].set_spacings(5, 5) self.frame_dict['Files'].show_all() navshell.pack_start(self.frame_dict['Files']) self.show_list.append(self.frame_dict['Files']) bopt_frame = gtk.GtkFrame('Basic Options') self.frame_dict['Basic Options'] = bopt_frame self.show_list.append(bopt_frame) navshell.pack_start(bopt_frame, gtk.FALSE, gtk.FALSE, 0) bopt_table = gtk.GtkTable(2, 4, gtk.FALSE) bopt_table.set_border_width(5) bopt_table.set_row_spacings(5) bopt_table.set_col_spacings(5) bopt_frame.add(bopt_table) self.show_list.append(bopt_table) # Might be nice to have more formats below, but # this involves error checking to test for # supported data types, etc. fmtlabel = gtk.GtkLabel('Output Format: ') fmtlabel.set_alignment(0, 0.5) self.show_list.append(fmtlabel) bopt_table.attach(fmtlabel, 0, 1, 0, 1) self.format_list = [] hist_idx = 0 for iDriver in gdal.GetDriverList(): create = None try: create = iDriver.GetMetadata()["DCAP_CREATE"] except KeyError: try: create = iDriver.GetMetadata()["DCAP_CREATECOPY"] except KeyError: pass if create == "YES": if iDriver.ShortName == 'DTED': # DTED is a special case that needs certain # conditions to be valid. Skip it. continue self.format_list.append(iDriver.ShortName) self.format_list.sort() # Default to GTiff if possible try: hist_idx = self.format_list.index('GTiff') except ValueError: pass self.format_menu = gvutils.GvOptionMenu(self.format_list) self.format_menu.set_history(hist_idx) self.show_list.append(self.format_menu) bopt_table.attach(self.format_menu, 1, 2, 0, 1) self.button_dict['Format_help'] = gtk.GtkButton('Help') self.show_list.append(self.button_dict['Format_help']) bopt_table.attach(self.button_dict['Format_help'], 2, 3, 0, 1) reslabel = gtk.GtkLabel('Output Resolution: ') reslabel.set_alignment(0, 0.5) self.show_list.append(reslabel) bopt_table.attach(reslabel, 0, 1, 1, 2) self.res_list = ['Full', '1:2', '1:4', '1:8'] self.res_menu = gvutils.GvOptionMenu(self.res_list) bopt_table.attach(self.res_menu, 1, 2, 1, 2) self.show_list.append(self.res_menu) self.button_dict['Mode'] = gtk.GtkCheckButton('Advanced Options') navshell.pack_start(self.button_dict['Mode']) self.show_list.append(self.button_dict['Mode']) self.frame_dict['IP_window'] = DataWindowFrame(navshell) self.adv_show_list.append(self.frame_dict['IP_window']) iopt_frame = gtk.GtkFrame('Interactive Options') self.frame_dict['Interactive Options'] = iopt_frame self.adv_show_list.append(iopt_frame) navshell.pack_start(iopt_frame, gtk.FALSE, gtk.FALSE, 0) iopt_table = gtk.GtkTable(3, 3, gtk.FALSE) iopt_table.set_border_width(5) iopt_table.set_row_spacings(5) iopt_table.set_col_spacings(5) iopt_frame.add(iopt_table) self.adv_show_list.append(iopt_table) self.button_dict['IP_window'] = gtk.GtkCheckButton('Window Input File') iopt_table.attach(self.button_dict['IP_window'], 0, 2, 0, 1) self.adv_show_list.append(self.button_dict['IP_window']) self.button_dict['Scale'] = gtk.GtkCheckButton( 'Scale to View Settings') self.tips.set_tip( self.button_dict['Scale'], 'Scale the output bands ' + 'according to the min/max settings of the ' + 'currently active raster layer. This only ' + 'applies to real data.') iopt_table.attach(self.button_dict['Scale'], 0, 2, 1, 2) self.adv_show_list.append(self.button_dict['Scale']) self.button_dict['Refresh'] = gtk.GtkButton( 'Active Layer->Input Filename') self.tips.set_tip( self.button_dict['Refresh'], 'Set the input ' + 'filename to that of the currently active layer') iopt_table.attach(self.button_dict['Refresh'], 0, 1, 2, 3) self.adv_show_list.append(self.button_dict['Refresh']) self.button_dict['Enable_ROI'] = gtk.GtkButton('Draw ROI mode') self.tips.set_tip( self.button_dict['Enable_ROI'], 'Re-activate the ' + 'ROI mode used for interactive input file window definition') iopt_table.attach(self.button_dict['Enable_ROI'], 1, 2, 2, 3) self.adv_show_list.append(self.button_dict['Enable_ROI']) self.frame_dict['Other_Advanced'] = gtk.GtkFrame('') self.frame_dict['Other_Advanced'].set_shadow_type(gtk.SHADOW_NONE) self.adv_show_list.append(self.frame_dict['Other_Advanced']) oadvbox = gtk.GtkVBox(spacing=5, homogeneous=gtk.FALSE) oadvbox.set_border_width(5) self.adv_show_list.append(oadvbox) self.frame_dict['Other_Advanced'].add(oadvbox) otable = gtk.GtkTable(2, 3, gtk.FALSE) otable.set_row_spacings(5) otable.set_col_spacings(5) self.adv_show_list.append(otable) oadvbox.pack_start(otable) self._overview_list = ['None', 'Nearest', 'Average'] self.overview_menu = gvutils.GvOptionMenu(self._overview_list) ovrlabel = gtk.GtkLabel('Overviews:') self.tips.set_tip(self.overview_menu, 'Tiled overview creation options') ovrlabel.set_alignment(0, 0.5) self.adv_show_list.append(ovrlabel) otable.attach(ovrlabel, 0, 1, 0, 1) otable.attach(self.overview_menu, 1, 2, 0, 1) self.adv_show_list.append(self.overview_menu) self._geocode_list = ['Default', 'GCP', 'Geotransform'] self.geocoding_menu = gvutils.GvOptionMenu(self._geocode_list) geolabel = gtk.GtkLabel('Geocoding:') self.tips.set_tip( self.geocoding_menu, 'Specify the type of georeferencing ' + 'information to output. Default is to output ' + 'all available geocoding from the input file. ' + 'If GCP or Geotransform is selected, geocoding ' + 'information will only be output if it is of the ' + 'selected type. This may later be updated to ' + 'generate information of the specified form if ' + 'it is not present but can be accurately computed ' + 'from the existing information.') geolabel.set_alignment(0, 0.5) self.adv_show_list.append(geolabel) otable.attach(geolabel, 0, 1, 1, 2) otable.attach(self.geocoding_menu, 1, 2, 1, 2) self.adv_show_list.append(self.geocoding_menu) opthbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) self.adv_show_list.append(opthbox) oadvbox.pack_start(opthbox) optlabel = gtk.GtkLabel('Create Options:') optlabel.set_alignment(0, 0.5) self.adv_show_list.append(optlabel) self.optentry = gtk.GtkEntry() self.optentry.set_editable(editable=gtk.TRUE) self.optentry.set_usize(400, 25) self.optentry.set_text('') self.adv_show_list.append(self.optentry) opthbox.pack_start(optlabel) opthbox.pack_start(self.optentry) navshell.pack_start(self.frame_dict['Other_Advanced'], gtk.FALSE, gtk.FALSE, 0) echbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE) echbox.set_border_width(3) navshell.pack_end(echbox, gtk.FALSE, gtk.FALSE, 0) self.show_list.append(echbox) self.button_dict['Close'] = gtk.GtkButton('Close') echbox.pack_end(self.button_dict['Close'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Close']) self.button_dict['Export'] = gtk.GtkButton('Export') echbox.pack_end(self.button_dict['Export'], expand=gtk.TRUE) self.show_list.append(self.button_dict['Export']) self.button_dict['Format_help'].connect('clicked', self.format_help_cb) self.button_dict['Enable_ROI'].connect('clicked', self.set_roitool) self.button_dict['Refresh'].connect('clicked', self.refresh_fileinfo) self.button_dict['Export'].connect('clicked', self.export_cb) self.button_dict['Close'].connect('clicked', self.close) self.button_dict['IP_window'].connect('toggled', self.ip_window_toggled_cb) self.button_dict['Mode'].connect('toggled', self.mode_toggled_cb) self.button_dict['IP_window'].set_active(gtk.FALSE) self.button_dict['Mode'].set_active(gtk.FALSE) self.frame_dict['IP_window'].set_entry_sensitivities(gtk.FALSE) # Trap window close event self.dialog.connect('delete-event', self.close) for item in self.show_list: item.show() if self.button_dict['Mode'].get_active(): for item in self.adv_show_list: item.show() else: for item in self.adv_show_list: item.hide()
def create_gui(self): box1 = GtkVBox(spacing = 10) box1.set_border_width(10) self.add(box1) self.tips=GtkTooltips() box1.show() # File open controls frame1 = GtkFrame('Select raw image file') frame1.show() box1.pack_start(frame1, expand=FALSE) box2 = GtkHBox(spacing = 5) box2.set_border_width(5) box2.show() open_btn = GtkButton('Open...') open_btn.connect("clicked", self.open_cb) box2.pack_start(open_btn) self.open_entry = GtkEntry() self.open_entry.set_editable(TRUE) self.open_entry.set_text('') box2.pack_start(self.open_entry) frame1.add(box2) # Image geometry controls frame2 = GtkFrame('Set image geometry') frame2.show() box1.pack_start(frame2, expand=FALSE) tbl = GtkTable(4, 5) tbl.set_border_width(5) tbl.set_row_spacings(5) tbl.set_col_spacings(5) tbl.show() width_label = GtkLabel('Image width:') width_label.set_alignment(0, 0.5) tbl.attach(width_label, 0, 1, 0, 1) self.width_entry = GtkEntry() self.width_entry.set_text('0') self.width_entry.set_editable(TRUE) tbl.attach(self.width_entry, 1, 2, 0, 1) height_label = GtkLabel('Image height:') height_label.set_alignment(0, 0.5) tbl.attach(height_label, 0, 1, 1, 2) self.height_entry = GtkEntry() self.height_entry.set_text('0') self.height_entry.set_editable(TRUE) tbl.attach(self.height_entry, 1, 2, 1, 2) bands_label = GtkLabel('Number of bands:') bands_label.set_alignment(0, 0.5) tbl.attach(bands_label, 0, 1, 2, 3) self.bands_entry = GtkEntry() self.bands_entry.set_text('1') self.bands_entry.set_editable(TRUE) tbl.attach(self.bands_entry, 1, 2, 2, 3) header_label = GtkLabel('Image header size:') header_label.set_alignment(0, 0.5) tbl.attach(header_label, 0, 1, 3, 4) self.header_entry = GtkEntry() self.header_entry.set_text('0') self.header_entry.set_editable(TRUE) tbl.attach(self.header_entry, 1, 2, 3, 4) guess_btn = GtkButton("Guess image geometry") guess_btn.connect("clicked", self.guess_cb) tbl.attach(guess_btn, 0, 2, 4, 5) size_label = GtkLabel('File size in bytes:') size_label.set_alignment(0, 0.5) tbl.attach(size_label, 2, 3, 0, 1) self.bytes_label = GtkLabel('') self.bytes_label.set_alignment(0, 0.5) tbl.attach(self.bytes_label, 3, 4, 0, 1) type_label = GtkLabel('Image data type:') type_label.set_alignment(0, 0.5) tbl.attach(type_label, 2, 3, 1, 2) self.type_list = ['Byte', 'UInt16', 'Int16', 'UInt32','Int32', 'Float32','Float64','CInt16','CInt32', 'CFloat32','CFloat64'] self.type_menu = gvutils.GvOptionMenu(self.type_list) tbl.attach(self.type_menu, 3, 4, 1, 2) swap_label = GtkLabel('Byte Order:') swap_label.set_alignment(0, 0.5) tbl.attach(swap_label, 2, 3, 2, 3) swap_list = ['LSB (Swapped)', 'MSB (Unswapped)'] self.swap_menu = gvutils.GvOptionMenu(swap_list) tbl.attach(self.swap_menu, 3, 4, 2, 3) interleave_label = GtkLabel('Type of interleaving:') interleave_label.set_alignment(0, 0.5) tbl.attach(interleave_label, 2, 3, 3, 4) self.interleave_list = ['Pixel', 'Band', 'Line'] self.interleave_menu = gvutils.GvOptionMenu(self.interleave_list) tbl.attach(self.interleave_menu, 3, 4, 3, 4) frame2.add(tbl) # Output header format. A possible route for future # improvement would be adding a creation option to CreateCopy for the # simple-flat-binary-raster-plus-header formats that specifies # header-only output and avoids copying all the associated binary data. # We might also want to add a GDAL_DMD-type metadata item to the driver # so that the tool can pick up which formats support header-only output # (sort of like the datatypes and creation options are currently set as # metadata items in the drivers). sbox = GtkHBox(spacing=10) label=GtkLabel('Output Header Format:') label.set_alignment(0,0.5) label.show() sbox.pack_start(label) self.format_list = ['VRT','PAux'] self.format_menu = gvutils.GvOptionMenu(self.format_list) self.format_menu.show() sbox.pack_start(self.format_menu) box1.pack_start(sbox) sbox.show() # Ok/Cancel buttons separator = GtkHSeparator() box1.pack_start(separator, expand=FALSE) box3 = GtkHBox(spacing=10) box1.pack_start(box3, expand=FALSE) current_btn = GtkButton("Current View") current_btn.connect("clicked", self.import_cb,'Current') box3.pack_start(current_btn) new_btn = GtkButton("New View") new_btn.connect("clicked", self.import_cb,'New') box3.pack_start(new_btn) save_btn = GtkButton("Save") save_btn.connect("clicked", self.import_cb,'Save') box3.pack_start(save_btn) close_btn = GtkButton("Close") close_btn.connect("clicked", self.close) box3.pack_start(close_btn) self.tips.set_tip(close_btn, 'Exit the Open Raw tool') self.tips.set_tip(save_btn, 'Create dataset and save header in selected format') self.tips.set_tip(new_btn, 'Create dataset and display in a new view') self.tips.set_tip(current_btn, 'Create dataset and display in current view') box3.show()
def create_projprop(self): projpane = GtkVBox(spacing=10) projpane.set_border_width(10) self.notebook.append_page(projpane, GtkLabel('Coordinate System')) # Projection frame proj_frame = GtkFrame('Projection') proj_frame.show() projpane.pack_start(proj_frame, expand=FALSE) self.proj_vbox = GtkVBox(spacing=5) # Fetch projection record self.proj_full = '' proj_name = '' projection = self.layer.get_projection() self.sr = None if projection is not None and len(projection) > 0: self.sr = osr.SpatialReference() if self.sr.ImportFromWkt(projection) == 0: self.proj_full = self.sr.ExportToPrettyWkt(simplify=1) if self.proj_full is None: self.proj_full = '' proj_name = self.sr.GetAttrValue("PROJECTION") if proj_name is None: proj_name = '' # Create projection switch proj_hbox = GtkHBox(spacing=5) proj_hbox.pack_start(GtkLabel('Projection Name:'), \ expand=FALSE, padding=5) proj_methods = osr.GetProjectionMethods() self.projs = map(lambda x: x.__getitem__(0), proj_methods) self.projs.insert(0, '') proj_names = map(lambda x: x.__getitem__(1), proj_methods) proj_names.insert(0, 'None') self.proj_parms = map(lambda x: x.__getitem__(2), proj_methods) self.proj_parms.insert(0, []) self.proj_index = self.projs.index(proj_name) self.proj_table = None self.proj_om = gvutils.GvOptionMenu(proj_names, self.set_proj_cb) self.create_projparms() self.proj_om.set_history(self.proj_index) proj_hbox.pack_start(self.proj_om, padding=5) self.proj_vbox.pack_start(proj_hbox, expand=FALSE) proj_frame.add(self.proj_vbox) # Datum frame datum_frame = GtkFrame('Datum') datum_frame.show() projpane.pack_start(datum_frame, expand=FALSE) datum_hbox = GtkHBox(spacing=5) datum_hbox.pack_start(GtkLabel('Datum Name:'), expand=FALSE, padding=5) try: self.datum_name = self.sr.GetAttrValue("DATUM") except: self.datum_name = None self.datum_names = {None:"None", osr.SRS_DN_NAD27:"NAD27", \ osr.SRS_DN_NAD83:"NAD83", osr.SRS_DN_WGS72:"WGS72", \ osr.SRS_DN_WGS84:"WGS84"} try: self.datum_index = self.datum_names.keys().index(self.datum_name) except ValueError: self.datum_index = self.datum_names.keys().index(None) self.datum_om = gvutils.GvOptionMenu(self.datum_names.values(), \ self.set_datum_cb) self.datum_om.set_history(self.datum_index) datum_hbox.pack_start(self.datum_om, expand=FALSE, padding=5) datum_frame.add(datum_hbox) # Units frame units_frame = GtkFrame('Units') #units_frame.show() #projpane.pack_start(units_frame, expand=FALSE) units_hbox = GtkHBox(spacing=5) units_hbox.pack_start(GtkLabel('Units:'), expand=FALSE, padding=5) units_frame.add(units_hbox) # WKT frame proj_text_frame = GtkFrame('Well Known Text') proj_text_frame.show() projpane.pack_end(proj_text_frame, expand=TRUE) self.proj_text = GtkText() self.proj_text.set_line_wrap(TRUE) self.proj_text.set_word_wrap(FALSE) self.proj_text.set_editable(FALSE) self.proj_text.show() self.proj_text.insert_defaults(self.proj_full) proj_scrollwin = GtkScrolledWindow() proj_scrollwin.set_usize(0, 300) proj_scrollwin.add(self.proj_text) proj_text_frame.add(proj_scrollwin)
def init_dialog(self): self.dialog = GtkWindow() self.dialog.set_title('Open Subarea') self.dialog.set_border_width(10) mainshell = GtkVBox(spacing=5) self.dialog.add(mainshell) mainshell.show() self.geocoding = 0 coord_system_list = ["Pixels", "Geodetic (Lat/Long)", "Georeferenced"] self.coord_system = \ gvutils.GvOptionMenu(coord_system_list,self.update_gui) mainshell.pack_start(self.coord_system) self.coord_system.show() self.frame_dict = {} pix_fields_names = \ ('Start Line','Start Pixel','Num of Lines','Num of Pixels') self.frame_dict['pixcoord'] = \ CoordFrame('Pixel Coordinates', pix_fields_names, TRUE) mainshell.pack_start(self.frame_dict['pixcoord'][0], expand=FALSE) geo_fields_names = ('Westmost Longitude', 'Eastmost Longitude', \ 'Northmost Latitude', 'Southmost Latitude') self.frame_dict['geodetic'] = \ CoordFrame('Geodetic (Lat/Long) Coordinates', \ geo_fields_names, FALSE) mainshell.pack_start(self.frame_dict['geodetic'][0], expand=FALSE) proj_fields_names = ('Northing', 'Westing', 'Southing', 'Easting') self.frame_dict['geocoord'] = \ CoordFrame('Georeferenced Coordinates', proj_fields_names, FALSE) mainshell.pack_start(self.frame_dict['geocoord'][0], expand=FALSE) self.band_grid = pgugrid.pguGrid(config=(2, 0, 1, 1, 4, 0, 0, 0)) self.band_grid.subscribe("cell-selection-changed", self.band_selected_cb) mainshell.pack_start(self.band_grid, expand=TRUE) button_box = GtkHBox(spacing=10) mainshell.pack_start(button_box, expand=FALSE) button_box.show() btOK = GtkButton('OK') button_box.pack_start(btOK) btOK.connect("clicked", self.open_subarea_cb) btOK.show() btCancel = GtkButton('Cancel') button_box.pack_start(btCancel) btCancel.connect("clicked", self.close) btCancel.show() # Trap window close event self.dialog.connect('delete-event', self.close) for item in self.frame_dict.keys(): if self.frame_dict[item][2]: self.frame_dict[item][0].show() for item in self.frame_dict.keys(): if self.frame_dict[item][2]: self.frame_dict[item][0].show()
def __init__(self, view): GtkWindow.__init__(self) self.set_title('Print') self.connect('delete-event', self.close) self.view = view gvhtml.set_help_topic(self, "gvprint.html") self.command = gview.get_preference('print_command') if self.command is None: self.command = 'lpr' self.filename = 'openev.ps' cgroup = GtkVBox(spacing=6) cgroup.set_border_width(10) self.add(cgroup) table = GtkTable() table.n_columns = 2 table.n_rows = 4 cgroup.add(table) # Setup Driver Option Menu driver_label = GtkLabel('Driver:') driver_label.set_alignment(0, 0.5) table.attach(driver_label, 0, 1, 0, 1) if os.name == "nt": self.driver = gvutils.GvOptionMenu( ('PostScript', 'TIFF', 'PNG', 'Windows Print Driver', 'GIF'), self.update_cb) else: self.driver = gvutils.GvOptionMenu( ('PostScript', 'TIFF', 'PNG', '', 'GIF'), self.update_cb) table.attach(self.driver, 1, 2, 0, 1) # Setup Device Option Menu device_label = GtkLabel('Device:') device_label.set_alignment(0, 0.5) table.attach(device_label, 0, 1, 1, 2) self.device = gvutils.GvOptionMenu(('File', 'Spool to Printer'), self.device_cb) table.attach(self.device, 1, 2, 1, 2) # Setup File/Command entry. self.file_label = GtkLabel('File:') self.file_label.set_alignment(0, 0.5) table.attach(self.file_label, 0, 1, 2, 3) self.file = GtkEntry(maxlen=40) table.attach(self.file, 1, 2, 2, 3) # Setup Output Type self.output_label = GtkLabel('Output Type:') self.output_label.set_alignment(0, 0.5) table.attach(self.output_label, 0, 1, 3, 4) self.output = gvutils.GvOptionMenu(('Greyscale', 'Color'), None) table.attach(self.output, 1, 2, 3, 4) # Setup Paper Type self.paper_label = GtkLabel('Paper:') self.paper_label.set_alignment(0, 0.5) table.attach(self.paper_label, 0, 1, 4, 5) sizes = [] for entry in paper_sizes: sizes.append(entry[0]) self.paper = gvutils.GvOptionMenu(sizes, self.update_cb) table.attach(self.paper, 1, 2, 4, 5) # Setup Scale slider self.scale_label = GtkLabel('Scale:') self.scale_label.set_alignment(0, 0.5) table.attach(self.scale_label, 0, 1, 5, 6) self.scale_adjustment = GtkAdjustment(1, 0, 1.25, 0.05, 0.05, 0.05) self.scale_slider = GtkHScale(self.scale_adjustment) table.attach(self.scale_slider, 1, 2, 5, 6) # Setup Resolution spinner resolution_label = GtkLabel('Resolution:') resolution_label.set_alignment(0, 0.5) table.attach(resolution_label, 0, 1, 6, 7) self.resolution_adjustment = GtkAdjustment(1, 0, 10, 0.1, 0.1, 0.1) self.resolution_spinner = \ GtkSpinButton(self.resolution_adjustment,climb_rate=0.1,digits=1) self.resolution_spinner.connect("changed", self.resolution_cb) table.attach(self.resolution_spinner, 1, 2, 6, 7) # Setup Size entries size_label = GtkLabel('Image size:') size_label.set_alignment(0, 0.5) table.attach(size_label, 0, 1, 7, 8) size_box = GtkHBox(spacing=5) self.xsize_entry = GtkEntry() self.xsize_entry.connect('activate', self.resolution_cb) self.xsize_entry.connect('leave-notify-event', self.resolution_cb) size_box.pack_start(self.xsize_entry) size_box.pack_start(GtkLabel('x')) self.ysize_entry = GtkEntry() self.ysize_entry.connect('activate', self.resolution_cb) self.ysize_entry.connect('leave-notify-event', self.resolution_cb) size_box.pack_start(self.ysize_entry) table.attach(size_box, 1, 2, 7, 8) # Add Print, and Close button(s) btn_box = GtkHBox(spacing=10) but = GtkButton('Print') but.connect('clicked', self.print_cb) btn_box.pack_start(but) but = GtkButton('Close') but.connect('clicked', self.close) btn_box.pack_start(but) table.attach(btn_box, 0, 2, 8, 9) # Initialize values. if gview.get_preference('print_driver') is not None: self.driver.set_history(int(gview.get_preference('print_driver'))) elif os.name == 'nt': self.driver.set_history(DR_WINPRINT) if gview.get_preference('print_device') is not None: self.device.set_history(int(gview.get_preference('print_device'))) if self.device.get_history() == 0: self.set_default_filename() else: self.file.set_text(self.command) if gview.get_preference('print_paper') is not None: self.paper.set_history(int(gview.get_preference('print_paper'))) if gview.get_preference('print_output') is not None: self.output.set_history(int(gview.get_preference('print_output'))) if gview.get_preference('print_resolution') is not None: resolution = float(gview.get_preference('print_resolution')) self.resolution_adjustment.set_value(resolution) width = int(self.view.get_width() * resolution + 0.5) height = int(self.view.get_height() * resolution + 0.5) self.xsize_entry.set_text(str(width)) self.ysize_entry.set_text(str(height)) self.set_paper_size() self.scale_adjustment.set_value(1.0) # Show table.set_row_spacings(6) table.show_all() self.update_cb() cgroup.show() self.show()
def __init__(self, layer): GtkWindow.__init__(self) self.set_title('GView') self.layer = layer self.updating = FALSE gvhtml.set_help_topic(self, "gvpquerypropdlg.html") # create the general layer properties dialog self.create_notebook() self.create_pane1() if self.layer is not None: self.layer.connect('display-change', self.refresh_cb) # Setup Object Drawing Properties Tab self.pane2 = GtkVBox(spacing=10) self.pane2.set_border_width(10) self.notebook.append_page(self.pane2, GtkLabel('Draw Styles')) vbox = GtkVBox(spacing=10) self.pane2.add(vbox) # Create Color control. box = GtkHBox(spacing=3) vbox.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Color:'), expand=FALSE) self.point_color = \ pgucolorsel.ColorControl('Point Color', self.color_cb,'_point_color') box.pack_start(self.point_color) # Point size box = GtkHBox(spacing=3) vbox.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Point Size:'), expand=FALSE) self.point_size = GtkCombo() self.point_size.set_popdown_strings( ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20')) self.point_size.entry.connect('changed', self.point_size_cb) box.pack_start(self.point_size, expand=FALSE) # Coordinate box = GtkHBox(spacing=3) vbox.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Coordinate:'), expand=FALSE) self.coord_om = gvutils.GvOptionMenu( ('Off', 'Raster Pixel/Line', 'Georeferenced', 'Geodetic (lat/long)'), self.set_coordinate_mode) box.pack_start(self.coord_om, expand=FALSE) # Raster Value box = GtkHBox(spacing=3) vbox.pack_start(box, expand=FALSE) box.pack_start(GtkLabel('Pixel Value:'), expand=FALSE) self.pixel_mode_om = \ gvutils.GvOptionMenu(('On','Off'), self.set_pixel_mode) box.pack_start(self.pixel_mode_om, expand=FALSE) self.update_gui() self.show_all()