On-Screen Keyboard
from tkinter import *
def insert_character(char):
text_area.insert(INSERT, char)
win = Tk()
win.title("On Screen Keyboard")
win.geometry("400x200")
win.resizable(False, False)
fnt = ("Arial", 20)
title_label = Label(win, text="On-screen Keyboard", font=fnt)
title_label.grid(row=0, column=0, columnspan=10) # Adjusted columnspan for the title
text_area = Text(win, width=49, height=2, borderwidth=1, relief="groove")
text_area.grid(row=1, column=0, columnspan=10) # Adjusted columnspan for the text area
# Define rows and columns for keys
rows = [
"1234567890",
"QWERTYUIOP",
"ASDFGHJKL;",
"ZXCVBNM,./"
]
rw = 2
for row in rows:
colmn = 0
for button in row:
Button(win, text=button, width=2, padx=2, pady=2, borderwidth=2, relief="raised", bg= "#EFEFEF",fg= "#000000",command=lambda char=button: insert_character(char)).grid(row=rw, column=colmn)
colmn += 1
rw += 1
win.mainloop()
Comments
Post a Comment