def __init__(self): gtk.Window.__init__(self) self.set_title("Legend: Empty") self.set_resizable(True) self.set_default_size(300, 300) self.layer = None self.teardown_id = None self.changed_id = None self.resizing = False self.resize_count = 0 self.viewarea = gview.GvViewArea() back_color = pref('legend-background-color', white) self.viewarea.set_background_color(color_string_to_tuple(back_color)) self.shapes = gview.GvShapes() self.shapes.set_name('Legend shapes') self.vlayer = gview.GvShapesLayer(self.shapes) self.vlayer.set_name('Legend layer') self.viewarea.add_layer(self.vlayer) self.add(self.viewarea) self.connect('delete-event', self.close) self.show_all() self.changing_view_state = False self.viewarea.connect('view-state-changed', self.view_state_cb) if 'CIETMAP_HOME' in os.environ: set_help_topic(self, _('cm-help-legend'))
def __init__(self, cls, cwd=None): """Initialize a GvClassificationDlg on a particular GvLayer""" gtk.Window.__init__(self) self.set_title(_("Layer Classification")) self.connect('delete-event', self.close) self.set_border_width(5) self.color_buttons = [] self.sym_menus = [] self.scale_spinners = [] self.view_mgr = None self.ranges = [] self.labels = [] self.reclassdlg = None self.updating = False items = load_ramp_config_file() self.ramp = None self.ramps = items if cwd: self.cwd = cwd else: self.cwd = os.getcwd() if cls is None: self.cls = GvClassification() elif isinstance(cls, GvClassification): self.cls = cls else: raise TypeError, "GvClassificationDlg now requires a GvClassification instance" self.classification = self.cls if self.cls.count <= 0: self.ramp = items[0] self.cls.prepare_default() #main vertical box vbox = gtk.VBox(spacing=5) self.add(vbox) if isinstance(cls.layers[0], gview.GvShapesLayer): self.property_list = pgu.ComboText(action=self.property_select_cb) self.property_list.set_size_request(125, -1) self.update_property_list() ncols = 3 else: self.property_list = None ncols = 2 hbox = gtk.HBox(homogeneous=True, spacing=30) vbox.pack_start(hbox, expand=False) button = gtk.Button(stock=gtk.STOCK_OPEN) button.connect('clicked', self.load_cb) hbox.pack_start(button, expand=False) button = gtk.Button(stock=gtk.STOCK_SAVE) button.connect('clicked', self.save_cb) hbox.pack_start(button, expand=False) if self.property_list: hbox.pack_start(self.property_list, expand=False) #classification frame class_frame = gtk.Frame() vbox.pack_start(class_frame) frame_box = gtk.VBox(spacing=3) frame_box.set_border_width(5) class_frame.add(frame_box) hbox = gtk.HBox(spacing=5) frame_box.pack_start(hbox, expand=False) label = pgu.Label(_("Legend Title:")) hbox.pack_start(label, expand=False) self.title_txt = gtk.Entry() self.title_txt.set_text(self.cls.get_title()) self.title_txt.connect('changed', self.title_changed_cb) hbox.pack_start(self.title_txt) #classification list class_box = gtk.ScrolledWindow() # let the viewport determine the sizes class_box.set_size_request(436, 148) class_box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.class_list = gtk.VBox() class_box.add_with_viewport(self.class_list) frame_box.pack_start(class_box) self.reset_cls_list() hbox = gtk.HBox(homogeneous=True, spacing=30) frame_box.pack_start(hbox, expand=False) # Classification buttons button = gtk.Button(_("Add class")) button.connect('clicked', self.add_class_cb) hbox.pack_start(button, expand=False) button = gtk.Button(_("Reclassify")) button.connect('clicked', self.reclassify_cb) hbox.pack_start(button, expand=False) button = gtk.Button(_("Revert")) button.connect('clicked', self.reset_cb) hbox.pack_start(button, expand=False) #Color Ramp choices hbox = gtk.HBox(spacing=5) frame_box.pack_start(hbox, expand=False) label = pgu.Label(_("Color Ramps:")) hbox.pack_start(label, expand=False) lst = gtk.ListStore(gtk.gdk.Pixbuf,str) for ramp in items: lst.append((ramp.gradient.get_pixbuf(), ramp.title)) combo = pgu.ComboBox(model=lst) combo.set_active(0) combo.connect(cb=self.ramp_cb) hbox.pack_end(combo, expand=False) # buttons hbox = gtk.HBox(homogeneous=True, spacing=30) vbox.pack_start(hbox, expand=False) self.ok_button = gtk.Button(stock=gtk.STOCK_OK) self.ok_button.connect('clicked', self.ok_cb) hbox.pack_start(self.ok_button, expand=False) self.apply_button = gtk.Button(_("Apply")) self.apply_button.connect('clicked', self.apply_cb) hbox.pack_start(self.apply_button, expand=False) self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL) self.cancel_button.connect('clicked', self.cancel_cb) hbox.pack_start(self.cancel_button, expand=False) self.show_all() #make ok_button a default button self.ok_button.set_flags(gtk.CAN_DEFAULT) self.ok_button.grab_default() self.publish('classification-changed') # sets help for CIETMap if 'CIETMAP_HOME' in os.environ: set_help_topic(self, _('cm-help-classification'))
def __init__(self, view): gtk.Window.__init__(self) self.set_title(_("Print")) self.connect('delete-event',self.close) self.view = view self.command = gview.get_preference('print_command', 'lpr') cgroup = gtk.VBox(spacing=6) cgroup.set_border_width(5) self.add(cgroup) frame = gtk.Frame() cgroup.pack_start(frame, expand=False) table = gtk.Table() table.set_row_spacings(6) table.set_border_width(5) frame.add(table) # Setup Driver Option Menu driver_label = pgu.Label(_("Driver:")) table.attach(driver_label, 0,1,0,1, yoptions=gtk.SHRINK) if os.name == 'nt': drivers = ("PostScript", "TIFF", "PNG", "Windows Print Driver", "GIF") else: drivers = ("PostScript", "TIFF", "PNG", "GIF") self.driver = pgu.ComboText(strings=drivers, action=self.update_cb) table.attach(self.driver, 1,2,0,1, yoptions=gtk.SHRINK) # Setup Device Option Menu device_label = pgu.Label(_("Device:")) table.attach(device_label, 0,1,1,2, yoptions=gtk.SHRINK) self.device = pgu.ComboText(strings=(_("File"), _("Spool to Printer")), action=self.device_cb) table.attach(self.device, 1,2,1,2, yoptions=gtk.SHRINK) # Setup File/Command entry. self.file_label = pgu.Label(_("File:")) table.attach(self.file_label, 0,1,2,3, yoptions=gtk.SHRINK) self.file = gtk.Entry() table.attach(self.file, 1,2,2,3, yoptions=gtk.SHRINK) # Setup Output Type self.output_label = pgu.Label(_("Output type:")) table.attach(self.output_label, 0,1,3,4, yoptions=gtk.SHRINK) self.output = pgu.ComboText(strings=(_("Greyscale"), _("Color"))) table.attach(self.output, 1,2,3,4, yoptions=gtk.SHRINK) # Setup Paper Type self.paper_label = pgu.Label(_("Paper:")) table.attach(self.paper_label, 0,1,4,5, yoptions=gtk.SHRINK) sizes = [] for entry in paper_sizes: sizes.append(entry[0]) self.paper = pgu.ComboText(strings=sizes, action=self.update_cb) table.attach(self.paper, 1,2,4,5, yoptions=gtk.SHRINK) # Setup Scale slider self.scale_label = pgu.Label(_("Scale:")) table.attach(self.scale_label, 0,1,5,6, yoptions=gtk.SHRINK) self.scale_adjustment = gtk.Adjustment(1, 0, 1.25, 0.05, 0.05, 0.05) self.scale_slider = gtk.HScale(self.scale_adjustment) table.attach(self.scale_slider, 1,2,5,6, yoptions=gtk.SHRINK) # Setup Resolution spinner resolution_label = pgu.Label(_("Resolution:")) table.attach(resolution_label, 0,1,6,7, yoptions=gtk.SHRINK) self.resolution_adjustment = gtk.Adjustment(1, 0, 10, 0.1, 0.1, 0.1) self.resolution_spinner = gtk.SpinButton(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, yoptions=gtk.SHRINK) # Setup Size entries size_label = pgu.Label(_("Image size:")) table.attach(size_label,0,1,7,8, yoptions=gtk.SHRINK) size_box = gtk.HBox(spacing=5) self.xsize_entry = gtk.Entry() 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(gtk.Label("x")) self.ysize_entry = gtk.Entry() 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, yoptions=gtk.SHRINK) # Add Print, and Close button(s) btn_box = gtk.HBox(homogeneous=True, spacing=20) but = gtk.Button(stock=gtk.STOCK_PRINT) but.connect('clicked',self.print_cb) btn_box.pack_start(but, expand=False) but = gtk.Button(stock=gtk.STOCK_CLOSE) but.connect('clicked',self.close) btn_box.pack_start(but, expand=False) cgroup.pack_end(btn_box, expand=False) # Initialize values. # lazy prefs = gview.get_preference pref = prefs('print_driver', -1) self.driver.set_active(int(pref)) if os.name == 'nt': self.driver.set_active(DR_WINPRINT) pref = prefs('print_device', -1) self.device.set_active(int(pref)) if self.device.get_active() == DV_FILE: self.set_default_filename() else: self.file.set_text(self.command) pref = prefs('print_paper', -1) self.paper.set_active(int(pref)) pref = prefs('print_output', -1) self.output.set_active(int(pref)) pref = prefs('print_resolution') if pref: resolution = float(pref) 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) if 'CIETMAP_HOME' in os.environ: topic = "Pages/Printing.htm" self.filename = 'cietmap.ps' else: topic = "gvprint.html" self.filename = 'openev.ps' set_help_topic(self, topic) # Show self.show_all() self.update_cb()