Exemplo n.º 1
0
    def __init__(self, layer):
        gtk.Window.__init__(self)
        self.set_border_width(3)
        if layer is not None:
            self.set_title(layer.get_name()+' Properties')
        else:
            self.set_title('Raster Properties')

        gvhtml.set_help_topic(self, "gvrasterpropdlg.html")
        self.layer = layer
        self.updating = False

        if self.layer is not None:
            self.display_change_id = self.layer.connect('display-change', self.refresh_cb)
            self.teardown_id = layer.connect('teardown', self.close)

        # create the general layer properties dialog
        self.create_notebook()

        self.create_pane1()

        self.updating = True
        self.create_sourcepane()
        self.updating = False

        self.create_openglprop()
        self.create_lutprop()
        self.create_projprop()
        self.create_imageinfo()

        self.show_all()
        self.update_gui()

        for source in self.sources:
            source.gui_refresh()
Exemplo n.º 2
0
    def __init__(self, app=None,startpath=None):
        gviewapp.Tool_GViewApp.__init__(self,app)

        self.init_dialog()
        self.init_menu()
        
        # store the id for the roi-changed signal
        # connection so it can be disconnected later
        self.roichanged_id=None

        # Set help topic
        gvhtml.set_help_topic(self.dialog,"Tool_Export.html")
Exemplo n.º 3
0
    def __init__(self, app=None, startpath=None):
        gviewapp.Tool_GViewApp.__init__(self, app)

        self.init_dialog()
        self.init_menu()

        # store the id for the roi-changed signal
        # connection so it can be disconnected later
        self.roichanged_id = None

        # Set help topic
        gvhtml.set_help_topic(self.dialog, "Tool_Export.html")
Exemplo n.º 4
0
    def __init__(self, layer):
        GtkWindow.__init__(self)
        self.set_border_width(3)
        if layer is not None:
            self.set_title(layer.get_name() + ' Properties')
        else:
            self.set_title('Raster Properties')

        gvhtml.set_help_topic(self, "gvrasterpropdlg.html")
        self.layer = layer
        self.updating = FALSE

        if self.layer is not None:
            self.display_change_id = self.layer.connect(
                'display-change', self.refresh_cb)
            self.teardown_id = layer.connect('teardown', self.close)

        # create the general layer properties dialog
        self.create_notebook()

        self.create_pane1()

        self.updating = TRUE
        self.create_sourcepane()
        self.updating = FALSE

        self.create_openglprop()
        self.create_lutprop()
        self.create_projprop()
        self.create_imageinfo()

        self.update_gui()
        self.show_all()
        self.update_gui()

        for source in self.sources:
            source.gui_refresh()
Exemplo n.º 5
0
    def __init__(self, ds, viewwindow):
        gtk.Window.__init__(self)
        self.set_title("Vector Layer Selection")
        self.set_size_request(350, 600)
        self.set_border_width(3)
        self.set_resizable(True)
        self.connect("delete-event", self.close)
        shell = gtk.VBox(homogeneous=False, spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "veclayerselect.html")

        # Layer list
        layerbox = gtk.ScrolledWindow()
        shell.pack_start(layerbox)
        layerstore = gtk.ListStore(str)
        layerlist = gtk.TreeView(layerstore)
        column = gtk.TreeViewColumn("Layer", gtk.CellRendererText(), text=0)
        layerlist.append_column(column)
        layerlist.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        layerbox.add_with_viewport(layerlist)

        # Clip to view?

        hbox = gtk.HBox(homogeneous=False)
        shell.pack_start(hbox, expand=False)

        self.clip_to_view_btn = gtk.CheckButton()
        hbox.pack_start(self.clip_to_view_btn, expand=False)

        hbox.pack_start(gtk.Label("Clip To View"), expand=False)

        # SQL Box.

        hbox = gtk.HBox(homogeneous=False, spacing=3)
        shell.pack_start(hbox, expand=False)

        sql_button = gtk.Button("Execute SQL:")
        sql_button.connect("clicked", self.execute_sql)
        hbox.pack_start(sql_button, expand=False)

        self.sql_cmd = gtk.Entry()
        hbox.pack_start(self.sql_cmd, expand=True)

        # buttons
        button_box = gtk.HButtonBox()
        button_box.set_layout(gtk.BUTTONBOX_START)
        ok_button = gtk.Button("Accept")
        ok_button.connect("clicked", self.accept)
        loadall_button = gtk.Button("Load All")
        loadall_button.connect("clicked", self.load_all)
        cancel_button = gtk.Button("Cancel")
        cancel_button.connect("clicked", self.close)
        help_button = gtk.Button("Help")
        help_button.connect("clicked", self.help_cb)
        button_box.pack_start(ok_button, expand=False)
        button_box.pack_start(loadall_button, expand=False)
        button_box.pack_start(cancel_button, expand=False)
        button_box.pack_start(help_button, expand=False)
        shell.pack_start(button_box, expand=False)

        shell.show_all()

        self.ds = ds
        self.viewwindow = viewwindow
        self.layerstore = layerstore
        self.layerlist = layerlist

        layer_count = ds.GetLayerCount()
        for i in range(layer_count):
            layer = ds.GetLayer(i)
            layerstore.append(["%s" % layer.GetName()])

        self.show_all()
