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

Browser selection #1406

Merged
merged 3 commits into from Feb 19, 2012
Merged

Browser selection #1406

merged 3 commits into from Feb 19, 2012

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Feb 14, 2012

Someone in the Astronomy 250: Python for Scientific Computing class asked how one can specify which browser is used for the notebook interface. I found that this was undocumented, and added a description of how one can do it using environment variable BROWSER, since that's what python standard libarary's webbrowser module looks at to override the default. This is the first commit in the PR

In talking with @stefanv about it, we decided it's be more pythonic to be able to specifically specify --browser=foo, since the environment solution makes a change for any other code that uses the webbrowser standard library module and feels awkward if you want to change it to have to change it at the beginning of every command. That's the second commit, but it does not preclude the first (i.e. $BROWSER is still respected when --browser is not used)

now you can specify --browser=firefox when starting ipython notebook
@minrk
Copy link
Member

minrk commented Feb 14, 2012

Why would we ever launch with anything other than the user's default? I can't think of a single application that allows opening a url in a webbrowser that lets you choose one other than the system default.

@stefanv
Copy link
Contributor

stefanv commented Feb 14, 2012

My default browser is Firefox, but I typically want to run the notebooks in Chrome. I don't think this is an uncommon situation at all.

@ivanov
Copy link
Member Author

ivanov commented Feb 14, 2012

I can't think of a single application that allows opening a url in a webbrowser that lets you choose one other than the system default.

IPython's Notebook very different from any other application that opens URLs - the URLs those other applications open are typically viewable in any web browser - whereas the Notebook is currently usable only on the more recent version of Firefox and Chrome.

So I might have uzbl or opera or vimprobable or w3m or surf etc as my system default browser - where I want all of my urls to open inside of - given the current features required for the nice user experience of the ipython notebook, I ought to be able to configure a separate IPython specific default.

@takluyver
Copy link
Member

I think this is reasonable, since the default browser may not be up to running the notebook, and the extra code complexity seems minimal.

Just to check one thing: I think there was a command-line flag like --no-browser to prevent launching a browser. I assume this doesn't interfere with that?

(Of course, the option to suppress a browser could work like --browser=no, but I think the --no-browser flag is still clearer)

@stefanv
Copy link
Contributor

stefanv commented Feb 14, 2012

Hehe, I love the idea of browser=no, but I would hate to shout at my IPython like that :)

@minrk
Copy link
Member

minrk commented Feb 14, 2012

Okay, fair points all, and this seems like a reasonable solution for a real use case I didn't expect to exist. From my perspective: I disabled the browser launch, because I find it super annoying.

@@ -427,7 +441,11 @@ def start(self):

if self.open_browser:
ip = self.ip or '127.0.0.1'
b = lambda : webbrowser.open("%s://%s:%i%s" % (proto, ip, self.port,
if len(self.browser) == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't a simpler if self.browser: test more logical here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point, i knew it looked too ugly but forgot about this cleaner syntax.

@ivanov
Copy link
Member Author

ivanov commented Feb 14, 2012

Just to check one thing: I think there was a command-line flag like --no-browser to prevent launching a browser. I assume this doesn't interfere with that?

no it doesn't, --no-browser still works as it always did - although maybe I should change it such that using --browser=foo automatically overrides NotebookApp.open_browser=False, and then document it as much in the --browser doc string (i.e. in --browser description say "using this option overrides NotebookApp.open_browser=False" - what do ya'll think?

@takluyver
Copy link
Member

Yes, I think that makes sense - not so much for the --no-browser flag, but if someone sets ..open_browser=False in config, they might want to override it with --browser=firefox.

@minrk
Copy link
Member

minrk commented Feb 14, 2012

maybe I should change it such that using --browser=foo automatically overrides NotebookApp.open_browser=False

You will want to be a bit careful with this, because you don't want config-file values to end up overriding those set at the command-line.

@ivanov
Copy link
Member Author

ivanov commented Feb 15, 2012

yeah, actually, after more examination, I think I want to leave this as is - I don't see a way of disambiguate --no-browser from NotebookApp.open_browser=False set in the profile config.

So this is ready to merge as far as I'm concerned.

minrk added a commit that referenced this pull request Feb 19, 2012
adds new `NotebookApp.browser` configurable and corresponding `--browser` alias for specifying which browser should be launched with the notebook landing page.
@minrk minrk merged commit 7bebaca into ipython:master Feb 19, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
adds new `NotebookApp.browser` configurable and corresponding `--browser` alias for specifying which browser should be launched with the notebook landing page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants