Skip to content

Commit e8f2443

Browse files
committed
Patch #754022: Greatly enhanced webbrowser.py.
1 parent 76390de commit e8f2443

File tree

3 files changed

+393
-197
lines changed

3 files changed

+393
-197
lines changed

Diff for: Doc/lib/libwebbrowser.tex

+53-22
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ \section{\module{webbrowser} ---
66
\moduleauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
77
\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
88

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. Under most
9+
The \module{webbrowser} module provides a high-level interface to
10+
allow displaying Web-based documents to users. Under most
1211
circumstances, simply calling the \function{open()} function from this
1312
module will do the right thing.
1413

@@ -17,19 +16,26 @@ \section{\module{webbrowser} ---
1716
display isn't available. If text-mode browsers are used, the calling
1817
process will block until the user exits the browser.
1918

20-
Under \UNIX, if the environment variable \envvar{BROWSER} exists, it
19+
If the environment variable \envvar{BROWSER} exists, it
2120
is interpreted to override the platform default list of browsers, as a
22-
colon-separated list of browsers to try in order. When the value of
21+
os.pathsep-separated list of browsers to try in order. When the value of
2322
a list part contains the string \code{\%s}, then it is interpreted as
2423
a literal browser command line to be used with the argument URL
2524
substituted for the \code{\%s}; if the part does not contain
2625
\code{\%s}, it is simply interpreted as the name of the browser to
2726
launch.
2827

29-
For non-\UNIX{} platforms, or when X11 browsers are available on
28+
For non-\UNIX{} platforms, or when a remote browser is available on
3029
\UNIX, the controlling process will not wait for the user to finish
31-
with the browser, but allow the browser to maintain its own window on
32-
the display.
30+
with the browser, but allow the remote browser to maintain its own
31+
windows on the display. If remote browsers are not available on \UNIX,
32+
the controlling process will launch a new browser and wait.
33+
34+
The script \program{webbrowser} can be used as a command-line interface
35+
for the module. It accepts an URL as the argument. It accepts the following
36+
optional parameters: \programopt{-n} opens the URL in a new browser window,
37+
if possible; \programopt{-t} opens the URL in a new browser page ("tab"). The
38+
options are, naturally, mutually exclusive.
3339

3440
The following exception is defined:
3541

@@ -40,15 +46,24 @@ \section{\module{webbrowser} ---
4046
The following functions are defined:
4147

4248
\begin{funcdesc}{open}{url\optional{, new=0}\optional{, autoraise=1}}
43-
Display \var{url} using the default browser. If \var{new} is true,
44-
a new browser window is opened if possible. If \var{autoraise} is
49+
Display \var{url} using the default browser. If \var{new} is 0, the
50+
\var{url} is opened in the same browser window. If \var{new} is 1,
51+
a new browser window is opened if possible. If \var{new} is 2,
52+
a new browser page ("tab") is opened if possible. If \var{autoraise} is
4553
true, the window is raised if possible (note that under many window
4654
managers this will occur regardless of the setting of this variable).
55+
4756
\end{funcdesc}
4857

49-
\begin{funcdesc}{open_new}{url}
58+
\begin{funcdesc}{open_new_win}{url}
5059
Open \var{url} in a new window of the default browser, if possible,
51-
otherwise, open \var{url} in the only browser window.
60+
otherwise, open \var{url} in the only browser window. Alias
61+
\function{open_new}.
62+
\end{funcdesc}
63+
64+
\begin{funcdesc}{open_new_tab}{url}
65+
Open \var{url} in a new page ("tab") of the default browser, if possible,
66+
otherwise equivalent to \function{open_new_win}.
5267
\end{funcdesc}
5368

5469
\begin{funcdesc}{get}{\optional{name}}
@@ -67,7 +82,7 @@ \section{\module{webbrowser} ---
6782

6883
This entry point is only useful if you plan to either set the
6984
\envvar{BROWSER} variable or call \function{get} with a nonempty
70-
argument matching the name of a handler you declare.
85+
argument matching the name of a handler you declare.
7186
\end{funcdesc}
7287

7388
A number of browser types are predefined. This table gives the type
@@ -76,16 +91,24 @@ \section{\module{webbrowser} ---
7691
in this module.
7792

7893
\begin{tableiii}{l|l|c}{code}{Type Name}{Class Name}{Notes}
79-
\lineiii{'mozilla'}{\class{Netscape('mozilla')}}{}
80-
\lineiii{'netscape'}{\class{Netscape('netscape')}}{}
81-
\lineiii{'mosaic'}{\class{GenericBrowser('mosaic \%s \&')}}{}
94+
\lineiii{'mozilla'}{\class{Mozilla('mozilla')}}{}
95+
\lineiii{'firefox'}{\class{Mozilla('mozilla')}}{}
96+
\lineiii{'netscape'}{\class{Mozilla('netscape')}}{}
97+
\lineiii{'galeon'}{\class{Galeon('galeon')}}{}
98+
\lineiii{'epiphany'}{\class{Galeon('epiphany')}}{}
99+
\lineiii{'skipstone'}{\class{GenericBrowser('skipstone \%s \&')}}{}
100+
\lineiii{'konqueror'}{\class{Konqueror()}}{(1)}
82101
\lineiii{'kfm'}{\class{Konqueror()}}{(1)}
102+
\lineiii{'mosaic'}{\class{GenericBrowser('mosaic \%s \&')}}{}
103+
\lineiii{'opera'}{\class{Opera()}}{}
83104
\lineiii{'grail'}{\class{Grail()}}{}
84105
\lineiii{'links'}{\class{GenericBrowser('links \%s')}}{}
106+
\lineiii{'elinks'}{\class{Elinks('elinks')}}{}
85107
\lineiii{'lynx'}{\class{GenericBrowser('lynx \%s')}}{}
86108
\lineiii{'w3m'}{\class{GenericBrowser('w3m \%s')}}{}
87109
\lineiii{'windows-default'}{\class{WindowsDefault}}{(2)}
88110
\lineiii{'internet-config'}{\class{InternetConfig}}{(3)}
111+
\lineiii{'macosx'}{\class{MacOSX('default')}}{(4)}
89112
\end{tableiii}
90113

91114
\noindent
@@ -101,13 +124,15 @@ \section{\module{webbrowser} ---
101124
implementation selects the best strategy for running Konqueror.
102125

103126
\item[(2)]
104-
Only on Windows platforms; requires the common
105-
extension modules \module{win32api} and \module{win32con}.
127+
Only on Windows platforms.
106128

107129
\item[(3)]
108130
Only on MacOS platforms; requires the standard MacPython \module{ic}
109131
module, described in the \citetitle[../mac/module-ic.html]{Macintosh
110132
Library Modules} manual.
133+
134+
\item[(4)]
135+
Only on MacOS X platform.
111136
\end{description}
112137

113138

@@ -117,12 +142,18 @@ \subsection{Browser Controller Objects \label{browser-controllers}}
117142
module-level convenience functions:
118143

119144
\begin{funcdesc}{open}{url\optional{, new}}
120-
Display \var{url} using the browser handled by this controller. If
121-
\var{new} is true, a new browser window is opened if possible.
145+
Display \var{url} using the browser handled by this controller.
146+
If \var{new} is 1, a new browser window is opened if possible.
147+
If \var{new} is 2, a new browser page ("tab") is opened if possible.
122148
\end{funcdesc}
123149

124-
\begin{funcdesc}{open_new}{url}
150+
\begin{funcdesc}{open_new_win}{url}
125151
Open \var{url} in a new window of the browser handled by this
126152
controller, if possible, otherwise, open \var{url} in the only
127-
browser window.
153+
browser window. Alias \function{open_new}.
154+
\end{funcdesc}
155+
156+
\begin{funcdesc}{open_new_tab}{url}
157+
Open \var{url} in a new page ("tab") of the browser handled by this
158+
controller, if possible, otherwise equivalent to \function{open_new_win}.
128159
\end{funcdesc}

0 commit comments

Comments
 (0)