Opened 6 years ago

Closed 3 years ago

#15152 closed defect (fixed)

Sage interpreter blocks Tkinter GUI

Reported by: dunfield Owned by:
Priority: major Milestone: sage-7.3
Component: user interface Keywords: days74
Cc: mgoerner, culler, jdemeyer, jhpalmieri, leif, mstreng, nbruin, slabbe, tscrim, vbraun Merged in:
Authors: Volker Braun Reviewers: Vincent Delecroix, Nathan Dunfield
Report Upstream: N/A Work issues:
Branch: 06e7dbf (Commits) Commit: 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
Dependencies: Stopgaps:

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 6 years ago by 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 5 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 3 years ago by slelievre

  • Cc jdemeyer jhpalmieri leif mstreng nbruin slabbe tscrim vbraun added

Cc-ing people from #14523.

comment:6 Changed 3 years ago by vbraun

  • Branch set to u/vbraun/sage_interpreter_blocks_tkinter_gui

comment:7 Changed 3 years ago by vbraun

  • Commit set to fb2a1f9e6d73dfee69ff14eaf397de657b646d3a
  • Keywords days74 added
  • Status changed from new to needs_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 3 years ago by git

  • Commit changed from fb2a1f9e6d73dfee69ff14eaf397de657b646d3a to 2f375c76580bdd5a66faef9e46f32fee2b492684

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

2f375c7Add doctest

comment:9 Changed 3 years ago by vdelecroix

  • Authors set to Volker Braun
  • Reviewers set to Vincent Delecroix

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

comment:10 Changed 3 years ago by dunfield

  • Cc mgoerner culler added
  • Reviewers changed from Vincent Delecroix to Vincent 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 follow-up: Changed 3 years ago by vdelecroix

  • Milestone changed from sage-6.4 to sage-7.3
  • Status changed from needs_review to positive_review

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

comment:12 in reply to: ↑ 11 Changed 3 years ago by dunfield

Replying to vdelecroix:

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

Agreed.

comment:13 Changed 3 years ago by fbissey

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 3 years ago by git

  • Commit changed from 2f375c76580bdd5a66faef9e46f32fee2b492684 to 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
  • Status changed from positive_review to needs_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 3 years ago by fbissey

  • Status changed from needs_review to positive_review

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

comment:16 Changed 3 years ago by vbraun

  • Branch changed from u/vbraun/sage_interpreter_blocks_tkinter_gui to 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.