예제 #1
0
    def init_create_gui_panel(self):

        # Basic Buttons...
        self.button_dict['Analyze'] = gtk.GtkButton('Analyze')
        self.show_list.append(self.button_dict['Analyze'])

        self.button_dict['Activate'] = gtk.GtkCheckButton('Activate')
        self.show_list.append(self.button_dict['Activate'])

        self.button_dict['Auto Update'] = gtk.GtkCheckButton('Auto Update')
        self.show_list.append(self.button_dict['Auto Update'])

        self.button_dict['Set Tool'] = gtk.GtkButton('Set Tool')
        self.show_list.append(self.button_dict['Set Tool'])

        # Basic Frames...

        # first frame
        self.frame_dict['base_frame1'] = gtk.GtkFrame()
        self.show_list.append(self.frame_dict['base_frame1'])

        hbox1 = gtk.GtkHBox(gtk.TRUE,5)
        self.show_list.append(hbox1)
        hbox1.pack_end(self.button_dict['Analyze'],gtk.TRUE,gtk.TRUE,0)
        self.frame_dict['base_frame1'].add(hbox1)

        # second frame- will contain roi or poi info
        self.frame_dict['base_frame2'] = gtk.GtkFrame()
        self.show_list.append(self.frame_dict['base_frame2'])

        # third frame
        self.frame_dict['base_frame3'] = gtk.GtkFrame();
        self.show_list.append(self.frame_dict['base_frame3'])

        hbox3 = gtk.GtkHBox(gtk.TRUE,5)
        self.show_list.append(hbox3)
        hbox3.pack_start(self.button_dict['Activate'],gtk.TRUE,gtk.TRUE,0)
        hbox3.pack_start(self.button_dict['Auto Update'],gtk.TRUE,gtk.TRUE,0)
        hbox3.pack_start(self.button_dict['Set Tool'],gtk.TRUE,gtk.TRUE,0)
        self.frame_dict['base_frame3'].add(hbox3)

        # Top level panel...
        self.main_panel = gtk.GtkVBox(gtk.FALSE,5)
        self.main_panel.pack_start(self.frame_dict['base_frame1'],gtk.FALSE,gtk.FALSE,0)
        self.main_panel.pack_start(self.frame_dict['base_frame2'],gtk.FALSE,gtk.FALSE,0)
        self.main_panel.pack_end(self.frame_dict['base_frame3'],gtk.FALSE,gtk.FALSE,0)
        self.add(self.main_panel)
        self.show_list.append(self.main_panel)
예제 #2
0
    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()
