GNU Info

Info Node: (python2.1-lib.info)webbrowser

(python2.1-lib.info)webbrowser


Next: cgi Prev: Internet Protocols and Support Up: Internet Protocols and Support
Enter node , (file) or (file)node

Convenient Web-browser controller
=================================

Easy-to-use controller for Web browsers.  This module was written by
Fred L. Drake, Jr. <fdrake@acm.org>.
This manual section was written by Fred L. Drake, Jr. <fdrake@acm.org>.
The `webbrowser' module provides a very high-level interface to allow
displaying Web-based documents to users.  The controller objects are
easy to use and are platform-independent.  Under most circumstances,
simply calling the `open()' function from this module will do the right
thing.

Under UNIX, graphical browsers are preferred under X11, but text-mode
browsers will be used if graphical browsers are not available or an X11
display isn't available.  If text-mode browsers are used, the calling
process will block until the user exits the browser.

Under UNIX, if the environment variable `BROWSER' exists, it is
interpreted to override the platform default list of browsers, as a
colon-separated list of browsers to try in order.  When the value of a
list part contains the string `%s', then it is interpreted as a literal
browser command line to be used with the argument URL substituted for
the `%s'; if the part does not contain `%s', it is simply interpreted
as the name of the browser to launch.

For non-UNIX platforms, or when X11 browsers are available on UNIX, the
controlling process will not wait for the user to finish with the
browser, but allow the browser to maintain its own window on the
display.

The following exception is defined:

`Error'
     Exception raised when a browser control error occurs.

The following functions are defined:

`open(url[, new=0][, autoraise=1])'
     Display URL using the default browser.  If NEW is true, a new
     browser window is opened if possible.  If AUTORAISE is true, the
     window is raised if possible (note that under many window managers
     this will occur regardless of the setting of this variable).

`open_new(url)'
     Open URL in a new window of the default browser, if possible,
     otherwise, open URL in the only browser window.

`get([name])'
     Return a controller object for the browser type NAME.  If NAME is
     empty, return a controller for a default browser appropriate to
     the caller's environment.

`register(name, constructor[, instance])'
     Register the browser type NAME.  Once a browser type is
     registered, the `get()' function can return a controller for that
     browser type.  If INSTANCE is not provided, or is `None',
     CONSTRUCTOR will be called without parameters to create an
     instance when needed.  If INSTANCE is provided, CONSTRUCTOR will
     never be called, and may be `None'.

     This entry point is only useful if you plan to either set the
     `BROWSER' variable or call `get' with a nonempty argument matching
     the name of a handler you declare.

A number of browser types are predefined.  This table gives the type
names that may be passed to the `get()' function and the corresponding
instantiations for the controller classes, all defined in this module.

Type Name                Class Name               Notes
------                   -----                    -----
'mozilla'                `Netscape('mozilla')'    
'netscape'               `Netscape('netscape')'   
'mosaic'                 `GenericBrowser('mosaic  
                         %s &')'                  
'kfm'                    `Konqueror()'            (1)
'grail'                  `Grail()'                
'links'                  `GenericBrowser('links   
                         %s')'                    
'lynx'                   `GenericBrowser('lynx    
                         %s')'                    
'w3m'                    `GenericBrowser('w3m     
                         %s')'                    
'windows-default'        `WindowsDefault'         (2)
'internet-config'        `InternetConfig'         (3)

Notes:

`(1)'
     "Konqueror" is the file manager for the KDE desktop environment for
     UNIX, and only makes sense to use if KDE is running.  Some way of
     reliably detecting KDE would be nice; the `KDEDIR' variable is not
     sufficient.  Note also that the name "kfm" is used even when using
     the `konqueror' command with KDE 2 -- the implementation selects
     the best strategy for running Konqueror.

`(2)'
     Only on Windows platforms; requires the common extension modules
     `win32api' and `win32con'.

`(3)'
     Only on MacOS platforms; requires the standard MacPython `ic'
     module, described in the  manual.

Browser Controller Objects

automatically generated by info2www version 1.2.2.9