Exemplo n.º 6
0
    def __init__(self, ds, viewwindow):
        GtkWindow.__init__(self)
        self.set_title('Vector Layer Selection')
        self.set_usize(500, 500)
        self.set_border_width(3)
        self.set_policy(TRUE, TRUE, FALSE)
        self.connect('delete-event', self.close)
        shell = GtkVBox(homogeneous=FALSE, spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "veclayerselect.html")

        # Layer list
        layerbox = GtkScrolledWindow()
        shell.pack_start(layerbox)
        layerlist = GtkCList(cols=2)

        layerbox.add_with_viewport(layerlist)
        layerlist.set_shadow_type(SHADOW_NONE)
        layerlist.set_selection_mode(SELECTION_SINGLE)
        layerlist.set_row_height(30)
        layerlist.set_column_width(0, 24)
        #layerlist.connect('select-row', self.layer_selected)
        layerlist.connect('button-press-event', self.list_clicked)

        # Clip to view?

        hbox = GtkHBox(homogeneous=FALSE)
        shell.pack_start(hbox, expand=FALSE)

        self.clip_to_view_btn = GtkCheckButton()
        hbox.pack_start(self.clip_to_view_btn, expand=FALSE)

        hbox.pack_start(GtkLabel('Clip To View'), expand=FALSE)

        # SQL Box.

        hbox = GtkHBox(homogeneous=FALSE, spacing=3)
        shell.pack_start(hbox, expand=FALSE)

        sql_button = GtkButton('Execute SQL:')
        sql_button.connect('clicked', self.execute_sql)
        hbox.pack_start(sql_button, expand=FALSE)

        self.sql_cmd = GtkEntry()
        hbox.pack_start(self.sql_cmd, expand=TRUE)

        # buttons
        button_box = GtkHButtonBox()
        button_box.set_layout_default(BUTTONBOX_START)
        ok_button = GtkButton('Accept')
        ok_button.connect('clicked', self.accept)
        loadall_button = GtkButton('Load All')
        loadall_button.connect('clicked', self.load_all)
        cancel_button = GtkButton('Cancel')
        cancel_button.connect('clicked', self.close)
        help_button = GtkButton('Help')
        help_button.connect('clicked', self.help_cb)
        button_box.pack_start(ok_button, expand=FALSE)
        button_box.pack_start(loadall_button, expand=FALSE)
        button_box.pack_start(cancel_button, expand=FALSE)
        button_box.pack_start(help_button, expand=FALSE)
        shell.pack_start(button_box, expand=FALSE)

        self.connect('realize', self.realize)

        self.sel_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics',
                                        'ck_on_l.xpm'))
        self.not_sel_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics',
                                        'ck_off_l.xpm'))

        shell.show_all()

        self.ds = ds
        self.viewwindow = viewwindow
        self.layerlist = layerlist

        layer_count = ds.GetLayerCount()
        self.layer_names = []
        self.layer_sel = []
        for i in range(layer_count):
            layer = ds.GetLayer(i)
            self.layer_names.append(layer.GetName())
            self.layer_sel.append(0)

        self.show_all()
