import os import sys import datetime import logging import pprint def format_now(): return datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S') os.environ['ECD_BASEDIR'] = os.path.join( os.path.dirname(__file__)) if os.path.exists(os.path.join(os.path.dirname(__file__), 'share')): os.environ['PROJ_LIB'] = os.path.join(os.path.dirname(__file__), 'share/proj') os.environ['GDAL_DATA'] = os.path.join(os.path.dirname(__file__), 'share') BASE_DIR = os.path.join( os.path.dirname(__file__)) os.makedirs(os.path.join(BASE_DIR, 'logs'), exist_ok=True) logging.basicConfig(level=logging.INFO, filename=os.path.join(BASE_DIR, 'logs', format_now() + '_log.txt'), filemode='a', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logging.info('sys path :' + pprint.pformat(sys.path)) logging.info('os.environ :' + pprint.pformat(os.environ)) import time from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont, QPixmap from PyQt5.QtWidgets import QSplashScreen, QProgressBar, QStyleFactory, QMessageBox from qgis.core import QgsApplication # from qgis.core import from rscder.gui.mainwindow import MainWindow from rscder.gui import license from rscder.utils.setting import Settings import os class MulStart: def __init__(self, **kargs) -> None: super(MulStart, self).__init__() self.kargs = kargs def run(self): app = QgsApplication([], True) QgsApplication.setPrefixPath('qgis', True) QgsApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QgsApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) QgsApplication.setOrganizationName("ImgSciGroup") QgsApplication.setApplicationName("Easy Change Detection") QgsApplication.setApplicationVersion("v0.0.1") QgsApplication.setFont(QFont("Segoe UI", 10)) QgsApplication.setStyle(QStyleFactory.create("Fusion")) # pyrcc5 res.qrc -o rc.py # import rscder.rc QgsApplication.initQgis() while not Settings.General().license: QMessageBox.warning(None, "Warning", "Please select a license file.") if(license.License().exec_() == license.License.Accepted): continue else: sys.exit(0) # Create and display the splash screen splash_pix = QPixmap(os.path.join(BASE_DIR, "./icons/splash.png")) # splash_pix.scaledToWidth(800) # splash_pix.scaledToHeight(600) splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) # splash # splash.setFixedSize(800, 600) progressBar = QProgressBar(splash) progressBar.setMaximum(10) progressBar.setTextVisible(False) progressBar.setGeometry(106, splash_pix.height() - 60, splash_pix.width()-212, 10) splash.show() for i in range(1, 11): progressBar.setValue(i) t = time.time() while time.time() < t + 0.05: app.processEvents() ex = MainWindow(**self.kargs) # ex.canvas.load_image(r'data\100001678.jpg') # ex.canvas.load_result_from_txt(r'data\100001678.txt') # ex.showMaximized() ex.show() splash.finish(ex) sys.exit(app.exec_()) def main(): # print(sys.path) t = MulStart() t.run() if __name__ == '__main__': main()