Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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

Carlos Cordoba Fernando Perez Jonathan March Min RK
Carlos Cordoba
  • This will let other project to easily provide its own widgets
  • Try to fix #1920
Carlos Cordoba 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
Carlos Cordoba

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

Fernando Perez
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...

Min RK 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
Min RK 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
Jonathan March
Collaborator

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

Carlos Cordoba ccordoba12 Call custom control variables when creating the widgets
- This better matches how they are normally created
d8c3121
Min RK
Owner

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

Fernando Perez
Owner

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

Jonathan March
Collaborator

Got the ok - thanks @punchagan

Fernando Perez
Owner

Great, thanks! Merging now then.

Fernando Perez fperez merged commit 4abd769 into from
Carlos Cordoba

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. Carlos Cordoba

    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. Carlos Cordoba

    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
15 IPython/frontend/qt/console/console_widget.py
View
@@ -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()
Min RK 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.