Exemplo n.º 7
0
def SimpleFileSelect(ok_cb, cb_data=None, title=None, default_filename=None, cancel_cb=None, help_topic=None):

    """Simplified File Selection

    This method launches a file selector, and calls the caller supplied
    OK callback when the user selects a file.  Creation, tailoring and
    cleanup of the GtkFileselection is managed internally.

    Arguments:

    ok_cb -- callback to call when user selects a file.  It should take
    a filename and cb_data argument.

    cb_data -- extra data to pass to ok, and cancel callbacks.  Defaults to
    None.

    title -- the title to use for the dialog.  Defaults to nothing.

    default_filename -- the initial filename to be shown in the file selector.
    Defaults to no file, and the current (or last accessed) directory.

    cancel_cb -- callback called when the user hits the cancel button or
    closes the file selection dialog.  If defaulted the caller isn't notified
    of cancels.  If supplied, the callback should take one argument which is
    the callback data.

    Example:

    The following code launches a simple file selector, and does an action
    in the callback.  The title, and default filename are set, but
        pgufilesel.SimpleFileSelect( self.save_vector_layer_with_file,
                                     cb_data = layer.get_parent(),
                                     title = 'Shapefile To Save to',
                                     default_filename = layer.get_name() )

    def save_vector_layer_with_file( self, filename, shapes_data ):
        shapes_data.save_to( filename )

    """

    global simple_file_sel

    if simple_file_sel is not None:
        simple_file_sel.destroy()

    simple_file_sel = gtk.FileChooserDialog(
        title,
        None,
        gtk.FILE_CHOOSER_ACTION_SAVE,
        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK),
    )
    simple_file_sel.set_default_response(gtk.RESPONSE_OK)
    if default_filename is not None:
        simple_file_sel.set_filename(default_filename)
    else:
        if simple_file_sel_dir is not None:
            simple_file_sel.set_filename(simple_file_sel_dir)

    if help_topic is not None:
        import gvhtml

        gvhtml.set_help_topic(simple_file_sel, help_topic)

    response = simple_file_sel.run()
    if response == gtk.RESPONSE_OK:
        ok_cb(simple_file_sel.get_filename(), cb_data)
    elif response == gtk.RESPONSE_CANCEL:
        if cancel_cb != None:
            cancel_cb()
    simple_file_sel.destroy()

    simple_file_sel.ok_button.connect("clicked", SFSOkCB, ok_cb, cb_data)
    simple_file_sel.cancel_button.connect("clicked", SFSCancelCB, cancel_cb, cb_data)
Exemplo n.º 8
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title('Layers')
        self.set_size_request(250, 500)
        self.set_border_width(3)
        self.set_resizable(True)
        self.connect('delete-event',self.close)
        shell = gtk.VBox(spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "layerdlg.html" );

        # View chooser menu
        hbox = gtk.HBox(spacing=3)
        shell.pack_start(hbox, expand=False)
        hbox.pack_start(gtk.Label('View:'), expand=False, padding=3)
        viewopt = gtk.OptionMenu()
        hbox.pack_start(viewopt)
        viewmenu = gtk.Menu()
        viewopt.set_menu(viewmenu)

        # Do we want to include a thumbnail?  This is buggy on some platforms.
        # Note: GTK2 PORT - Thumbnails in tree view not tested
        if gview.get_preference('layer_thumbnail') is None \
           or gview.get_preference('layer_thumbnail') == 'off':
            self.thumbnail = False
        else:
            self.thumbnail = True

        self.updating = False

        #
        # Layer list model
        #
        if self.thumbnail:
           self.list_store = gtk.ListStore( gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, 
                                            gobject.TYPE_STRING)
        else:
           self.list_store = gtk.ListStore( gtk.gdk.Pixbuf, gobject.TYPE_STRING)

        #
        # Layer list view
        #
        self.make_tree_view(self.list_store)

        layerbox = gtk.ScrolledWindow()
        shell.pack_start(layerbox)
        layerbox.add_with_viewport(self.tree_view)

        self.tree_view.get_selection().set_mode(gtk.SELECTION_SINGLE)

        self.tree_view.connect('button-press-event', self.list_pressed)
        self.tree_view.connect('button-release-event', self.list_released)

        # Option buttons
        opts = (('new.xpm', 'New layer', self.new_layer),
                ('raise.xpm', 'Raise layer', self.raise_layer),
                ('lower.xpm', 'Lower layer', self.lower_layer),
                ('delete.xpm','Delete layer', self.delete_layer))
        butbox = gtk.HBox(spacing=1)
        shell.pack_start(butbox, expand=False)
        for opt in opts:
            but = gtk.Button()
            butbox.pack_start(but)

            img = gtk.Image()
            img.set_from_file(os.path.join(gview.home_dir,'pics',opt[0]))
            img.show()
            but.add(img)

            # This works too...
            #pixmap = gtk.gdk.pixmap_create_from_xpm(self.window, None, 
            #    os.path.join(gview.home_dir,'pics',opt[0]))
            #img = gtk.Image()
            #img.set_from_pixmap(pixmap[0], pixmap[1])
            #img.show()
            #but.add(img)

            # tooltips.set_tip(but, opt[1])
            but.connect('clicked', opt[2])

        self.connect('realize', self.realize)

        shell.show_all()
        self.viewopt = viewopt
        self.viewmenu = viewmenu
        self.views = {}
        self.menuitems = {}
        self.selected_view = None

        path =  os.path.join(gview.home_dir,'pics','eye.xpm')
        self.eye_pixbuf = gtk.gdk.pixbuf_new_from_file(path)

        # Publish signals
        self.publish('active-view-changed')
        self.publish('deleted-layer')
