2.7.3.1: Step 1

2.7.3.1: Step 1 mrs110

We start by importing the different packages of the Python standard library and PyQt6 that we will need in this project. In addition, we import the gui_main.py and gui_newshapefile.py files so that the Ui_MainWindow and Ui_Dialog classes defined in them are available for creating the GUIs of the main window and dialog for creating a new shapefile, and of course the core_functions module.

We are not importing arcpy here because we want the tool to be usable even when arcpy is not available and that is why we defined the auxiliary function for testing its availability in core_functions.py. In addition, we are including some comments to define sections within the script for different purposes. We will fill in the code for these sections step-by-step in the following steps. At the very end, we already have the by-now-familiar code for showing the main window and starting the event processing loop of our application (even though we are not creating the application and main window objects yet).

import sys, csv

from PyQt6.QtWidgets import QApplication, QMainWindow, QStyle, QFileDialog, QDialog, QMessageBox, QSizePolicy
from PyQt6.QtGui import QStandardItemModel, QStandardItem,  QDoubleValidator, QIntValidator
from PyQt6.QtCore import Qt

from PyQt6.QtWebEngineWidgets import QWebEngineView as WebMapWidget

import gui_main
import gui_newshapefile
import core_functions

# =======================================
# GUI event handler and related functions
# =======================================

if __name__ == '__main__':
    #==========================================
    # create app and main window + dialog GUI
    # =========================================

    #==========================================
    # connect signals
    #==========================================

    #==================================
    # initialize global variables
    #==================================

    #============================================
    # test availability and if run as script tool
    #============================================

    #=======================================
    # run app
    #=======================================
    mainWindow.show()
    sys.exit(app.exec())