[GRASS-CVS] [addons] r1239 - in trunk/grassaddons/gui: . gui_modules

grass-commit-addons at grass.itc.it grass-commit-addons at grass.itc.it
Tue Dec 4 11:35:00 EST 2007


Author: landa
Date: 2007-12-04 17:35:00 +0100 (Tue, 04 Dec 2007)
New Revision: 1239

Modified:
   trunk/grassaddons/gui/gui_modules/dbm.py
   trunk/grassaddons/gui/gui_modules/globalvar.py
   trunk/grassaddons/gui/gui_modules/menuform.py
   trunk/grassaddons/gui/wxgui.py
Log:
Attribute Table Manager: cosmetics in 'extract selected'
Use globally defined style and color definition for FlatNotebook.


Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py	2007-12-04 14:33:10 UTC (rev 1238)
+++ trunk/grassaddons/gui/gui_modules/dbm.py	2007-12-04 16:35:00 UTC (rev 1239)
@@ -233,7 +233,7 @@
         if cat not in self.selectedCats:
             self.selectedCats.append(cat)
             self.selectedCats.sort()
-
+        
         event.Skip()
 
     def OnItemDeselected(self, event):
@@ -409,41 +409,36 @@
         # really needed (ML)
         # self.notebook.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, ''))
 
-        dbmStyle = FN.FNB_VC8 | \
-            FN.FNB_BACKGROUND_GRADIENT | \
-            FN.FNB_NODRAG | \
-            FN.FNB_TABS_BORDER_SIMPLE
-        
         self.notebook = FN.FlatNotebook(parent=self, id=wx.ID_ANY,
-                                                 style=FN.FNB_BOTTOM |
-                                                 FN.FNB_NO_NAV_BUTTONS | FN.FNB_FANCY_TABS)
+                                        style=FN.FNB_BOTTOM |
+                                        FN.FNB_NO_NAV_BUTTONS |
+                                        FN.FNB_FANCY_TABS)
+
+        dbmStyle = globalvar.FNPageStyle
+
         self.browsePage = FN.FlatNotebook(self, id=wx.ID_ANY,
                                           style=dbmStyle)
-        self.browsePage.SetTabAreaColour(wx.Colour(125,200,175))
-        #self.notebook.AddPage(self.browsePage, caption=_("Browse data"))
+        # self.notebook.AddPage(self.browsePage, caption=_("Browse data"))
         self.notebook.AddPage(self.browsePage, text=_("Browse data")) # FN
-        self.browsePage.SetTabAreaColour(wx.Colour(125,200,175))
+        self.browsePage.SetTabAreaColour(globalvar.FNPageColor)
 
         self.manageTablePage = FN.FlatNotebook(self, id=wx.ID_ANY,
                                           style=dbmStyle)
-        self.manageTablePage.SetTabAreaColour(wx.Colour(125,200,175))
         #self.notebook.AddPage(self.manageTablePage, caption=_("Manage tables"))
         self.notebook.AddPage(self.manageTablePage, text=_("Manage tables")) # FN
-        self.manageTablePage.SetTabAreaColour(wx.Colour(125,200,175))
+        self.manageTablePage.SetTabAreaColour(globalvar.FNPageColor)
 
         self.manageLayerPage = FN.FlatNotebook(self, id=wx.ID_ANY,
                                                style=dbmStyle)
-        self.manageLayerPage.SetTabAreaColour(wx.Colour(125,200,175))
         #self.notebook.AddPage(self.manageLayerPage, caption=_("Manage layers"))
         self.notebook.AddPage(self.manageLayerPage, text=_("Manage layers")) # FN
-        self.manageLayerPage.SetTabAreaColour(wx.Colour(125,200,175))
+        self.manageLayerPage.SetTabAreaColour(globalvar.FNPageColor)
 
         self.settingsPage = FN.FlatNotebook(self, id=wx.ID_ANY,
                                             style=dbmStyle)
-        self.settingsPage.SetTabAreaColour(wx.Colour(125,200,175))
         #self.notebook.AddPage(self.settingsPage, caption=_("Settings"))
         self.notebook.AddPage(self.settingsPage, text=_("Settings")) # FN
