Ejemplo n.º 1
0
    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.CenterOnScreen()
                if dlg.ShowModal() == wx.ID_YES:
                    self.ImportFile(gWizard.georeffile)
                dlg.Destroy()
            if gWizard.default_region:
                defineRegion = RegionDef(self, location=gWizard.location)
                defineRegion.CenterOnScreen()
                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)
Ejemplo n.º 2
0
 def SetDefaultRegion(self, location):
     """Asks to set default region."""
     caption = _("Location <%s> created") % location
     message = _("Do you want to set the default "
                 "region extents and resolution now?")
     dlg = wx.MessageDialog(
         parent=self,
         message="%(caption)s.\n\n%(extent)s" % ({
             'caption': caption,
             'extent': message
         }),
         caption=caption,
         style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
     dlg.CenterOnScreen()
     if dlg.ShowModal() == wx.ID_YES:
         dlg.Destroy()
         defineRegion = RegionDef(self, location=location)
         defineRegion.CenterOnScreen()
         defineRegion.ShowModal()
         defineRegion.Destroy()
     else:
         dlg.Destroy()