Esempio n. 1
0
        def src_load(_button, *args):
            fname = GtkExtra.file_sel_box(title="Select GDAL Dataset")
            if fname is None:
                return
            ds = gdal.OpenShared(fname)
            if ds is None:
                gvutils.error('Not a valid gdal dataset!')
                return

            dict = {}
            for i in range(1, ds.RasterCount + 1):
                curband = fname + '.band[' + str(i) + ']'
                dict[gtk.GtkListItem(curband)] = (ds, i, curband)

            if srctoggle.get_active() == gtk.TRUE:
                slist = vrtutils.GetSimilarFiles(fname)
                for nname in slist:
                    ds = gdal.OpenShared(nname)
                    if ds is None:
                        continue
                    for i in range(1, ds.RasterCount + 1):
                        curband = nname + '.band[' + str(i) + ']'
                        dict[gtk.GtkListItem(curband)] = (ds, i, curband)

            self.add_input_bands(dict)
Esempio n. 2
0
def get_list_of_bands_as_dict(size=None):
    """Returns dictionary of the bands of the opened layers. The key 
    of dictionary is the GtkListItem object produced from the name of
    layer+band number, members of dictionary are view-object (index = 0),
    layer-object (index = 1), band-number and name"""

    layer = gview.app.sel_manager.get_active_layer()
    if layer is None:
        return {}
    if size is None:
        size = get_raster_size(layer)
    dict = {}
    for curview in gview.app.view_manager.view_list:
        for curlayer in curview.viewarea.list_layers():
            curname = curlayer.get_name()
            cursize = get_raster_size(curlayer)
            if cursize == size:
                num_bands = curlayer.get_parent().get_dataset().RasterCount
                ds = curlayer.get_parent().get_dataset()
                for i in range(1, num_bands + 1):
                    curband = curname + '.band[' + str(i) + ']'
                    dict[gtk.GtkListItem(curband)] = (ds, i, curband)
    if dict is None:
        return None
    return dict
Esempio n. 3
0
 def set_head(self, typ, term):
     self.lb_rel.clear_items(0, -1)
     for e in self.dat:
         if (e[0].typ == typ) and e[0].name == term:
             for x in e[1]:
                 obj = gtk.GtkListItem(make_tv(x.typ, x.name))
                 obj.show()
                 self.lb_rel.append_items([obj])
             return
Esempio n. 4
0
 def recieve(self, obj):
     if str(obj.__class__) == 'jabber.Message':
         m = self._regexp.match(obj.getBody())
         if m:
             list_item = gtk.GtkListItem(m.group())
             self._list.add(list_item)
             list_item.show()
             return TRUE
     return FALSE
Esempio n. 5
0
	def __init__(self):
		gtk.GtkHBox.__init__(self, gtk.FALSE, 5)
		self.entry = gtk.GtkEntry()
		self.pack_start(self.entry)
		self.entry.show()
		self.button = gtk.GtkButton("...")
		self.button.connect("clicked", self.show_dialog)
		self.pack_start(self.button, expand=gtk.FALSE)
		self.button.show()

		self.dialog = gtk.GtkDialog()
		self.dialog.set_title(self.get_title())
		def delete_event(win, event):
			win.hide()
			return gtk.TRUE
		self.dialog.connect("delete_event", delete_event)

		box = gtk.GtkVBox()
		box.set_border_width(5)
		self.dialog.vbox.pack_start(box)
		box.show()

		swin = gtk.GtkScrolledWindow()
		swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		box.pack_start(swin)
		swin.show()
		
		items = map(None, self.get_list())
		list = gtk.GtkList()
		list.set_selection_mode(gtk.SELECTION_BROWSE)
		self.selected = self.get_default()
		self.entry.set_text(self.selected)
		items.sort()
		for s in items:
			item = gtk.GtkListItem(s)
			list.add(item)
			if s == self.selected:
				list.select_child(item)
			item.show()
		swin.add_with_viewport(list)
		list.show()

		b = gtk.GtkButton("OK")
		self.dialog.action_area.pack_start(b)
		b.set_flags(gtk.CAN_DEFAULT)
		b.grab_default()
		b.show()
		b.connect("clicked", self.selection_ok, list)

		b = gtk.GtkButton("Cancel")
		self.dialog.action_area.pack_start(b)
		b.set_flags(gtk.CAN_DEFAULT)
		b.show()
		b.connect("clicked", self.dialog.hide)

		self.dialog.set_usize(300, 225)
