Source code for friendlypics2.main

"""Main entry point module for the application"""
import sys
import logging
from qtpy.QtWidgets import QApplication, QPlainTextEdit
from qtpy.QtCore import Qt
from friendlypics2.dialogs.main_window import MainWindow
from friendlypics2.misc.gui_helpers import GuiLogger
from friendlypics2.version import __version__


[docs]def configure_logging(): """Configure the Python logging system for the app Only configures the console based logger""" logging.basicConfig(level=logging.DEBUG)
[docs]def run(args): """Main entrypoint function Args: args (list): command line arguments to be passed to the application Returns: int: return code to report back to the shell with """ configure_logging() # HACK: this next line was needed to silence an odd warning message generated by Qt QApplication.setAttribute(Qt.AA_ShareOpenGLContexts) # Configure our application app = QApplication(args) app.setOrganizationName("The Friendly Coder") app.setOrganizationDomain("https://github.com/TheFriendlyCoder") app.setApplicationName("FriendlyPics2") app.setApplicationVersion(__version__) # Configure our main window window = MainWindow() window.show() # Attach the Python logging system to the GUI log_handler = GuiLogger(window.findChild(QPlainTextEdit, "debug_log")) logging.getLogger().addHandler(log_handler) # Run our app return app.exec_()
if __name__ == "__main__": sys.exit(run(sys.argv))