Demo entry 6685063

Python

   

Submitted by anonymous on Dec 18, 2017 at 13:44
Language: Python. Code size: 781 Bytes.

#Create project folder

import os
from PyQt4.QtGui import QAction
from PyQt4.QtCore import *

folder_name = "\qgis_project"
folder_directory = "C:\Users\User\Downloads"

#Create folder path
folder = folder_directory + folder_name

#Create a folder if it doesn't exist yet. 
if not os.path.isdir(folder):
    os.makedirs(folder)
else:
    print "This foldername already exist."

project_file = "\\temp_project.qgs"
project_directory = folder + project_file
f = QFileInfo(project_directory)
project = QgsProject.instance()

#create a project file
if not os.path.isdir(project_directory):
    project.write(f)
    iface.mainWindow().findChild( QAction, 'mActionSaveProject' ).trigger()
else:
    print "This project file already exist."
    

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).