FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/src/cefpython3.wx/examples/sample1.py at cefpython57 · lineCode/cefpython · GitHub
lineCode
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
src
/
cefpython3.wx
/
examples
/
sample1.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (50 loc) · 1.86 KB
Breadcrumbs
cefpython
/
src
/
cefpython3.wx
/
examples
/
sample1.py
Copy path
File metadata and controls
59 lines (50 loc) · 1.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# Simple sample ilustrating the usage of CEFWindow class.
# On Mac the cefpython library must be imported the very first,
# before any other libraries (Issue 155).
import
cefpython3
.
wx
.
chromectrl
as
chrome
import
os
import
wx
import
platform
class
MainFrame
(
wx
.
Frame
):
def
__init__
(
self
):
wx
.
Frame
.
__init__
(
self
,
parent
=
None
,
id
=
wx
.
ID_ANY
,
title
=
'cefwx example1'
,
size
=
(
800
,
600
))
self
.
cefWindow
=
chrome
.
ChromeWindow
(
self
,
url
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"sample1.html"
))
sizer
=
wx
.
BoxSizer
()
sizer
.
Add
(
self
.
cefWindow
,
1
,
wx
.
EXPAND
,
0
)
self
.
SetSizer
(
sizer
)
self
.
Bind
(
wx
.
EVT_CLOSE
,
self
.
OnClose
)
def
OnClose
(
self
,
event
):
# Remember to destroy all CEF browser references before calling
# Destroy(), so that browser closes cleanly. In this specific
# example there are no references kept, but keep this in mind
# for the future.
self
.
Destroy
()
# On Mac the code after app.MainLoop() never executes, so
# need to call CEF shutdown here.
if
platform
.
system
()
==
"Darwin"
:
chrome
.
Shutdown
()
wx
.
GetApp
().
Exit
()
class
MyApp
(
wx
.
App
):
def
OnInit
(
self
):
frame
=
MainFrame
()
self
.
SetTopWindow
(
frame
)
frame
.
Show
()
return
True
if
__name__
==
'__main__'
:
chrome
.
Initialize
({
"debug"
:
True
,
"log_file"
:
"debug.log"
,
"log_severity"
:
chrome
.
cefpython
.
LOGSEVERITY_INFO
,
# "cache_path": "webcache/",
})
print
(
'[sample1.py] wx.version=%s'
%
wx
.
version
())
app
=
MyApp
(
False
)
app
.
MainLoop
()
# Important: do the wx cleanup before calling Shutdown
del
app
# On Mac Shutdown is called in OnClose
if
platform
.
system
()
in
[
"Linux"
,
"Windows"
]:
chrome
.
Shutdown
()
Back
|
FazBrowse Home
|
New Git URL