Skip to content

Commit 0af803f

Browse files
committed
Fix popup widgets placement (e.g. <select>) in Tkinter example (cztomczak#255).
Popup widgets appeared at wrong location. Also when window was moved or resized their location was not updated.
1 parent b80ff78 commit 0af803f

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

api/Browser.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,11 @@ This is an alias for the `LoadUrl` method.
602602
| --- | --- |
603603
| __Return__ | void |
604604

605-
Notify the browser of move or resize events so that popup windows are
606-
displayed in the correct location and dismissed when the window moves.
607-
Also so that drag&drop areas are updated accordingly. In upstream
608-
cefclient this method is being called only on Linux and Windows.
605+
Notify the browser of move or resize events so that popup widgets
606+
(e.g. `<select>`) are displayed in the correct location and dismissed
607+
when the window moves. Also so that drag&drop areas are updated
608+
accordingly. In upstream cefclient this method is being called
609+
only on Linux and Windows.
609610

610611

611612
### NotifyScreenInfoChanged

examples/tkinter_.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, master):
4646
tk.Frame.__init__(self, master)
4747
self.master.title("Tkinter example")
4848
self.master.protocol("WM_DELETE_WINDOW", self.on_close)
49+
self.master.bind("<Configure>", self.on_root_configure)
4950
self.setup_icon()
5051
self.bind("<Configure>", self.on_configure)
5152
self.bind("<FocusIn>", self.on_focus_in)
@@ -68,10 +69,19 @@ def __init__(self, master):
6869
# Pack MainFrame
6970
self.pack(fill=tk.BOTH, expand=tk.YES)
7071

72+
def on_root_configure(self, _):
73+
logger.debug("MainFrame.on_root_configure")
74+
if self.browser_frame:
75+
self.browser_frame.on_root_configure()
76+
7177
def on_configure(self, event):
72-
self.browser_frame.on_root_configure(
73-
event.width,
74-
event.height-self.navigation_bar.winfo_height())
78+
logger.debug("MainFrame.on_configure")
79+
if self.browser_frame:
80+
width = event.width
81+
height = event.height
82+
if self.navigation_bar:
83+
height = height - self.navigation_bar.winfo_height()
84+
self.browser_frame.on_mainframe_configure(width, height)
7585

7686
def on_focus_in(self, _):
7787
logger.debug("MainFrame.on_focus_in")
@@ -177,6 +187,7 @@ def on_url_focus_out(self, _):
177187

178188
def on_load_url(self, _):
179189
if self.master.get_browser():
190+
self.master.get_browser().StopLoad()
180191
self.master.get_browser().LoadUrl(self.url_entry.get())
181192

182193
def on_button1(self, _):
@@ -252,9 +263,15 @@ def on_configure(self, _):
252263
if not self.browser:
253264
self.embed_browser()
254265

255-
def on_root_configure(self, width, height):
266+
def on_root_configure(self):
267+
# Root <Configure> event will be called when top window is moved
268+
if self.browser:
269+
self.browser.NotifyMoveOrResizeStarted()
270+
271+
def on_mainframe_configure(self, width, height):
256272
if self.browser:
257273
self.browser.SetBounds(0, 0, width, height)
274+
self.browser.NotifyMoveOrResizeStarted()
258275

259276
def on_focus_in(self, _):
260277
logger.debug("BrowserFrame.on_focus_in")

tools/automate.py

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

3-
"""This tool automates building CEF from with CEF Python patches applied.
3+
"""Automates building CEF from sources with CEF Python patches applied.
44
55
Usage:
66
automate.py (--prebuilt-cef | --build-cef)

0 commit comments

Comments
 (0)