Esempio n. 6
0
    def reset_classification_list(self, *args):
        """Set the contents of class_list to the classification
        scheme in the classification object."""

        #clear existing UI side items.
        self.class_list.clear_items(0, -1)
        del self.color_buttons, self.ranges, self.labels
        self.color_buttons = []
        self.ranges = []
        self.labels = []

        cls = self.classification
        #prepare a default classification if one doesn't exist
        if cls.count == 0:
            cls.prepare_default(5)

        symbol = cls.get_symbol(0)
        #setup the column headers
        class_item = gtk.GtkListItem()
        set_widget_background(class_item, (1.0, 0.0, 0.0))
        class_box = gtk.GtkHBox()
        clr_frm = gtk.GtkFrame()
        clr_frm.add(gtk.GtkLabel('Color'))
        clr_frm.set_shadow_type(gtk.SHADOW_OUT)
        if symbol is not None:
            sym_frm = gtk.GtkFrame()
            sym_frm.add(gtk.GtkLabel('Symbol'))
            sym_frm.set_shadow_type(gtk.SHADOW_OUT)

            scale_frm = gtk.GtkFrame()
            scale_frm.add(gtk.GtkLabel('Scale'))
            scale_frm.set_shadow_type(gtk.SHADOW_OUT)
        else:
            sym_frm = None
            scale_frm = None
        rng_frm = gtk.GtkFrame()
        rng_frm.add(gtk.GtkLabel('Range'))
        rng_frm.set_shadow_type(gtk.SHADOW_OUT)
        lbl_frm = gtk.GtkFrame()
        lbl_frm.add(gtk.GtkLabel('Label'))
        lbl_frm.set_shadow_type(gtk.SHADOW_OUT)
        self.add_classification_item(clr_frm, sym_frm, scale_frm, rng_frm,
                                     lbl_frm, gtk.FALSE)

        #for each class, create an entry in the list
        for n in range(cls.count):
            self.insert_class(n)

        self.class_list.show_all()

        if self.ramp is not None:
            self.apply_ramp(self.ramp)
Esempio n. 7
0
 def lookup(self, typ, term):  # takes typ for uniformity only, ignores
     if term == '':
         return
     self.textentry.set_text(term)
     self.lb_head.clear_items(0, -1)
     self.lb_rel.clear_items(0, -1)
     self.dat = self.zthes.lookup(term)
     toplist = [t[0] for t in self.dat]
     for e in toplist:
         obj = gtk.GtkListItem(make_tv(e.typ, e.name))
         obj.show()
         self.lb_head.append_items([obj])
     if len(self.dat) > 0:
         self.lb_head.select_item(0)
Esempio n. 8
0
        def dest_add(_button, *args):
            sel = source_list.get_selection()
            sel.reverse()  # add in order of selection
            if len(self.output_bands.keys()) == 0:
                refreshflag = 1
            else:
                refreshflag = 0

            for i in sel:
                list_item = gtk.GtkListItem(self.input_bands[i][2])
                self.dest_list.append_items([list_item])
                list_item.show()
                self.dest_list.select_child(self.dest_list.children()[-1])
                self.output_bands[list_item] = self.input_bands[i]

            if (refreshflag == 1) and (len(sel) > 0):
                self.notify('output-bands-notempty')
Esempio n. 9
0
    def __init__(self, master, jabberObj):
        gtk.GtkDialog.__init__(self)

        self.agents = jabberObj.requestAgents()

        self.done = None
        self.connect("delete_event", self.delete_event)
        self.master = master
        self.set_usize(200, 150)

        if self.master:
            self.set_transient_for(self.master)

        self.ok_button = gtk.GtkButton('Ok')
        self.ok_button.connect('clicked', self.okay)
        self.action_area.pack_start(self.ok_button, expand=gtk.FALSE)
        self.cancel_button = gtk.GtkButton('Cancel')
        self.cancel_button.connect('clicked', self.cancel)
        self.action_area.pack_start(self.cancel_button, expand=gtk.FALSE)

        self.scrolled_win = gtk.GtkScrolledWindow()
        self.scrolled_win.set_policy(gtk.POLICY_AUTOMATIC,
                                     gtk.POLICY_AUTOMATIC)
        self.vbox.pack_start(self.scrolled_win)

        self.list = gtk.GtkList()
        self.list.set_selection_mode(gtk.SELECTION_BROWSE)
        self.scrolled_win.add_with_viewport(self.list)

        for i in self.agents.keys():
            if self.agents[i].has_key('transport'):
                list_item = gtk.GtkListItem(self.agents[i]['name'])
                list_item.set_data('jid', i)
                self.list.add(list_item)
                list_item.show()

        self.list.connect("select-child", self.selectCB)

        self.vbox.pack_start(self.scrolled_win)
        self.vbox.show_all()
        self.action_area.show_all()
        self.show()
        self.selected = None
        self.set_modal(gtk.TRUE)
