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:  sage7.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
comment:2 Changed 5 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:3 Changed 5 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:4 Changed 5 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:5 Changed 3 years ago by
 Cc jdemeyer jhpalmieri leif mstreng nbruin slabbe tscrim vbraun added
Ccing people from #14523.
comment:6 Changed 3 years ago by
 Branch set to u/vbraun/sage_interpreter_blocks_tkinter_gui
comment:7 Changed 3 years ago by
 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
 Commit changed from fb2a1f9e6d73dfee69ff14eaf397de657b646d3a to 2f375c76580bdd5a66faef9e46f32fee2b492684
Branch pushed to git repo; I updated commit sha1. New commits:
2f375c7  Add doctest

comment:9 Changed 3 years ago by
 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
 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 followup: ↓ 12 Changed 3 years ago by
 Milestone changed from sage6.4 to sage7.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
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
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/scimathematics/sage9999/work/sage9999/srcpython2_7/sage_setup/docbuild/__init__.py", line 1629, in main builder() File "/scratch2/portage/scimathematics/sage9999/work/sage9999/srcpython2_7/sage_setup/docbuild/__init__.py", line 284, in _wrapper getattr(get_builder(document), 'inventory')(*args, **kwds) File "/scratch2/portage/scimathematics/sage9999/work/sage9999/srcpython2_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
 Commit changed from 2f375c76580bdd5a66faef9e46f32fee2b492684 to 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
 Status changed from positive_review to needs_review
comment:15 Changed 3 years ago by
 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
 Branch changed from u/vbraun/sage_interpreter_blocks_tkinter_gui to 06e7dbf62c21a536ac1b5b034f7c9e30e170b655
 Resolution set to fixed
 Status changed from positive_review to closed
I should have mentioned the following workaround in my initial report:
or what is essentially equivalently
This is why I think the new inputhook is the source of the change in behavior.