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
Browser selection #1406
Conversation
now you can specify --browser=firefox when starting ipython notebook
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. |
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. |
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. |
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 (Of course, the option to suppress a browser could work like |
Hehe, I love the idea of |
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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? |
Yes, I think that makes sense - not so much for the |
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. |
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. |
adds new `NotebookApp.browser` configurable and corresponding `--browser` alias for specifying which browser should be launched with the notebook landing page.
adds new `NotebookApp.browser` configurable and corresponding `--browser` alias for specifying which browser should be launched with the notebook landing page.
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 PRIn 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 thewebbrowser
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)