Skip to content
This repository

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

Merged
merged 2 commits into from almost 2 years ago

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 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
fperez commented June 22, 2012

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 June 23, 2012
IPython/frontend/qt/console/console_widget.py
@@ -989,7 +996,9 @@ def _create_control(self):
989 996
         """ Creates and connects the underlying text widget.
990 997
         """
991 998
         # Create the underlying control.
992  
-        if self.kind == 'plain':
  999
+        if self.custom_control:
  1000
+            control = self.custom_control
2
Min RK Owner
minrk added a note June 23, 2012

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

Carlos Cordoba
ccordoba12 added a note June 23, 2012

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 Call custom control variables when creating the widgets
- This better matches how they are normally created
d8c3121
Min RK
Owner
minrk commented June 23, 2012

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
fperez commented June 24, 2012

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
fperez commented June 25, 2012

Great, thanks! Merging now then.

Fernando Perez fperez merged commit 4abd769 into from June 25, 2012
Fernando Perez fperez closed this June 25, 2012
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

Showing 2 unique commits by 1 author.

Jun 22, 2012
Carlos Cordoba 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
Jun 23, 2012
Carlos Cordoba Call custom control variables when creating the widgets
- This better matches how they are normally created
d8c3121
This page is out of date. Refresh to see the latest.
15  IPython/frontend/qt/console/console_widget.py
@@ -158,6 +158,13 @@ def _font_family_default(self):
158 158
     # widget (Ctrl+n, Ctrl+a, etc). Enable this if you want this widget to take
159 159
     # priority (when it has focus) over, e.g., window-level menu shortcuts.
160 160
     override_shortcuts = Bool(False)
  161
+    
  162
+    # ------ Custom Qt Widgets -------------------------------------------------
  163
+    
  164
+    # For other projects to easily override the Qt widgets used by the console
  165
+    # (e.g. Spyder)
  166
+    custom_control = None
  167
+    custom_page_control = None
161 168
 
162 169
     #------ Signals ------------------------------------------------------------
163 170
 
@@ -989,7 +996,9 @@ def _create_control(self):
989 996
         """ Creates and connects the underlying text widget.
990 997
         """
991 998
         # Create the underlying control.
992  
-        if self.kind == 'plain':
  999
+        if self.custom_control:
  1000
+            control = self.custom_control()
  1001
+        elif self.kind == 'plain':
993 1002
             control = QtGui.QPlainTextEdit()
994 1003
         elif self.kind == 'rich':
995 1004
             control = QtGui.QTextEdit()
@@ -1026,7 +1035,9 @@ def _create_control(self):
1026 1035
     def _create_page_control(self):
1027 1036
         """ Creates and connects the underlying paging widget.
1028 1037
         """
1029  
-        if self.kind == 'plain':
  1038
+        if self.custom_page_control:
  1039
+            control = self.custom_page_control()
  1040
+        elif self.kind == 'plain':
1030 1041
             control = QtGui.QPlainTextEdit()
1031 1042
         elif self.kind == 'rich':
1032 1043
             control = QtGui.QTextEdit()
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.