Skip to content

Commit

Permalink
STYLE: Fix wording in comments
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
  • Loading branch information
lassoan and jcfr committed Jul 9, 2023
1 parent 44a5f63 commit 799ebba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Base/Python/slicer/ScriptedLoadableModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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))


Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerSettingsGeneralPanel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Docs/developer_guide/python_faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 799ebba

Please sign in to comment.