diff --git a/Base/Python/slicer/ScriptedLoadableModule.py b/Base/Python/slicer/ScriptedLoadableModule.py index 816c6ef2de4..91d68d2ecff 100644 --- a/Base/Python/slicer/ScriptedLoadableModule.py +++ b/Base/Python/slicer/ScriptedLoadableModule.py @@ -168,7 +168,7 @@ def createHLayout(elements): # edit python source code self.editSourceButton = qt.QPushButton("Edit") self.editSourceButton.toolTip = ("Edit the module's source code. Shift+Click to copy the source code path to the clipboard." - " Default editor can be changed in Python section of Application Settings.") + " The default editor can be changed in the Python section of the Application Settings.") self.editSourceButton.connect('clicked()', self.onEditSource) self.editModuleUiButton = None @@ -227,7 +227,7 @@ def onReloadAndTest(self, **kwargs): def onEditSource(self): filePath = slicer.util.modulePath(self.moduleName) - # On Shift+Click copy the module path instead of opening in editor + # On Shift+Click copy the module path instead of opening it in the editor if slicer.app.keyboardModifiers() == qt.Qt.ShiftModifier: absFilePath = os.path.abspath(filePath) slicer.app.clipboard().setText(absFilePath) @@ -236,15 +236,15 @@ def onEditSource(self): editor = slicer.app.settings().value("Python/Editor") if editor: - # User specified custom editor for .py files + # User specified a custom editor for .py files import subprocess try: - # Use startup environment to avoid Python environment issues with text editors implemented in Python + # Use the startup environment to avoid Python environment issues with text editors implemented in Python subprocess.Popen([editor, filePath], env=slicer.util.startupEnvironment()) except: slicer.util.errorDisplay(f"Failed to open file:\n\n{filePath}\n\nusing editor: {editor}") else: - # User default file association for opening .py file in editor + # Rely on the default file association for opening the .py file qt.QDesktopServices.openUrl(qt.QUrl("file:///" + filePath, qt.QUrl.TolerantMode)) diff --git a/Base/QTGUI/qSlicerSettingsGeneralPanel.cxx b/Base/QTGUI/qSlicerSettingsGeneralPanel.cxx index c01ea0889dd..c15a8c8d111 100644 --- a/Base/QTGUI/qSlicerSettingsGeneralPanel.cxx +++ b/Base/QTGUI/qSlicerSettingsGeneralPanel.cxx @@ -257,7 +257,7 @@ void qSlicerSettingsGeneralPanel::openSlicerRCFile() else { QProcess process; - // Use startup environment to avoid Python environment issues with text editors implemented in Python + // Use the startup environment to avoid Python environment issues with text editors implemented in Python process.setProcessEnvironment(qSlicerApplication::application()->startupEnvironment()); process.setProgram(editor); process.setArguments(QStringList() << slicerRcFileName); diff --git a/Docs/developer_guide/python_faq.md b/Docs/developer_guide/python_faq.md index dbd87c6f54c..c7c9b43547d 100644 --- a/Docs/developer_guide/python_faq.md +++ b/Docs/developer_guide/python_faq.md @@ -298,13 +298,15 @@ See more information in Python documentation: https://docs.python.org/3/tutorial ## How to modify a Python scripted module -If `Developer mode` is enabled in application settings then `Reload and Test` section is displayed at the top of user interface of Python scripted modules. This section contains buttons for convenient editing of the module source code (`.py` file) and user interface (`.ui` file). Clicking the `Edit` button opens the module source code in the program associated with `.py` files, as defined in operating system settings. This behavior can be overridden by specifying a text editor (such as VS Code, Sublime Text, ...) in application settings: `Editor for .py files` in `Python` section. +If `Developer mode` is enabled in the application settings then the `Reload and Test` section is displayed at the top of the user interface of Python scripted modules. This section contains buttons for convenient editing of the module source code (`.py` file) and user interface (`.ui` file). By default, clicking on the `Edit` button opens the module source code in the program associated with `.py` files, as defined in the operating system settings. This behavior can be overridden by specifying a text editor (such as VS Code, Sublime Text, ...) in the application settings: `Editor for .py files` in the `Python` section. +:::{tip} On Windows, VS Code text editor is installed by default at: ```txt C:/Users/YourUserName/AppData/Local/Programs/Microsoft VS Code/Code.exe ``` +::: ## How to include Python modules in an extension