예제 #3
0
    def __init__(self, master):

        gtk.GtkWindow.__init__(self)

        self.password = ''
        self.username = ''
        self.server = 'jabber.org'
        self.done = None

        self.connect("delete_event", self.delete_event)
        self.master = master

        self.vbox = gtk.GtkVBox(gtk.FALSE, 5)
        self.add(self.vbox)

        self.frame_s = gtk.GtkFrame("Server to use")
        self.table_s = gtk.GtkTable(1, 6, gtk.FALSE)
        self.server_lbl = gtk.GtkLabel('Server')
        self.server_lbl.set_alignment(1, 0.5)
        self.server_entry = gtk.GtkEntry()

        self.table_s.attach(self.server_lbl,
                            0,
                            2,
                            0,
                            1,
                            xpadding=3,
                            ypadding=2)
        self.table_s.attach(self.server_entry,
                            2,
                            6,
                            0,
                            1,
                            xpadding=3,
                            ypadding=2)
        self.frame_s.add(self.table_s)
        self.vbox.pack_start(self.frame_s)

        self.frame = gtk.GtkFrame("Have Account?")
        self.table = gtk.GtkTable(6, 6, gtk.FALSE)
        self.username_lbl = gtk.GtkLabel('Username')
        self.username_lbl.set_alignment(1, 0.5)
        self.password_lbl = gtk.GtkLabel('Password')
        self.password_lbl.set_alignment(1, 0.5)

        self.username_entry = gtk.GtkEntry()

        self.password_entry = gtk.GtkEntry()
        self.password_entry.set_visibility(gtk.FALSE)

        self.table.attach(self.username_lbl,
                          0,
                          2,
                          1,
                          2,
                          xpadding=3,
                          ypadding=2)
        self.table.attach(self.password_lbl,
                          0,
                          2,
                          2,
                          3,
                          xpadding=3,
                          ypadding=2)
        self.table.attach(self.username_entry,
                          2,
                          6,
                          1,
                          2,
                          xpadding=3,
                          ypadding=2)
        self.table.attach(self.password_entry,
                          2,
                          6,
                          2,
                          3,
                          xpadding=3,
                          ypadding=2)

        self.save_check = gtk.GtkCheckButton('Save Details')
        self.table.attach(self.save_check, 3, 6, 4, 5, xpadding=3, ypadding=2)

        self.login_button = gtk.GtkButton('Login')
        self.login_button.connect('clicked', self.login)
        self.table.attach(self.login_button, 3, 6, 5, 6, xpadding=5)
        self.frame.add(self.table)

        self.vbox.pack_start(self.frame)

        self.frame_acc = gtk.GtkFrame("New User?")
        self.table_acc = gtk.GtkTable(1, 1, gtk.FALSE)
        self.button_acc = gtk.GtkButton("Get an Account")
        self.button_acc.connect('clicked', self.new_account)
        self.table_acc.attach(self.button_acc,
                              0,
                              1,
                              0,
                              1,
                              xpadding=5,
                              ypadding=5)

        self.frame_acc.add(self.table_acc)
        self.vbox.pack_end(self.frame_acc)

        self.readRC()
        self.username_entry.set_text(self.username)
        self.password_entry.set_text(self.password)
        self.server_entry.set_text(self.server)

        self.vbox.show_all()
        self.show()
        self.set_modal(gtk.TRUE)
