blob: b65d5f98f65e354ae650f77ee1e4b950692fcc59 [file] [log] [blame]
Fred Drakee4dbb862000-07-07 03:36:12 +00001\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.}{fdrake@acm.org}
7\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
8
9The \module{webbrowser} module provides a very high-level interface to
10allow displaying Web-based documents to users. The controller objects
11are easy to use and are platform independent.
12
13Under \UNIX, graphical browsers are preferred under X11, but text-mode
Fred Drakef6791f32000-10-02 03:42:43 +000014browsers will be used if graphical browsers are not available or an X11
Fred Drakee4dbb862000-07-07 03:36:12 +000015display isn't available. If text-mode browsers are used, the calling
16process will block until the user exits the browser.
17
18For non-\UNIX{} platforms, or when X11 browsers are available on
19\UNIX, the controlling process will not wait for the user to finish
20with the browser, but allow the browser to maintain its own window on
21the display.
22
23The following exception is defined:
24
25\begin{excdesc}{Error}
26 Exception raised when a browser control error occurs.
27\end{excdesc}
28
29The 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
54Several browser types are defined. This table gives the type names
55that may be passed to the \function{get()} function and the names of
56the 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}}{}
Fred Drakec826ecb2000-07-07 17:08:40 +000060 \lineiii{'kfm'}{\class{Konquerer}}{(1)}
Fred Drakee4dbb862000-07-07 03:36:12 +000061 \lineiii{'grail'}{\class{Grail}}{}
Fred Drakec826ecb2000-07-07 17:08:40 +000062 \lineiii{'windows-default'}{\class{WindowsDefault}}{(2)}
63 \lineiii{'internet-config'}{\class{InternetConfig}}{(3)}
Fred Drakee4dbb862000-07-07 03:36:12 +000064 \lineiii{'command-line'}{\class{CommandLineBrowser}}{}
65\end{tableiii}
66
67\noindent
68Notes:
69
70\begin{description}
71\item[(1)]
Fred Drakef6791f32000-10-02 03:42:43 +000072``Konquerer'' is the file manager for the KDE desktop environment for
73UNIX, and only makes sense to use if KDE is running. Some way of
74reliably detecting KDE would be nice; the \envvar{KDEDIR} variable is
75not sufficient.
Fred Drakec826ecb2000-07-07 17:08:40 +000076
77\item[(2)]
Fred Drakee4dbb862000-07-07 03:36:12 +000078Only on Windows platforms; requires the common
79extension modules \module{win32api} and \module{win32con}.
80
Fred Drakec826ecb2000-07-07 17:08:40 +000081\item[(3)]
Fred Drakee4dbb862000-07-07 03:36:12 +000082Only on MacOS platforms; requires the standard MacPython \module{ic}
83module, described in the \citetitle[../mac/module-ic.html]{Macintosh
84Library Modules} manual.
85\end{description}
86
87
88\subsection{Browser Controller Objects \label{browser-controllers}}
89
90Browser controllers provide two methods which parallel two of the
91module-level convenience functions:
92
93\begin{funcdesc}{open}{url\optional{, new}}
94 Display \var{url} using the browser handled by this controller. If
95 \var{new} is true, a new browser window is opened if possible.
96\end{funcdesc}
97
98\begin{funcdesc}{open_new}{url}
99 Open \var{url} in a new window of the browser handled by this
100 controller, if possible, otherwise, open \var{url} in the only
101 browser window.
102\end{funcdesc}