-        self.settingsPage.SetTabAreaColour(wx.Colour(125,200,175))
+        self.settingsPage.SetTabAreaColour(globalvar.FNPageColor)
 
         self.infoCollapseLabelExp = _("Click here to show database connection information")
         self.infoCollapseLabelCol = _("Click here to hide database connection information")
@@ -496,15 +491,22 @@
             listSizer = wx.StaticBoxSizer(listBox, wx.VERTICAL)
             
             # display or extract selected records buttons
-            btnDisplay = wx.Button(parent=panel, id=wx.ID_ANY, label=_("Display selected"))
+            btnDisplay = wx.Button(parent=panel, id=wx.ID_ANY,
+                                   label=_("Display selected"),
+                                   size=(150, -1))
             btnDisplay.SetToolTip(wx.ToolTip (_("Display selected objects in highlight color")))
             btnDisplay.SetDefault()
             btnDisplay.Bind(wx.EVT_BUTTON, self.OnDataDrawSelected)
-            
-            btnExtract = wx.Button(parent=panel, id=wx.ID_ANY, label=_("Extract selected"))
-            btnExtract.SetToolTip(wx.ToolTip (_("Extract selected objects to new vector")))
-            btnExtract.Bind(wx.EVT_BUTTON, self.ExtractSelected)
-            
+            if not self.map:
+                btnDisplay.Enable(False)
+
+            btnExtract = wx.Button(parent=panel, id=wx.ID_ANY,
+                                   label=_("Extract selected"),
+                                   size=(150, -1))
+            btnExtract.SetToolTip(wx.ToolTip (_("Extract selected objects to "
+                                                "new vector map layer")))
+            btnExtract.Bind(wx.EVT_BUTTON, self.OnExtractSelected)
+
             btnsizer = wx.BoxSizer(wx.HORIZONTAL)
             btnsizer.Add(btnDisplay, 0, wx.ALIGN_LEFT | wx.EXPAND)
             btnsizer.Add((10,10), 1, wx.ALIGN_CENTRE_HORIZONTAL | wx.EXPAND)
@@ -903,12 +905,14 @@
             self.popupDataID4 = wx.NewId()
             self.popupDataID5 = wx.NewId()
             self.popupDataID6 = wx.NewId()
+            self.popupDataID7 = wx.NewId()
             self.Bind(wx.EVT_MENU, self.OnDataItemEdit,       id=self.popupDataID1)
             self.Bind(wx.EVT_MENU, self.OnDataItemAdd,        id=self.popupDataID2)
             self.Bind(wx.EVT_MENU, self.OnDataItemDelete,     id=self.popupDataID3)
             self.Bind(wx.EVT_MENU, self.OnDataItemDeleteAll,  id=self.popupDataID4)
             self.Bind(wx.EVT_MENU, self.OnDataReload,         id=self.popupDataID5)
             self.Bind(wx.EVT_MENU, self.OnDataDrawSelected,   id=self.popupDataID6)
+            self.Bind(wx.EVT_MENU, self.OnExtractSelected,    id=self.popupDataID7)
 
         list = self.FindWindowById(self.layerPage[self.layer]['data'])
         # generate popup-menu
@@ -927,7 +931,8 @@
         menu.AppendSeparator()
         menu.Append(self.popupDataID5, _("Reload"))
         menu.AppendSeparator()
-        menu.Append(self.popupDataID6, _("Highlight selected in the map"))
+        menu.Append(self.popupDataID6, _("Display selected"))
+        menu.Append(self.popupDataID7, _("Extract selected"))
         if not self.map:
             menu.Enable(self.popupDataID6, False)
 
@@ -1612,7 +1617,7 @@
         self.qlayer = map.AddLayer(type='vector', name=globalvar.QUERYLAYER, command=cmd,
                                    l_active=True, l_hidden=True, l_opacity=1.0)
 
