Exemplo n.º 1
0
    def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super().__init__(parent=parent, flags=flags)

        self._jupyter_widget = make_jupyter_widget_with_kernel()
        # self._jupyter_widget.hide()
        self.setCentralWidget(self._jupyter_widget)
        app.get().aboutToQuit.connect(self.shutdown_kernel)

        self.statusBar()

        self.toolBarFile = QToolBar(self)

        # def resizeHeight(wdg, height) :
        #     size = wdg.size()
        #     size.setHeight(height)
        #     wdg.resize(size)

        # def showjw() :
        #     if not self._jupyter_widget.isVisible() or self._jupyter_widget.isMinimized() :
        #         self.showNormal()
        #         self._jupyter_widget.raise_()
        #     else:
        #         self._jupyter_widget.hide()

        ctb = self.toolBarFile.addAction("Console")
        ctb.setIcon(imagect.icon("console.png"))
        self.addToolBar(self.toolBarFile)

        self.resize(600, 600)
Exemplo n.º 2
0
            def comp():
                d = proc(stack, p)

                def cb():
                    dataset.updateStack(index, d)
                    mainwin.get().showMessage("Complete")

                app.get().asyncio_loop().call_soon_threadsafe(cb)
Exemplo n.º 3
0
        def comp():
            if not ParaKlass:
                d = proc(stack)
            else:
                d = proc(stack, p)

            # update ui
            def cb():
                dataset.updateCurrentStack(d)
                mainwin.get().showMessage("Complete")

            app.get().asyncio_loop().call_soon_threadsafe(cb)
Exemplo n.º 4
0
        def proc_data(p):
            def comp():
                d = proc(stack, p)

                def cb():
                    dataset.updateStack(index, d)
                    mainwin.get().showMessage("Complete")

                app.get().asyncio_loop().call_soon_threadsafe(cb)

            if config.RUN_THREAD:
                app.get().asyncio_loop().run_in_executor(
                    app.get().threadpool(), comp)
            else:
                comp()
Exemplo n.º 5
0
 def save(self):
     """
     save
     """
     datadir = app.get().appDataDir()
     os.makedirs(datadir, exist_ok=True)
     filepath = os.path.join(datadir, Recent._filename)
     with open(filepath, mode="wb") as outfile:
         pickle.dump(self._files, outfile, pickle.HIGHEST_PROTOCOL)
Exemplo n.º 6
0
 def load(self):
     """
     load file list from file
     """
     datadir = app.get().appDataDir()
     filepath = os.path.join(datadir, Recent._filename)
     if os.path.exists(filepath):
         with open(filepath, mode="rb") as infile:
             self._files = pickle.load(infile)
Exemplo n.º 7
0
    def fun():

        ret = False

        # 如果有参数模板
        if ParaKlass:
            p = ParaKlass()
            ret = p.configure_traits(kind="modal")

            # 给定参数模板,但被用户放弃
            if not ret:
                return

        vm = vmm.get()
        v = vm.currentView()
        dataset = vm.currentDataSet()
        stack = vm.currentStack().copy()

        mainwin.get().showMessage("Running")

        def comp():
            if not ParaKlass:
                d = proc(stack)
            else:
                d = proc(stack, p)

            # update ui
            def cb():
                dataset.updateCurrentStack(d)
                mainwin.get().showMessage("Complete")

            app.get().asyncio_loop().call_soon_threadsafe(cb)

        if config.RUN_THREAD:
            app.get().asyncio_loop().run_in_executor(app.get().threadpool(),
                                                     comp)
        else:
            comp()
Exemplo n.º 8
0
def make_jupyter_widget_with_kernel():
    """
    Start a kernel, connect to it, and create a RichJupyterWidget to use it
    """
    kernel_manager = QtInProcessKernelManager(kernel_name='python3')
    kernel_manager.start_kernel(show_banner=True)
    kernel = kernel_manager.kernel
    kernel.io_loop = app.get().asyncio_loop()

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

    jupyter_widget = RichJupyterWidget(gui_completion="droplist")
    jupyter_widget.kernel_manager = kernel_manager
    jupyter_widget.kernel_client = kernel_client
    return jupyter_widget
Exemplo n.º 9
0
def log(msg):
    app.get().asyncio_loop().call_soon_threadsafe(mainwin.get().showMessage,
                                                  msg)
Exemplo n.º 10
0
def appexit():
    app.get().exit()