By Jochen Schwarze


2019-04-15 10:09:07 8 Comments

I would like to add a menu entry in the Help menu pointing to some web ressource, say https://gis.stackexchange.com. The following code executed from the python console works perfect:

from qgis.utils import iface
import webbrowser

def open_gis_se():
    webbrowser.open('https://gis.stackexchange.com')

iface.helpMenu().addSeparator()

gis_se_action = QAction('Go to gis.stackexchange')
iface.helpMenu().addAction(gis_se_action)
gis_se_action.triggered.connect(open_gis_se)

Result when typed in the python console:

enter image description here

... but putting it into my startup.py has no effect (Help menu remains 'as it is').

In QGIS 2, the above code put in the startup.py adds the desired menu entry as expected.

Why?

1 comments

@Fran Raga 2019-04-15 10:20:42

Great idea

you need place startup.py in C:\Users\<username>\AppData\Roaming\QGIS\QGIS3 and add missing import ,and voilá

from qgis.utils import iface
from PyQt5.QtWidgets import QAction
import webbrowser

def open_gis_se():
    webbrowser.open('https://gis.stackexchange.com')

iface.helpMenu().addSeparator()

gis_se_action = QAction('Go to gis.stackexchange')
iface.helpMenu().addAction(gis_se_action)
gis_se_action.triggered.connect(open_gis_se)

enter image description here

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] How to resolve QGIS 3 syntax error from processing.algorithmHelp?

2 Answered Questions

1 Answered Questions

[SOLVED] How to add an existing QGSVectorLayer to QGIS project?

  • 2019-03-06 12:48:57
  • Ian Turton
  • 100 View
  • 5 Score
  • 1 Answer
  • Tags:   qgis-3 pyqgis-3

0 Answered Questions

QGIS Processing Script to Create and Add CSV Layer

0 Answered Questions

QGIS 3.6 menu bar missing

1 Answered Questions

Writing pyQGIS 3 script to modify layer (add field and feel it) inside QGIS?

2 Answered Questions

[SOLVED] How to add a rownumber in QGIS 3 using Python

1 Answered Questions

[SOLVED] QGIS "Raster->Georeference" menu item not showing up

2 Answered Questions

[SOLVED] Finding help for QGIS 3.0?

1 Answered Questions

[SOLVED] QGIS 3.0 (from OSGeo4W Installer) unusable on HiRes Displays?

  • 2018-02-27 10:41:53
  • Jochen Schwarze
  • 72 View
  • 6 Score
  • 1 Answer
  • Tags:   gui qgis-3

Sponsored Content