Skip to content

Provide an easy way to override the Qt widget used by qtconsole #1920

@ccordoba12

Description

@ccordoba12

We at Spyder are developing a better integration with qtconsole for our next release. In the process we found that we need a widget with more functionality than QTextEdit (to add to it our find widget for example). But it seems right now there is no easy way to provide a custom widget instead of it, which has forced us to copy/paste the _create_control method of ConsoleWidget, as can be seen here:

http://code.google.com/p/spyderlib/source/browse/spyderlib/widgets/ipython.py#106

Pierre suggested adding an additional attribute to the class, something like:

self.control_factory 

which could be used like this:

def _create_control(self):
    """ Creates and connects the underlying text widget.
    """
    # Create the underlying control.
    if self.control_factory:
        control = self.control_factory
    elif self.kind == 'plain':
        control = QtGui.QPlainTextEdit()
    elif self.kind == 'rich':
        control = QtGui.QTextEdit()
        control.setAcceptRichText(False)

I'm willing to do the pull request job but I wanted to ask you first what you consider is the best way to proceed. Or in case we are using your API in the wrong way, what would be the right one to achieve what we want?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions