-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wxGUI/lmgr: add menu item for launching dialog for setting RStudio path #1232
base: main
Are you sure you want to change the base?
Changes from all commits
2ffc6e9
776e401
400c0e1
2097bf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -18,20 +18,23 @@ | |||
- :class:`SymbolDialog` | ||||
- :class:`QuitDialog` | ||||
- :class:`DefaultFontDialog` | ||||
- :class:`DirBrowseDialog` | ||||
|
||||
(C) 2008-2016 by the GRASS Development Team | ||||
(C) 2008-2021 by the GRASS Development Team | ||||
|
||||
This program is free software under the GNU General Public License | ||||
(>=v2). Read the file COPYING that comes with GRASS for details. | ||||
|
||||
@author Martin Landa <landa.martin gmail.com> | ||||
@author Anna Kratochvilova <kratochanna gmail.com> (GroupDialog, SymbolDialog) | ||||
@author Tomas Zigo <tomas.zigo slovanet.sk> (DirBrowseDialog) | ||||
""" | ||||
|
||||
import os | ||||
import re | ||||
|
||||
import wx | ||||
import wx.lib.filebrowsebutton as filebrowse | ||||
|
||||
from grass.script import core as grass | ||||
from grass.script.utils import naturally_sorted, try_remove | ||||
|
@@ -47,7 +50,13 @@ | |||
OgrTypeSelect, | ||||
SubGroupSelect, | ||||
) | ||||
from gui_core.widgets import SingleSymbolPanel, SimpleValidator, MapValidator | ||||
from gui_core.widgets import ( | ||||
GenericValidator, | ||||
GListCtrl, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ruff] reported by reviewdog 🐶
Suggested change
|
||||
MapValidator, | ||||
SimpleValidator, | ||||
SingleSymbolPanel, | ||||
) | ||||
from core.settings import UserSettings | ||||
from core.debug import Debug | ||||
from core.utils import is_shell_running | ||||
|
@@ -2611,3 +2620,85 @@ | |||
else: | ||||
self.renderfont.SetBitmap(EmptyBitmap(size[0], size[1])) | ||||
try_remove(self.tmp_file) | ||||
|
||||
|
||||
class DirBrowseDialog(wx.Dialog): | ||||
"""Simple dialog with DirBrowseButton widget.""" | ||||
|
||||
def __init__( | ||||
self, | ||||
parent, | ||||
message, | ||||
caption="", | ||||
defaultValue="", | ||||
validator=wx.DefaultValidator, | ||||
style=wx.OK | wx.CANCEL | wx.CENTRE, | ||||
textStyle=0, | ||||
textSize=(300, -1), | ||||
size=(400, -1), | ||||
**kwargs, | ||||
): | ||||
wx.Dialog.__init__( | ||||
self, parent=parent, id=wx.ID_ANY, title=caption, size=size, **kwargs | ||||
) | ||||
|
||||
vbox = wx.BoxSizer(wx.VERTICAL) | ||||
|
||||
stline = StaticText(self, id=wx.ID_ANY, label=message) | ||||
vbox.Add(stline, proportion=0, flag=wx.EXPAND | wx.ALL, border=10) | ||||
|
||||
self._dirBrowse = filebrowse.DirBrowseButton( | ||||
parent=self, | ||||
id=wx.ID_ANY, | ||||
labelText=_("Directory:"), | ||||
dialogTitle=_("Choose directory for export"), | ||||
buttonText=_("Browse"), | ||||
startDirectory=os.getcwd(), | ||||
) | ||||
self._dirBrowse.SetValidator( | ||||
GenericValidator( | ||||
condition=self._pathExists, callback=self._pathDoesNotExists | ||||
) | ||||
) | ||||
wx.CallAfter(self._dirBrowse.SetFocus) | ||||
|
||||
vbox.Add( | ||||
self._dirBrowse, | ||||
proportion=0, | ||||
flag=wx.EXPAND | wx.LEFT | wx.RIGHT, | ||||
border=10, | ||||
) | ||||
|
||||
sizer = self.CreateSeparatedButtonSizer(style) | ||||
vbox.Add(sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=10) | ||||
|
||||
self.SetSizerAndFit(vbox) | ||||
self.SetSizeHints(size[0], size[1], -1, -1) | ||||
|
||||
self.Bind(wx.EVT_BUTTON, self.OnPathValidation, self.FindWindow(id=wx.ID_OK)) | ||||
|
||||
def _pathExists(self, path): | ||||
return os.path.exists(path) | ||||
|
||||
def _pathDoesNotExists(self, ctrl): | ||||
GMessage( | ||||
parent=self, | ||||
message=_( | ||||
"RStudio path <{}> doesn't exists. " | ||||
"Set correct path, please.".format(ctrl.GetValue()) | ||||
Check failure on line 2688 in gui/wxpython/gui_core/dialogs.py GitHub Actions / Python Code Quality Checks (ubuntu-22.04)Ruff (INT002)
|
||||
), | ||||
) | ||||
|
||||
def OnPathValidation(self, event): | ||||
if self.Validate() and self.TransferDataFromWindow(): | ||||
if self.IsModal(): | ||||
self.EndModal(wx.ID_OK) | ||||
else: | ||||
self.SetReturnCode(wx.ID_OK) | ||||
self.Show(False) | ||||
|
||||
def GetValue(self): | ||||
return self._dirBrowse.GetValue() | ||||
|
||||
def SetValue(self, value): | ||||
self._dirBrowse.SetValue(value) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update date range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.