예제 #4
0
파일: compose.py 프로젝트: lmarabi/tareeg
    def __init__(self, parent, tips):
        self.frame = gtk.GtkFrame('Raster Bands')
        self.tips = tips
        self.input_bands = get_list_of_bands_as_dict()
        self.output_bands = {}

        hbox1 = gtk.GtkHBox(spacing=spc)
        hbox1.set_border_width(spc)
        self.frame.add(hbox1)

        # source (input)
        srcvbox = gtk.GtkVBox(spacing=spc)
        label = gtk.GtkLabel('Input:')
        label.set_alignment(0, 0.5)
        srcvbox.pack_start(label, expand=gtk.FALSE)
        hbox1.pack_start(srcvbox)
        source_win = gtk.GtkScrolledWindow()
        source_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        source_win.set_usize(300, 200)
        srcvbox.pack_start(source_win)

        source_list = gtk.GtkList()
        source_list.set_selection_mode(gtk.SELECTION_MULTIPLE)
        source_win.add_with_viewport(source_list)
        source_list.append_items(self.input_bands.keys())

        # signals sent up to top level so that defaults can
        # be updated.  Defaults are updated whenever the output
        # bands are cleared, or the first one is specified.
        self.publish('output-bands-empty')
        self.publish('output-bands-notempty')

        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)

        def src_get_active_layers(_button, *args):
            size = None
            if len(self.input_bands) > 0:
                ckey = self.input_bands.keys()[0]
                size = (self.input_bands[ckey][0].RasterXSize,
                        self.input_bands[ckey][0].RasterYSize)
            new_dict = get_list_of_bands_as_dict(size)
            self.add_input_bands(new_dict)

        def src_clear(_button, *args):
            self.clear_input_bands()

        self.source_list = source_list

        # source control buttons
        srcbbox = gtk.GtkHBox(spacing=spc)
        srcvbox.pack_start(srcbbox, expand=gtk.FALSE)
        load_btn = gtk.GtkButton("Load File")
        self.tips.set_tip(load_btn, 'Add bands from a file to the input list')
        srcbbox.pack_start(load_btn)
        load_btn.connect("clicked", src_load)
        act_btn = gtk.GtkButton("Views->List")
        self.tips.set_tip(act_btn, 'Add bands from views to the input list')
        srcbbox.pack_start(act_btn)
        act_btn.connect("clicked", src_get_active_layers)
        clear_btn = gtk.GtkButton("Clear")
        srcbbox.pack_start(clear_btn)
        clear_btn.connect("clicked", src_clear)

        srctoggle = gtk.GtkCheckButton("Include Similar")
        self.tips.set_tip(
            srctoggle, 'Include bands from same-size files ' +
            'in the same directory when using Load File.')
        srcbbox.pack_start(srctoggle, expand=gtk.FALSE)
        srctoggle.set_active(gtk.TRUE)

        # destination
        btn_box = gtk.GtkVBox(spacing=10)
        btn_box.set_border_width(10)
        hbox1.pack_start(btn_box, expand=gtk.FALSE)
        btn_box.show()

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

        def dest_del(_button, *args):
            selection = self.dest_list.get_selection()
            self.dest_list.remove_items(selection)
            for i in selection:
                del self.output_bands[i]
                i.destroy()
            rest = self.dest_list.children()
            if len(rest) > 0:
                self.dest_list.select_child(self.dest_list.children()[-1])
            else:
                self.notify('output-bands-empty')

        def dest_raise(_button, *args):
            selection = self.dest_list.get_selection()
            if len(selection) != 1:
                return
            pos = self.dest_list.child_position(selection[0])
            if pos < 1:
                return
            self.dest_list.remove_items(selection)
            self.dest_list.insert_items(selection, pos - 1)
            self.dest_list.select_item(pos - 1)

        def dest_lower(_button, *args):
            selection = self.dest_list.get_selection()
            if len(selection) != 1:
                return
            pos = self.dest_list.child_position(selection[0])
            if pos > len(self.output_bands) - 2:
                return
            self.dest_list.remove_items(selection)
            self.dest_list.insert_items(selection, pos + 1)
            self.dest_list.select_item(pos + 1)

        add_btn = gtk.GtkButton("Add->")
        add_btn.connect("clicked", dest_add)
        # The label below just makes things align more nicely (adds space)
        btn_box.pack_start(gtk.GtkLabel(''), expand=gtk.FALSE)
        btn_box.pack_start(add_btn, expand=gtk.FALSE)

        destvbox = gtk.GtkVBox(spacing=spc)
        label = gtk.GtkLabel('Output:')
        label.set_alignment(0, 0.5)
        destvbox.pack_start(label, expand=gtk.FALSE)
        dest_win = gtk.GtkScrolledWindow()
        dest_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        dest_win.set_usize(300, 200)
        destvbox.pack_start(dest_win)

        hbox1.pack_start(destvbox)
        destbbox = gtk.GtkHBox(spacing=spc)
        destvbox.pack_start(destbbox, expand=gtk.FALSE)
        del_btn = gtk.GtkButton()
        del_btn.add(
            gtk.GtkPixmap(parent,
                          os.path.join(gview.home_dir, 'pics', 'delete.xpm')))
        del_btn.connect("clicked", dest_del)
        destbbox.pack_start(del_btn, expand=gtk.FALSE)
        r_btn = gtk.GtkButton()
        r_btn.add(
            gtk.GtkPixmap(parent,
                          os.path.join(gview.home_dir, 'pics', 'raise.xpm')))
        r_btn.connect("clicked", dest_raise)
        destbbox.pack_start(r_btn, expand=gtk.FALSE)
        l_btn = gtk.GtkButton()
        l_btn.add(
            gtk.GtkPixmap(parent,
                          os.path.join(gview.home_dir, 'pics', 'lower.xpm')))
        l_btn.connect("clicked", dest_lower)
        destbbox.pack_start(l_btn, expand=gtk.FALSE)

        self.dest_list = gtk.GtkList()
        self.dest_list.set_selection_mode(gtk.SELECTION_BROWSE)
        dest_win.add_with_viewport(self.dest_list)

        parent.shell.pack_start(self.frame)
