Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add custom_control and custom_page_control variables to override the Qt widgets used by qtconsole #2007

Merged
merged 2 commits into from

4 participants

@ccordoba12
  • This will let other project to easily provide its own widgets
  • Try to fix #1920
@ccordoba12 ccordoba12 Add custom_control and custom_page_control variables to override the …
…Qt widgets used by qtconsole

- This will let other project to easily provide its own widgets
- Try to fix #1920
6173df6
@ccordoba12

@fperez, I tried this approach in conjunction with Spyder and it works great, letting us easily use our subclass of QTextEdit.

@fperez
Owner

Great, thanks for the report. @jdmarch, @epatters, since Enthought is likely the largest consumer of the Qt code, I'd like to make sure it doesn't cause any headaches for your gang before proceeding further...

@minrk minrk commented on the diff
IPython/frontend/qt/console/console_widget.py
@@ -989,7 +996,9 @@ def _create_control(self):
""" Creates and connects the underlying text widget.
"""
# Create the underlying control.
- if self.kind == 'plain':
+ if self.custom_control:
+ control = self.custom_control
@minrk Owner
minrk added a note

Shouldn't this be a callable? control = self.custom_control()

I was planning to use it as: self.custom_control = SpyderControlWidget() but I think you're right. It would better match how you create control in the next line. I'm going to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jdmarch

Looks fine to me. Handing it on to bleeding edgers for a look as well.

@ccordoba12 ccordoba12 Call custom control variables when creating the widgets
- This better matches how they are normally created
d8c3121
@minrk
Owner

This looks fine to me now, so when we get one more OK from @jdmarch's beeding edgers, it's ready to go.

@fperez
Owner

Targeting for 0.13 then, @jdmarch let us know how things go so we can squeeze this one in before release.

@jdmarch

Got the ok - thanks @punchagan

@fperez
Owner

Great, thanks! Merging now then.

@fperez fperez merged commit 4abd769 into ipython:master
@ccordoba12

Thanks guys for your support and to Enthought guys for giving their OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 22, 2012
  1. @ccordoba12

    Add custom_control and custom_page_control variables to override the …

    ccordoba12 authored
    …Qt widgets used by qtconsole
    
    - This will let other project to easily provide its own widgets
    - Try to fix #1920
Commits on Jun 24, 2012
  1. @ccordoba12

    Call custom control variables when creating the widgets

    ccordoba12 authored
    - This better matches how they are normally created
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 2 deletions.
  1. +13 −2 IPython/frontend/qt/console/console_widget.py
View
15 IPython/frontend/qt/console/console_widget.py
@@ -158,6 +158,13 @@ def _font_family_default(self):
# widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take
# priority (when it has focus) over, e.g., window-level menu shortcuts.
override_shortcuts = Bool(False)
+
+ # ------ Custom Qt Widgets -------------------------------------------------
+
+ # For other projects to easily override the Qt widgets used by the console
+ # (e.g. Spyder)
+ custom_control = None
+ custom_page_control = None
#------ Signals ------------------------------------------------------------
@@ -989,7 +996,9 @@ def _create_control(self):
""" Creates and connects the underlying text widget.
"""
# Create the underlying control.
- if self.kind == 'plain':
+ if self.custom_control:
+ control = self.custom_control()
@minrk Owner
minrk added a note

Shouldn't this be a callable? control = self.custom_control()

I was planning to use it as: self.custom_control = SpyderControlWidget() but I think you're right. It would better match how you create control in the next line. I'm going to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ elif self.kind == 'plain':
control = QtGui.QPlainTextEdit()
elif self.kind == 'rich':
control = QtGui.QTextEdit()
@@ -1026,7 +1035,9 @@ def _create_control(self):
def _create_page_control(self):
""" Creates and connects the underlying paging widget.
"""
- if self.kind == 'plain':
+ if self.custom_page_control:
+ control = self.custom_page_control()
+ elif self.kind == 'plain':
control = QtGui.QPlainTextEdit()
elif self.kind == 'rich':
control = QtGui.QTextEdit()
Something went wrong with that request. Please try again.