def OnWizard(self, event): """Location wizard started""" from location_wizard.wizard import LocationWizard gWizard = LocationWizard(parent=self, grassdatabase=self.tgisdbase.GetValue()) if gWizard.location is not None: self.tgisdbase.SetValue(gWizard.grassdatabase) self.OnSetDatabase(None) self.UpdateMapsets(os.path.join(self.gisdbase, gWizard.location)) self.lblocations.SetSelection( self.listOfLocations.index( gWizard.location)) self.lbmapsets.SetSelection(0) self.SetLocation(self.gisdbase, gWizard.location, 'PERMANENT') if gWizard.georeffile: message = _("Do you want to import <%(name)s> to the newly created location?") % { 'name': gWizard.georeffile} dlg = wx.MessageDialog(parent=self, message=message, caption=_( "Import data?"), style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_YES: self.ImportFile(gWizard.georeffile) dlg.Destroy() if gWizard.default_region: defineRegion = RegionDef(self, location=gWizard.location) defineRegion.CenterOnParent() defineRegion.ShowModal() defineRegion.Destroy() if gWizard.user_mapset: self.OnCreateMapset(event)
def create_location_interactively(guiparent, grassdb): """ Create new location using Location Wizard. Returns tuple (database, location, mapset) where mapset is "PERMANENT" by default or another mapset a user created and may want to switch to. """ from location_wizard.wizard import LocationWizard gWizard = LocationWizard(parent=guiparent, grassdatabase=grassdb) if gWizard.location is None: gWizard_output = (None, None, None) # Returns Nones after Cancel return gWizard_output if gWizard.georeffile: message = _( "Do you want to import {} " "to the newly created location?" ).format(gWizard.georeffile) dlg = wx.MessageDialog(parent=guiparent, message=message, caption=_("Import data?"), style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_YES: gisrc_file, env = create_environment(gWizard.grassdatabase, gWizard.location, 'PERMANENT') import_file(guiparent, gWizard.georeffile, env) try_remove(gisrc_file) dlg.Destroy() if gWizard.default_region: defineRegion = RegionDef(guiparent, location=gWizard.location) defineRegion.CenterOnParent() defineRegion.ShowModal() defineRegion.Destroy() if gWizard.user_mapset: mapset = create_mapset_interactively(guiparent, gWizard.grassdatabase, gWizard.location) # Returns database and location created by user # and a mapset user may want to switch to gWizard_output = (gWizard.grassdatabase, gWizard.location, mapset) else: # Returns PERMANENT mapset when user mapset not defined gWizard_output = (gWizard.grassdatabase, gWizard.location, "PERMANENT") return gWizard_output
def OnWizard(self, event): """Location wizard started""" from location_wizard.wizard import LocationWizard gWizard = LocationWizard(parent=self, grassdatabase=self.tgisdbase.GetValue()) if gWizard.location is not None: self.tgisdbase.SetValue(gWizard.grassdatabase) self.OnSetDatabase(None) self.UpdateMapsets(os.path.join(self.gisdbase, gWizard.location)) self.lblocations.SetSelection( self.listOfLocations.index(gWizard.location)) self.lbmapsets.SetSelection(0) self.SetLocation(self.gisdbase, gWizard.location, "PERMANENT") if gWizard.georeffile: message = _( "Do you want to import <%(name)s> to the newly created location?" ) % { "name": gWizard.georeffile } dlg = wx.MessageDialog( parent=self, message=message, caption=_("Import data?"), style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION, ) dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_YES: self.ImportFile(gWizard.georeffile) dlg.Destroy() if gWizard.default_region: defineRegion = RegionDef(self, location=gWizard.location) defineRegion.CenterOnParent() defineRegion.ShowModal() defineRegion.Destroy() if gWizard.user_mapset: dlg = TextEntryDialog( parent=self, message=_("New mapset:"), caption=_("Create new mapset"), defaultValue=self._getDefaultMapsetName(), validator=GenericValidator(grass.legal_name, self._nameValidationFailed), style=wx.OK | wx.CANCEL | wx.HELP, ) help = dlg.FindWindowById(wx.ID_HELP) help.Bind(wx.EVT_BUTTON, self.OnHelp) if dlg.ShowModal() == wx.ID_OK: mapsetName = dlg.GetValue() self.CreateNewMapset(mapsetName)