Repository navigation
Expand file tree
/
Copy pathwxpython.html
More file actions
212 lines (173 loc) · 6.07 KB
/
Copy pathwxpython.html
File metadata and controls
212 lines (173 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>wxPython CEF 3 example (utf-8: ąś)</title>
<style>
body { font: 13px Segoe UI, Arial; line-height: 1.4em; }
pre { background: #ddd; font: 12px Consolas, Courier New; }
</style>
</head>
<body>
Use mouse context menu to go Back/Forward in history navigation.
<h3>Google Search</h3>
<a href="http://www.google.com/">http://www.google.com/</a>
<h3>User agent</h3>
<script>document.write(navigator.userAgent)</script>
<h3>Popup</h3>
<a href="javascript:window.open('wxpython.html')">
window.open('wxpython.html')</a>
<h3>HTML5 video and accelerated content</h3>
<a href="http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True">
HTML 5 video</a><br>
<a href="http://mudcu.be/labs/JS1k/BreathingGalaxies.html">
Accelerated canvas</a><br>
<a href="http://www.webkit.org/blog-files/3d-transforms/poster-circle.html">
Accelerated layers</a><br>
<h3>Javascript bindings</h3>
<a href="javascript:PyPrint('printing in python console from js')">
PyPrint('printing in python console from js')</a><br>
<a href="javascript:window.alert(window.pyProperty)">
window.alert(window.pyProperty)</a><br>
<a href="javascript:window.alert(JSON.stringify(window.pyConfig))">
window.alert(JSON.stringify(window.pyConfig))</a><br>
<a href="javascript:external.Print('printing again from js')">
external.Print('printing again from js')</a><br>
<a href="javascript:external.TestAllTypes(undefined, null, true, 1,
((1<<31)>>>0), 2.14, 'Date not yet supported', 'string',
{key1: 1, key2: 2}, {key1: {'key1.1': 'nested object'}, 'key1.2': [1]},
[1, 2], [1, [2.1, 'nested array']], [{key1: [{}]}])">
external.TestAllTypes</a>
<small>(undefined, null, true, 1,
((1<<31)>>>0), 2.14, 'Date not yet supported', 'string',
{key1: 1, key2: 2}, {key1: {'key1.1': 'nested object'}, 'key1.2': [1]},
[1, 2], [1, [2.1, 'nested array']], [{key1: [{}]}])</small>
<br>
<script>
function JavascriptAlert(message) { window.alert(message); }
</script>
<pre>
<script>
function JavascriptAlert(message) { window.alert(message); }
</script>
</pre>
<a href="javascript:external.ExecuteFunction('JavascriptAlert',
'python called from js and then js called from python')">
external.ExecuteFunction('JavascriptAlert',
'python called from js and then js called from python')</a>
<h3>Javascript callbacks</h3>
<script>
function JSCallback(arg1) {
window.alert(arg1)
}
</script>
<pre>
<script>
function JSCallback(arg1) {
window.alert(arg1)
}
</script>
</pre>
<pre>
def TestJSCallback(self, jsCallback):
print("jsCallback.GetFunctionName() = %s" % jsCallback.GetFunctionName())
print("jsCallback.GetFrame().GetIdentifier() = %s" % \
jsCallback.GetFrame().GetIdentifier())
jsCallback.Call("This message was sent from python using js callback")
</pre>
<a href="javascript:external.TestJSCallback(JSCallback)">
external.TestJSCallback(JSCallback)</a>
<script>
function JSCallback2() {
window.alert(JSON.stringify(arguments))
}
</script>
<pre>
<script>
function JSCallback2() {
window.alert(JSON.stringify(arguments))
}
</script>
</pre>
<pre>
def TestJSCallbackComplexArguments(self, jsObject):
jsCallback = jsObject["myCallback"];
jsCallback.Call(1, None, 2.14, "string", ["list", ["nested list", \
{"nested object":None}]], \
{"nested list next":[{"deeply nested object":1}]})
</pre>
<a href="javascript:external.TestJSCallbackComplexArguments(
{'myCallback':JSCallback2})">
external.TestJSCallbackComplexArguments({"myCallback": JSCallback2})
</a>
<h3>Python callbacks</h3>
<script>
function JSCallback3(pyCallback) {
pyCallback(1, 2.14, "string", [1, [2, {"key": "value"}]], {"list": [1,2]});
}
</script>
<pre>
<script>
function JSCallback3(pyCallback) {
pyCallback(1, 2.14, "string", [1, [2, {"key": "value"}]], {"list": [1,2]});
}
</script>
</pre>
<pre>
def TestPythonCallback(self, jsCallback):
jsCallback.Call(PyCallback)
def PyCallback(self, *args):
message = "PyCallback() was executed successfully! Arguments: %s" \
% str(args)
print(message)
self.mainBrowser.GetMainFrame().ExecuteJavascript(
"window.alert(\"%s\")" % message)
</pre>
<a href="javascript:external.TestPythonCallback(JSCallback3)">
external.TestPythonCallback(JSCallback3)</a>
<h3>Display handler</h3>
See messages in the console.
<pre>
def OnLoadingStateChange(self, browser, isLoading, canGoBack,
canGoForward):
print("ClientHandler::OnLoadingStateChange()")
print("isLoading = %s, canGoBack = %s, canGoForward = %s" \
% (isLoading, canGoBack, canGoForward))
def OnAddressChange(self, browser, frame, url):
print("ClientHandler::OnAddressChange()")
print("url = %s" % url)
def OnTitleChange(self, browser, title):
print("ClientHandler::OnTitleChange()")
print("title = %s" % title)
def OnTooltip(self, browser, text):
print("ClientHandler::OnTooltip()")
print("text = %s")
def OnStatusMessage(self, browser, value):
print("ClientHandler::OnStatusMessage()")
print("value = %s" % value)
def OnConsoleMessage(self, browser, message, source, line):
print("ClientHandler::OnConsoleMessage()")
print("message = %s" % message)
print("source = %s" % source)
print("line = %s" % line)
</pre>
<h3>Keyboard handler</h3>
<p>
Click anywhere in the window first to set keyboard focus.
Next press F5 to reload the page.
</p>
<pre>
def OnPreKeyEvent(self, browser, event, eventHandle,
isKeyboardShortcutOut):
print("ClientHandler::OnPreKeyEvent()")
def OnKeyEvent(self, browser, event, eventHandle):
print("ClientHandler::OnKeyEvent()")
print("native_key_code = %s" % event["native_key_code"])
if platform.system() == "Linux":
# F5 = 71
if event["native_key_code"] == 71:
print("F5 pressed! Reloading page..")
browser.ReloadIgnoreCache()
</pre>
</body>
</html>