~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/library/webbrowser.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
The :mod:`webbrowser` module provides a high-level interface to allow displaying
12
12
Web-based documents to users. Under most circumstances, simply calling the
13
 
:func:`open` function from this module will do the right thing.
 
13
:func:`.open` function from this module will do the right thing.
14
14
 
15
15
Under Unix, graphical browsers are preferred under X11, but text-mode browsers
16
16
will be used if graphical browsers are not available or an X11 display isn't
18
18
the user exits the browser.
19
19
 
20
20
If the environment variable :envvar:`BROWSER` exists, it is interpreted to
21
 
override the platform default list of browsers, as a os.pathsep-separated list
22
 
of browsers to try in order.  When the value of a list part contains the string
23
 
``%s``, then it is  interpreted as a literal browser command line to be used
24
 
with the argument URL substituted for ``%s``; if the part does not contain
 
21
override the platform default list of browsers, as a :data:`os.pathsep`-separated
 
22
list of browsers to try in order.  When the value of a list part contains the
 
23
string ``%s``, then it is  interpreted as a literal browser command line to be
 
24
used with the argument URL substituted for ``%s``; if the part does not contain
25
25
``%s``, it is simply interpreted as the name of the browser to launch. [1]_
26
26
 
27
27
For non-Unix platforms, or when a remote browser is available on Unix, the
46
46
The following functions are defined:
47
47
 
48
48
 
49
 
.. function:: open(url[, new=0[, autoraise=1]])
 
49
.. function:: open(url[, new=0[, autoraise=True]])
50
50
 
51
 
   Display *url* using the default browser. If *new* is 0, the *url* is opened in
52
 
   the same browser window if possible.  If *new* is 1, a new browser window is
53
 
   opened if possible.  If *new* is 2, a new browser page ("tab") is opened if
54
 
   possible.  If *autoraise* is true, the window is raised if possible (note that
55
 
   under many window managers this will occur regardless of the setting of this
56
 
   variable).
 
51
   Display *url* using the default browser. If *new* is 0, the *url* is opened
 
52
   in the same browser window if possible.  If *new* is 1, a new browser window
 
53
   is opened if possible.  If *new* is 2, a new browser page ("tab") is opened
 
54
   if possible.  If *autoraise* is ``True``, the window is raised if possible
 
55
   (note that under many window managers this will occur regardless of the
 
56
   setting of this variable).
57
57
 
58
58
   Note that on some platforms, trying to open a filename using this function,
59
59
   may work and start the operating system's associated program.  However, this
162
162
 
163
163
Here are some simple examples::
164
164
 
165
 
   url = 'http://www.python.org'
 
165
   url = 'http://www.python.org/'
166
166
 
167
167
   # Open URL in a new tab, if a browser window is already open.
168
 
   webbrowser.open_new_tab(url + '/doc')
 
168
   webbrowser.open_new_tab(url + 'doc/')
169
169
 
170
170
   # Open URL in new window, raising the window if possible.
171
171
   webbrowser.open_new(url)
176
176
Browser Controller Objects
177
177
--------------------------
178
178
 
179
 
Browser controllers provide these methods which parallel two of the module-level
180
 
convenience functions:
181
 
 
182
 
 
183
 
.. method:: controller.open(url[, new[, autoraise=1]])
 
179
Browser controllers provide these methods which parallel three of the
 
180
module-level convenience functions:
 
181
 
 
182
 
 
183
.. method:: controller.open(url[, new=0[, autoraise=True]])
184
184
 
185
185
   Display *url* using the browser handled by this controller. If *new* is 1, a new
186
186
   browser window is opened if possible. If *new* is 2, a new browser page ("tab")