Esempio n. 10
0
 def add_classification_item(self,
                             clr,
                             sym,
                             scl,
                             rng,
                             lbl,
                             delete_button=gtk.TRUE):
     """add a single row to the classification list.  Optionally add a delete 
     button that will delete that row from the classification.
     """
     class_item = gtk.GtkListItem()
     class_box = gtk.GtkHBox()
     #explicitly size the first 5, let the last one fill the rest of the
     #space.
     clr.set_usize(70, -1)
     if sym is not None:
         sym.set_usize(70, -1)
     if scl is not None:
         scl.set_usize(70, -1)
     rng.set_usize(130, -1)
     lbl.set_usize(130, -1)
     class_box.pack_start(clr, expand=gtk.FALSE, fill=gtk.FALSE)
     if sym is not None:
         class_box.pack_start(sym, expand=gtk.FALSE, fill=gtk.FALSE)
     if scl is not None:
         class_box.pack_start(scl, expand=gtk.FALSE, fill=gtk.FALSE)
     class_box.pack_start(rng, expand=gtk.FALSE, fill=gtk.FALSE)
     class_box.pack_start(lbl, expand=gtk.FALSE, fill=gtk.FALSE)
     if delete_button:
         del_btn = gtk.GtkButton('x')
         del_btn.set_usize(45, -1)
         del_btn.connect('clicked', self.delete_item, class_item)
         class_box.pack_start(del_btn, expand=gtk.FALSE, fill=gtk.FALSE)
     class_box.add(gtk.GtkLabel(''))
     class_item.add(class_box)
     class_item.show()
     self.class_list.add(class_item)
Esempio n. 11
0
    def __init__(self):
        # Create a window to put all the widgets in
        # connect main_quit() to the "destroy" event of
        # the window to handle window manager close-window-events
        window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL)
        window.set_title("GtkList Example")
        window.connect("destroy", gtk.mainquit)

        # Inside the window we need a box to arrange the widgets
        # vertically
        vbox = gtk.GtkVBox(gtk.FALSE, 5)
        vbox.set_border_width(5)
        window.add(vbox)
        vbox.show()

        # This is the scrolled window to put the List widget inside
        scrolled_window = gtk.GtkScrolledWindow()
        scrolled_window.set_usize(250, 150)
        vbox.add(scrolled_window)
        scrolled_window.show()

        # Create the GtkList widget.
        # Connect the sigh_print_selection() signal handler
        # function to the "selection_changed" signal of the List
        # to print out the selected items each time the selection
        # has changed
        gtklist = gtk.GtkList()
        scrolled_window.add_with_viewport(gtklist)
        gtklist.show()
        gtklist.connect("selection_changed", self.sigh_print_selection)

        # We create a "Prison" to put a list item in )
        frame = gtk.GtkFrame("Prison")
        frame.set_usize(200, 50)
        frame.set_border_width(5)
        frame.set_shadow_type(gtk.SHADOW_OUT)
        vbox.add(frame)
        frame.show()

        # Connect the sigh_button_event() signal handler to the List
        # which will handle the "arresting" of list items
        gtklist.connect("button_release_event", self.sigh_button_event, frame)

        # Create a separator
        separator = gtk.GtkHSeparator()
        vbox.add(separator)
        separator.show()

        # Finally create a button and connect its "clicked" signal
        # to the destruction of the window
        button = gtk.GtkButton("Close")
        vbox.add(button)
        button.show()
        button.connect_object("clicked", window.destroy, window)

        # Now we create 5 list items, each having its own
        # label and add them to the List using add()
        # Also we query the text string from the label and
        # associate it with the list_item_data_key for each list item

        for i in range(5):
            buffer = "ListItemContainer with Label #%d" % i
            label = gtk.GtkLabel(buffer)
            list_item = gtk.GtkListItem()
            list_item.add(label)
            label.show()
            gtklist.add(list_item)
            list_item.show()
            string = label.get()
            list_item.set_data(self.list_item_data_key, string)

        # Here, we are creating another 5 labels, this time
        # we use GtkListItem() for the creation
        # For adding of the list items we put them all into a
        # list, and then add them by a single call to
        # append_items().

        dlist = []
        for i in range(5, 10):
            buffer = "List Item with Label %d" % i
            list_item = gtk.GtkListItem(buffer)
            dlist.append(list_item)
            list_item.show()
            list_item.set_data(self.list_item_data_key,
                               list_item.children()[0].get())

        gtklist.append_items(dlist)

        # Finally we want to see the window, don't we? )
        window.show()