-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Python console interactive help #58962
base: master
Are you sure you want to change the base?
Conversation
Nice work @YoannQDQ !!
Is there a compelling reason we'd want to use C++ now? In the last month the PyQGIS docs.have greatly improved, and I'd argue they are at least as good as the C++ ones now...
This is the right call for the qt docs 👍 |
This is great! |
Out of habit, I mostly read the C++ API doc myself, but I'm completely willing to letting it go. Should it also be removed from the help menu?
I took it from QtCreator, but if it doesn't feel right, we can ditch it. I'd appreciate some more feedback on this. |
d1bdd2b
to
b8bd03c
Compare
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
03fbd6e
to
26aaf49
Compare
206dcfb
to
c85d82c
Compare
Just curious, what QtCreator version is this in? On my 13.0.2 the hovered item is ignored, and it makes perfect sense for me as the mouse cursor may be anywhere when navigating with the keyboard! |
It's an ancient version of qt creator that we keep using on a specific project for ungodly reasons... Namely QtCreator 4.11. This behavior has indeed disappeared in later versions. |
@nyalldawson The "search" function of the PyQGIS documentation works with QWebEngineView. Are there any plan to make it available in C++? Maybe integrate it to QgsWebView? |
We should just be able to use the QWebEngineView class directly, without any need for a Qgs wrapper class. We'd just need to conditionally use it only in |
c85d82c
to
3781162
Compare
3781162
to
5057238
Compare
Thanks for the review! I also added the conditional QWebEngineView include. |
4789e4b
to
f2e5f90
Compare
f208a81
to
5978cbc
Compare
5978cbc
to
a2c9374
Compare
@nyalldawson Would it be possible to merge this now? |
Sorry, was off last week with FOSS4G Oceania ... it's going to take me a bit of time to catch back up on QGIS work now 😆 |
This pull request has been tagged for the changelog.
You can edit the description. Format available for credits
Thank you! |
@YoannQDQ A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged. Please update the description (not the comments) with helpful description and screenshot to help the work from documentors. Thank you! |
Description
Add a shortcut in python editors to open the API
When pressing F1, open the API page matching
Behavior is slighltly different for the Python Console (and editors) and for the others generic QgsCodeEditorPython (e.g Expression Editor).
Generic editors
This PR only improves the already existing "Search in PyQGIS Documentation" action in the context menu to add the F1 shortcut and the word under mouse logic. Besides, if the text hovered matches a Qt class name, the Qt API is opened at the correct page. PyQGIS documentation urls cannot be deduced from the class name only as they also include the module name, so pressing F1 will only search the PyQGIS documentation.
Python console (where the PR truly shines)
Add a widget in the devtools panel to display the API documentation (PyQGIS and Qt)
The buttons at the top of the widget access the home pages of the APIs.
The button at the top right opens the current URL in the system web browser
When pressing F1 while hovering a symbol on the Python Console or Editors tab, the object is evaluated to get its class and module. The relevant API (PyQGIS or Qt) is then opened at the correct page. It works for class names, class, or even objects
Consider the following snippet:
Let's say the active layer is a vector layer. With the text cursor at the following words, pressing F1 will
myLayer
: open the PyQGIS api page for QgsVectorLayer.iface
: open the PyQGIS api page for QgisInterface.If the symbol is not recognized, open the PyQGIS API home page.
Settings
Demo