-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAIKeyboard.py
More file actions
49 lines (42 loc) · 1.4 KB
/
AIKeyboard.py
File metadata and controls
49 lines (42 loc) · 1.4 KB
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
from tkinter import *
import tkinter.scrolledtext as scrolledtext
root = Tk()
root.title("On Screen Keyboard")
root.resizable(0,0)
def select(value):
if value=="<-":
txt = text.get(1.0,END)
val = len(txt)
text.delete(1.0,END)
text.insert(1.0,txt[:val-2])
elif value=="Space":
text.insert(END," ")
elif value == "Tab":
text.insert(END," ")
else:
text.insert(END,value)
# Root Widgets......
text = scrolledtext.ScrolledText(root,width=120,height=5,wrap=WORD,padx=10,pady=10,borderwidth=5,relief=RIDGE)
text.grid(row=1,columnspan=16)
buttons = ['q','w','e','r','t','y','u','i','o','p','<-','7','8','9','-'
,'a','s','d','f','g','h','j','k','l','[',']','4','5','6','+'
,'z','x','c','v','b','n','m',',','.','Tab','0','1','2','3','/',
'Space']
varrow = 2
varcolumn = 0
for button in buttons:
command = lambda x=button:select(x)
if button !='Space':
Button(root,text=button,width=5,bg='black',fg='white',activebackground="white",activeforeground='black',
relief='raised',padx=8,pady=4,bd=6,command=command).grid(row=varrow,column=varcolumn)
if button =='Space':
Button(root,text=button,width=5,bg='black',fg='white',activebackground="white",activeforeground='black',
relief='raised',padx=180,pady=4,bd=6,command=command).grid(row=6,columnspan=16)
varcolumn+=1
if varcolumn > 14 and varrow==2:
varcolumn=0
varrow+=1
if varcolumn > 14 and varrow ==3:
varcolumn=0
varrow+=1
root.mainloop()