Skip to content
This repository

BUG: Completion widget position and pager focus. #862

Closed
wants to merge 1 commit into from

2 participants

Prabhu Ramachandran Fernando Perez
Prabhu Ramachandran

When the console widget is used with gui-completion, the positioning of
the completion widget was incorrect the first time a completion was
performed since the size of the widget is initially bogus. Using
sizeHint fixes this. If the paging mode is set to vsplit/hsplit, the
focus was lost after the pager is quit.

Prabhu Ramachandran BUG: Completion widget position and pager focus.
When the console widget is used with gui-completion, the positioning of
the completion widget was incorrect the first time a completion was
performed since the size of the widget is initially bogus.  Using
sizeHint fixes this.  If the paging mode is set to vsplit/hsplit, the
focus was lost after the pager is quit.
4f11d31
Fernando Perez
Owner

Note: I can't reproduce the two problems you describe in my limited testing with PyQt. Perhaps the first is a function of window size/position on the desktop or size of the completion list itself. As for the second, I have no idea why I don't see the problem.

Having said that, I also don't see any problems with the code itself, and the explicit focus reset can't hurt even for those users who weren't seeing the problem. So I'm merging now, many thanks for the contribution!

Fernando Perez
Owner

Merged (with rebase to avoid a recursive merge for just one commit), pushed.

Fernando Perez fperez closed this October 13, 2011
Prabhu Ramachandran

The first seems to occur when the console is embedded into another application and can be triggered if the console is too close to the bottom of the screen. The second occurs when you have other widgets along with the console (only then would a loss of focus become painfully obvious). I guess I should have created a simple standalone app to demonstrate this. Thanks for merging regardless though, much appreciated!

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

Showing 1 unique commit by 1 author.

Oct 12, 2011
Prabhu Ramachandran BUG: Completion widget position and pager focus.
When the console widget is used with gui-completion, the positioning of
the completion widget was incorrect the first time a completion was
performed since the size of the widget is initially bogus.  Using
sizeHint fixes this.  If the paging mode is set to vsplit/hsplit, the
focus was lost after the pager is quit.
4f11d31
This page is out of date. Refresh to see the latest.
5  IPython/frontend/qt/console/completion_widget.py
@@ -86,10 +86,11 @@ def show_items(self, cursor, items):
86 86
         text_edit = self._text_edit
87 87
         point = text_edit.cursorRect(cursor).bottomRight()
88 88
         point = text_edit.mapToGlobal(point)
  89
+        height = self.sizeHint().height()
89 90
         screen_rect = QtGui.QApplication.desktop().availableGeometry(self)
90  
-        if screen_rect.size().height() - point.y() - self.height() < 0:
  91
+        if screen_rect.size().height() - point.y() - height < 0:
91 92
             point = text_edit.mapToGlobal(text_edit.cursorRect().topRight())
92  
-            point.setY(point.y() - self.height())
  93
+            point.setY(point.y() - height)
93 94
         self.move(point)
94 95
 
95 96
         self._start_position = cursor.position()
1  IPython/frontend/qt/console/console_widget.py
@@ -1261,6 +1261,7 @@ def _event_filter_page_keypress(self, event):
1261 1261
         elif key in (QtCore.Qt.Key_Q, QtCore.Qt.Key_Escape):
1262 1262
             if self._splitter:
1263 1263
                 self._page_control.hide()
  1264
+                self._control.setFocus()
1264 1265
             else:
1265 1266
                 self.layout().setCurrentWidget(self._control)
1266 1267
             return True
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.