Opened 6 years ago

Closed 4 years ago

#16995 closed enhancement (invalid)

Detect the user interface

Reported by: tmonteil Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: user interface Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: u/tmonteil/detect_the_user_interface (Commits) Commit: 335d7195ca91b78e0fb7aafa080a531af52059d5
Dependencies: Stopgaps:

Description

The aim of this ticket is to implement a user_interface() function that tells which user interface is used, to deal with different behaviours between sage notebook, ipython notebook and ipython command line, e.g. for printing latex or html.

Change History (11)

comment:1 Changed 6 years ago by tmonteil

  • Branch set to u/tmonteil/detect_the_user_interface

comment:2 Changed 6 years ago by tmonteil

  • Commit set to 335d7195ca91b78e0fb7aafa080a531af52059d5
  • Status changed from new to needs_review

New commits:

335d719#16995 : let Sage detect the user interface.

comment:3 Changed 6 years ago by vbraun

Are you working on ipython notebook integration?

IMHO it is a bad design choice (much like the ACPI OSI fail) to allow directly querying the underlying system. We should abstract capabilities like user_interface.graphics_display() instead. Otherwise there will be if/elses scattered everywhere, relying on string comparisons with potentially misspelled magic names (== 'IPython' vs == 'ipython' etc).

comment:4 Changed 6 years ago by jdemeyer

And if you want to do this right, you should get rid of DOCTEST_MODE and EMBEDDED_MODE and use these new functions instead.

comment:5 Changed 6 years ago by tmonteil

Thanks for your replies. I completely agree with you, as explicitly stated in the doctest of the function.

However, we still have to support Sage notebook that works by querying the system and Sage is already full of EMBEDDED_MODE and related if/else statements (good luck to remove them), and currently features like pretty_print are just not working on ipython notebook (and provide some raw uninterpreted html). So we currently have both an ugly code as well as a not well integrated ipython notebook.

I have been recently asked for a %display typeset for the ipython notebook (to get the same typeset feature as in Sage notebook) and i see how to do it with a minimal impact on existing Sage's code with such a function (actually i was just about to open a ticket with this one as a dependency).

The question is about the transition: adding a layer of _repr_*_() methods on classes that have a specific output (no idea how much work it represents) or using the existing if/then structure (which should not add uglinesses, only modify the existing).

This stuff is not my usual business, but it has to be done before Sage notebook get de facto unmaintained. It seems that no one is really working on the ipython notebook integration, and i bet that having a more friendly ipython notebook early will ease its adoption, therefore its development.

So, if you have plans to do it right (and preferably short), it could be nice to share your options, i am likely to follow them since i am not used to such stuff.

comment:6 Changed 6 years ago by vbraun

My first stab at the IPython notebook is at #16996.

I'll have to look a bit more into the IPython zmq-based displayhook to have any suggestions for integrating it...

comment:7 Changed 6 years ago by vbraun

Thinking a bit about the issue, most of the graphics-related DOCTEST_MODE uses should just move into a special doctest-mode displayhook (that doesn't display graphics). Really, this is Python's hook for customizing the user interface, so put it there. Related: #16746

comment:8 Changed 6 years ago by novoselt

  • Status changed from needs_review to needs_info

So - is this one "wontfix"?

comment:9 Changed 5 years ago by novoselt

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from needs_info to needs_review

Wontfix!

comment:10 Changed 4 years ago by paulmasson

  • Status changed from needs_review to positive_review

comment:11 Changed 4 years ago by vbraun

  • Resolution set to invalid
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.