| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en-US"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1"> |
| 6 |
<title>Loading animation | pywebview (v2.4)</title> |
| 7 |
<meta name="description" content="Build GUI for your Python program with JavaScript, HTML, and CSS"> |
| 8 |
|
| 9 |
|
| 10 |
<link rel="preload" href="/2.4/assets/css/0.styles.e542dfbb.css" as="style"><link rel="preload" href="/2.4/assets/js/app.ab883ad2.js" as="script"><link rel="preload" href="/2.4/assets/js/20.b1804ec3.js" as="script"><link rel="prefetch" href="/2.4/assets/js/10.946430c0.js"><link rel="prefetch" href="/2.4/assets/js/11.9f37de77.js"><link rel="prefetch" href="/2.4/assets/js/12.cc649247.js"><link rel="prefetch" href="/2.4/assets/js/13.94ca571d.js"><link rel="prefetch" href="/2.4/assets/js/14.a047eef4.js"><link rel="prefetch" href="/2.4/assets/js/15.788bb271.js"><link rel="prefetch" href="/2.4/assets/js/16.694894b2.js"><link rel="prefetch" href="/2.4/assets/js/17.2edfeaf2.js"><link rel="prefetch" href="/2.4/assets/js/18.7b4619dc.js"><link rel="prefetch" href="/2.4/assets/js/19.ec102f84.js"><link rel="prefetch" href="/2.4/assets/js/2.06af3526.js"><link rel="prefetch" href="/2.4/assets/js/21.82f7ca23.js"><link rel="prefetch" href="/2.4/assets/js/22.0e759d36.js"><link rel="prefetch" href="/2.4/assets/js/23.8e7b242c.js"><link rel="prefetch" href="/2.4/assets/js/24.720f51e9.js"><link rel="prefetch" href="/2.4/assets/js/25.3af86868.js"><link rel="prefetch" href="/2.4/assets/js/26.562c94d4.js"><link rel="prefetch" href="/2.4/assets/js/27.7c95cefd.js"><link rel="prefetch" href="/2.4/assets/js/28.d5836b93.js"><link rel="prefetch" href="/2.4/assets/js/29.528821ab.js"><link rel="prefetch" href="/2.4/assets/js/3.c462cbf1.js"><link rel="prefetch" href="/2.4/assets/js/30.e6e32fda.js"><link rel="prefetch" href="/2.4/assets/js/31.c651468e.js"><link rel="prefetch" href="/2.4/assets/js/32.6c8529fe.js"><link rel="prefetch" href="/2.4/assets/js/33.96fe48c6.js"><link rel="prefetch" href="/2.4/assets/js/34.1503f1f8.js"><link rel="prefetch" href="/2.4/assets/js/35.2c565ae8.js"><link rel="prefetch" href="/2.4/assets/js/36.60799f3e.js"><link rel="prefetch" href="/2.4/assets/js/37.5656488c.js"><link rel="prefetch" href="/2.4/assets/js/38.30116eb6.js"><link rel="prefetch" href="/2.4/assets/js/39.8b7a8ec5.js"><link rel="prefetch" href="/2.4/assets/js/4.cc18902f.js"><link rel="prefetch" href="/2.4/assets/js/40.14c37596.js"><link rel="prefetch" href="/2.4/assets/js/5.b85830ed.js"><link rel="prefetch" href="/2.4/assets/js/6.fe285e19.js"><link rel="prefetch" href="/2.4/assets/js/7.5eeb60d8.js"><link rel="prefetch" href="/2.4/assets/js/8.b9ad99cd.js"><link rel="prefetch" href="/2.4/assets/js/9.6a770a26.js"> |
| 11 |
<link rel="stylesheet" href="/2.4/assets/css/0.styles.e542dfbb.css"> |
| 12 |
</head> |
| 13 |
<body> |
| 14 |
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/2.4/" class="home-link router-link-active"><!----> <span class="site-name">pywebview (v2.4)</span></a> <div class="links" style="max-width:nullpx;"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/2.4/guide/" class="nav-link">Guide</a></div><div class="nav-item"><a href="/2.4/examples/" class="nav-link router-link-active">Examples</a></div><div class="nav-item"><a href="/2.4/contributing/" class="nav-link">Contributing</a></div><div class="nav-item"><a href="https://pywebview.flowrl.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| 15 |
Current version |
| 16 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://github.com/r0x0r/pywebview/blob/master/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| 17 |
Changelog |
| 18 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <a href="https://github.com/r0x0r/pywebview" target="_blank" rel="noopener noreferrer" class="repo-link"> |
| 19 |
GitHub |
| 20 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/2.4/guide/" class="nav-link">Guide</a></div><div class="nav-item"><a href="/2.4/examples/" class="nav-link router-link-active">Examples</a></div><div class="nav-item"><a href="/2.4/contributing/" class="nav-link">Contributing</a></div><div class="nav-item"><a href="https://pywebview.flowrl.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| 21 |
Current version |
| 22 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><a href="https://github.com/r0x0r/pywebview/blob/master/CHANGELOG.md" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| 23 |
Changelog |
| 24 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <a href="https://github.com/r0x0r/pywebview" target="_blank" rel="noopener noreferrer" class="repo-link"> |
| 25 |
GitHub |
| 26 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav> <ul class="sidebar-links"><li><a href="/2.4/examples/change_url.html" class="sidebar-link">Change URL</a></li><li><a href="/2.4/examples/css_load.html" class="sidebar-link">CSS load</a></li><li><a href="/2.4/examples/debug.html" class="sidebar-link">Debugging</a></li><li><a href="/2.4/examples/destroy_window.html" class="sidebar-link">Destroy window</a></li><li><a href="/2.4/examples/fullscreen.html" class="sidebar-link">Fullscreen window</a></li><li><a href="/2.4/examples/get_current_url.html" class="sidebar-link">Get current URL</a></li><li><a href="/2.4/examples/html_load.html" class="sidebar-link">HTML load</a></li><li><a href="/2.4/examples/js_evaluate.html" class="sidebar-link">Javascript evaluation</a></li><li><a href="/2.4/examples/js_api.html" class="sidebar-link">Javascript API</a></li><li><a href="/2.4/examples/loading_animation.html" class="active sidebar-link">Loading animation</a></li><li><a href="/2.4/examples/localization.html" class="sidebar-link">Localization</a></li><li><a href="/2.4/examples/min_size.html" class="sidebar-link">Minimum window size</a></li><li><a href="/2.4/examples/multiple_windows.html" class="sidebar-link">Multi-window</a></li><li><a href="/2.4/examples/open_file_dialog.html" class="sidebar-link">Open file dialog</a></li><li><a href="/2.4/examples/open_url.html" class="sidebar-link">Open URL</a></li><li><a href="/2.4/examples/quit_confirm.html" class="sidebar-link">Quit confirmation dialog</a></li><li><a href="/2.4/examples/save_file_dialog.html" class="sidebar-link">Save file dialog</a></li><li><a href="/2.4/examples/toggle_fullscreen.html" class="sidebar-link">Toggle full-screen</a></li><li><a href="/2.4/examples/window_title_change.html" class="sidebar-link">Window title change</a></li></ul> </div> <div class="page"> <div class="content"><h1 id="loading-animation"><a href="#loading-animation" aria-hidden="true" class="header-anchor">#</a> Loading animation</h1> <p>Create a loading animation that is displayed before application is loaded.</p> <div class="language-python extra-class"><pre class="language-python"><code><span class="token keyword">import</span> webview |
| 27 |
<span class="token keyword">import</span> threading |
| 28 |
|
| 29 |
|
| 30 |
<span class="token keyword">def</span> <span class="token function">load_html</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> |
| 31 |
webview<span class="token punctuation">.</span>load_html<span class="token punctuation">(</span><span class="token triple-quoted-string string">""" |
| 32 |
<style> |
| 33 |
body { |
| 34 |
background-color: #333; |
| 35 |
color: white; |
| 36 |
font-family: Helvetica Neue, Helvetica, Arial, sans-serif; |
| 37 |
} |
| 38 |
|
| 39 |
.main-container { |
| 40 |
width: 100%; |
| 41 |
height: 90vh; |
| 42 |
display: flex; |
| 43 |
display: -webkit-flex; |
| 44 |
align-items: center; |
| 45 |
-webkit-align-items: center; |
| 46 |
justify-content: center; |
| 47 |
-webkit-justify-content: center; |
| 48 |
overflow: hidden; |
| 49 |
} |
| 50 |
|
| 51 |
.loading-container { |
| 52 |
} |
| 53 |
|
| 54 |
.loader { |
| 55 |
font-size: 10px; |
| 56 |
margin: 50px auto; |
| 57 |
text-indent: -9999em; |
| 58 |
width: 3rem; |
| 59 |
height: 3rem; |
| 60 |
border-radius: 50%; |
| 61 |
background: #ffffff; |
| 62 |
background: -moz-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%); |
| 63 |
background: -webkit-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%); |
| 64 |
background: -o-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%); |
| 65 |
background: -ms-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%); |
| 66 |
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%); |
| 67 |
position: relative; |
| 68 |
-webkit-animation: load3 1.4s infinite linear; |
| 69 |
animation: load3 1.4s infinite linear; |
| 70 |
-webkit-transform: translateZ(0); |
| 71 |
-ms-transform: translateZ(0); |
| 72 |
transform: translateZ(0); |
| 73 |
} |
| 74 |
.loader:before { |
| 75 |
width: 50%; |
| 76 |
height: 50%; |
| 77 |
background: #ffffff; |
| 78 |
border-radius: 100% 0 0 0; |
| 79 |
position: absolute; |
| 80 |
top: 0; |
| 81 |
left: 0; |
| 82 |
content: ''; |
| 83 |
} |
| 84 |
.loader:after { |
| 85 |
background: #333; |
| 86 |
width: 75%; |
| 87 |
height: 75%; |
| 88 |
border-radius: 50%; |
| 89 |
content: ''; |
| 90 |
margin: auto; |
| 91 |
position: absolute; |
| 92 |
top: 0; |
| 93 |
left: 0; |
| 94 |
bottom: 0; |
| 95 |
right: 0; |
| 96 |
} |
| 97 |
@-webkit-keyframes load3 { |
| 98 |
0% { |
| 99 |
-webkit-transform: rotate(0deg); |
| 100 |
transform: rotate(0deg); |
| 101 |
} |
| 102 |
100% { |
| 103 |
-webkit-transform: rotate(360deg); |
| 104 |
transform: rotate(360deg); |
| 105 |
} |
| 106 |
} |
| 107 |
@keyframes load3 { |
| 108 |
0% { |
| 109 |
-webkit-transform: rotate(0deg); |
| 110 |
transform: rotate(0deg); |
| 111 |
} |
| 112 |
100% { |
| 113 |
-webkit-transform: rotate(360deg); |
| 114 |
transform: rotate(360deg); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
.loaded-container { |
| 119 |
display: none; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
</style> |
| 124 |
<body> |
| 125 |
<div class="main-container"> |
| 126 |
<div id="loader" class="loading-container"> |
| 127 |
<div class="loader">Loading...</div> |
| 128 |
</div> |
| 129 |
|
| 130 |
<div id="main" class="loaded-container"> |
| 131 |
<h1>Content is loaded!</h1> |
| 132 |
</div> |
| 133 |
</div> |
| 134 |
|
| 135 |
<script> |
| 136 |
setTimeout(function() { |
| 137 |
document.getElementById('loader').style.display = 'none' |
| 138 |
document.getElementById('main').style.display = 'block' |
| 139 |
}, 5000) |
| 140 |
</script> |
| 141 |
</body> |
| 142 |
|
| 143 |
"""</span><span class="token punctuation">)</span> |
| 144 |
|
| 145 |
|
| 146 |
<span class="token keyword">if</span> __name__ <span class="token operator">==</span> <span class="token string">'__main__'</span><span class="token punctuation">:</span> |
| 147 |
t <span class="token operator">=</span> threading<span class="token punctuation">.</span>Thread<span class="token punctuation">(</span>target<span class="token operator">=</span>load_html<span class="token punctuation">)</span> |
| 148 |
t<span class="token punctuation">.</span>start<span class="token punctuation">(</span><span class="token punctuation">)</span> |
| 149 |
|
| 150 |
webview<span class="token punctuation">.</span>create_window<span class="token punctuation">(</span><span class="token string">'Loading Animation'</span><span class="token punctuation">,</span> background_color<span class="token operator">=</span><span class="token string">'#333333'</span><span class="token punctuation">)</span> |
| 151 |
</code></pre></div></div> <div class="page-edit"><div class="edit-link"><a href="https://github.com/r0x0r/pywebview/edit/docs/docs/examples/loading_animation.md" target="_blank" rel="noopener noreferrer">Help us improve this page!</a> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></div> <!----></div> <div class="page-nav"><p class="inner"><span class="prev"> |
| 152 |
← |
| 153 |
<a href="/2.4/examples/js_api.html" class="prev"> |
| 154 |
Javascript API |
| 155 |
</a></span> <span class="next"><a href="/2.4/examples/localization.html"> |
| 156 |
Localization |
| 157 |
</a> |
| 158 |
→ |
| 159 |
</span></p></div> </div> <!----></div></div> |
| 160 |
<script src="/2.4/assets/js/app.ab883ad2.js" defer></script><script src="/2.4/assets/js/20.b1804ec3.js" defer></script> |
| 161 |
</body> |
| 162 |
</html> |