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)
def comp(): d = proc(stack, p) def cb(): dataset.updateStack(index, d) mainwin.get().showMessage("Complete") app.get().asyncio_loop().call_soon_threadsafe(cb)
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)
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()
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)
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)
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()
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
def log(msg): app.get().asyncio_loop().call_soon_threadsafe(mainwin.get().showMessage, msg)
def appexit(): app.get().exit()