-    def ExtractSelected(self, event):
+    def OnExtractSelected(self, event):
         """
         Extract vector objects selected in attribute browse window
         to new vector map
@@ -1621,12 +1626,26 @@
         list = self.FindWindowById(self.layerPage[self.layer]['data'])
         # cats = list.selectedCats[:]
         cats = list.GetSelectedItems()
+        if len(cats) == 0:
+            wx.MessageBox(message=_('Nothing to extract.'), caption=_('Extract selected'))
+            return False
+        else:
+            # dialog to get file name
+            dlg = wx.TextEntryDialog(parent=self, caption=_('Extract selected'),
+                                     message=_('Name of new vector map layer'))
 
-        # dialog to get file name
-        dlg = wx.TextEntryDialog(self, 'Name of new vector file')
-
         if dlg.ShowModal() == wx.ID_OK:
             outmap = dlg.GetValue()
+            if outmap == '':
+                dlgErr = wx.MessageDialog(self.parent,
+                                       _("Unable to create new vector map layer.%s"
+                                         "Name for map layer is missing.") % \
+                                           (os.linesep),
+                                       _("Error"), wx.OK | wx.ICON_ERROR)
+                dlgErr.ShowModal()
+                dlgErr.Destroy()
+                dlg.Destroy()
+                return False
 
         dlg.Destroy()
 

Modified: trunk/grassaddons/gui/gui_modules/globalvar.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/globalvar.py	2007-12-04 14:33:10 UTC (rev 1238)
+++ trunk/grassaddons/gui/gui_modules/globalvar.py	2007-12-04 16:35:00 UTC (rev 1239)
@@ -16,8 +16,18 @@
            for details.
 """
 
+import wx
+import wx.lib.flatnotebook as FN
+
 """
 Query layer (generated for example by selecting item in the Attribute Table Manager)
 Deleted automatically on re-render action
 """
 QUERYLAYER = 'qlayer'
+
+"""Style definition for FlatNotebook pages"""
+FNPageStyle = FN.FNB_VC8 | \
+    FN.FNB_BACKGROUND_GRADIENT | \
+    FN.FNB_NODRAG | \
+    FN.FNB_TABS_BORDER_SIMPLE 
+FNPageColor = wx.Colour(125,200,175)

Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py	2007-12-04 14:33:10 UTC (rev 1238)
+++ trunk/grassaddons/gui/gui_modules/menuform.py	2007-12-04 16:35:00 UTC (rev 1239)
@@ -83,6 +83,7 @@
 import grassenv
 import gselect
 import gcmd
+import globalvar
 try:
     import subprocess
 except:
@@ -793,9 +794,9 @@
         panelsizer = wx.BoxSizer(orient=wx.VERTICAL)
 
         # Build notebook
-        nbStyle=FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT
+        nbStyle = globalvar.FNPageStyle
         self.notebook = FN.FlatNotebook( self, id=wx.ID_ANY, style=nbStyle)
-        self.notebook.SetTabAreaColour(wx.Colour(125,200,175))
+        self.notebook.SetTabAreaColour(globalvar.FNPageColor)
         self.notebook.Bind( FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange )
         tab = {}
         tabsizer = {}

Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py	2007-12-04 14:33:10 UTC (rev 1238)
+++ trunk/grassaddons/gui/wxgui.py	2007-12-04 16:35:00 UTC (rev 1239)
@@ -76,6 +76,7 @@
 import gui_modules.gcmd as gcmd
 import gui_modules.georect as georect
 import gui_modules.dbm as dbm
+import gui_modules.globalvar as globalvar
 from   icons.icon import Icons as Icons
 from   gui_modules.debug import Debug as Debug
 
@@ -246,12 +247,9 @@
         #self.notebook.SetFont(wx.Font(pointSize=11, family=wx.FONTFAMILY_DEFAULT, style=wx.NORMAL, weight=0))
 
         # create displays notebook widget and add it to main notebook page
-        cbStyle = FN.FNB_VC8 | \
-            FN.FNB_BACKGROUND_GRADIENT | \
-            FN.FNB_X_ON_TAB | \
-            FN.FNB_TABS_BORDER_SIMPLE
+        cbStyle = globalvar.FNPageStyle
         self.gm_cb = FN.FlatNotebook(self, id=wx.ID_ANY, style=cbStyle)
-        self.gm_cb.SetTabAreaColour(wx.Colour(125,200,175))
+        self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
         self.notebook.AddPage(self.gm_cb, text=_("Map layers for each display"))
 
         # create command output text area and add it to main notebook page



More information about the grass-commit mailing list