Changeset 30759


Ignore:
Timestamp:
Mar 27, 2008, 7:30:56 AM (16 years ago)
Author:
martinl
Message:

wxGUI (welcome screen): don't crash on '<UNKNOWN>' location

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/gui/wxpython/gis_set.py

    r30746 r30759  
    144144        self.mpanel = wx.Panel(parent=self.panel, id=wx.ID_ANY)
    145145        self.lbmapsets = GListBox(parent=self.mpanel,
    146                                   id=wx.ID_ANY, size=(150, 200),
     146                                  id=wx.ID_ANY, size=(180, 200),
    147147                                  choices=self.listOfMapsets)
    148148
     
    546546
    547547        # disable mapset with denied permission
     548        locationName = os.path.basename(location)
     549        if self._getRCValue("LOCATION_NAME") == "<UNKNOWN>":
     550            gcmd.Command(["g.gisenv",
     551                          "set=GISDBASE=%s" % self.gisdbase])
     552            gcmd.Command(["g.gisenv",
     553                          "set=LOCATION_NAME=%s" % locationName])
     554            gcmd.Command(["g.gisenv",
     555                          "set=MAPSET=PERMANENT"])
     556
    548557        for line in gcmd.Command(['g.mapset',
    549558                                  '-l',
    550                                   'location=%s' % os.path.basename(location),
     559                                  'location=%s' % locationName,
    551560                                  'gisdbase=%s' % self.gisdbase]).ReadStdOutput():
    552561            self.listOfMapsetsSelectable += line.split(' ')
     
    566575        """Location selected"""
    567576        if event:
    568             self.lblocations.SetSelection(event.GetIndex())
     577            try:
     578                self.lblocations.SetSelection(event.GetIndex())
     579            except AttributeError:
     580                self.lblocations.SetSelection(0)
    569581           
    570582        if self.lblocations.GetSelection() > -1:
     
    717729        self.Layout()
    718730
    719 class GListBox(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
     731# class GListBox(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
     732class GListBox(wx.ListCtrl):
    720733    """Use wx.ListCtrl instead of wx.ListBox, different style for
    721734    non-selectable items (e.g. mapsets with denied permission)"""
     
    724737
    725738        wx.ListCtrl.__init__(self, parent, id, size=size,
    726                              style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL)
    727 
    728         listmix.ListCtrlAutoWidthMixin.__init__(self)
     739                             style=wx.LC_REPORT | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL |
     740                             wx.BORDER_RAISED)
     741
     742        self.width = size[0] - 20 # FIXME (width of vertical scrollbar)
     743       
     744        # listmix.ListCtrlAutoWidthMixin.__init__(self)
    729745       
    730746        self.InsertColumn(0, '')
     
    748764                self.SetItemTextColour(idx, wx.Colour(150, 150, 150))
    749765            idx += 1
     766
     767        for col in range(self.GetColumnCount()):
     768            self.SetColumnWidth(col, self.width)
    750769           
    751770    def Clear(self):
Note: See TracChangeset for help on using the changeset viewer.