Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easily customize different viewers for PNG, DVI, PDF #11795

Closed
nexttime mannequin opened this issue Sep 13, 2011 · 18 comments
Closed

Easily customize different viewers for PNG, DVI, PDF #11795

nexttime mannequin opened this issue Sep 13, 2011 · 18 comments

Comments

@nexttime
Copy link
Mannequin

nexttime mannequin commented Sep 13, 2011

Currently, all viewers default to $SAGE_BROWSER if it is set, $BROWSER or some other system-specific defaults (like xdg-open, if present) otherwise.

The original proposal on this ticket was to support environment variables for what is currently

  • sage.misc.viewer.DVI_VIEWER,
  • sage.misc.viewer.PDF_VIEWER, and
  • sage.misc.viewer.PNG_VIEWER.

I think instead that if the user wants to change the defaults, then that should happen in their init.sage file. The current patch allows them to add lines like these:

from sage.misc.viewer import viewer
viewer.browser('open -a /Applications/Chrome.app')
viewer.png_viewer('display')
viewer.pdf_viewer('acroread')
viewer.dvi_viewer('/usr/bin/xdvi')

(or of course to use these interactively from the command line) and then the appropriate program will be used.


Apply :

CC: @kcrisman

Component: user interface

Keywords: plot browser

Author: John Palmieri

Reviewer: Nathann Cohen

Merged: sage-5.6.beta1

Issue created by migration from https://trac.sagemath.org/ticket/11795

@nexttime nexttime mannequin added this to the sage-5.6 milestone Sep 13, 2011
@nexttime nexttime mannequin assigned williamstein Sep 13, 2011
@jhpalmieri
Copy link
Member

comment:1

Oh, good, more environment variables. ;)

@jhpalmieri
Copy link
Member

comment:2

On further thought, I think this is a bad idea. These variables are only used within Sage, so rather than environment variables, they should be set in .sage/init.sage. I'm attaching a patch (which needs work: no doctests and not really tested at all), which allows for this sort of behavior:

# init.sage file
from sage.misc.viewer import viewer
viewer.pdf_viewer('open -a /Applications/Adobe\ Reader.app')

Then if a is some Sage object, this opens up Adobe Reader on my Mac:

view(a, pdflatex=True)

(The attached patch also fixes a few bugs in latex.py so that this actually works.)

Opinions about using init.sage instead of environment variables?

@jhpalmieri
Copy link
Member

comment:3

Okay, this has doctests and is ready for review.

@jhpalmieri
Copy link
Member

Author: John Palmieri

@jhpalmieri

This comment has been minimized.

@jhpalmieri jhpalmieri changed the title Support environment variables for different viewers (e.g. PNG, DVI, PDF) Easily customize different viewers for PNG, DVI, PDF Nov 30, 2011
@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 16, 2012

comment:5

Just rebased the patch on 5.5.rc0

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 16, 2012

comment:6

Attachment: trac_11795-rev.patch.gz

ellooooooooooooo John !!

Thank you very much for this patch ! I had actually begun to write a (much worse) version of it, then noticed you had already done the job ! I joined a patch adding unimportant details to yours, and there's one question keeping me from giving a positive review to your patch immediately : why isn't _viewer_prefs just a dictionary ?

This should get in quickly :-)

Nathann

@jhpalmieri
Copy link
Member

Attachment: trac_11795.v2.patch.gz

@jhpalmieri

This comment has been minimized.

@jhpalmieri
Copy link
Member

comment:8

I don't know why _viewer_prefs is not just a dictionary. Maybe that class used to do more things in some prehistoric version of the patch? Anyway, I changed it so it's just a dictionary now.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 16, 2012

comment:9

Well, then...

Thank you again ! :-)

Nathann

Apply trac_11795.v2.patch, trac_11795-rev.patch

@nathanncohen

This comment has been minimized.

@jdemeyer
Copy link

Reviewer: Nathann Cohen

@greg-minshall
Copy link

comment:11

hi. fwiw, i downloaded an applied these two patches on my macosx 10.8 system (using fink). i added the following to my init.sage:

from sage.misc.viewer import viewer
viewer.browser('/sw/bin/w3m')
viewer.dvi_viewer('/sw/bin/xdvi')
viewer.pdf_viewer('/sw/bin/xpdf')
viewer.png_viewer('/sw/bin/display')

and ran simple tests. everything worked just fine. (i had a separate issue with error reporting for non-existent viewers, but i don't think that's in the scope of this patch.)

i would also like the ability to get plot3d to use other than jmol. i suspect that's also out of scope for this patch. so, i'm basically happy. cheers.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 19, 2012

comment:12

Helloooooooooooo !!

Well, as this one has been reviewed and fixes something already let's not disturb it. This being said, if you create a ticket to fix your problem do add me as a Cc, if I understand it the review will be fast :-)

Nathann

@greg-minshall
Copy link

comment:13

hello, back.

okay. i've added #13842 (give an error or warning if user specified program does not exist) and #13843 (allow configuration of 3D plot program).

i wasn't sure of who to add as CCs, etc. i'm happy to be educated in the way of the sage...

cheers.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Dec 19, 2012

comment:14

Hellooooooooooo !!!

Well, you can add as a CC whoever may feel involved by the patch. Like me, as I reviewed this, or John (who did all the smart work). This being said, it is very likely that these tickets will remain open for a while unless you write a patch yourself and want it to be reviewed :-)

Nathann

@jdemeyer
Copy link

Merged: sage-5.6.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants