Skip to content

Commit 8201335

Browse files
committed
[pyqgis-console] update help
- shows help at the first launch of the console
1 parent 3a33ceb commit 8201335

File tree

10 files changed

+141
-142
lines changed

10 files changed

+141
-142
lines changed

images/images.qrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
<file>themes/default/console/iconScriptConsole.png</file>
7777
<file>themes/default/console/iconSettingsConsole.png</file>
7878
<file>themes/default/console/iconSextanteConsole.png</file>
79-
<file>themes/default/console/imgHelpConsole.png</file>
80-
<file>themes/default/console/imgHelpDialog.png</file>
81-
<file>themes/default/console/imgHelpMenu.png</file>
79+
<file>themes/default/console/consoleHelp.png</file>
80+
<file>themes/default/console/editorHelp.png</file>
81+
<file>themes/default/console/classBrowserHelp.png</file>
8282
<file>themes/default/console/iconTabEditorConsole.png</file>
8383
<file>themes/default/console/iconNewTabEditorConsole.png</file>
8484
<file>themes/default/console/iconRestoreTabsConsole.png</file>
Loading
41.9 KB
Loading
68.2 KB
Loading
-34.4 KB
Binary file not shown.
-5.49 KB
Binary file not shown.
-7.79 KB
Binary file not shown.

python/console/console.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def show_console():
5050
# set focus to the console so the user can start typing
5151
if _console.isVisible():
5252
_console.activate()
53+
## Shows help on first launch of the console
54+
settings = QSettings()
55+
if settings.value('pythonConsole/contextHelpOnFirstLaunch', True).toBool():
56+
QgsContextHelp.run( "PythonConsole" )
57+
settings.setValue('pythonConsole/contextHelpOnFirstLaunch', QVariant(False))
5358

5459
_old_stdout = sys.stdout
5560
_console_output = None

python/console/console_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def focusInEvent(self, e):
675675
for line in reversed(fileLines):
676676
self.insert(line)
677677
QApplication.restoreOverrideCursor()
678-
self.setModified(True)
678+
self.setModified(False)
679679
self.endUndoAction()
680680

