-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
64 lines (46 loc) · 1.59 KB
/
app.py
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
60
61
62
63
64
#!/usr/bin/env python
# encoding: utf-8
"""
app.py
app root file for Slide-OSK
(c) 2019 SnooeyNET
"""
from tkinter import *
import keyboard
from core import windowing
from core.ui_extender import *
class App(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
self.btn = KeyButton(self, text="ㄱ", width=10, height=10, takefocus=0)
self.btn.pack(padx=20, pady=20)
self.btn2 = KeyButton(self, text="ㅜ", width=10, height=10, takefocus=0)
self.btn2.pack(padx=20, pady=20)
self.set_event()
self.set_window()
self.set_window_size()
self.set_window_position()
def app_got_focus(self, event):
self.config(background="yellow")
def app_lost_focus(self, event):
self.config(background="grey")
def handle_return(self, event):
print(f"return: event.widget is {event.widget}")
print(f"focus is {self.focus_get()}")
def set_event(self):
self.bind("<FocusIn>", self.app_got_focus)
self.bind("<FocusOut>", self.app_lost_focus)
self.bind("<Return>", self.handle_return)
def set_window(self):
self.title('keyboard')
self.focusmodel(model=None)
self.attributes("-toolwindow", True)
self.attributes("-topmost", True)
def set_window_size(self):
width = self.winfo_screenwidth()
height = self.winfo_screenheight()
self.geometry('%sx%s' % (int(width/2), int(height/2)))
def set_window_position(self):
self.geometry('-%s-%s' % (5, 5))
if __name__ == '__main__':
windowing.run(App())