[GRASS-SVN] r30607 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 17 17:02:44 EDT 2008


Author: martinl
Date: 2008-03-17 17:02:43 -0400 (Mon, 17 Mar 2008)
New Revision: 30607

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/dbm.py
   grass/trunk/gui/wxpython/gui_modules/globalvar.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: (globalvar, menuform, gis_set, utils, dbm) check for wx version fixed
(wxgui_utils) opacity level enabled/disabled fixes


Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -28,16 +28,15 @@
 ### i18N
 import gettext
 
+from gui_modules import globalvar
+globalvar.CheckForWx()
 from gui_modules import utils
 
-utils.CheckForWx()
 import wx
 import wx.html
 import wx.lib.rcsizer as rcs
 import wx.lib.filebrowsebutton as filebrowse
 
-from gui_modules import globalvar
-
 class GRASSStartup(wx.Frame):
     """GRASS start-up screen"""
     def __init__(self, parent=None, id=wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE):

Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -41,6 +41,9 @@
 import gettext
 gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
 
+import globalvar
+globalvar.CheckForWx()
+
 import wx
 import wx.lib.mixins.listctrl as listmix
 import wx.lib.flatnotebook as FN
@@ -49,7 +52,6 @@
 import sqlbuilder
 import grassenv
 import gcmd
-import globalvar
 import utils
 from debug import Debug as Debug
 from preferences import globalSettings as UserSettings

Modified: grass/trunk/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/globalvar.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gui_modules/globalvar.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -93,3 +93,23 @@
 
 """@Toolbar icon size"""
 toolbarSize = (24, 24)
+
+def CheckForWx():
+    """Try to import wx module and check its version"""
+    majorVersion = 2.8
+    minorVersion = 1.1
+    try:
+        import wx
+        version = wx.__version__
+        if float(version[:3]) < majorVersion:
+            raise ValueError('You are using wxPython version %s' % str(version))
+        if float(version[:3]) == 2.8 and \
+                float(version[4:]) < minorVersion:
+            raise ValueError('You are using wxPython version %s' % str(version))
+
+    except (ImportError, ValueError), e:
+        print >> sys.stderr, 'ERROR: ' + str(e) + \
+            '. wxPython >= %s.%s is required. Detailed information in README file.' % \
+            (str(majorVersion), str(minorVersion))
+        sys.exit(1)
+

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -52,13 +52,17 @@
 import textwrap
 import os
 from os import system
+import time
+start = time.time()
 
 ### i18N
 import gettext
 gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
 
-import utils
-utils.CheckForWx()
+
+import globalvar
+globalvar.CheckForWx()
+
 import wx
 import wx.lib.flatnotebook as FN
 import wx.lib.colourselect as csel
@@ -72,8 +76,9 @@
 HandlerBase=xml.sax.handler.ContentHandler
 from xml.sax import make_parser
 
+import utils
+
 gisbase = os.getenv("GISBASE")
-import globalvar
 if gisbase is None:
     print >>sys.stderr, "We don't seem to be properly installed, or we are being run outside GRASS. Expect glitches."
     gisbase = os.path.join(os.path.dirname( sys.argv[0] ), os.path.pardir)
@@ -791,6 +796,9 @@
     def OnCancel(self, event):
         """Cancel button pressed"""
         self.MakeModal(False)
+        # update only propwin reference
+        self.get_dcmd(dcmd=None, layer=self.layer, params=None,
+                      propwin=None)
         self.Destroy()
 
     def OnCloseWindow(self, event):
@@ -1314,6 +1322,7 @@
         self.mf = mainFrame(parent=None, ID=wx.ID_ANY, task_description=self.grass_task)
         self.mf.Show(True)
         self.SetTopWindow(self.mf)
+        # print >> sys.stderr, time.time() - start
         return True
 
 class GUI:
