Ask Your Question
3

How to change the default program which open the 2D picture which the plot producted?

asked 2011-11-29 09:04:10 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I'm using SageMath4.7.2 in Ubuntu10.04. When I called the plot() to draw the 2D picture of some functions in command line of SageMath(not the GUI session in web browser), SageMath show the pictures in evince,which is my PDF files reader. My default picture viewer in Ubuntu is set to gpicview, not evince. When I delete the evince?SageMath call the ImageMagic to display the result. But I need evince to read ebooks, so I installed the evince again. After that the SageMath still call evince to display the 2D pictures. I wonder are there any method to change the default program to open the 2D pictures in SageMath? PS: My mother language is Chinese, not English, so please forgive me for my language errors. Thanks!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2011-11-29 11:01:02 +0100

DSM gravatar image

updated 2011-11-29 19:06:50 +0100

Hi! On Ubuntu, I think Sage finds xdg-open and uses that, so it'll use whatever xdg-open is set to use to view pngs.

It looks like Sage calls sage.misc.viewer.browser() instead of sage.misc.viewer.png_viewer() even when it knows that the file is a png.

You can change the default viewer by typing

sage.misc.viewer.BROWSER = 'gpicview'

at the command line. (This may cause problems for anything which uses BROWSER but which gpicview can't handle, though..)

UPDATE:

If you want this to be the new default setting, you can add the above line to ~/.sage/init.sage:

localhost-2:~ $ cat ~/.sage/init.sage
# personal options
sage.misc.viewer.BROWSER = 'gpicview'

The init.sage file is executed at startup time.

edit flag offensive delete link more

Comments

Thank you for your help! It works perfectly! I'm sorry I didn't see the comment function so I posted 2 answers.

zwdnet gravatar imagezwdnet ( 2011-11-29 19:20:42 +0100 )edit

See also http://trac.sagemath.org/sage_trac/ticket/11795 for a modified way to accomplish this, which should allow for easy setting of viewers for PNG, PDF, and DVI, in addition to the BROWSER setting.

John Palmieri gravatar imageJohn Palmieri ( 2011-11-29 23:15:18 +0100 )edit

Thank you very much, John!

zwdnet gravatar imagezwdnet ( 2011-11-30 08:35:39 +0100 )edit
0

answered 2011-11-29 19:01:53 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Thank you very much! It works! But I still have a problem: When I typed sage.misc.viewer.BROWSER = 'gpicview' at the sage command line, and called plot to draw picture again, the display program was changed to gpicview. That's what I want. But when I typed "quit" to exit the sage and ran sage command again, the display program was backed to evince again! How to change the sage.misc.view.BROWSER value forever? Or do I need to type this every time when I run SageMath?

edit flag offensive delete link more

Comments

I've updated the answer.

DSM gravatar imageDSM ( 2011-11-29 19:07:03 +0100 )edit
0

answered 2011-11-29 19:14:17 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Haha, I find the answer! Put the

sage.misc.viewer.BROWSER = 'gpicview'

in the $HOME/.sage/init.sage file (If there isn't init.sage, create it), so I needn't type it every time when I run SageMath. I fount the answer in this web

http://comments.gmane.org/gmane.comp....

by google! Thank DSM!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2011-11-29 09:04:10 +0100

Seen: 2,762 times

Last updated: Nov 29 '11