Example #1
0
def main():
    app = QApplication(sys.argv)

    if len(sys.argv) > 1:
        config.app_dir = sys.argv[1]

    if os.path.exists(config.config_path):
        # User is already registered

        config.load()

        dialog = LoginDialog()

        if dialog.exec() != 1:
            print("Error: failed to login user\n"
                  "Will exit the program!",
                  file=sys.stderr)
            sys.exit(1)

        # Get registered client
        client = dialog.client

    else:
        # User needs to register first

        # Present the user with the register dialog
        dialog = RegisterDialog()

        if dialog.exec() != 1:
            print("Error: failed to register user\n"
                  "Will exit the program!",
                  file=sys.stderr)
            sys.exit(1)

        # Get registered client
        client = dialog.client

    window = MainWindow(client)
    window.refresh()
    window.adjustSize()
    window.show()
    sys.exit(app.exec_())