681681
self.parent.tw.listObject(self.parent.tw.currentWidget())
Lines changed: 132 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,94 @@
1-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2-
<html xmlns="http://www.w3.org/1999/xhtml">
3-
<head>
4-
<title>Help Python Console</title>
5-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6-
7-
<style>
8-
body{
9-
font-family: 'Trebuchet MS', sans-serif;
10-
font-size : 12px;
11-
}
12-
#header{
13-
background: #f6f6f6;
14-
border-bottom: 3px solid #000;
15-
width: 100%;
16-
}
17-
#headerTool td{
18-
background: #f6f6f6;
19-
/*width: 100%;*/
20-
}
21-
._titleP {
22-
padding: 5px;
23-
font-size: 15px;
24-
font-weight: bold;
25-
color: #000;
26-
}
27-
._title {
28-
font-size: 20px;
29-
font-weight: bold;
30-
color: #000;
31-
}
32-
</style>
33-
</head>
34-
<body>
35-
<table id="header">
36-
<tr>
1+
<style>
2+
#toolbarConsole td{
3+
background: #f6f6f6;
4+
}
5+
</style>
6+
<h3>Python Console for QGIS</h3>
7+
<a href="#console">Console</a><br>
8+
<a href="#editor">Editor</a><br>
9+
<a href="#settings">Settings</a><br><br>
10+
<table>
11+
<tr>
3712
<td>
38-
<img src="qrc:/images/themes/default/console/imgHelpDialog.png" />
13+
<p align='justify'>
14+
The QGIS Python Console is an interactive shell for the python command executions.
15+
It also has a python file editor that allows you to edit and save your python scripts.
16+
Both console and editor are based on PyQScintilla2 package.<br>
17+
The console is split in two main panes, top and bottom one
18+
resizable by using the horizontal splitter. Output area pane is a widget read-only which
19+
shows the commands output. You can drag and drop or copy and paste text into input area and
20+
execute code snippets from the output pane by selecting some text and clicking on the
21+
<label>Enter selected</label> command from the context menu.
22+
No matter if selected text contains the interpreter prompt (>>>, ...). Input area pane is the interactive
23+
python shell for input commands.<br>To access to the python file editor use the
24+
<label>Show editor</label> button
25+
from the toolbar. The editor allows to edit and save python file and it offers basic functionality
26+
for managing your code (comment and
27+
uncomment code, check syntax, share the code via codepad.org and much more).
28+
</p>
3929
</td>
30+
</tr>
31+
</table>
32+
<a name="console">
33+
<h4>Console</h4>
34+
</a>
35+
<b><i>Main features:</i></b>
36+
<table>
37+
<tr>
4038
<td>
41-
<span class="_title">Python Console for QGIS</span>
42-
</td>
43-
</tr>
44-
</table>
45-
<table>
46-
<tr>
47-
<td>
48-
<p align="justify">
49-
Python Console based on PyQScintilla2.
50-
<br><br>
51-
To access the QGIS environment from this console
52-
use qgis.utils.iface object (instance of QgisInterface class).
53-
To import the class QgisInterface can also use the dedicated
54-
button on the toolbar on the left.
55-
</p>
56-
</td>
57-
</tr>
58-
<tr>
59-
<td><img src="qrc:/images/themes/default/console/imgHelpConsole.png" /></td>
60-
</tr>
61-
<tr>
62-
<td>
63-
<p align="justify">
64-
The console is split in two main panes, output and input areas.
65-
Both are resizable by using the horizontal splitter.
66-
Output area pane is a widget read-only which shows the commands output.
67-
You can drag and drop or copy text into input area
68-
(no matter if selected text contains >>> or ...).
69-
Use 'Share on codepad' from contextual menu for sharing snippets code.
70-
The context menu looks like the image below.
71-
<img src="qrc:/images/themes/default/console/imgHelpMenu.png"><br>
72-
Input area pane is the interactive python shell for input commands.
73-
</p>
74-
</td>
75-
</tr>
76-
</table>
77-
<table id="header">
78-
<tr>
79-
<td>
80-
<span class="_titleP">Features</span>
81-
</td>
82-
</tr>
83-
</table>
84-
<p align="justify">
85-
<ul>
86-
<li>Auto-completion and highlighting syntax for the following APIs:
87-
<ol>
39+
<ul>
40+
<li>Code completion, highlighting syntax and calltips for the following APIs:
41+
<ol>
8842
<li>Python</li>
89-
<li>PyQGIS-master</li>
43+
<li>PyQGIS</li>
9044
<li>PyQt4</li>
9145
<li>QScintilla2</li>
9246
<li>osgeo-gdal-ogr</li>
93-
</ol>
94-
</li>
95-
<br>
96-
<li>CTRL+SPACE to view the auto-completion list.</li>
97-
<br>
98-
<li>CTRL+ALT+SPACE to view the command history list.</li>
99-
<br>
100-
<li>Open QGIS API documentation by typing '_api'.</li>
101-
<br>
102-
<li>Open PyQGIS Cookbook by typing '_pyqgis'.</li>
103-
<br>
104-
<li>Saves the command history by typing '_save' or closing the widget.
105-
This command saves the history command in the file ~/.qgis2/console_history.txt</li>
106-
<br>
107-
<li>Clears the command history by typing <b>_clear</b>.
108-
This command clears the command history from file ~/.qgis2/console_history.txt</li>
109-
<br>
110-
<li>Clears completely command history by typing '_clearAll'.
111-
This command clears completely the command history. It has an irreversible effect.</li>
112-
</ul>
113-
</p>
114-
<table id="header">
115-
<tr>
116-
<td>
117-
<span class="_titleP">Toolbar</span>
47+
</ol>
48+
</li>
49+
<br>
50+
<li><label>Ctrl+Alt+Space</label> to view the auto-completion list.</li>
51+
<br>
52+
<li><label>Ctrl+Shift+Space</label> to view the command history list.</li>
53+
<br>
54+
<li>Execute code snippets with the <label>Enter selected</label> command from output pane.</li>
55+
<br>
56+
<li>Open QGIS API documentation by typing <label>_api</label>.</li>
57+
<br>
58+
<li>Open PyQGIS Cookbook by typing <label>_pyqgis</label>.</li>
59+
<br>
60+
<li>Save and clear the command history accessing from context menu of input pane.
61+
The history will be saved into the file ~/.qgis2/console_history.txt</li>
62+
<br>
63+
</ul>
11864
</td>
119-
</tr>
120-
</table>
121-
<p>The following is a description of the tools in the toolbar:</p>
122-
<table width="100%" border="0" id="headerTool">
65+
<td><img src="qrc:/images/themes/default/console/consoleHelp.png" /></td>
66+
</tr>
67+
</table>
68+
<b><i>Toolbar:</i></b>
69+
<table width="100%" id='toolbarConsole'>
12370
<tr>
12471
<td><img src="qrc:/images/themes/default/console/iconClearConsole.png" /></td>
125-
<td colspan="2">Tool to clear python console</td>
72+
<td colspan="2">Clear python console</td>
12673
</tr>
12774
<tr>
12875
<td><img src="qrc:/images/themes/default/console/iconClassConsole.png" /></td>
129-
<td><img src="qrc:/images/themes/default/console/iconIfaceConsole.png" /></td>
130-
<td>Tool to import iface class</td>
131-
</tr>
132-
<tr>
133-
<td></td>
13476
<td><img src="qrc:/images/themes/default/console/iconSextanteConsole.png" /></td>
135-
<td>Tool to import Sextante class</td>
77+
<td>Import Sextante class</td>
13678
</tr>
13779
<tr>
13880
<td></td>
13981
<td><img src="qrc:/images/themes/default/console/iconQtCoreConsole.png" /></td>
140-
<td>Tool to import PyQt4.QtCore class</td>
82+
<td>Import PyQt4.QtCore class</td>
14183
</tr>
14284
<tr>
14385
<td></td>
14486
<td><img src="qrc:/images/themes/default/console/iconQtGuiConsole.png" /></td>
14587
<td>Tool to import PyQt4.QtGui class</td>
14688
</tr>
147-
<tr>
148-
<td><img src="qrc:/images/themes/default/console/iconScriptConsole.png" /></td>
149-
<td><img src="qrc:/images/themes/default/console/iconOpenConsole.png" /></td>
150-
<td>Tool to open a python script and load in console</td>
151-
</tr>
152-
<tr>
153-
<td></td>
154-
<td><img src="qrc:/images/themes/default/console/iconSaveConsole.png" /></td>
155-
<td>Tool to save a python script</td>
89+
<tr>
90+
<td><img src="qrc:/images/themes/default/console/iconRunConsole.png" /></td>
91+
<td colspan="2">Run command (like Enter key pressed)</td>
15692
</tr>
15793
<tr>
15894
<td><img src="qrc:/images/themes/default/console/iconSettingsConsole.png" /></td>
@@ -162,10 +98,68 @@
16298
<td><img src="qrc:/images/themes/default/console/iconHelpConsole.png" /></td>
16399
<td colspan="2">Help</td>
164100
</tr>
165-
<tr>
166-
<td><img src="qrc:/images/themes/default/console/iconRunConsole.png" /></td>
167-
<td colspan="2">Run command (like Enter key pressed)</td>
168-
</tr>
169-
</table>
170-
</body>
171-
</html>
101+
</table>
102+
<a name="editor">
103+
<h4>Editor</h4>
104+
</a>
105+
<b><i>Main features:</i></b>
106+
<table>
107+
<tr>
108+
<td>
109+
<img src="qrc:/images/themes/default/console/editorHelp.png" />
110+
<img src="qrc:/images/themes/default/console/classBrowserHelp.png" />
111+
</td>
112+
<td>
113+
<ul>
114+
<li>Code completion, highlighting syntax and calltips for the following APIs:
115+
<ol>
116+
<li>Python</li>
117+
<li>PyQGIS</li>
118+
<li>PyQt4</li>
119+
<li>QScintilla2</li>
120+
<li>osgeo-gdal-ogr</li>
121+
</ol>
122+
</li>
123+
<br>
124+
<li><label>Ctrl+Space</label> to view the auto-completion list.</li>
125+
<br>
126+
<li>Sharing code snippets via codepad.org.</li>
127+
<br>
128+
<li><label>Ctrl+4</label> Syntax check.</li>
129+
<br>
130+
<li>Object inspector: a class and function browser.</li>
131+
<br>
132+
<li>Go to an object definition with a mouse click. (from Object inspector)</li>
133+
<br>
134+
<li>Execute code snippets with the <label>Enter selected</label> command.</li>
135+
<br>
136+
<li>Execute the whole script with the <label>Run script</label> command
137+
(this creates a byte-compiled file with the extension .pyc)</li>
138+
<br>
139+
</ul>
140+
</td>
141+
</tr>
142+
</table>
143+
<a name="settings">
144+
<h4>Settings</h4>
145+
</a>
146+
<b><i>Further settings for python console:</i></b>
147+
<ul>
148+
<li><label>Autocompletion:</label> If checked the code completion is enabled. You can get autocompletion
149+
from current document, from installed APIs and both from APIs and current document</li>
150+
<br>
151+
<li><label>Autocompletion threshold:</label> Sets the threshold to display the autocompletion list (in chars typed)</li>
152+
<br>
153+
<li><label>Automatic parentheses insertion:</label> If checked enables the autoclosing for bracket</li>
154+
<br>
155+
<li><label>Auto-save script before running:</label> Allows you to save automatically the
156+
script to be executed in order to avoid to save it after any modification.
157+
This action will store a temporary file into the temporary system directory
158+
that will be automatically deleted after running.</li>
159+
<br>
160+
<li><label>Using preloaded APIs file:</label> You can choose whether use the preload APIs file or load some APIs files saved on your system.</li>
161+
</ul>
162+
<p style='border: 1px solid; background:#f6f6f6;' align='justify'>
163+
<b>Note:</b> To save the state of console's widgets you have to close the Python Console
164+
from the close button. This allows you to save the geometry to be restored to the next start.
165+
</p>

0 commit comments

Comments
 (0)