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
| #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tkinter as TK
class TestApp (TK.Tk):
def __init__ (self):
TK.Tk.__init__(self)
self.geometry("300x200+100+50")
self.bind("<FocusIn>", self.window_selected)
self.bind("<FocusOut>", self.window_unselected)
# end def
def window_selected (self, tk_event=None, *args, **kw):
print("FocusIn!")
# end def
def window_unselected (self, tk_event=None, *args, **kw):
print("FocusOut!")
# end def
# end class TestApp
# running test...
if __name__ == "__main__":
TestApp().mainloop()
# end if |
Partager