@@ -1334,6 +1343,7 @@
         * add key name for first parameter if not given
         * change mapname to mapname at mapset
         """
+        start = time.time()
         dcmd_params = {}
         if completed == None:
             get_dcmd = None
@@ -1406,6 +1416,7 @@
         else:
             self.mf.OnApply(None)
         
+        # print >> sys.stderr, time.time() - start
         return cmd
 
 class StaticWrapText(wx.StaticText):

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -127,25 +127,6 @@
         
     return catstr.strip(',')
 
-def CheckForWx():
-    """Try to import wx module and check its version"""
-    majorVersion = 2.8
-    minorVersion = 1.1
-    try:
-        import wx
-        version = wx.__version__
-        if float(version[:3]) < majorVersion:
-            raise ValueError('You are using wxPython version %s' % str(version))
-        if float(version[:3]) == 2.8 and \
-                float(version[4:]) < minorVersion:
-            raise ValueError('You are using wxPython version %s' % str(version))
-
-    except (ImportError, ValueError), e:
-        print >> sys.stderr, 'ERROR: ' + str(e) + \
-            '. wxPython >= %s.%s is required. Detailed information in README file.' % \
-            (str(majorVersion), str(minorVersion))
-        sys.exit(1)
-
 def ListOfMapsets():
     """Get list of available/accessible mapsets
 

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -46,6 +46,8 @@
 except:
     from compat import subprocess
 
+TREE_ITEM_HEIGHT = 25
+
 # define event for GRASS console (running GRASS command in separate thread)
 (UpdateGMConsoleEvent, EVT_UPDATE_GMCONSOLE) = wx.lib.newevent.NewEvent()
 
@@ -58,8 +60,8 @@
                  id=wx.ID_ANY, pos=wx.DefaultPosition,
                  size=wx.DefaultSize, style=wx.SUNKEN_BORDER,
                  ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
-                 CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT|
-                 CT.TR_EDIT_LABELS|CT.TR_MULTIPLE,
+                 CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT |
+                 CT.TR_EDIT_LABELS | CT.TR_SINGLE,
                  idx=None, gismgr=None, notebook=None, auimgr=None, showMapDisplay=True):
         CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle)
 
@@ -108,11 +110,11 @@
         self.SetPyData(self.root, (None,None))
 
         #create image list to use with layer tree
-        il = wx.ImageList(16, 16, False)
+        il = wx.ImageList(16, 16, mask=False)
 
-        trart = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, (16,16))
+        trart = wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, (16, 16))
         self.folder_open = il.Add(trart)
-        trart = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16,16))
+        trart = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16))
         self.folder = il.Add(trart)
 
         bmpsize = (16, 16)
@@ -158,8 +160,6 @@
         trgif = Icons["addcmd"].GetBitmap(bmpsize)
         self.cmd_icon = il.Add(trgif)
 
-        checksize = il.GetSize(0)
-        checkbmp = il.GetBitmap(0)
         self.AssignImageList(il)
 
         # use when groups implemented
@@ -376,7 +376,7 @@
         """Popup opacity level indicator"""
         if not self.GetPyData(self.layer_selected)[0]['ctrl']:
             return
-        
+
         win = self.FindWindowById(self.GetPyData(self.layer_selected)[0]['ctrl'])
         type = win.GetName()
 
@@ -384,7 +384,7 @@
 
         opacity = self.GetPyData(self.layer_selected)[0]['maplayer'].GetOpacity()
         if type == 'staticText':
-            ctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
+            ctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="",
                                style=wx.SP_ARROW_KEYS, initial=100, min=0, max=100,
                                name='spinCtrl')
             ctrl.SetValue(opacity)
@@ -393,7 +393,7 @@
             ctrl = wx.StaticText(self, id=wx.ID_ANY,
                                  name='staticText')
             if opacity < 100:
-                ctrl.SetLabel('(' + str(opacity) + '%)')
+                ctrl.SetLabel('   (' + str(opacity) + '%)')
                 
         self.GetPyData(self.layer_selected)[0]['ctrl'] = ctrl.GetId()
         self.layer_selected.SetWindow(ctrl)
@@ -436,7 +436,7 @@
         else:
             # all other items (raster, vector, ...)
             if UserSettings.Get(group='general', key='changeOpacityLevel', subkey='enabled'):
-                ctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
+                ctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="",
                                    style=wx.SP_ARROW_KEYS, initial=100, min=0, max=100,
                                    name='spinCtrl')
                 
