<gh_stars>1-10
from    qtconsole.rich_ipython_widget   import  RichJupyterWidget
from    qtconsole.inprocess             import  QtInProcessKernelManager


class QIPythonWidget(RichJupyterWidget):
    ''' Convenience class for a live IPython console widget. 
        We can replace the standard banner using the customBanner argument
    '''
    def __init__(self, customBanner=None, *args, **kwargs):
        super(QIPythonWidget, self).__init__(*args, **kwargs)

        # Set customized banner
        if customBanner!=None: 
            self.banner=customBanner

        # Define kernel and launch kernel
        self.kernel_manager = kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel_manager.kernel.gui = 'qt'
        
        # Define user and start channel
        self.kernel_client = kernel_client = self.kernel_manager.client()
        kernel_client.start_channels()
        
        # Connect stop signal
        self.exit_requested.connect(self.stop)
   
    def stop(self):
        ''' Stop console
        '''
        self.kernel_client.stop_channels()
        self.kernel_manager.shutdown_kernel()
 
    def pushVariables(self, variableDict):
        ''' Given a dictionary containing name / value pairs, 
            push those variables to the IPython console widget.
        '''
        self.kernel_manager.kernel.shell.push(variableDict)
    
    def clearTerminal(self):
        ''' Clears the terminal
        '''
        self._control.clear()    
    
    def printText(self, text):
        ''' Prints text to the console
        '''
        self._append_plain_text(text)        
    
    def executeCommand(self, command):
        ''' Execute a command in the frame of the console widget
        '''
        self._execute(command, False)

from    qtconsole.rich_ipython_widget   import  RichJupyterWidget
from    qtconsole.inprocess             import  QtInProcessKernelManager


class QIPythonWidget(RichJupyterWidget):
    ''' Convenience class for a live IPython console widget. 
        We can replace the standard banner using the customBanner argument
    '''
    def __init__(self, customBanner=None, *args, **kwargs):
        super(QIPythonWidget, self).__init__(*args, **kwargs)

        # Set customized banner
        if customBanner!=None: 
            self.banner=customBanner

        # Define kernel and launch kernel
        self.kernel_manager = kernel_manager = QtInProcessKernelManager()
        kernel_manager.start_kernel()
        kernel_manager.kernel.gui = 'qt'
        
        # Define user and start channel
        self.kernel_client = kernel_client = self.kernel_manager.client()
        kernel_client.start_channels()
        
        # Connect stop signal
        self.exit_requested.connect(self.stop)
   
    def stop(self):
        ''' Stop console
        '''
        self.kernel_client.stop_channels()
        self.kernel_manager.shutdown_kernel()
 
    def pushVariables(self, variableDict):
        ''' Given a dictionary containing name / value pairs, 
            push those variables to the IPython console widget.
        '''
        self.kernel_manager.kernel.shell.push(variableDict)
    
    def clearTerminal(self):
        ''' Clears the terminal
        '''
        self._control.clear()    
    
    def printText(self, text):
        ''' Prints text to the console
        '''
        self._append_plain_text(text)        
    
    def executeCommand(self, command):
        ''' Execute a command in the frame of the console widget
        '''
        self._execute(command, False)
Convenience class for a live IPython console widget.          We can replace the standard banner using the customBanner argument # Set customized banner # Define kernel and launch kernel # Define user and start channel # Connect stop signal Stop console Given a dictionary containing name / value pairs,              push those variables to the IPython console widget. Clears the terminal Prints text to the console Execute a command in the frame of the console widget