Exemplo n.º 9
0
    def __init__(self, ds, viewwindow):
        GtkWindow.__init__(self)
        self.set_title('Vector Layer Selection')
        self.set_usize(500, 500)
        self.set_border_width(3)
        self.set_policy(TRUE,TRUE,FALSE)
        self.connect('delete-event',self.close)
        shell = GtkVBox(homogeneous=FALSE,spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "veclayerselect.html" );

        # Layer list
        layerbox = GtkScrolledWindow()
        shell.pack_start(layerbox)
        layerlist = GtkCList(cols=2)
            
        layerbox.add_with_viewport(layerlist)
        layerlist.set_shadow_type(SHADOW_NONE)
        layerlist.set_selection_mode(SELECTION_SINGLE)
        layerlist.set_row_height(30)
        layerlist.set_column_width(0, 24)
        #layerlist.connect('select-row', self.layer_selected)
        layerlist.connect('button-press-event', self.list_clicked)

        # Clip to view?

        hbox = GtkHBox(homogeneous=FALSE)
        shell.pack_start( hbox, expand=FALSE )

        self.clip_to_view_btn = GtkCheckButton()
        hbox.pack_start( self.clip_to_view_btn, expand=FALSE )

        hbox.pack_start( GtkLabel('Clip To View' ), expand=FALSE )

        # SQL Box.

        hbox = GtkHBox(homogeneous=FALSE, spacing=3)
        shell.pack_start( hbox,expand=FALSE )
        
        sql_button = GtkButton('Execute SQL:')
        sql_button.connect('clicked', self.execute_sql)
        hbox.pack_start(sql_button, expand=FALSE)
        
        self.sql_cmd = GtkEntry()
        hbox.pack_start(self.sql_cmd,expand=TRUE)

        # buttons
        button_box = GtkHButtonBox()
        button_box.set_layout_default(BUTTONBOX_START)
        ok_button = GtkButton('Accept')
        ok_button.connect('clicked', self.accept)
        loadall_button = GtkButton('Load All')
        loadall_button.connect('clicked', self.load_all)
        cancel_button = GtkButton('Cancel')
        cancel_button.connect('clicked', self.close)
        help_button = GtkButton('Help')
        help_button.connect('clicked', self.help_cb)
        button_box.pack_start(ok_button, expand=FALSE)
        button_box.pack_start(loadall_button, expand=FALSE)
        button_box.pack_start(cancel_button, expand=FALSE)
        button_box.pack_start(help_button, expand=FALSE)
        shell.pack_start(button_box,expand=FALSE)

        self.connect('realize', self.realize)

        self.sel_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics',
                                        'ck_on_l.xpm'))
        self.not_sel_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics',
                                        'ck_off_l.xpm'))
        
        shell.show_all()

        self.ds = ds
        self.viewwindow = viewwindow
        self.layerlist = layerlist

        layer_count = ds.GetLayerCount()
        self.layer_names = []
        self.layer_sel = []
        for i in range(layer_count):
            layer = ds.GetLayer( i )
            self.layer_names.append( layer.GetName() )
            self.layer_sel.append( 0 )

        self.show_all()
Exemplo n.º 10
0
    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()
Exemplo n.º 11
0
    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()