예제 #5
0
파일: compose.py 프로젝트: lmarabi/tareeg
    def __init__(self, app=None):
        gtk.GtkWindow.__init__(self)
        self.set_title('Compose Dataset')
        self.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE)
        self.set_border_width(10)
        self.shell = gtk.GtkVBox(spacing=spc)
        self.add(self.shell)
        self.tips = gtk.GtkTooltips()
        self.input_frame = InputFrame(self, self.tips)
        self.show_list = []
        self.adv_show_list = []
        self.show_list.append(self.input_frame)
        self.app = app

        self.button_dict = {}
        self.button_dict['Mode'] = gtk.GtkCheckButton('Advanced Options')
        self.shell.pack_start(self.button_dict['Mode'])
        self.show_list.append(self.button_dict['Mode'])

        self.adv_notebook = gtk.GtkNotebook()
        self.shell.pack_start(self.adv_notebook)
        self.adv_show_list.append(self.adv_notebook)
        self.geo_frame = GeocodingFrame(self.tips)
        self.adv_notebook.append_page(self.geo_frame,
                                      gtk.GtkLabel('Geocoding'))

        echbox = gtk.GtkHBox(spacing=5, homogeneous=gtk.FALSE)
        echbox.set_border_width(3)
        self.shell.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.button_dict['Save'] = gtk.GtkButton('Save VRT')
        echbox.pack_end(self.button_dict['Save'], expand=gtk.TRUE)
        self.button_dict['New'] = gtk.GtkButton('New View')
        echbox.pack_end(self.button_dict['New'], expand=gtk.TRUE)
        self.button_dict['Current'] = gtk.GtkButton('Current View')
        echbox.pack_end(self.button_dict['Current'], expand=gtk.TRUE)

        self.tips.set_tip(self.button_dict['Close'],
                          'Exit the Compose Dataset tool')
        self.tips.set_tip(self.button_dict['Save'],
                          'Create dataset and save to a VRT format file')
        self.tips.set_tip(self.button_dict['New'],
                          'Create dataset and display in a new view')
        self.tips.set_tip(self.button_dict['Current'],
                          'Create dataset and display in current view')

        for item in self.show_list:
            item.show_all()
            item.show()

        # geocode frame hides some of its contents
        self.geo_frame.show()

        self.button_dict['Save'].connect('clicked', self.create_cb, 'Save')
        self.button_dict['New'].connect('clicked', self.create_cb, 'New')
        self.button_dict['Current'].connect('clicked', self.create_cb,
                                            'Current')
        self.button_dict['Close'].connect('clicked', self.close)
        self.button_dict['Mode'].connect('toggled', self.mode_toggled_cb)

        self.input_frame.subscribe('output-bands-empty', self.clear_defaults)
        self.input_frame.subscribe('output-bands-notempty',
                                   self.update_defaults)

        self.button_dict['Mode'].set_active(0)
        self.mode_toggled_cb()
        self.shell.show()
