|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.WebBrowser.Tools.WebBrowserTools</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.WebBrowser.Tools.WebBrowserTools</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing tool functions for the web browser. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>WebBrowserDataDirectory</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 <tr><td>None</td></tr> |
|
37 </table> |
|
38 <h3>Functions</h3> |
|
39 |
|
40 <table> |
|
41 |
|
42 <tr> |
|
43 <td><a href="#containsSpace">containsSpace</a></td> |
|
44 <td>Function to check, if a string contains whitespace characters.</td> |
|
45 </tr> |
|
46 <tr> |
|
47 <td><a href="#ensureUniqueFilename">ensureUniqueFilename</a></td> |
|
48 <td>Module function to generate an unique file name based on a pattern.</td> |
|
49 </tr> |
|
50 <tr> |
|
51 <td><a href="#filterCharsFromFilename">filterCharsFromFilename</a></td> |
|
52 <td>Module function to filter illegal characters.</td> |
|
53 </tr> |
|
54 <tr> |
|
55 <td><a href="#getFileNameFromUrl">getFileNameFromUrl</a></td> |
|
56 <td>Module function to generate a file name based on the given URL.</td> |
|
57 </tr> |
|
58 <tr> |
|
59 <td><a href="#getHtmlPage">getHtmlPage</a></td> |
|
60 <td>Module function to load a HTML page.</td> |
|
61 </tr> |
|
62 <tr> |
|
63 <td><a href="#getJavascript">getJavascript</a></td> |
|
64 <td>Module function to load a JavaScript source file.</td> |
|
65 </tr> |
|
66 <tr> |
|
67 <td><a href="#getWebEngineVersions">getWebEngineVersions</a></td> |
|
68 <td>Module function to extract the web engine version from the default user agent string.</td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td><a href="#pixmapFileToDataUrl">pixmapFileToDataUrl</a></td> |
|
72 <td>Module function to load a pixmap file and convert the pixmap to a data: URL.</td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td><a href="#pixmapFromByteArray">pixmapFromByteArray</a></td> |
|
76 <td>Module function to convert a byte array to a pixmap.</td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td><a href="#pixmapToByteArray">pixmapToByteArray</a></td> |
|
80 <td>Module function to convert a pixmap to a byte array containing the pixmap as a PNG encoded as base64.</td> |
|
81 </tr> |
|
82 <tr> |
|
83 <td><a href="#pixmapToDataUrl">pixmapToDataUrl</a></td> |
|
84 <td>Module function to convert a pixmap to a data: URL.</td> |
|
85 </tr> |
|
86 <tr> |
|
87 <td><a href="#readAllFileByteContents">readAllFileByteContents</a></td> |
|
88 <td>Function to read the bytes contents of the given file.</td> |
|
89 </tr> |
|
90 <tr> |
|
91 <td><a href="#readAllFileContents">readAllFileContents</a></td> |
|
92 <td>Function to read the string contents of the given file.</td> |
|
93 </tr> |
|
94 </table> |
|
95 <hr /> |
|
96 <hr /> |
|
97 <a NAME="containsSpace" ID="containsSpace"></a> |
|
98 <h2>containsSpace</h2> |
|
99 <b>containsSpace</b>(<i>string</i>) |
|
100 |
|
101 <p> |
|
102 Function to check, if a string contains whitespace characters. |
|
103 </p> |
|
104 <dl> |
|
105 |
|
106 <dt><i>string</i> (str)</dt> |
|
107 <dd> |
|
108 string to be checked |
|
109 </dd> |
|
110 </dl> |
|
111 <dl> |
|
112 <dt>Return:</dt> |
|
113 <dd> |
|
114 flag indicating the presence of at least one whitespace character |
|
115 </dd> |
|
116 </dl> |
|
117 <dl> |
|
118 <dt>Return Type:</dt> |
|
119 <dd> |
|
120 bool |
|
121 </dd> |
|
122 </dl> |
|
123 <div align="right"><a href="#top">Up</a></div> |
|
124 <hr /> |
|
125 <hr /> |
|
126 <a NAME="ensureUniqueFilename" ID="ensureUniqueFilename"></a> |
|
127 <h2>ensureUniqueFilename</h2> |
|
128 <b>ensureUniqueFilename</b>(<i>name, appendFormat="({0})"</i>) |
|
129 |
|
130 <p> |
|
131 Module function to generate an unique file name based on a pattern. |
|
132 </p> |
|
133 <dl> |
|
134 |
|
135 <dt><i>name</i></dt> |
|
136 <dd> |
|
137 desired file name (string) |
|
138 </dd> |
|
139 <dt><i>appendFormat</i></dt> |
|
140 <dd> |
|
141 format pattern to be used to make the unique name |
|
142 (string) |
|
143 </dd> |
|
144 </dl> |
|
145 <dl> |
|
146 <dt>Return:</dt> |
|
147 <dd> |
|
148 unique file name |
|
149 </dd> |
|
150 </dl> |
|
151 <div align="right"><a href="#top">Up</a></div> |
|
152 <hr /> |
|
153 <hr /> |
|
154 <a NAME="filterCharsFromFilename" ID="filterCharsFromFilename"></a> |
|
155 <h2>filterCharsFromFilename</h2> |
|
156 <b>filterCharsFromFilename</b>(<i>name</i>) |
|
157 |
|
158 <p> |
|
159 Module function to filter illegal characters. |
|
160 </p> |
|
161 <dl> |
|
162 |
|
163 <dt><i>name</i></dt> |
|
164 <dd> |
|
165 name to be sanitized (string) |
|
166 </dd> |
|
167 </dl> |
|
168 <dl> |
|
169 <dt>Return:</dt> |
|
170 <dd> |
|
171 sanitized name (string) |
|
172 </dd> |
|
173 </dl> |
|
174 <div align="right"><a href="#top">Up</a></div> |
|
175 <hr /> |
|
176 <hr /> |
|
177 <a NAME="getFileNameFromUrl" ID="getFileNameFromUrl"></a> |
|
178 <h2>getFileNameFromUrl</h2> |
|
179 <b>getFileNameFromUrl</b>(<i>url</i>) |
|
180 |
|
181 <p> |
|
182 Module function to generate a file name based on the given URL. |
|
183 </p> |
|
184 <dl> |
|
185 |
|
186 <dt><i>url</i></dt> |
|
187 <dd> |
|
188 URL (QUrl) |
|
189 </dd> |
|
190 </dl> |
|
191 <dl> |
|
192 <dt>Return:</dt> |
|
193 <dd> |
|
194 file name (string) |
|
195 </dd> |
|
196 </dl> |
|
197 <div align="right"><a href="#top">Up</a></div> |
|
198 <hr /> |
|
199 <hr /> |
|
200 <a NAME="getHtmlPage" ID="getHtmlPage"></a> |
|
201 <h2>getHtmlPage</h2> |
|
202 <b>getHtmlPage</b>(<i>pageFileName</i>) |
|
203 |
|
204 <p> |
|
205 Module function to load a HTML page. |
|
206 </p> |
|
207 <p> |
|
208 Note: If the given HTML file path is not absolute, it is assumed to |
|
209 denote a HTML file in the html data directory. |
|
210 </p> |
|
211 <dl> |
|
212 |
|
213 <dt><i>pageFileName</i> (str)</dt> |
|
214 <dd> |
|
215 file name of the HTML file |
|
216 </dd> |
|
217 </dl> |
|
218 <dl> |
|
219 <dt>Return:</dt> |
|
220 <dd> |
|
221 HTML page |
|
222 </dd> |
|
223 </dl> |
|
224 <dl> |
|
225 <dt>Return Type:</dt> |
|
226 <dd> |
|
227 str |
|
228 </dd> |
|
229 </dl> |
|
230 <div align="right"><a href="#top">Up</a></div> |
|
231 <hr /> |
|
232 <hr /> |
|
233 <a NAME="getJavascript" ID="getJavascript"></a> |
|
234 <h2>getJavascript</h2> |
|
235 <b>getJavascript</b>(<i>jsFileName</i>) |
|
236 |
|
237 <p> |
|
238 Module function to load a JavaScript source file. |
|
239 </p> |
|
240 <p> |
|
241 Note: If the given JavaScript source file path is not absolute, it is |
|
242 assumed to denote a JavaScript source file in the javascript data |
|
243 directory. |
|
244 </p> |
|
245 <dl> |
|
246 |
|
247 <dt><i>jsFileName</i> (str)</dt> |
|
248 <dd> |
|
249 file name of the JavaScript source file |
|
250 </dd> |
|
251 </dl> |
|
252 <dl> |
|
253 <dt>Return:</dt> |
|
254 <dd> |
|
255 JavaScript source |
|
256 </dd> |
|
257 </dl> |
|
258 <dl> |
|
259 <dt>Return Type:</dt> |
|
260 <dd> |
|
261 str |
|
262 </dd> |
|
263 </dl> |
|
264 <div align="right"><a href="#top">Up</a></div> |
|
265 <hr /> |
|
266 <hr /> |
|
267 <a NAME="getWebEngineVersions" ID="getWebEngineVersions"></a> |
|
268 <h2>getWebEngineVersions</h2> |
|
269 <b>getWebEngineVersions</b>(<i></i>) |
|
270 |
|
271 <p> |
|
272 Module function to extract the web engine version from the default user |
|
273 agent string. |
|
274 </p> |
|
275 <dl> |
|
276 <dt>Return:</dt> |
|
277 <dd> |
|
278 tuple containing the Chrome version and the QtWebEngine version |
|
279 </dd> |
|
280 </dl> |
|
281 <dl> |
|
282 <dt>Return Type:</dt> |
|
283 <dd> |
|
284 tuple of str |
|
285 </dd> |
|
286 </dl> |
|
287 <div align="right"><a href="#top">Up</a></div> |
|
288 <hr /> |
|
289 <hr /> |
|
290 <a NAME="pixmapFileToDataUrl" ID="pixmapFileToDataUrl"></a> |
|
291 <h2>pixmapFileToDataUrl</h2> |
|
292 <b>pixmapFileToDataUrl</b>(<i>pixmapFile, asString=False</i>) |
|
293 |
|
294 <p> |
|
295 Module function to load a pixmap file and convert the pixmap to a |
|
296 data: URL. |
|
297 </p> |
|
298 <p> |
|
299 Note: If the given pixmap file path is not absolute, it is assumed to |
|
300 denote a pixmap file in the icons data directory. |
|
301 </p> |
|
302 <dl> |
|
303 |
|
304 <dt><i>pixmapFile</i> (str)</dt> |
|
305 <dd> |
|
306 file name of the pixmap file |
|
307 </dd> |
|
308 <dt><i>asString</i> (bool)</dt> |
|
309 <dd> |
|
310 flag indicating a string representation is requested |
|
311 </dd> |
|
312 </dl> |
|
313 <dl> |
|
314 <dt>Return:</dt> |
|
315 <dd> |
|
316 data: URL |
|
317 </dd> |
|
318 </dl> |
|
319 <dl> |
|
320 <dt>Return Type:</dt> |
|
321 <dd> |
|
322 QUrl or str |
|
323 </dd> |
|
324 </dl> |
|
325 <div align="right"><a href="#top">Up</a></div> |
|
326 <hr /> |
|
327 <hr /> |
|
328 <a NAME="pixmapFromByteArray" ID="pixmapFromByteArray"></a> |
|
329 <h2>pixmapFromByteArray</h2> |
|
330 <b>pixmapFromByteArray</b>(<i>data</i>) |
|
331 |
|
332 <p> |
|
333 Module function to convert a byte array to a pixmap. |
|
334 </p> |
|
335 <dl> |
|
336 |
|
337 <dt><i>data</i> (bytes or QByteArray)</dt> |
|
338 <dd> |
|
339 data for the pixmap |
|
340 </dd> |
|
341 </dl> |
|
342 <dl> |
|
343 <dt>Return:</dt> |
|
344 <dd> |
|
345 extracted pixmap |
|
346 </dd> |
|
347 </dl> |
|
348 <dl> |
|
349 <dt>Return Type:</dt> |
|
350 <dd> |
|
351 QPixmap |
|
352 </dd> |
|
353 </dl> |
|
354 <div align="right"><a href="#top">Up</a></div> |
|
355 <hr /> |
|
356 <hr /> |
|
357 <a NAME="pixmapToByteArray" ID="pixmapToByteArray"></a> |
|
358 <h2>pixmapToByteArray</h2> |
|
359 <b>pixmapToByteArray</b>(<i>pixmap</i>) |
|
360 |
|
361 <p> |
|
362 Module function to convert a pixmap to a byte array containing the pixmap |
|
363 as a PNG encoded as base64. |
|
364 </p> |
|
365 <dl> |
|
366 |
|
367 <dt><i>pixmap</i> (QPixmap)</dt> |
|
368 <dd> |
|
369 pixmap to be converted |
|
370 </dd> |
|
371 </dl> |
|
372 <dl> |
|
373 <dt>Return:</dt> |
|
374 <dd> |
|
375 byte array containing the pixmap |
|
376 </dd> |
|
377 </dl> |
|
378 <dl> |
|
379 <dt>Return Type:</dt> |
|
380 <dd> |
|
381 QByteArray |
|
382 </dd> |
|
383 </dl> |
|
384 <div align="right"><a href="#top">Up</a></div> |
|
385 <hr /> |
|
386 <hr /> |
|
387 <a NAME="pixmapToDataUrl" ID="pixmapToDataUrl"></a> |
|
388 <h2>pixmapToDataUrl</h2> |
|
389 <b>pixmapToDataUrl</b>(<i>pixmap, mimetype="image/png"</i>) |
|
390 |
|
391 <p> |
|
392 Module function to convert a pixmap to a data: URL. |
|
393 </p> |
|
394 <dl> |
|
395 |
|
396 <dt><i>pixmap</i> (QPixmap)</dt> |
|
397 <dd> |
|
398 pixmap to be converted |
|
399 </dd> |
|
400 <dt><i>mimetype</i> (str)</dt> |
|
401 <dd> |
|
402 MIME type to be used |
|
403 </dd> |
|
404 </dl> |
|
405 <dl> |
|
406 <dt>Return:</dt> |
|
407 <dd> |
|
408 data: URL |
|
409 </dd> |
|
410 </dl> |
|
411 <dl> |
|
412 <dt>Return Type:</dt> |
|
413 <dd> |
|
414 QUrl |
|
415 </dd> |
|
416 </dl> |
|
417 <div align="right"><a href="#top">Up</a></div> |
|
418 <hr /> |
|
419 <hr /> |
|
420 <a NAME="readAllFileByteContents" ID="readAllFileByteContents"></a> |
|
421 <h2>readAllFileByteContents</h2> |
|
422 <b>readAllFileByteContents</b>(<i>filename</i>) |
|
423 |
|
424 <p> |
|
425 Function to read the bytes contents of the given file. |
|
426 </p> |
|
427 <dl> |
|
428 |
|
429 <dt><i>filename</i> (str)</dt> |
|
430 <dd> |
|
431 name of the file |
|
432 </dd> |
|
433 </dl> |
|
434 <dl> |
|
435 <dt>Return:</dt> |
|
436 <dd> |
|
437 contents of the file |
|
438 </dd> |
|
439 </dl> |
|
440 <dl> |
|
441 <dt>Return Type:</dt> |
|
442 <dd> |
|
443 str |
|
444 </dd> |
|
445 </dl> |
|
446 <div align="right"><a href="#top">Up</a></div> |
|
447 <hr /> |
|
448 <hr /> |
|
449 <a NAME="readAllFileContents" ID="readAllFileContents"></a> |
|
450 <h2>readAllFileContents</h2> |
|
451 <b>readAllFileContents</b>(<i>filename</i>) |
|
452 |
|
453 <p> |
|
454 Function to read the string contents of the given file. |
|
455 </p> |
|
456 <dl> |
|
457 |
|
458 <dt><i>filename</i> (str)</dt> |
|
459 <dd> |
|
460 name of the file |
|
461 </dd> |
|
462 </dl> |
|
463 <dl> |
|
464 <dt>Return:</dt> |
|
465 <dd> |
|
466 contents of the file |
|
467 </dd> |
|
468 </dl> |
|
469 <dl> |
|
470 <dt>Return Type:</dt> |
|
471 <dd> |
|
472 str |
|
473 </dd> |
|
474 </dl> |
|
475 <div align="right"><a href="#top">Up</a></div> |
|
476 <hr /> |
|
477 </body></html> |