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:  sage7.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: 
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
comment:2 Changed 9 years ago by
Milestone:  sage6.1 → sage6.2 

comment:3 Changed 9 years ago by
Milestone:  sage6.2 → sage6.3 

comment:4 Changed 8 years ago by
Milestone:  sage6.3 → sage6.4 

comment:5 Changed 7 years ago by
Cc:  Jeroen Demeyer John Palmieri Leif Leonhardy Marco Streng Nils Bruin Sébastien Labbé Travis Scrimshaw Volker Braun added 

Ccing people from #14523.
comment:6 Changed 7 years ago by
Branch:  → u/vbraun/sage_interpreter_blocks_tkinter_gui 

comment:7 Changed 7 years ago by
Commit:  → fb2a1f9e6d73dfee69ff14eaf397de657b646d3a 

Keywords:  days74 added 
Status:  new → 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 7 years ago by
Commit:  fb2a1f9e6d73dfee69ff14eaf397de657b646d3a → 2f375c76580bdd5a66faef9e46f32fee2b492684 

Branch pushed to git repo; I updated commit sha1. New commits:
2f375c7  Add doctest

comment:9 Changed 7 years ago by
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
Cc:  Matthias Goerner Marc Culler added 

Reviewers:  Vincent Delecroix → 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 6 years ago by
Milestone:  sage6.4 → sage7.3 

Status:  needs_review → positive_review 
Would be better with doc but more importantly this should be in Sage asap.
comment:12 Changed 6 years ago by
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
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 6 years ago by
Commit:  2f375c76580bdd5a66faef9e46f32fee2b492684 → 06e7dbf62c21a536ac1b5b034f7c9e30e170b655 

Status:  positive_review → needs_review 
comment:15 Changed 6 years ago by
Status:  needs_review → positive_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
Branch:  u/vbraun/sage_interpreter_blocks_tkinter_gui → 06e7dbf62c21a536ac1b5b034f7c9e30e170b655 

Resolution:  → fixed 
Status:  positive_review → 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.