Exemplo n.º 12
0
    def __init__(self, layer):
        GtkWindow.__init__(self)
        self.set_title(layer.get_name()+' Properties')
        self.layer = layer
        self.updating = FALSE

        if self.layer is not None:
            self.display_change_id = layer.connect('display-change',
                                                   self.refresh_cb)
            self.teardown_id = layer.connect('teardown',self.close)

        # create the general layer properties dialog
        self.create_notebook()
        self.create_pane1()

        # 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'))

        gvhtml.set_help_topic( self, "gvvectorpropdlg.html" )


        # ANTIALIASING
        box = GtkHBox(spacing=3)
        self.pane2.pack_start(box)
        box.pack_start( GtkLabel("Anti-alias:"), expand=FALSE )
        self.antialias = pgutogglebutton.pguToggleButton()
        self.antialias.connect('toggled', self.antialias_cb )
        box.pack_start( self.antialias, expand=FALSE )

        # POINT CONTROLS -----------------------------------------------------
        frame = GtkFrame('Points')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        #create a symbol control
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Symbol:'), expand=FALSE)
        self.point_symbol = GtkCombo()
        #add a default to symbol names
        self.point_symbol.set_popdown_strings( tuple(symbols) )
        self.point_symbol.entry.set_editable(FALSE)
        #self.point_symbol.set_value_in_list(TRUE, FALSE)
        self.point_symbol.entry.connect('changed', self.symbol_cb)
        box.pack_start(self.point_symbol)

        # 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.symbol_cb)
        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)

        # LINE CONTROLS ------------------------------------------------------
        frame = GtkFrame('Lines')
        self.pane2.pack_start(frame)

        vbox = GtkVBox()
        vbox.set_border_width(10)
        frame.add(vbox)

        # Create Color control.
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Color:'),expand=FALSE)
        self.line_color = pgucolorsel.ColorControl('Line Color',
                                         self.color_cb,'_line_color')
        box.pack_start(self.line_color)
        
        #Line Width
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Width:'), expand=FALSE)
        self.line_width = GtkEntry()
        self.line_width.connect('changed', self.line_width_cb)
        box.pack_start( self.line_width, expand=FALSE)
        

        # AREA CONTROLS ------------------------------------------------------
        frame = GtkFrame('Areas')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        # Create Color controls
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Edge Color:'),expand=FALSE)
        self.area_edge_color = pgucolorsel.ColorControl('Area Edge Color',
                                              self.color_cb,'_area_edge_color')
        box.pack_start(self.area_edge_color)

        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Fill Color:'),expand=FALSE)
        self.area_fill_color = pgucolorsel.ColorControl('Area Fill Color',
                                              self.color_cb,'_area_fill_color')
        box.pack_start(self.area_fill_color)

        #Area Edge Width
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Edge Width:'), expand=FALSE)
        self.area_edge_width = GtkEntry()
        self.area_edge_width.connect('changed', self.area_edge_width_cb)
        box.pack_start( self.area_edge_width, expand=FALSE)
        

        # LABEL CONTROLS -----------------------------------------------------
        frame = GtkFrame('Labels')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        # collect candidate field names from the schema.
        fnlist = [ 'disabled' ]
        schema = self.layer.get_parent().get_schema()
        for item in schema:
            fnlist.append( item[0] )

        # Field Name
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Label Field:'),expand=FALSE)
        self.label_field = GtkCombo()
        self.label_field.set_popdown_strings( fnlist )
        self.label_field.entry.connect('changed', self.label_change_cb)
        box.pack_start(self.label_field,expand=FALSE)

        # Create Color control.
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Color:'),expand=FALSE)
        self.label_color = pgucolorsel.ColorControl('Label Color',
                                                    self.label_change_cb)
        box.pack_start(self.label_color)

        # Font
        font_list = self.layer.get_view().get_fontnames()
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Font:'),expand=FALSE)
        self.label_font = GtkCombo()
        self.label_font.set_popdown_strings(font_list)
        self.label_font.entry.connect('changed', self.label_change_cb)
        box.pack_start(self.label_font,expand=FALSE)

        self.update_gui()

        self.show_all()
