Skip to content

Commit b80ff78

Browse files
committed
Update API docs, build instructions, tools and Tkinter example (cztomczak#255).
1 parent f8286e0 commit b80ff78

File tree

7 files changed

+32
-7
lines changed

7 files changed

+32
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build/
33
*.log
44
__pycache__/
55
*.pyc
6+
cefclient

api/ApplicationSettings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ The default values of options that are suggested in descriptions may not always
4747

4848
There are hundreds of options that can be set through CEF/Chromium command line switches. These switches can be set programmatically by passing a dictionary with switches as second argument to [cefpython](cefpython.md).Initialize(). See the [CommandLineSwitches](CommandLineSwitches.md) wiki page for more information.
4949

50+
Issue #244 is to add even more configurable settings by exposing API
51+
to Chromium Preferences.
52+
5053

5154
## Settings
5255

api/PaintBuffer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Table of contents:
2323

2424
Get int pointer to the `void*` buffer.
2525

26+
Description from upstream CEF:
27+
> |buffer| will be |width|*|height|*4 bytes in size and represents a BGRA
28+
> image with an upper-left origin.
29+
2630

2731
### GetString
2832

docs/Build-instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,9 @@ to be correct, try the -p0 or -p1 flag:
264264
```
265265
git apply -p0 issue251.patch
266266
```
267+
268+
To create a patch from last two commits (no --relative flag available
269+
in this case, so must be in root CEF dir):
270+
```
271+
git format-patch --no-prefix -2 HEAD --stdout > issue251.patch
272+
```

examples/tkinter_.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Example of embedding CEF Python browser using Tkinter toolkit.
22
# This example has two widgets: a navigation bar and a browser.
33
# Tested with Tk 8.6.
4-
# TODO: fix focus issues when switching controls / moving window
4+
5+
# TODO: url entry loses keyboard focus when mouse hovers over browser (#255)
56

67
from cefpython3 import cefpython as cef
78
try:
@@ -143,6 +144,7 @@ def __init__(self, master):
143144
self.url_entry.bind("<FocusIn>", self.on_url_focus_in)
144145
self.url_entry.bind("<FocusOut>", self.on_url_focus_out)
145146
self.url_entry.bind("<Return>", self.on_load_url)
147+
self.url_entry.bind("<Button-1>", self.on_button1)
146148
self.url_entry.grid(row=0, column=3,
147149
sticky=(tk.N + tk.S + tk.E + tk.W))
148150
tk.Grid.rowconfigure(self, 0, weight=100)
@@ -177,6 +179,11 @@ def on_load_url(self, _):
177179
if self.master.get_browser():
178180
self.master.get_browser().LoadUrl(self.url_entry.get())
179181

182+
def on_button1(self, _):
183+
"""Fix CEF focus issues (#255). See also FocusHandler.OnGotFocus."""
184+
logger.debug("NavigationBar.on_button1")
185+
self.master.master.focus_force()
186+
180187
def update_state(self):
181188
browser = self.master.get_browser()
182189
if not browser:
@@ -233,7 +240,8 @@ def embed_browser(self):
233240
url="https://www.google.com/")
234241
self.browser.SetClientHandler(LoadHandler(self))
235242
# FocusHandler requires cefpython 53.2+
236-
# self.browser.SetClientHandler(FocusHandler(self))
243+
if cef.__version__ >= "53.2":
244+
self.browser.SetClientHandler(FocusHandler(self))
237245
self.message_loop_work()
238246

239247
def message_loop_work(self):
@@ -277,6 +285,7 @@ def OnLoadStart(self, browser, _):
277285

278286

279287
class FocusHandler(object):
288+
"""FocusHandler is available in CEF Python 53.2 and higher."""
280289

281290
def __init__(self, browser_frame):
282291
self.browser_frame = browser_frame
@@ -291,7 +300,10 @@ def OnSetFocus(self, _, source):
291300
return False
292301

293302
def OnGotFocus(self, _):
303+
"""Fix CEF focus issues (#255). Call browser frame's focus_set
304+
to get rid of type cursor in url entry widget."""
294305
logger.debug("FocusHandler.OnGotFocus")
306+
self.browser_frame.focus_set()
295307

296308

297309
if __name__ == '__main__':

src/cefpython.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ from cef_path_util cimport *
429429
from cef_drag_data cimport *
430430
from cef_image cimport *
431431
from main_message_loop cimport *
432+
# noinspection PyUnresolvedReferences
432433
from cef_scoped_ptr cimport scoped_ptr
433434

434435

tools/automate.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright (c) 2016 CEF Python, see the Authors file. All rights reserved.
22

3-
# TODO: run automate-git.py using Python 2.7 from depot_tools
4-
5-
"""Build CEF Python and use prebuilt CEF binaries or build CEF from sources.
3+
"""This tool automates building CEF from with CEF Python patches applied.
64
75
Usage:
86
automate.py (--prebuilt-cef | --build-cef)
@@ -24,9 +22,9 @@
2422
--no-cef-update Do not update CEF sources (by default both cef/
2523
directories are deleted on every run).
2624
--cef-branch=<b> CEF branch. Defaults to CHROME_VERSION_BUILD from
27-
"src/version/cef_version_{platform}.h" (TODO).
25+
"src/version/cef_version_{platform}.h".
2826
--cef-commit=<c> CEF revision. Defaults to CEF_COMMIT_HASH from
29-
"src/version/cef_version_{platform}.h" (TODO).
27+
"src/version/cef_version_{platform}.h".
3028
--build-dir=<dir1> Build directory.
3129
--cef-build-dir=<dir2> CEF build directory. By default same
3230
as --build-dir.

0 commit comments

Comments
 (0)