예제 #6
0
def prefs_window():
    win = gtk.GtkWindow()
    gui["prefs_window"] = win
    win.set_policy(gtk.TRUE, gtk.TRUE, gtk.FALSE)
    win.set_title("Preferences")
    win.connect("delete_event", prefs_window_close)
    win.set_border_width(2)

    window_pos_mode(win)

    frame = gtk.GtkFrame()
    frame.show()
    frame.set_border_width(2)
    win.add(frame)

    vbox = gtk.GtkVBox(spacing=5)
    vbox.show()
    frame.add(vbox)

    gui["cb_ascii"] = gtk.GtkCheckButton("ASCII only")
    vbox.pack_start(gui["cb_ascii"])
    gui["cb_ascii"].connect("toggled", prefs_toggled, 0)
    gui["cb_ascii"].show()

    gui["cb_rexp"] = gtk.GtkCheckButton("Remember last expression")
    vbox.pack_start(gui["cb_rexp"])
    gui["cb_rexp"].connect("toggled", prefs_toggled, 1)
    gui["cb_rexp"].show()

    hbox = gtk.GtkHBox()
    vbox.pack_start(hbox)
    hbox.show()

    label = gtk.GtkLabel(" Window placement: ")
    label.show()
    hbox.pack_start(label)

    menu = gtk.GtkMenu()

    menuitem = gtk.GtkMenuItem("None")
    menuitem.connect("activate", prefs_selected_1, 0)
    menu.append(menuitem)
    menuitem.show()
    menuitem = gtk.GtkMenuItem("Center")
    menuitem.connect("activate", prefs_selected_1, 1)
    menu.append(menuitem)
    menuitem.show()
    menuitem = gtk.GtkMenuItem("Mouse")
    menuitem.connect("activate", prefs_selected_1, 2)
    menu.append(menuitem)
    menuitem.show()

    gui["wp_menu"] = gtk.GtkOptionMenu()
    gui["wp_menu"].set_menu(menu)

    gui["wp_menu"].set_history(
        hive.get_integer("/window/placement", default_window_placement))

    hbox.pack_start(gui["wp_menu"])
    gui["wp_menu"].show()

    hbox = gtk.GtkHBox()
    vbox.pack_start(hbox)
    hbox.show()

    label = gtk.GtkLabel(" Binary separators: ")
    label.show()
    hbox.pack_start(label)

    menu = gtk.GtkMenu()

    menuitem = gtk.GtkMenuItem("0")
    menuitem.connect("activate", prefs_selected_2, 0)
    menu.append(menuitem)
    menuitem.show()
    menuitem = gtk.GtkMenuItem("1")
    menuitem.connect("activate", prefs_selected_2, 1)
    menu.append(menuitem)
    menuitem.show()
    menuitem = gtk.GtkMenuItem("3")
    menuitem.connect("activate", prefs_selected_2, 2)
    menu.append(menuitem)
    menuitem.show()
    menuitem = gtk.GtkMenuItem("7")
    menuitem.connect("activate", prefs_selected_2, 3)
    menu.append(menuitem)
    menuitem.show()

    gui["bs_menu"] = gtk.GtkOptionMenu()
    gui["bs_menu"].set_menu(menu)
    gui["bs_menu"].set_history(
        hive.get_integer("/binary_separators", default_binary_separators))

    hbox.pack_start(gui["bs_menu"])
    gui["bs_menu"].show()

    if hive.get_bool("/ascii_only", default_ascii_only):
        gui["cb_ascii"].set_active(gtk.TRUE)
    else:
        gui["cb_ascii"].set_active(gtk.FALSE)

    if hive.get_bool("/remember_expression", default_remember_expression):
        gui["cb_rexp"].set_active(gtk.TRUE)
    else:
        gui["cb_rexp"].set_active(gtk.FALSE)

    button = gtk.GtkButton("Close")
    button.connect("clicked", prefs_window_close)
    vbox.pack_start(button, expand=gtk.FALSE)
    button.set_flags(gtk.CAN_DEFAULT)
    button.grab_default()
    button.show()

    gui["main_window"].set_sensitive(gtk.FALSE)
    gui["prefs_window"].show()
