Skip to content

Commit 076b6a6

Browse files
committed
Fix tkinter focus problems on Linux (cztomczak#535).
1 parent b7f25aa commit 076b6a6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/tkinter_.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ def on_focus_in(self, _):
219219

220220
def on_focus_out(self, _):
221221
logger.debug("BrowserFrame.on_focus_out")
222+
"""For focus problems see Issue #255 and Issue #535. """
223+
if LINUX and self.browser:
224+
self.browser.SetFocus(False)
222225

223226
def on_root_close(self):
224227
if self.browser:
@@ -255,10 +258,15 @@ def OnTakeFocus(self, next_component, **_):
255258
def OnSetFocus(self, source, **_):
256259
logger.debug("FocusHandler.OnSetFocus, source={source}"
257260
.format(source=source))
258-
return True
261+
if LINUX:
262+
return False
263+
else:
264+
return True
259265

260266
def OnGotFocus(self, **_):
261267
logger.debug("FocusHandler.OnGotFocus")
268+
if LINUX:
269+
self.browser_frame.focus_set()
262270

263271

264272
class NavigationBar(tk.Frame):

0 commit comments

Comments
 (0)