I have developed a fairly complex GUI tool using the Qt Designer.


For more details about the tool see: https://github.com/3fon3fonov/trifon 


The tool has an embedded jupyter shell via the qtconsole. The shell works 
fine and is fully responsive. Unfortunately, if I run some 

heavy task on the jupyter shell, it hangs the GUI untill the job is done. 
In my case some calculations can take hours and in some

extreme cases even days! Any idea how to send the qtconsole to a separate 
thread?


I want to get a "spyder"-like qtconsole experience.


I must add that I successfully de-attach a number of heavy-lifting routines 
within my code using the QtCore.QThreadPool() 

and a Worker Class to handle the tasks. However, every time I try to do 
that with the qtconsole leads to 

different errors and here I am.... I need someone to open my eyes!

The ConsoleWidget_embed() class is defined as:



import sys #,os
from PyQt5 import QtWidgets, QtCore #, QtGui, uic

from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.inprocess import QtInProcessKernelManager
from qtconsole.console_widget import ConsoleWidget


class ConsoleWidget_embed(RichJupyterWidget,ConsoleWidget):
 global fit

 def __init__(self, customBanner=None, *args, **kwargs):
 super(ConsoleWidget_embed, self).__init__(*args, **kwargs)

 if customBanner is not None:
 self.banner = customBanner

 #self.process = QtCore.QProcess(self)

 #self.font_size = 4
 self.kernel_manager = QtInProcessKernelManager()
 self.kernel_manager.start_kernel(show_banner=True)
 self.kernel_manager.kernel.gui = 'qt'
 self.kernel = self.kernel_manager.kernel
 self.kernel_client = self._kernel_manager.client()
 self.kernel_client.start_channels()

 #self.process.start(self.kernel_client.start_channels())

 #self._execute("kernel = %s"%fit, False) 

 def stop():
 self.kernel_client.stop_channels()
 self.kernel_manager.shutdown_kernel()
 self.guisupport.get_app_qt().exit()

 self.exit_requested.connect(stop)


 def push_vars(self, variableDict):
 """
 Given a dictionary containing name / value pairs, push those variables
 to the Jupyter console widget
 """
 self.kernel_manager.kernel.shell.push(variableDict)

 def clear(self):
 """
 Clears the terminal
 """
 self._control.clear()

 # self.kernel_manager

 def print_text(self, text):
 """
 Prints some plain text to the console
 """
 self._append_plain_text(text, before_prompt=True)

 def execute_command(self, command):
 """
 Execute a command in the frame of the console widget
 """
 self._execute(command, False)


if __name__ == "__main__":
 app = QtWidgets.QApplication(sys.argv)
 main = ConsoleWidget_embed()
 main.show()

while I am calling the juputer shell with:
  


def __init__(self):
    global fit

    QtWidgets.QMainWindow.__init__(self)
    Ui_MainWindow.__init__(self)

    self.setupUi(self)

    self.console_widget = ConsoleWidget_embed(font_size = 10)
    self.terminal_embeded.addTab(self.console_widget, "Jupyter")


Thanks!
Trifon

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/75aa0d51-11ea-4232-901d-32a31b61d19d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to