@@ -532,7 +532,7 @@
                     ctrl.SetValue(int(lopacity * 100))
                 else:
                     if opacity < 1.0:
-                        ctrl.SetLabel('(' + str(int(opacity * 100)) + '%)')
+                        ctrl.SetLabel('   (' + str(int(opacity * 100)) + '%)')
             else:
                 opacity = 1.0
             if lcmd and len(lcmd) > 1:
@@ -585,12 +585,15 @@
         if checked is True:
             self.mapdisplay.onRenderGauge.SetRange(len(self.Map.GetListOfLayers(l_active=True)))
 
+        # layer.SetHeight(TREE_ITEM_HEIGHT)
+
         return layer
 
     def PropertiesDialog (self, layer, show=True):
         """Launch the properties dialog"""
 
-        if self.GetPyData(layer)[0].has_key('propwin'):
+        if self.GetPyData(layer)[0].has_key('propwin') and \
+                self.GetPyData(layer)[0]['propwin'] is not None:
             # avoid duplicated GUI dialog for given map layer
             if self.GetPyData(layer)[0]['propwin'].IsShown():
                 self.GetPyData(layer)[0]['propwin'].SetFocus()
@@ -795,6 +798,7 @@
             self.mapdisplay.OnRender(None)
 
     def OnChangeSel(self, event):
+        """Selection changed"""
         oldlayer = event.GetOldItem()
         layer = event.GetItem()
         self.layer_selected = layer
@@ -870,9 +874,9 @@
                 newctrl = wx.StaticText(self, id=wx.ID_ANY,
                                         name='staticText')
                 if opacity < 100:
-                    newctrl.SetLabel('(' + str(opacity) + '%)')
+                    newctrl.SetLabel('   (' + str(opacity) + '%)')
             else:
-                newctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
+                newctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="",
                                       style=wx.SP_ARROW_KEYS, min=0, max=100,
                                       name='spinCtrl')
                 newctrl.SetValue(opacity)
@@ -928,7 +932,7 @@
             
         self.CheckItem(newItem, checked=checked)
 
-        event.Skip()
+        # newItem.SetHeight(TREE_ITEM_HEIGHT)
 
         return newItem
 
@@ -988,8 +992,7 @@
             self.SetPyData(layer, (self.GetPyData(layer)[0], params))
         if dcmd:
             self.GetPyData(layer)[0]['cmd'] = dcmd
-        if propwin:
-            self.GetPyData(layer)[0]['propwin'] = propwin
+        self.GetPyData(layer)[0]['propwin'] = propwin
         
         # check layer as active
         # self.CheckItem(layer, checked=True)
@@ -1061,8 +1064,8 @@
         if self.mapdisplay.autoRender.GetValue(): 
             self.mapdisplay.OnRender(None)
 
-        self.Refresh()
-        
+        # item.SetHeight(TREE_ITEM_HEIGHT)
+
     def setNotebookPage(self,pg):
         self.parent.notebook.SetSelection(pg)
 

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-03-17 20:59:44 UTC (rev 30606)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-03-17 21:02:43 UTC (rev 30607)
@@ -52,8 +52,9 @@
 gmpath = icons.__path__[0]
 sys.path.append(gmpath)
 
-import gui_modules.utils as utils
-utils.CheckForWx()
+import gui_modules.globalvar as globalvar
+globalvar.CheckForWx()
+
 import wx
 import wx.aui
 import wx.combo
@@ -67,6 +68,7 @@
 except:
     import compat.subprocess as subprocess
 
+import gui_modules.utils as utils
 import gui_modules.preferences as preferences
 import gui_modules.wxgui_utils as wxgui_utils
 import gui_modules.mapdisp as mapdisp
@@ -80,7 +82,6 @@
 import gui_modules.gcmd as gcmd
 import gui_modules.georect as georect
 import gui_modules.dbm as dbm
-import gui_modules.globalvar as globalvar
 import gui_modules.workspace as workspace
 import gui_modules.goutput as goutput
 from   gui_modules.debug import Debug as Debug



More information about the grass-commit mailing list