0

I'm following a tutorial, trying to use startup.py to change the main window title at startup and when new projects are opened. My code works in every circumstance (that I've checked), except when clicking on the New Empty Project option in the Project Templates section of the QGIS home.

enter image description here

from qgis.utils import iface
from qgis.core import QgsExpressionContextUtils

def customize():
    version = QgsExpressionContextUtils.globalScope().variable('qgis_version')
    title = 'QGIS'
    iface.mainWindow().setWindowTitle('{} | {}'.format(title, version))
    
iface.initializationCompleted.connect(customize)
iface.newProjectCreated.connect(customize)
iface.projectRead.connect(customize)

What signal is emitted when the new project is created from a template? There are no other relevant QgisInterface signals that I can see.

I believe this is related to this question, but that question has no answers.

I also tried using the customVariablesChanged signal based on the answer to this question but it has no effect when opening the template.

1 Answer 1

0

Should be newProject: "Start a blank project".

1
  • newProject produces an error on startup iface.newProject.connect(customize) AttributeError: 'builtin_function_or_method' object has no attribute 'connect'
    – GlenS
    Commented Aug 15, 2023 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.