Exemplo n.º 13
0
    def __init__(self):
        GtkWindow.__init__(self)
        self.set_title('Layers')
        self.set_usize(250, 500)
        self.set_border_width(3)
        self.set_policy(TRUE,TRUE,FALSE)
        self.connect('delete-event',self.close)
        shell = GtkVBox(spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "layerdlg.html" );

        # View chooser menu
        hbox = GtkHBox(spacing=3)
        shell.pack_start(hbox, expand=FALSE)
        hbox.pack_start(GtkLabel('View:'), expand=FALSE, padding=3)
        viewopt = GtkOptionMenu()
        hbox.pack_start(viewopt)
        viewmenu = GtkMenu()
        viewopt.set_menu(viewmenu)

        # Do we want to include a thumbnail?  This is buggy on some platforms.
        if gview.get_preference('layer_thumbnail') is None \
           or gview.get_preference('layer_thumbnail') == 'off':
            self.thumbnail = FALSE
        else:
            self.thumbnail = TRUE

        self.updating = FALSE

        # Layer list
        layerbox = GtkScrolledWindow()
        shell.pack_start(layerbox)
        if self.thumbnail:
            layerlist = GtkCList(cols=3)
        else:
            layerlist = GtkCList(cols=2)
            
        layerbox.add_with_viewport(layerlist)
        layerlist.set_shadow_type(SHADOW_NONE)
        layerlist.set_selection_mode(SELECTION_SINGLE)
        layerlist.set_row_height(THUMB_H + 4)
        layerlist.set_column_width(0, EYE_W)
        if self.thumbnail:
            layerlist.set_column_width(1, THUMB_W + 4)
        layerlist.connect('select-row', self.layer_selected)
        layerlist.connect('button-press-event', self.list_clicked)

        # Option buttons
        opts = (('new.xpm', 'New layer', self.new_layer),
                ('raise.xpm', 'Raise layer', self.raise_layer),
                ('lower.xpm', 'Lower layer', self.lower_layer),
                ('delete.xpm','Delete layer', self.delete_layer))
        butbox = GtkHBox(spacing=1)
        shell.pack_start(butbox, expand=FALSE)
        for opt in opts:
            but = GtkButton()
            butbox.pack_start(but)        
            but.add(GtkPixmap(self,os.path.join(gview.home_dir,'pics',opt[0])))
            tooltips.set_tip(but, opt[1])
            but.connect('clicked', opt[2])

        self.connect('realize', self.realize)

        shell.show_all()
        self.viewopt = viewopt
        self.viewmenu = viewmenu
        self.layerlist = layerlist
        self.views = {}
        self.menuitems = {}
        self.selected_view = None

        self.eye_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics','eye.xpm'))

        # Publish signals
        self.publish('active-view-changed')
        self.publish('deleted-layer')
Exemplo n.º 14
0
    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()
