4 @brief Global variables
6 This module provide the space for global variables
9 (C) 2007-2010 by the GRASS Development Team
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
14 @author Martin Landa <landa.martin gmail.com>
21 if not os.getenv(
"GISBASE"):
22 sys.exit(
"GRASS is not running. Exiting...")
25 gettext.install(
'grasswxpy', os.path.join(os.getenv(
"GISBASE"),
'locale'), unicode=
True)
28 ETCDIR = os.path.join(os.getenv(
"GISBASE"),
"etc")
29 ETCICONDIR = os.path.join(os.getenv(
"GISBASE"),
"etc",
"gui",
"icons")
30 ETCWXDIR = os.path.join(ETCDIR,
"wxpython")
31 ETCIMGDIR = os.path.join(ETCDIR,
"gui",
"images")
33 sys.path.append(os.path.join(ETCDIR,
"python"))
37 """!Check wx version"""
38 ver = wx.version().
split(
' ')[0]
39 if map(int, ver.split(
'.')) < version:
45 """!Try to import wx module and check its version"""
46 if 'wx' in sys.modules.keys():
49 minVersion = [2, 8, 1, 1]
53 except ImportError, e:
56 wxversion.ensureMinimal(str(minVersion[0]) +
'.' + str(minVersion[1]))
58 version = wx.version().
split(
' ')[0]
60 if map(int, version.split(
'.')) < minVersion:
61 raise ValueError(
'Your wxPython version is %s.%s.%s.%s' % tuple(version.split(
'.')))
63 except ImportError, e:
64 print >> sys.stderr,
'ERROR: wxGUI requires wxPython. %s' % str(e)
66 except (ValueError, wxversion.VersionError), e:
67 print >> sys.stderr,
'ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(minVersion) + \
70 except locale.Error, e:
71 print >> sys.stderr,
"Unable to set locale:", e
72 os.environ[
'LC_ALL'] =
''
74 if not os.getenv(
"GRASS_WXBUNDLED"):
77 import wx.lib.flatnotebook
as FN
80 Query layer (generated for example by selecting item in the Attribute Table Manager)
81 Deleted automatically on re-render action
86 """!Style definition for FlatNotebook pages"""
87 FNPageStyle = FN.FNB_VC8 | \
88 FN.FNB_BACKGROUND_GRADIENT | \
90 FN.FNB_TABS_BORDER_SIMPLE
92 FNPageDStyle = FN.FNB_FANCY_TABS | \
94 FN.FNB_NO_NAV_BUTTONS | \
97 FNPageColor = wx.Colour(125,200,175)
99 """!Dialog widget dimension"""
100 DIALOG_SPIN_SIZE = (150, -1)
101 DIALOG_COMBOBOX_SIZE = (300, -1)
102 DIALOG_GSELECT_SIZE = (400, -1)
103 DIALOG_TEXTCTRL_SIZE = (400, -1)
104 DIALOG_LAYER_SIZE = (100, -1)
105 DIALOG_COLOR_SIZE = (30, 30)
107 MAP_WINDOW_SIZE = (800, 600)
108 HIST_WINDOW_SIZE = (500, 350)
109 GM_WINDOW_SIZE = (500, 600)
111 MAP_DISPLAY_STATUSBAR_MODE = [_(
"Coordinates"),
114 _(
"Show comp. extent"),
116 _(
"Display geometry"),
121 """!File name extension binaries/scripts"""
122 if sys.platform ==
'win32':
130 """!Create list of available GRASS commands to use when parsing
131 string from the command line
133 @param bin True to include executable into list
134 @param scripts True to include scripts into list
135 @param gui_scripts True to include GUI scripts into list
137 gisbase = os.environ[
'GISBASE']
140 for executable
in os.listdir(os.path.join(gisbase,
'bin')):
141 ext = os.path.splitext(executable)[1]
143 ext
in (EXT_BIN, EXT_SCT):
144 cmd.append(executable)
147 cmd.append(
'vcolors')
148 if scripts
and sys.platform !=
"win32":
149 cmd = cmd + os.listdir(os.path.join(gisbase,
'scripts'))
151 os.environ[
"PATH"] = os.getenv(
"PATH") + os.pathsep + os.path.join(gisbase,
'etc',
'gui',
'scripts')
152 os.environ[
"PATH"] = os.getenv(
"PATH") + os.pathsep + os.path.join(gisbase,
'etc',
'wxpython',
'scripts')
153 cmd = cmd + os.listdir(os.path.join(gisbase,
'etc',
'gui',
'scripts'))
155 if os.getenv(
'GRASS_ADDON_PATH'):
156 for path
in os.getenv(
'GRASS_ADDON_PATH').
split(os.pathsep):
157 if not os.path.exists(path)
or not os.path.isdir(path):
159 for fname
in os.listdir(path):
160 name, ext = os.path.splitext(fname)
170 if sys.platform ==
'win32':
171 for idx
in range(len(cmd)):
172 name, ext = os.path.splitext(cmd[idx])
173 if ext
in (EXT_BIN, EXT_SCT):
178 """@brief Collected GRASS-relared binaries/scripts"""
181 grassCmd[
'script'] =
GetGRASSCmds(bin =
False, gui_scripts =
False)
183 """@Toolbar icon size"""
184 toolbarSize = (24, 24)
186 """@Is g.mlist available?"""
187 if 'g.mlist' in grassCmd[
'all']:
192 """@Check version of wxPython, use agwStyle for 2.8.11+"""