|
| 1 | +\section{\module{webbrowser} --- |
| 2 | + Convenient Web-browser controller} |
| 3 | + |
| 4 | +\declaremodule{standard}{webbrowser} |
| 5 | +\modulesynopsis{Easy-to-use controller for Web browsers.} |
| 6 | +\moduleauthor{Fred L. Drake, Jr.}{ [email protected]} |
| 7 | +\sectionauthor{Fred L. Drake, Jr.}{ [email protected]} |
| 8 | + |
| 9 | +The \module{webbrowser} module provides a very high-level interface to |
| 10 | +allow displaying Web-based documents to users. The controller objects |
| 11 | +are easy to use and are platform independent. |
| 12 | + |
| 13 | +Under \UNIX, graphical browsers are preferred under X11, but text-mode |
| 14 | +browser will be used if graphical browsers are not available or an X11 |
| 15 | +display isn't available. If text-mode browsers are used, the calling |
| 16 | +process will block until the user exits the browser. |
| 17 | + |
| 18 | +For non-\UNIX{} platforms, or when X11 browsers are available on |
| 19 | +\UNIX, the controlling process will not wait for the user to finish |
| 20 | +with the browser, but allow the browser to maintain its own window on |
| 21 | +the display. |
| 22 | + |
| 23 | +The following exception is defined: |
| 24 | + |
| 25 | +\begin{excdesc}{Error} |
| 26 | + Exception raised when a browser control error occurs. |
| 27 | +\end{excdesc} |
| 28 | + |
| 29 | +The following functions are defined: |
| 30 | + |
| 31 | +\begin{funcdesc}{open}{url\optional{, new}} |
| 32 | + Display \var{url} using the default browser. If \var{new} is true, |
| 33 | + a new browser window is opened if possible. |
| 34 | +\end{funcdesc} |
| 35 | + |
| 36 | +\begin{funcdesc}{open_new}{url} |
| 37 | + Open \var{url} in a new window of the default browser, if possible, |
| 38 | + otherwise, open \var{url} in the only browser window. |
| 39 | +\end{funcdesc} |
| 40 | + |
| 41 | +\begin{funcdesc}{get}{\optional{name}} |
| 42 | + Return a controller object for the browser type \var{name}. |
| 43 | +\end{funcdesc} |
| 44 | + |
| 45 | +\begin{funcdesc}{register}{name, constructor\optional{, controller}} |
| 46 | + Register the browser type \var{name}. Once a browser type is |
| 47 | + registered, the \function{get()} function can return a controller |
| 48 | + for that browser type. If \var{instance} is not provided, or is |
| 49 | + \code{None}, \var{constructor} will be called without parameters to |
| 50 | + create an instance when needed. If \var{instance} is provided, |
| 51 | + \var{constructor} will never be called, and may be \code{None}. |
| 52 | +\end{funcdesc} |
| 53 | + |
| 54 | +Several browser types are defined. This table gives the type names |
| 55 | +that may be passed to the \function{get()} function and the names of |
| 56 | +the implementation classes, all defined in this module. |
| 57 | + |
| 58 | +\begin{tableiii}{l|l|c}{code}{Type Name}{Class Name}{Notes} |
| 59 | + \lineiii{'netscape'}{\class{Netscape}}{} |
| 60 | + \lineiii{'grail'}{\class{Grail}}{} |
| 61 | + \lineiii{'windows-default'}{\class{WindowsDefault}}{(1)} |
| 62 | + \lineiii{'internet-config'}{\class{InternetConfig}}{(2)} |
| 63 | + \lineiii{'command-line'}{\class{CommandLineBrowser}}{} |
| 64 | +\end{tableiii} |
| 65 | + |
| 66 | +\noindent |
| 67 | +Notes: |
| 68 | + |
| 69 | +\begin{description} |
| 70 | +\item[(1)] |
| 71 | +Only on Windows platforms; requires the common |
| 72 | +extension modules \module{win32api} and \module{win32con}. |
| 73 | + |
| 74 | +\item[(2)] |
| 75 | +Only on MacOS platforms; requires the standard MacPython \module{ic} |
| 76 | +module, described in the \citetitle[../mac/module-ic.html]{Macintosh |
| 77 | +Library Modules} manual. |
| 78 | +\end{description} |
| 79 | + |
| 80 | + |
| 81 | +\subsection{Browser Controller Objects \label{browser-controllers}} |
| 82 | + |
| 83 | +Browser controllers provide two methods which parallel two of the |
| 84 | +module-level convenience functions: |
| 85 | + |
| 86 | +\begin{funcdesc}{open}{url\optional{, new}} |
| 87 | + Display \var{url} using the browser handled by this controller. If |
| 88 | + \var{new} is true, a new browser window is opened if possible. |
| 89 | +\end{funcdesc} |
| 90 | + |
| 91 | +\begin{funcdesc}{open_new}{url} |
| 92 | + Open \var{url} in a new window of the browser handled by this |
| 93 | + controller, if possible, otherwise, open \var{url} in the only |
| 94 | + browser window. |
| 95 | +\end{funcdesc} |
0 commit comments