예제 #7
0
파일: fusion.py 프로젝트: gfwei/code
        def createGUI(self):
            mainbox = gtk.GtkVBox(spacing=5)
            mainbox.set_border_width(5)
            self.add(mainbox)

            # RGB source
            frame = gtk.GtkFrame("Setup")
            mainbox.add(frame, expand=FALSE)

            vbox = gtk.GtkVBox(spacing=5)
            vbox.set_border_width(5)
            frame.add(vbox)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('RGB:'), expand=FALSE)
            self.rgbCB = gtk.GtkCombo()
            self.rgbCB.set_popdown_strings(self.rgbDict.keys())
            box.add(self.rgbCB)

            # Pan source
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Pan:'), expand=FALSE)

            self.panCB = gtk.GtkCombo()
            self.panCB.set_popdown_strings(self.panDict.keys())
            box.add(self.panCB)

            # output
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Format:'), expand=FALSE)
            self.formatCB = gtk.GtkCombo()
            wDrvs = filter(lambda drv: 'DCAP_CREATE' in drv.GetMetadata(),
                           gdal.GetDriverList())
            drivers = map(lambda d: d.ShortName, wDrvs)
            drivers.sort()
            self.formatCB.set_popdown_strings(drivers)
            self.formatCB.entry.set_text('GTiff')
            self.tips.set_tip(self.formatCB.entry,
                              'Output formats. Some may not work.')
            box.add(self.formatCB, expand=FALSE)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Output file:'), expand=FALSE)
            self.outTE = gtk.GtkEntry()
            box.add(self.outTE)

            # warp options
            box = gtk.GtkHBox(spacing=5)
            box.set_border_width(5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Resampling'), expand=FALSE)
            self.algCB = gtk.GtkCombo()
            self.tips.set_tip(
                self.algCB.entry,
                'Resampling algorithm. Cubic Spline is recommended for best results'
            )
            box.add(self.algCB, expand=FALSE)
            self.algCB.set_popdown_strings(
                ['Nearest Neighbor', 'Bilinear', 'Cubic', 'Cubic Spline'])

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Create options:'), expand=FALSE)
            self.coptTE = gtk.GtkEntry()
            self.coptTE.set_text('tiled=yes')
            box.add(self.coptTE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('Pixel: '), expand=FALSE)
            self.xoffTE = gtk.GtkEntry()
            self.xoffTE.set_usize(50, -1)
            box.add(self.xoffTE, expand=FALSE)

            box.add(gtk.GtkLabel('Line:'), expand=FALSE)
            self.yoffTE = gtk.GtkEntry()
            self.yoffTE.set_usize(50, -1)
            box.add(self.yoffTE, expand=FALSE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('Width: '), expand=FALSE)
            self.widthTE = gtk.GtkEntry()
            self.widthTE.set_usize(50, -1)
            box.add(self.widthTE, expand=FALSE)

            box.add(gtk.GtkLabel('Height:'), expand=FALSE)
            self.heightTE = gtk.GtkEntry()
            self.heightTE.set_usize(50, -1)
            box.add(self.heightTE, expand=FALSE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('X offset: '), expand=FALSE)
            self.panXoffTE = gtk.GtkEntry()
            self.panXoffTE.set_usize(50, -1)
            self.panXoffTE.set_text('0')
            self.tips.set_tip(self.panXoffTE, 'Pan X offset')
            box.add(self.panXoffTE, expand=FALSE)

            box.add(gtk.GtkLabel('Y offset:'), expand=FALSE)
            self.panYoffTE = gtk.GtkEntry()
            self.panYoffTE.set_usize(50, -1)
            self.panYoffTE.set_text('0')
            self.tips.set_tip(self.panYoffTE, 'Pan Y offset')
            box.add(self.panYoffTE, expand=FALSE)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            self.swapTO = gtk.GtkCheckButton(label='Swap R-B')
            self.tips.set_tip(self.swapTO,
                              'Swap Red and Blue bands. Used for Quickbird.')
            box.add(self.swapTO)

            box.add(gtk.GtkLabel('Datatype:'), expand=FALSE)
            self.sat0RB = gtk.GtkRadioButton(label='Byte')
            box.add(self.sat0RB)
            self.sat1RB = gtk.GtkRadioButton(label='UInt16', group=self.sat0RB)
            box.add(self.sat1RB)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            box.add(gtk.GtkLabel('Resize:'), expand=FALSE)
            self.reszFn0CB = gtk.GtkRadioButton(label='Gdalwarp')
            box.add(self.reszFn0CB)
            self.reszFn1CB = gtk.GtkRadioButton(label='gdal.py',
                                                group=self.reszFn0CB)
            box.add(self.reszFn1CB)

            # Params
            frame = gtk.GtkFrame('Fusion Method')
            mainbox.add(frame, expand=FALSE)
            vbox = gtk.GtkVBox(spacing=3)
            vbox.set_border_width(5)
            frame.add(vbox)
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            self.met0RB = gtk.GtkRadioButton(label='IHS')
            tipTxt = 'Standard Intensity-Hue-Saturation merging. '
            tipTxt += 'Sharpness setting has no effect. '
            self.tips.set_tip(self.met0RB, tipTxt)
            box.add(self.met0RB)

            self.met1RB = gtk.GtkRadioButton(label='Kernel', group=self.met0RB)
            tipTxt = 'Pan is run through a convolution kernel and added to RGB. '
            tipTxt += 'Recommended sharpness: 0.15-0.25 for Ikonos and Quickbird, '
            tipTxt += '0.3-0.5 for Landsat and SPOT. '
            tipTxt += 'Can be set higher if imagery is enhanced.'
            self.tips.set_tip(self.met1RB, tipTxt)
            box.add(self.met1RB)

            # params
            vbox2 = gtk.GtkVBox(spacing=5)
            vbox2.set_border_width(5)
            vbox.add(vbox2)

            box = gtk.GtkHBox(spacing=5)
            vbox2.add(box)
            box.add(gtk.GtkLabel('Sharpness:'), expand=FALSE)
            self.adjSharp = gtk.GtkAdjustment(0.15, 0.0, 1.0, 0.01, 0.1)
            slider = gtk.GtkHScale(self.adjSharp)
            slider.set_digits(2)
            box.add(slider)

            # Buttons
            box = gtk.GtkHBox(homogeneous=1, spacing=5)
            mainbox.add(box, expand=FALSE)

            mergeBT = gtk.GtkButton("Merge")
            mergeBT.connect("clicked", self.compute, 'merge')
            self.tips.set_tip(mergeBT, 'Proceed with merging')
            box.add(mergeBT)

            pviewBT = gtk.GtkButton("Preview")
            pviewBT.connect("clicked", self.compute, 'pview')
            self.tips.set_tip(pviewBT, 'Preview merging')
            box.add(pviewBT)

            closeBT = gtk.GtkButton("Close")
            closeBT.connect("clicked", self.close)
            box.add(closeBT)

            # do the connects last so events are not fired during init
            self.panCB.entry.connect('changed', self.panChanged)
            self.rgbCB.entry.connect('changed', self.rgbChanged)
            self.formatCB.entry.connect('changed', self.formatChanged)
            return TRUE
예제 #8
0
    def init_dialog(self):
        self.dialog = gtk.GtkWindow()
        self.dialog.set_title('Tabular Shapes Attribute Grid Demo')
        self.dialog.set_default_size(300, 400)
        self.dialog.set_policy(gtk.FALSE, gtk.TRUE, gtk.TRUE)

        shell = gtk.GtkVBox(spacing=5)
        shell.set_border_width(10)
        self.dialog.add(shell)

        self.pgugrid = pgugrid.pguGrid(config=(3, 2, 0, 2, 4, 2, 0, 0, 0))

        shell.pack_start(self.pgugrid, expand=gtk.TRUE)

        hbox = gtk.GtkHBox(spacing=5)
        shell.pack_start(hbox)
        self.column_button = gtk.GtkCheckButton("Schema properties only")
        self.column_button.connect("toggled", self.refresh_columns)
        self.column_button.set_active(gtk.TRUE)
        hbox.pack_start(self.column_button)

        rbutton = gtk.GtkButton("Refresh columns")
        rbutton.connect("clicked", self.refresh_columns)
        hbox.pack_start(rbutton, expand=gtk.FALSE)

        button = gtk.GtkButton("close")
        button.connect("clicked", self.close)
        shell.pack_start(button, expand=gtk.FALSE)
        button.show()

        shell.show_all()

        # Trap window close event
        self.dialog.connect('delete-event', self.close)

        self.app.sel_manager.subscribe('active-layer-changed',
                                       self.layer_update)

        self.pgugrid.subscribe("clicked", self.clicked_cb)
        self.pgugrid.connect("button-release-event", self.clicked_nocolumns_cb)
        #self.pgugrid.subscribe("cell-selection-changed",self.cell_cb)
        #self.pgugrid.subscribe("cell-changed",self.cellch_cb)
        #self.pgugrid.subscribe("row-selection-changed",self.row_cb)
        #self.pgugrid.subscribe("column-selection-changed",self.column_cb)

        # Popup menus:
        itemlist = [  #('Configuration',None,None),
            ('Set subset/Selected', self.set_subset_selected_cb, None),
            ('Set subset/Unseleted', self.set_subset_unselected_cb, None),
            ('Set subset/All', self.set_subset_all_cb, None),
            ('New layer/Selected', self.new_layer_selected_cb, None),
            ('New layer/Unselected', self.new_layer_unselected_cb, None),
            ('Edit Schema', self.edit_schema, None),
            #('Query',None,None),
            #('Save',None,None),
            #('Help',None,None)
        ]

        self.cell_popup_menu = []
        self.cell_popup_menu.append(gtk.GtkMenu())
        for label, func, args in itemlist:
            menu_item = gtk.GtkMenuItem(label)
            if func is not None:
                menu_item.connect("activate", func, args)
            self.cell_popup_menu[0].append(menu_item)

        self.cell_popup_menu[0].show_all()

        itemlist2 = [  #('Configuration',None,None),
            ('Set subset/Selected', self.set_subset_selected_cb, None),
            ('Set subset/Unseleted', self.set_subset_unselected_cb, None),
            ('Set subset/All', self.set_subset_all_cb, None),
            ('New layer/Selected', self.new_layer_selected_cb, None),
            ('New layer/Unselected', self.new_layer_unselected_cb, None),
            ('Edit Schema', self.edit_schema, None),
            ('Add property', self.add_property_column, None),
            #('Query',None,None),
            #('Save',None,None),
            #('Help',None,None)
        ]

        self.cell_popup_menu.append(gtk.GtkMenu())
        for label, func, args in itemlist2:
            menu_item = gtk.GtkMenuItem(label)
            if func is not None:
                menu_item.connect("activate", func, args)
            self.cell_popup_menu[1].append(menu_item)

        self.cell_popup_menu[1].show_all()
        # Only do actions when grid is visible
        self.active = 0
예제 #9
0
    def init_customize_gui_panel(self):
        # Inherit all the usual stuff...
        General_ROIToolDlg.init_customize_gui_panel(self)

        # Add new frame with pixel info, keeping track of
        # the frame and text object...
        self.frame_dict['region_info_frame'] = gtk.GtkFrame()
        self.show_list.append(self.frame_dict['region_info_frame'])

        pixel_vbox = gtk.GtkVBox()
        self.show_list.append(pixel_vbox)
        self.frame_dict['region_info_frame'].add(pixel_vbox)

        pixel_scroll = gtk.GtkScrolledWindow()
        self.show_list.append(pixel_scroll)
        pixel_vbox.pack_start(pixel_scroll,expand = gtk.TRUE)

        self.entry_dict['region_info_text'] = gtk.GtkText()
        self.show_list.append(self.entry_dict['region_info_text'])
        self.entry_dict['region_info_text'].set_line_wrap(gtk.FALSE)
        self.entry_dict['region_info_text'].set_word_wrap(gtk.FALSE)
        self.entry_dict['region_info_text'].set_editable(gtk.FALSE)
        pixel_scroll.add(self.entry_dict['region_info_text'])
        self.entry_dict['region_info_text'].insert_defaults('')


        # Add a frame with the log file options
        self.frame_dict['log_frame']=gtk.GtkFrame()
        self.show_list.append(self.frame_dict['log_frame'])

        log_table = gtk.GtkTable(2,4,gtk.FALSE)
        self.show_list.append(log_table)
        self.frame_dict['log_frame'].add(log_table)
        
        log_table.set_border_width(5)
        log_table.set_col_spacings(5)
        log_table.set_col_spacing(1, 20)

        self.button_dict['Log To File'] = gtk.GtkCheckButton('Log To File')
        self.show_list.append(self.button_dict['Log To File'])
        log_table.attach(self.button_dict['Log To File'], 0,1, 0, 1)

        self.button_dict['Select Log'] = gtk.GtkButton('Select Log')
        self.show_list.append(self.button_dict['Select Log'])
        log_table.attach(self.button_dict['Select Log'], 3,4, 0, 1)

        log_label = gtk.GtkLabel('Log File (full path): ')
        log_label.set_alignment(0, 0.5)
        log_table.attach(log_label, 0,1, 1, 2)

        self.entry_dict['log_file'] = gtk.GtkEntry()
        self.entry_dict['log_file'].set_editable(gtk.TRUE)
        self.entry_dict['log_file'].set_usize(400,25)
        self.entry_dict['log_file'].set_text('')
        log_table.attach(self.entry_dict['log_file'], 1,4, 1,2)

        self.main_panel.pack_start(self.frame_dict['region_info_frame'],gtk.TRUE,gtk.TRUE,0)   
        self.main_panel.pack_start(self.frame_dict['log_frame'],gtk.FALSE,gtk.FALSE,0)      

        # Customized connections
        self.button_dict['Select Log'].connect('clicked',self.select_log_cb)

        # Set default sensitivities for customized tool
        self.button_dict['Log To File'].set_active(gtk.FALSE)
        self.button_dict['Log To File'].set_sensitive(gtk.TRUE)
        self.button_dict['Select Log'].set_sensitive(gtk.TRUE)