packages/vaex-ui/vaex/ui/main.py
def main(argv=sys.argv[1:]):
    global main_thread
    global vaex
    global app
    global kernel
    global ipython_console
    global current
    vaex.set_log_level_warning()

    if app is None:
        app = QtGui.QApplication(argv)
        if not (frozen and darwin):  # osx app has its own icon file
            import vaex.ui.icons
            icon = QtGui.QIcon(vaex.ui.icons.iconfile('vaex128'))
            app.setWindowIcon(icon)
    # import vaex.ipkernel_qtapp
    # ipython_window = vaex.ipkernel_qtapp.SimpleWindow(app)
    main_thread = QtCore.QThread.currentThread()

    # print select_many(None, "lala", ["aap", "noot"] + ["item-%d-%s" % (k, "-" * k) for k in range(30)])
    # sys.exit(0)

    # sys._excepthook = sys.excepthook
    def qt_exception_hook(exctype, value, traceback):
        print("qt hook in thread: %r" % threading.currentThread())
        sys.__excepthook__(exctype, value, traceback)
        qt_exception(None, exctype, value, traceback)
        # sys._excepthook(exctype, value, traceback)
        # sys.exit(1)
    sys.excepthook = qt_exception_hook
    vaex.promise.Promise.unhandled = staticmethod(qt_exception_hook)
    # raise RuntimeError, "blaat"

    vaex_app = VaexApp(argv, open_default=True)

    def plot(*args, **kwargs):
        vaex_app.plot(*args, **kwargs)

    def select(*args, **kwargs):
        vaex_app.select(*args, **kwargs)

    """if 1:
        #   app = guisupport.get_app_qt4()
        print_process_id()

        # Create an in-process kernel
        # >>> print_process_id( )
        # will print the same process ID as the main process
        kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel = kernel_manager.kernel
        kernel.gui = 'qt4'
        kernel.shell.push({'foo': 43, 'print_process_id': print_process_id, "vaex_app":vaex_app, "plot": plot, "current": current, "select": select})

        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        def stop():
            kernel_client.stop_channels()
            kernel_manager.shutdown_kernel()
            app.exit()

        ipython_console = RichJupyterWidget()
        ipython_console.kernel_manager = kernel_manager
        ipython_console.kernel_client = kernel_client
        ipython_console.exit_requested.connect(stop)
        #ipython_console.show()

        sys.exit(guisupport.start_event_loop_qt4(app))
    """

    # w = QtGui.QWidget()
    # w.resize(250, 150)
    # w.move(300, 300)
    # w.setWindowTitle('Simple')
    # w.show()
    # ipython_window.show()
    # ipython_window.ipkernel.start()
    sys.exit(app.exec_())
def main(argv=sys.argv[1:]):
    global main_thread
    global vaex
    global app
    global kernel
    global ipython_console
    global current
    vaex.set_log_level_warning()

    if app is None:
        app = QtGui.QApplication(argv)
        if not (frozen and darwin):  # osx app has its own icon file
            import vaex.ui.icons
            icon = QtGui.QIcon(vaex.ui.icons.iconfile('vaex128'))
            app.setWindowIcon(icon)
    # import vaex.ipkernel_qtapp
    # ipython_window = vaex.ipkernel_qtapp.SimpleWindow(app)
    main_thread = QtCore.QThread.currentThread()

    # print select_many(None, "lala", ["aap", "noot"] + ["item-%d-%s" % (k, "-" * k) for k in range(30)])
    # sys.exit(0)

    # sys._excepthook = sys.excepthook
    def qt_exception_hook(exctype, value, traceback):
        print("qt hook in thread: %r" % threading.currentThread())
        sys.__excepthook__(exctype, value, traceback)
        qt_exception(None, exctype, value, traceback)
        # sys._excepthook(exctype, value, traceback)
        # sys.exit(1)
    sys.excepthook = qt_exception_hook
    vaex.promise.Promise.unhandled = staticmethod(qt_exception_hook)
    # raise RuntimeError, "blaat"

    vaex_app = VaexApp(argv, open_default=True)

    def plot(*args, **kwargs):
        vaex_app.plot(*args, **kwargs)

    def select(*args, **kwargs):
        vaex_app.select(*args, **kwargs)

    """if 1:
        #   app = guisupport.get_app_qt4()
        print_process_id()

        # Create an in-process kernel
        # >>> print_process_id( )
        # will print the same process ID as the main process
        kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel = kernel_manager.kernel
        kernel.gui = 'qt4'
        kernel.shell.push({'foo': 43, 'print_process_id': print_process_id, "vaex_app":vaex_app, "plot": plot, "current": current, "select": select})

        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        def stop():
            kernel_client.stop_channels()
            kernel_manager.shutdown_kernel()
            app.exit()

        ipython_console = RichJupyterWidget()
        ipython_console.kernel_manager = kernel_manager
        ipython_console.kernel_client = kernel_client
        ipython_console.exit_requested.connect(stop)
        #ipython_console.show()

        sys.exit(guisupport.start_event_loop_qt4(app))
    """

    # w = QtGui.QWidget()
    # w.resize(250, 150)
    # w.move(300, 300)
    # w.setWindowTitle('Simple')
    # w.show()
    # ipython_window.show()
    # ipython_window.ipkernel.start()
    sys.exit(app.exec_())
if 1:
        #   app = guisupport.get_app_qt4()
        print_process_id()

        # Create an in-process kernel
        # >>> print_process_id( )
        # will print the same process ID as the main process
        kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel = kernel_manager.kernel
        kernel.gui = 'qt4'
        kernel.shell.push({'foo': 43, 'print_process_id': print_process_id, "vaex_app":vaex_app, "plot": plot, "current": current, "select": select})

        kernel_client = kernel_manager.client()
        kernel_client.start_channels()

        def stop():
            kernel_client.stop_channels()
            kernel_manager.shutdown_kernel()
            app.exit()

        ipython_console = RichJupyterWidget()
        ipython_console.kernel_manager = kernel_manager
        ipython_console.kernel_client = kernel_client
        ipython_console.exit_requested.connect(stop)
        #ipython_console.show()

        sys.exit(guisupport.start_event_loop_qt4(app))