Exemplo n.º 15
0
    def __init__(self, layer):
        GtkWindow.__init__(self)
        self.set_title(layer.get_name() + ' Properties')
        self.layer = layer
        self.updating = FALSE

        if self.layer is not None:
            self.display_change_id = layer.connect('display-change',
                                                   self.refresh_cb)
            self.teardown_id = layer.connect('teardown', self.close)

        # create the general layer properties dialog
        self.create_notebook()
        self.create_pane1()

        # 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'))

        gvhtml.set_help_topic(self, "gvvectorpropdlg.html")

        # ANTIALIASING
        box = GtkHBox(spacing=3)
        self.pane2.pack_start(box)
        box.pack_start(GtkLabel("Anti-alias:"), expand=FALSE)
        self.antialias = pgutogglebutton.pguToggleButton()
        self.antialias.connect('toggled', self.antialias_cb)
        box.pack_start(self.antialias, expand=FALSE)

        # POINT CONTROLS -----------------------------------------------------
        frame = GtkFrame('Points')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        #create a symbol control
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Symbol:'), expand=FALSE)
        self.point_symbol = GtkCombo()
        #add a default to symbol names
        self.point_symbol.set_popdown_strings(tuple(symbols))
        self.point_symbol.entry.set_editable(FALSE)
        #self.point_symbol.set_value_in_list(TRUE, FALSE)
        self.point_symbol.entry.connect('changed', self.symbol_cb)
        box.pack_start(self.point_symbol)

        # 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.symbol_cb)
        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)

        # LINE CONTROLS ------------------------------------------------------
        frame = GtkFrame('Lines')
        self.pane2.pack_start(frame)

        vbox = GtkVBox()
        vbox.set_border_width(10)
        frame.add(vbox)

        # Create Color control.
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Color:'), expand=FALSE)
        self.line_color = pgucolorsel.ColorControl('Line Color', self.color_cb,
                                                   '_line_color')
        box.pack_start(self.line_color)

        #Line Width
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Width:'), expand=FALSE)
        self.line_width = GtkEntry()
        self.line_width.connect('changed', self.line_width_cb)
        box.pack_start(self.line_width, expand=FALSE)

        # AREA CONTROLS ------------------------------------------------------
        frame = GtkFrame('Areas')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        # Create Color controls
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Edge Color:'), expand=FALSE)
        self.area_edge_color = pgucolorsel.ColorControl(
            'Area Edge Color', self.color_cb, '_area_edge_color')
        box.pack_start(self.area_edge_color)

        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Fill Color:'), expand=FALSE)
        self.area_fill_color = pgucolorsel.ColorControl(
            'Area Fill Color', self.color_cb, '_area_fill_color')
        box.pack_start(self.area_fill_color)

        #Area Edge Width
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Edge Width:'), expand=FALSE)
        self.area_edge_width = GtkEntry()
        self.area_edge_width.connect('changed', self.area_edge_width_cb)
        box.pack_start(self.area_edge_width, expand=FALSE)

        # LABEL CONTROLS -----------------------------------------------------
        frame = GtkFrame('Labels')
        self.pane2.pack_start(frame)

        vbox = GtkVBox(spacing=10)
        vbox.set_border_width(10)
        frame.add(vbox)

        # collect candidate field names from the schema.
        fnlist = ['disabled']
        schema = self.layer.get_parent().get_schema()
        for item in schema:
            fnlist.append(item[0])

        # Field Name
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Label Field:'), expand=FALSE)
        self.label_field = GtkCombo()
        self.label_field.set_popdown_strings(fnlist)
        self.label_field.entry.connect('changed', self.label_change_cb)
        box.pack_start(self.label_field, expand=FALSE)

        # Create Color control.
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Color:'), expand=FALSE)
        self.label_color = pgucolorsel.ColorControl('Label Color',
                                                    self.label_change_cb)
        box.pack_start(self.label_color)

        # Font
        font_list = self.layer.get_view().get_fontnames()
        box = GtkHBox(spacing=3)
        vbox.pack_start(box, expand=FALSE)
        box.pack_start(GtkLabel('Font:'), expand=FALSE)
        self.label_font = GtkCombo()
        self.label_font.set_popdown_strings(font_list)
        self.label_font.entry.connect('changed', self.label_change_cb)
        box.pack_start(self.label_font, expand=FALSE)

        self.update_gui()

        self.show_all()
