def geticonfile(name, package=None): '''Return the icon file path. It is assumed that icon files are located in the "images" subfolder of the package. .. seealso:: :func:`gsdview.utils.getresource` ''' return utils.getresource(os.path.join('images', name), package)
def getuifile(name, package=None): '''Return the ui file path. It is assumed that Qt UI files are located in the "ui" subfolfer of the package. .. seealso:: :func:`gsdview.utils.getresource` ''' return utils.getresource(os.path.join('ui', name), package)
def geticon(name, package=None): '''Build and return requested icon. It is assumed that icon files are located in the "images" subfolder of the package. .. seealso:: :func:`gsdview.utils.getresource` ''' iconfile = utils.getresource(os.path.join('images', name), package) return QtGui.QIcon(iconfile)
def main(): # @IMPORTANT: force numeric locale to 'C' in order to avoid problems # with GDAL and PPROJ4 # @SEEALSO: http://trac.osgeo.org/gdal/wiki/FAQMiscellaneous#DoesGDALworkindifferentinternationalnumericlocales import os os.environ['LC_NUMERIC'] = 'C' args = parse_args() if args.log_level != 'NOTSET': loglevel = logging.getLevelName(args.log_level) else: loglevel = logging.INFO logging.basicConfig( level=loglevel, #format='%(levelname)s: %(message)s') format='%(asctime)s %(name)s %(levelname)s: %(message)s') # set the logging level explicitly on gsdview logger #logging.getLogger().setLevel(loglevel) logging.getLogger('gsdview').setLevel(loglevel) # PyQt loggers logging.getLogger('PyQt5.uic').setLevel(logging.WARNING) log = logging.getLogger(__name__) log.debug('log level set to %s', logging.getLevelName(log.level)) # @TODO: # * config logging using options.configfile, USER_CFG, SYS_CFG # * if options.debug: set rootlogger.level = logging.DEBUG # * maybe set loglevelfor other loggers timer = Timer() # splash screen ######################################################### from qtsix import QtWidgets, QtGui log.debug('Qt import: %d.%06ds', *timer.update()) import sys from gsdview.info import name as NAME from gsdview.info import version as VERSION from gsdview.utils import getresource app = QtWidgets.QApplication(sys.argv) app.setApplicationName(NAME) app.setApplicationVersion(VERSION) pngfile = getresource(os.path.join('images', 'splash.png'), __name__) pixmap = QtGui.QPixmap(pngfile) splash = QtWidgets.QSplashScreen(pixmap) splash.show() app.processEvents() splash_loghandler = SplashLogHandler(splash, app) splash_loghandler.setFormatter(logging.Formatter('%(message)s')) log.addHandler(splash_loghandler) log.info('Splash screen setup completed') log.debug('splash screen setup: %d.%06ds', *timer.update()) # modules loading ####################################################### preload(MODULES, app) # GUI ################################################################### log.info('Build GUI ...') from gsdview.app import GSDView # @TODO: pass plugins_path?? mainwin = GSDView(loglevel=args.log_level) mainwin.show() log.info('GUI setup completed') log.debug('GUI setup: %d.%06ds', *timer.update()) # close splash and run app ############################################## log.removeHandler(splash_loghandler) splash.finish(mainwin) app.processEvents() log.info('Install the exception hook') sys.excepthook = mainwin.excepthook # @TODO: check log.info('Enter main event loop') # @COMPATIBILITY: this will raise the window on Mac OS X mainwin.raise_() sys.exit(app.exec_())