3
3
from PyQt5 .QtWebKitWidgets import QWebView , QWebPage , QWebInspector
4
4
from PyQt5 .QtWebKit import QWebSettings
5
5
from PyQt5 .QtWidgets import QShortcut , QDialog , QGridLayout , QWidget
6
- from PyQt5 .QtCore import Qt
6
+ from PyQt5 .QtCore import Qt , QDir
7
7
8
8
9
9
class WebViewPlus (QWebView ):
@@ -26,15 +26,28 @@ def __init__(self):
26
26
self ._setupWebview ()
27
27
28
28
def _setupWebview (self ):
29
- self .settings ().setAttribute (QWebSettings .LocalStorageEnabled , True )
30
- self .settings ().setAttribute (QWebSettings .OfflineStorageDatabaseEnabled , True )
31
- self .settings ().setLocalStoragePath ("storage" )
29
+ settings = self .settings ()
30
+ currentPath = QDir .currentPath ()
31
+ settings .setAttribute (QWebSettings .LocalStorageEnabled , True )
32
+ settings .setAttribute (QWebSettings .OfflineStorageDatabaseEnabled , True )
33
+ settings .setAttribute (QWebSettings .OfflineWebApplicationCacheEnabled , True )
34
+ settings .setAttribute (QWebSettings .DnsPrefetchEnabled , True )
35
+ settings .setAttribute (QWebSettings .CSSGridLayoutEnabled , True )
36
+ settings .setAttribute (QWebSettings .JavascriptCanOpenWindows , True )
37
+ settings .setAttribute (QWebSettings .JavascriptCanCloseWindows , True )
38
+ settings .setAttribute (QWebSettings .JavascriptCanAccessClipboard , True )
39
+ settings .setAttribute (QWebSettings .DeveloperExtrasEnabled , True )
40
+ settings .setOfflineStoragePath (currentPath + "/storage/offline" )
41
+ settings .setOfflineWebApplicationCachePath (currentPath + "/storage/webcache" )
42
+ settings .setLocalStoragePath (currentPath + "/storage/local" )
43
+ settings .setOfflineStorageDefaultQuota (5 * 1024 * 1024 )
44
+ settings .setOfflineWebApplicationCacheQuota (5 * 1024 * 1024 )
45
+ settings .enablePersistentStorage ()
32
46
33
47
"""
34
48
F12키를 누르면 "개발자 도구"가 노출됨
35
49
"""
36
50
# webinspector
37
- self .settings ().setAttribute (QWebSettings .DeveloperExtrasEnabled , True )
38
51
self .webInspector = QWebInspector (self )
39
52
self .webInspector .setPage (self .page ())
40
53
0 commit comments