0
# Browser Management
1
2
Browser-specific modules and functions for launching Eel applications in different browsers with custom configurations and platform-specific optimizations.
3
4
## Capabilities
5
6
### Browser Configuration
7
8
Set custom browser executable paths and retrieve configured paths.
9
10
```python { .api }
11
# From eel.browsers module
12
def set_path(browser_name: str, path: str) -> None:
13
"""
14
Set custom browser executable path.
15
16
Parameters:
17
- browser_name: str - Browser identifier ('chrome', 'electron', 'edge', 'msie')
18
- path: str - Full path to browser executable
19
20
Returns:
21
None
22
"""
23
24
def get_path(browser_name: str) -> Optional[str]:
25
"""
26
Get configured browser executable path.
27
28
Parameters:
29
- browser_name: str - Browser identifier
30
31
Returns:
32
Optional[str] - Path to browser executable or None if not set
33
"""
34
35
def open(start_pages: Iterable[Union[str, Dict[str, str]]], options: OptionsDictT) -> None:
36
"""
37
Open pages in configured browser.
38
39
Parameters:
40
- start_pages: Iterable[Union[str, Dict[str, str]]] - Pages to open
41
- options: OptionsDictT - Browser and display options
42
43
Returns:
44
None
45
"""
46
```
47
48
**Usage Examples:**
49
50
```python
51
import eel
52
import eel.browsers
53
54
# Set custom Chrome path
55
eel.browsers.set_path('chrome', '/opt/google/chrome/chrome')
56
57
# Get configured path
58
chrome_path = eel.browsers.get_path('chrome')
59
print(f"Chrome path: {chrome_path}")
60
61
# Start with custom browser configuration
62
eel.init('web')
63
eel.start('index.html', mode='chrome')
64
```
65
66
### Chrome/Chromium Support
67
68
Auto-detection and launching of Chrome or Chromium browsers with app mode support.
69
70
```python { .api }
71
# From eel.chrome module
72
name: str = 'Google Chrome/Chromium'
73
74
def run(path: str, options: OptionsDictT, start_urls: List[str]) -> None:
75
"""
76
Launch Chrome/Chromium with specified options.
77
78
Parameters:
79
- path: str - Path to Chrome executable
80
- options: OptionsDictT - Configuration options
81
- start_urls: List[str] - URLs to open
82
83
Returns:
84
None
85
"""
86
87
def find_path() -> Optional[str]:
88
"""
89
Auto-detect Chrome/Chromium executable path.
90
91
Returns:
92
Optional[str] - Path to Chrome executable or None if not found
93
"""
94
```
95
96
**Platform Detection:**
97
- **Windows**: Registry-based detection
98
- **macOS**: Application bundle detection with Spotlight fallback
99
- **Linux**: Multiple binary name detection (chromium-browser, chromium, google-chrome, google-chrome-stable)
100
101
**Usage Example:**
102
103
```python
104
import eel
105
106
eel.init('web')
107
108
# Launch in Chrome app mode (default)
109
eel.start('app.html', mode='chrome', app_mode=True)
110
111
# Launch in Chrome regular mode
112
eel.start('app.html', mode='chrome', app_mode=False)
113
114
# Custom Chrome arguments
115
eel.start('app.html',
116
mode='chrome',
117
cmdline_args=['--start-fullscreen', '--disable-web-security'])
118
```
119
120
### Electron Support
121
122
Support for running Eel applications in Electron for enhanced desktop integration.
123
124
```python { .api }
125
# From eel.electron module
126
name: str = 'Electron'
127
128
def run(path: str, options: OptionsDictT, start_urls: List[str]) -> None:
129
"""
130
Launch Electron with specified options.
131
132
Parameters:
133
- path: str - Path to Electron executable
134
- options: OptionsDictT - Configuration options
135
- start_urls: List[str] - URLs to open
136
137
Returns:
138
None
139
"""
140
141
def find_path() -> Optional[str]:
142
"""
143
Auto-detect Electron executable path.
144
145
Returns:
146
Optional[str] - Path to Electron executable or None if not found
147
"""
148
```
149
150
**Usage Example:**
151
152
```python
153
import eel
154
155
eel.init('web')
156
157
# Launch with Electron
158
eel.start('main.html', mode='electron')
159
160
# Custom Electron arguments
161
eel.start('app.html',
162
mode='electron',
163
cmdline_args=['--enable-logging'])
164
```
165
166
### Microsoft Edge Support
167
168
Support for Microsoft Edge browser on Windows systems.
169
170
```python { .api }
171
# From eel.edge module
172
name: str = 'Edge'
173
174
def run(_path: str, options: OptionsDictT, start_urls: List[str]) -> None:
175
"""
176
Launch Microsoft Edge with specified options.
177
178
Parameters:
179
- _path: str - Path parameter (unused for Edge)
180
- options: OptionsDictT - Configuration options
181
- start_urls: List[str] - URLs to open
182
183
Returns:
184
None
185
"""
186
187
def find_path() -> bool:
188
"""
189
Check if Microsoft Edge is available.
190
191
Returns:
192
bool - True if Edge is available (Windows only)
193
"""
194
```
195
196
**Usage Example:**
197
198
```python
199
import eel
200
201
eel.init('web')
202
203
# Launch with Edge
204
eel.start('index.html', mode='edge')
205
206
# Edge in app mode
207
eel.start('app.html', mode='edge', app_mode=True)
208
```
209
210
### Internet Explorer Support
211
212
Legacy support for Internet Explorer through Edge redirection.
213
214
```python { .api }
215
# From eel.msIE module
216
name: str = 'MSIE'
217
218
def run(_path: str, options: OptionsDictT, start_urls: List[str]) -> None:
219
"""
220
Launch Internet Explorer (redirects to Edge).
221
222
Parameters:
223
- _path: str - Path parameter (unused)
224
- options: OptionsDictT - Configuration options
225
- start_urls: List[str] - URLs to open
226
227
Returns:
228
None
229
"""
230
231
def find_path() -> bool:
232
"""
233
Check if IE is available.
234
235
Returns:
236
bool - True if available (Windows only)
237
"""
238
```
239
240
### Custom Browser Mode
241
242
Use custom browser commands and configurations.
243
244
**Usage Example:**
245
246
```python
247
import eel
248
249
eel.init('web')
250
251
# Custom browser command
252
eel.start('app.html',
253
mode='custom',
254
cmdline_args=['firefox', '--new-window'])
255
256
# No browser (server only)
257
eel.start('app.html', mode=False) # or mode=None
258
```
259
260
## Browser Mode Options
261
262
Available browser modes for the `mode` parameter in `eel.start()`:
263
264
- **`'chrome'`** - Google Chrome/Chromium (default)
265
- **`'electron'`** - Electron framework
266
- **`'edge'`** - Microsoft Edge
267
- **`'msie'`** - Internet Explorer (legacy)
268
- **`'custom'`** - Custom browser command via `cmdline_args`
269
- **`False`** or **`None`** - No browser (server only)
270
271
## Browser-Specific Options
272
273
### App Mode vs Regular Mode
274
275
```python
276
# App mode (no browser UI)
277
eel.start('app.html', mode='chrome', app_mode=True)
278
279
# Regular browser mode (with address bar, etc.)
280
eel.start('app.html', mode='chrome', app_mode=False)
281
```
282
283
### Command Line Arguments
284
285
```python
286
# Chrome-specific flags
287
eel.start('app.html',
288
mode='chrome',
289
cmdline_args=[
290
'--disable-http-cache',
291
'--disable-web-security',
292
'--allow-running-insecure-content',
293
'--start-fullscreen'
294
])
295
296
# Electron-specific flags
297
eel.start('app.html',
298
mode='electron',
299
cmdline_args=['--enable-logging', '--remote-debugging-port=9222'])
300
```
301
302
### Window Geometry
303
304
```python
305
# Single window size and position
306
eel.start('main.html',
307
size=(1200, 800),
308
position=(100, 50))
309
310
# Per-page geometry
311
eel.start('main.html',
312
geometry={
313
'main.html': {'size': (1200, 800), 'position': (100, 50)},
314
'settings.html': {'size': (600, 400), 'position': (200, 100)}
315
})
316
```