Skip to content
This repository

minor improvements to text placement in qtconsole #1053

Merged
merged 1 commit into from over 2 years ago

3 participants

Min RK Fernando Perez Prabhu Ramachandran
Min RK
Owner
  • allow before_prompt=True behavior to have effect during raw_input
  • append 'cannot restart' message before the prompt, so it doesn't get mixed up with input.

This isn't quite there yet. A known issue - subsequent prints during raw_input are inserted above the previous print, rather than below. While these messages do not get into the input area, they can still prevent raw_input from accepting Enter for submission or Esc for clearing. I presume the issue is simply improperly updating the prompt cursor location during raw input.

A background printer, to get stdout coming at peculiar times during input:

import threading
def printer():
    while True:
        time.sleep(1)
        print time.time()
t = threading.Thread(target=printer)
t.start()

This branch is ipython-owned, so people with more qtconsole knowledge (e.g. @epatters) are welcome to commit the parts I'm missing.

Min RK minor improvements to text placement in qtconsole
* allow `before_prompt=True` behavior to have effect during raw_input
* append 'cannot restart' message before the prompt, so it doesn't
  get mixed up with input.
ae00bad
Fernando Perez
Owner

This one is tied to #993, which it should help a lot with. It's definitely one of our remaining key issues before we can put 0.12 out, so any help will be greatly appreciated. Pinging @prabhuramachandran who recently contributed some improvements to the Qt code, in case you have some insights. As explained in #993, it's really easy right now to 'wedge' the qt console when taking raw input from the user, such as is the case during %debug sessions.

This PR already massively improves things, so if nothing else we'll merge it as-is. But it would be great if folks with better understanding of the Qt code spot ways to improve the situation.

@Carreau, you might also have some ideas, given your recent work on the console.

In any case, I'm just trying to ping anyone who can help us out :)

Prabhu Ramachandran

I'm afraid, with SciPy.in coming up this weekend plus end of semester craziness, I simply don't have the bandwidth to give you any sensible comments at this point. :(

Fernando Perez
Owner

No worries, Prabhu, totally understood. Have a great time at Scipy.In!

BTW, if you or your team later on have some bandwidth, you can filter the issues list to view only the Qt console issues. If you spot anything there that you can take a crack at, we'd greatly appreciate it. We don't have too much Qt expertise in the core team, so all of this rests mostly on @epatters' shoulders; it would be great to have some extra hands on those bugs.

Fernando Perez
Owner

OK, this is already such an improvement that I'm merging it. In the future we may work on a better solution, but we need this fix now.

Fernando Perez fperez merged commit 2ee14fc into from December 05, 2011
Fernando Perez fperez closed this December 05, 2011
Fernando Perez fperez referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
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.

Nov 27, 2011
Min RK minor improvements to text placement in qtconsole
* allow `before_prompt=True` behavior to have effect during raw_input
* append 'cannot restart' message before the prompt, so it doesn't
  get mixed up with input.
ae00bad
This page is out of date. Refresh to see the latest.
2  IPython/frontend/qt/console/console_widget.py
@@ -772,7 +772,7 @@ def _append_custom(self, insert, input, before_prompt=False):
772 772
         """
773 773
         # Determine where to insert the content.
774 774
         cursor = self._control.textCursor()
775  
-        if before_prompt and not self._executing:
  775
+        if before_prompt and (self._reading or not self._executing):
776 776
             cursor.setPosition(self._append_before_prompt_pos)
777 777
         else:
778 778
             cursor.movePosition(QtGui.QTextCursor.End)
8  IPython/frontend/qt/console/frontend_widget.py
@@ -597,7 +597,9 @@ def restart_kernel(self, message, now=False):
597 597
                     self.kernel_manager.restart_kernel(now=now)
598 598
                 except RuntimeError:
599 599
                     self._append_plain_text('Kernel started externally. '
600  
-                                            'Cannot restart.\n')
  600
+                                            'Cannot restart.\n',
  601
+                                            before_prompt=True
  602
+                                            )
601 603
                 else:
602 604
                     self.reset()
603 605
             else:
@@ -605,7 +607,9 @@ def restart_kernel(self, message, now=False):
605 607
 
606 608
         else:
607 609
             self._append_plain_text('Kernel process is either remote or '
608  
-                                    'unspecified. Cannot restart.\n')
  610
+                                    'unspecified. Cannot restart.\n',
  611
+                                    before_prompt=True
  612
+                                    )
609 613
 
610 614
     #---------------------------------------------------------------------------
611 615
     # 'FrontendWidget' protected interface
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.