Exemplo n.º 16
0
    def __init__(self, layer):
        gtk.Window.__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 = gtk.VBox(spacing=10)
        self.pane2.set_border_width(10)
        self.notebook.append_page( self.pane2, gtk.Label('Draw Styles'))

        vbox = gtk.VBox(spacing=10)
        self.pane2.add(vbox)

        # Create Color control.
        box = gtk.HBox(spacing=3)
        vbox.pack_start(box, expand=False)
        box.pack_start(gtk.Label('Color:'),expand=False)
        self.point_color = \
                 pgucolorsel.ColorControl('Point Color',
                                          self.color_cb,'_point_color')
        box.pack_start(self.point_color)

        # Point size
        box = gtk.HBox(spacing=3)
        vbox.pack_start(box, expand=False)
        box.pack_start(gtk.Label('Point Size:'),expand=False)
        self.point_size = gtk.Combo()
        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 = gtk.HBox(spacing=3)
        vbox.pack_start(box, expand=False)
        box.pack_start(gtk.Label('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 = gtk.HBox(spacing=3)
        vbox.pack_start(box, expand=False)
        box.pack_start(gtk.Label('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()
Exemplo n.º 17
0
    def __init__(self):
        GtkWindow.__init__(self)
        self.set_title('Layers')
        self.set_usize(250, 500)
        self.set_border_width(3)
        self.set_policy(TRUE, TRUE, FALSE)
        self.connect('delete-event', self.close)
        shell = GtkVBox(spacing=3)
        self.add(shell)
        gvhtml.set_help_topic(self, "layerdlg.html")

        # View chooser menu
        hbox = GtkHBox(spacing=3)
        shell.pack_start(hbox, expand=FALSE)
        hbox.pack_start(GtkLabel('View:'), expand=FALSE, padding=3)
        viewopt = GtkOptionMenu()
        hbox.pack_start(viewopt)
        viewmenu = GtkMenu()
        viewopt.set_menu(viewmenu)

        # Do we want to include a thumbnail?  This is buggy on some platforms.
        if gview.get_preference('layer_thumbnail') is None \
           or gview.get_preference('layer_thumbnail') == 'off':
            self.thumbnail = FALSE
        else:
            self.thumbnail = TRUE

        self.updating = FALSE

        # Layer list
        layerbox = GtkScrolledWindow()
        shell.pack_start(layerbox)
        if self.thumbnail:
            layerlist = GtkCList(cols=3)
        else:
            layerlist = GtkCList(cols=2)

        layerbox.add_with_viewport(layerlist)
        layerlist.set_shadow_type(SHADOW_NONE)
        layerlist.set_selection_mode(SELECTION_SINGLE)
        layerlist.set_row_height(THUMB_H + 4)
        layerlist.set_column_width(0, EYE_W)
        if self.thumbnail:
            layerlist.set_column_width(1, THUMB_W + 4)
        layerlist.connect('select-row', self.layer_selected)
        layerlist.connect('button-press-event', self.list_clicked)

        # Option buttons
        opts = (('new.xpm', 'New layer', self.new_layer),
                ('raise.xpm', 'Raise layer', self.raise_layer),
                ('lower.xpm', 'Lower layer', self.lower_layer),
                ('delete.xpm', 'Delete layer', self.delete_layer))
        butbox = GtkHBox(spacing=1)
        shell.pack_start(butbox, expand=FALSE)
        for opt in opts:
            but = GtkButton()
            butbox.pack_start(but)
            but.add(
                GtkPixmap(self, os.path.join(gview.home_dir, 'pics', opt[0])))
            tooltips.set_tip(but, opt[1])
            but.connect('clicked', opt[2])

        self.connect('realize', self.realize)

        shell.show_all()
        self.viewopt = viewopt
        self.viewmenu = viewmenu
        self.layerlist = layerlist
        self.views = {}
        self.menuitems = {}
        self.selected_view = None

        self.eye_pixmap = \
            GtkPixmap(self,os.path.join(gview.home_dir,'pics','eye.xpm'))

        # Publish signals
        self.publish('active-view-changed')
        self.publish('deleted-layer')
Exemplo n.º 18
0
def SimpleFileSelect(ok_cb,
                     cb_data=None,
                     title=None,
                     default_filename=None,
                     cancel_cb=None,
                     help_topic=None):
    """Simplified File Selection

    This method launches a file selector, and calls the caller supplied
    OK callback when the user selects a file.  Creation, tailoring and
    cleanup of the GtkFileselection is managed internally.

    Arguments:

    ok_cb -- callback to call when user selects a file.  It should take
    a filename and cb_data argument.

    cb_data -- extra data to pass to ok, and cancel callbacks.  Defaults to
    None.

    title -- the title to use for the dialog.  Defaults to nothing.

    default_filename -- the initial filename to be shown in the file selector.
    Defaults to no file, and the current (or last accessed) directory.

    cancel_cb -- callback called when the user hits the cancel button or
    closes the file selection dialog.  If defaulted the caller isn't notified
    of cancels.  If supplied, the callback should take one argument which is
    the callback data.

    Example:

    The following code launches a simple file selector, and does an action
    in the callback.  The title, and default filename are set, but
        pgufilesel.SimpleFileSelect( self.save_vector_layer_with_file,
                                     cb_data = layer.get_parent(),
                                     title = 'Shapefile To Save to',
                                     default_filename = layer.get_name() )

    def save_vector_layer_with_file( self, filename, shapes_data ):
        shapes_data.save_to( filename )

    """

    global simple_file_sel

    if simple_file_sel is not None:
        simple_file_sel.destroy()

    simple_file_sel = _gtk.GtkFileSelection()
    simple_file_sel.hide_fileop_buttons()
    simple_file_sel.ok_button.connect('clicked', SFSOkCB, ok_cb, cb_data)
    simple_file_sel.cancel_button.connect('clicked', SFSCancelCB, cancel_cb,
                                          cb_data)
    simple_file_sel.connect('destroy', SFSDestroyCB, cancel_cb, cb_data)

    if title is not None:
        simple_file_sel.set_title(title)

    if default_filename is not None:
        simple_file_sel.set_filename(default_filename)
    else:
        if simple_file_sel_dir is not None:
            simple_file_sel.set_filename(simple_file_sel_dir)

    if help_topic is not None:
        import gvhtml
        gvhtml.set_help_topic(simple_file_sel, help_topic)

    simple_file_sel.show()