def _getListOfMaps(self): """Get list of maps""" result = dict() result['raster'] = grass.list_strings('raster') result['vector'] = grass.list_strings('vector') return result
def _getListOfMaps(self): """Get list of maps""" result = dict() result["raster"] = grass.list_strings("raster") result["vector"] = grass.list_strings("vector") return result
def sampleAreaVector(vect, rast, vect_cats, layer='1', overwrite=False, progDialog=None): """Create the strings to add to the configuration file using vector""" areanum = len(vect_cats) output = [] #TODO if areanum == 0 exit from the program if areanum == 0: GError(message=_("The polygon seems to have 0 areas")) return None for n in range(areanum): cat = str(vect_cats[n]) outpref = "{rast}_{vect}_".format(vect=vect.split('@')[0], rast=rast.split('@')[0]) rast_name = "{pref}{cat}".format(pref=outpref, cat=cat) # check if raster already axist if len(grass.list_strings('raster', pattern=rast_name, mapset='.')) == 1 \ and not overwrite: GError(message=_("The raster map <%s> already exists." " Please remove or rename the maps " "with the prefix '%s' or select the " "option to overwrite existing maps" % (rast_name, outpref))) return None convertFeature(vect, rast_name, cat, rast, layer, overwrite) output.append(obtainAreaVector(rast_name)) if progDialog: progDialog.Update(n) return output
def filtro_img(radical): lista_img = grass.list_strings('rast') lista_sel = [] for img in lista_img: if img[:len(radical)] == radical: lista_sel.append(img) return lista_sel
def __init__(self, parent, statusbar, id=wx.ID_ANY, choices=[], **kwargs): """!Constructor works just like wx.TextCtrl except you can pass in a list of choices. You can also change the choice list at any time by calling setChoices. Inspired by http://wiki.wxpython.org/TextCtrlAutoComplete """ self.statusbar = statusbar if 'style' in kwargs: kwargs['style'] = wx.TE_PROCESS_ENTER | kwargs['style'] else: kwargs['style'] = wx.TE_PROCESS_ENTER wx.ComboBox.__init__(self, parent, id, **kwargs) # some variables self._choices = choices self._hideOnNoMatch = True self._module = None # currently selected module self._choiceType = None # type of choice (module, params, flags, raster, vector ...) self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) self._historyItem = 0 # last item # sort variable needed by listmix self.itemDataMap = dict() # widgets try: self.dropdown = wx.PopupWindow(self) except NotImplementedError: self.Destroy() raise NotImplementedError # create the list and bind the events self.dropdownlistbox = PromptListCtrl(parent = self.dropdown, style = wx.LC_REPORT | wx.LC_SINGLE_SEL | \ wx.LC_SORT_ASCENDING | wx.LC_NO_HEADER, pos = wx.Point(0, 0)) listmix.ColumnSorterMixin.__init__(self, 1) # set choices (list of GRASS modules) self._choicesCmd = globalvar.grassCmd self._choicesMap = dict() for type in ('raster', 'vector'): self._choicesMap[type] = grass.list_strings(type=type[:4]) # first search for GRASS module self.SetChoices(self._choicesCmd) self.SetMinSize(self.GetSize()) # bindings... self.Bind(wx.EVT_KILL_FOCUS, self.OnControlChanged) self.Bind(wx.EVT_TEXT, self.OnEnteredText) self.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) ### self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) # if need drop down on left click self.dropdown.Bind(wx.EVT_LISTBOX, self.OnListItemSelected, self.dropdownlistbox) self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.OnListClick) self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.OnListDClick) self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK, self.OnListColClick) self.Bind(wx.EVT_COMBOBOX, self.OnCommandSelect)
def __init__ (self, parent, statusbar, id = wx.ID_ANY, choices = [], **kwargs): """!Constructor works just like wx.TextCtrl except you can pass in a list of choices. You can also change the choice list at any time by calling setChoices. Inspired by http://wiki.wxpython.org/TextCtrlAutoComplete """ self.statusbar = statusbar if 'style' in kwargs: kwargs['style'] = wx.TE_PROCESS_ENTER | kwargs['style'] else: kwargs['style'] = wx.TE_PROCESS_ENTER wx.ComboBox.__init__(self, parent, id, **kwargs) # some variables self._choices = choices self._hideOnNoMatch = True self._module = None # currently selected module self._choiceType = None # type of choice (module, params, flags, raster, vector ...) self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) self._historyItem = 0 # last item # sort variable needed by listmix self.itemDataMap = dict() # widgets try: self.dropdown = wx.PopupWindow(self) except NotImplementedError: self.Destroy() raise NotImplementedError # create the list and bind the events self.dropdownlistbox = PromptListCtrl(parent = self.dropdown, style = wx.LC_REPORT | wx.LC_SINGLE_SEL | \ wx.LC_SORT_ASCENDING | wx.LC_NO_HEADER, pos = wx.Point(0, 0)) listmix.ColumnSorterMixin.__init__(self, 1) # set choices (list of GRASS modules) self._choicesCmd = globalvar.grassCmd['all'] self._choicesMap = dict() for type in ('raster', 'vector'): self._choicesMap[type] = grass.list_strings(type = type[:4]) # first search for GRASS module self.SetChoices(self._choicesCmd) self.SetMinSize(self.GetSize()) # bindings... self.Bind(wx.EVT_KILL_FOCUS, self.OnControlChanged) self.Bind(wx.EVT_TEXT, self.OnEnteredText) self.Bind(wx.EVT_TEXT_ENTER, self.OnRunCmd) self.Bind(wx.EVT_KEY_DOWN , self.OnKeyDown) ### self.Bind(wx.EVT_LEFT_DOWN, self.OnClick) # if need drop down on left click self.dropdown.Bind(wx.EVT_LISTBOX , self.OnListItemSelected, self.dropdownlistbox) self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.OnListClick) self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.OnListDClick) self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK, self.OnListColClick) self.Bind(wx.EVT_COMBOBOX, self.OnCommandSelect)