gtk.py 466 B

12345678910111213141516
  1. from sympy.printing.mathml import mathml
  2. from sympy.utilities.mathml import c2p
  3. import tempfile
  4. import subprocess
  5. def print_gtk(x, start_viewer=True):
  6. """Print to Gtkmathview, a gtk widget capable of rendering MathML.
  7. Needs libgtkmathview-bin"""
  8. with tempfile.NamedTemporaryFile('w') as file:
  9. file.write(c2p(mathml(x), simple=True))
  10. file.flush()
  11. if start_viewer:
  12. subprocess.check_call(('mathmlviewer', file.name))