Opened 9 years ago

Closed 6 years ago

#15152 closed defect (fixed)

Sage interpreter blocks Tkinter GUI

Reported by: Nathan Dunfield Owned by:
Priority: major Milestone: sage-7.3
Component: user interface Keywords: days74
Cc: Matthias Goerner, Marc Culler, Jeroen Demeyer, John Palmieri, Leif Leonhardy, Marco Streng, Nils Bruin, Sébastien Labbé, Travis Scrimshaw, Volker Braun Merged in:
Authors: Volker Braun Reviewers: Vincent Delecroix, Nathan Dunfield
Report Upstream: N/A Work issues:
Branch: 06e7dbf (Commits, GitHub, GitLab) Commit: 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
Dependencies: Stopgaps:

Status badges

Description

IPython allows running Tkinter (and many other GUI toolkits) so that the GUI doesn't block the IPython interpreter. In Sage 5.10 and earlier this worked in Sage's interpreter as well as vanilla IPython. However, in Sage 5.11 it only works in vanilla IPython. A minimal example (for both Linux and OS X) is:

sage: import Tkinter
sage: root = Tkinter.Tk()

Pre version 5.11, this brings up a small window titled "tk"; in Sage 5.11 it does nothing. In 5.11 you can manually start the Tk gui via:

sage: root.mainloop()

but you don't get a new interpreter prompt until you quit the Tk GUI.

I strongly suspect the issue is the new IPython inputhook (in "sage/misc/inputhook.pyx") that was added in Sage 5.11 as part of #14523.

Change History (16)

comment:1 Changed 9 years ago by Nathan Dunfield

I should have mentioned the following work-around in my initial report:

sage: %gui none

or what is essentially equivalently

sage: import IPython.lib.inputhook as ih
sage: ih.clear_inputhook()

This is why I think the new inputhook is the source of the change in behavior.

comment:2 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:3 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:4 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:5 Changed 7 years ago by Samuel Lelièvre

Cc: Jeroen Demeyer John Palmieri Leif Leonhardy Marco Streng Nils Bruin Sébastien Labbé Travis Scrimshaw Volker Braun added

Cc-ing people from #14523.

comment:6 Changed 7 years ago by Volker Braun

Branch: u/vbraun/sage_interpreter_blocks_tkinter_gui

comment:7 Changed 7 years ago by Volker Braun

Commit: fb2a1f9e6d73dfee69ff14eaf397de657b646d3a
Keywords: days74 added
Status: newneeds_review

The branch installs the input hook only while files are attached. Hence tkinter can grab it iff you don't have files attached.

comment:8 Changed 7 years ago by git

Commit: fb2a1f9e6d73dfee69ff14eaf397de657b646d3a2f375c76580bdd5a66faef9e46f32fee2b492684

Branch pushed to git repo; I updated commit sha1. New commits:

2f375c7Add doctest

comment:9 Changed 7 years ago by Vincent Delecroix

Authors: Volker Braun
Reviewers: Vincent Delecroix

Nice! I guess there should be an explicit warning in the documentation of "attach".

comment:10 Changed 6 years ago by Nathan Dunfield

Cc: Matthias Goerner Marc Culler added
Reviewers: Vincent DelecroixVincent Delecroix, Nathan Dunfield

I tried out this patch on OS X and everything worked as intended. Should I set the status to "positive review" or does some documentation need to be added first as Vincent suggests?

comment:11 Changed 6 years ago by Vincent Delecroix

Milestone: sage-6.4sage-7.3
Status: needs_reviewpositive_review

Would be better with doc but more importantly this should be in Sage asap.

comment:12 in reply to:  11 Changed 6 years ago by Nathan Dunfield

Replying to vdelecroix:

Would be better with doc but more importantly this should be in Sage asap.

Agreed.

comment:13 Changed 6 years ago by François Bissey

I get

Error building the documentation.
Traceback (most recent call last):
  File "sage_setup/docbuild/__main__.py", line 2, in <module>
    main()
  File "/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/sage_setup/docbuild/__init__.py", line 1629, in main
    builder()
  File "/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/sage_setup/docbuild/__init__.py", line 284, in _wrapper
    getattr(get_builder(document), 'inventory')(*args, **kwds)
  File "/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/sage_setup/docbuild/__init__.py", line 495, in _wrapper
    x.get(99999)
  File "/usr/lib64/python2.7/multiprocessing/pool.py", line 567, in get
    raise self._value
OSError: [repl     ] docstring of sage.repl.inputhook.is_installed:15: WARNING: Block quote ends without a blank line; unexpected unindent.

comment:14 Changed 6 years ago by git

Commit: 2f375c76580bdd5a66faef9e46f32fee2b49268406e7dbf62c21a536ac1b5b034f7c9e30e170b655
Status: positive_reviewneeds_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

3131a68Fix documentation build
06e7dbfAdd explanatory note

comment:15 Changed 6 years ago by François Bissey

Status: needs_reviewpositive_review

Yes, that fixed it. It looks like commenting on a ticket doesn't add you to cc automatically anymore...

comment:16 Changed 6 years ago by Volker Braun

Branch: u/vbraun/sage_interpreter_blocks_tkinter_gui06e7dbf62c21a536ac1b5b034f7c9e30e170b655
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.