diff --git a/gui/wxpython/gui_core/preferences.py b/gui/wxpython/gui_core/preferences.py index c9f74cb25af..04eb65a8cba 100644 --- a/gui/wxpython/gui_core/preferences.py +++ b/gui/wxpython/gui_core/preferences.py @@ -202,6 +202,33 @@ def OnSave(self, event): group="language", key="locale", subkey="lc_all", value=None ) lang = None + env = grass.gisenv() + nprocs_gisenv = "NPROCS" + memorydb_gisenv = "MEMORYMB" + # Set gisenv MEMORYMB var value + memorymb = self.memorymb.GetValue() + if memorymb: + grass.run_command( + "g.gisenv", + set=f"{memorydb_gisenv}={memorymb}", + ) + elif env.get(memorydb_gisenv): + grass.run_command( + "g.gisenv", + unset=memorydb_gisenv, + ) + # Set gisenv NPROCS var value + nprocs = self.nprocs.GetValue() + if nprocs: + grass.run_command( + "g.gisenv", + set=f"{nprocs_gisenv}={nprocs}", + ) + elif env.get(nprocs_gisenv): + grass.run_command( + "g.gisenv", + unset=nprocs_gisenv, + ) self.settings.SaveToFile() Debug.msg(1, "Settings saved to file '%s'" % self.settings.filePath) self.settingsChanged.emit() @@ -1245,6 +1272,56 @@ def _createCmdPage(self, notebook): gridSizer.Add(verbosity, pos=(row, 1), flag=wx.ALIGN_RIGHT) + row += 1 + # nprocs + gridSizer.Add( + StaticText( + parent=panel, + id=wx.ID_ANY, + label=_( + "Number of threads for parallel computing (supported tools only):" + ), + ), + flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, + pos=(row, 0), + ) + self.nprocs = TextCtrl( + parent=panel, + id=wx.ID_ANY, + value=grass.gisenv().get("NPROCS", ""), + validator=IntegerValidator(), + name="NumberOfProcs", + ) + gridSizer.Add( + self.nprocs, + flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, + pos=(row, 1), + ) + + row += 1 + # memorymb + gridSizer.Add( + StaticText( + parent=panel, + id=wx.ID_ANY, + label=_("Maximum memory in MB to be used (supported tools only):"), + ), + flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, + pos=(row, 0), + ) + self.memorymb = TextCtrl( + parent=panel, + id=wx.ID_ANY, + value=grass.gisenv().get("MEMORYMB", ""), + validator=IntegerValidator(), + name="MemorySizeMB", + ) + gridSizer.Add( + self.memorymb, + flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, + pos=(row, 1), + ) + gridSizer.AddGrowableCol(0) sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)