我将树莓派3b型连接到7英寸触摸屏,我希望编写一个将屏幕用作按钮的python代码,但有必要使整个屏幕的工作与普通按钮相反。< / p>
有什么主意吗? 在这里我被困住了
***python
from tkinter import * # Import Tkinter
from tkinter import ttk
from tkinter import font
import time
from datetime import datetime, date
def quit(*args):
root.destroy()
def show_time():
txt.set(time.strftime("%H:%M:%S"))
root.after(1000, show_time)
def motion(event):
print("Mouse position: (%s %s)" % (event.x, event.y))
return
root = Tk()
root.attributes("-fullscreen", True)
root.bind("<Escape>", quit)
root.bind("x", quit)
root.geometry("800x600")
root.after(1000, show_time)
fnt = font.Font(family='Helvetica', size=55, weight='bold')
txt = StringVar()
datestr = StringVar()
photo = PhotoImage(file="splash8(1).png")
w = Label(root, image=photo)
w.pack()
w = photo.width()
h = photo.height()
root.geometry("%dx%d+50+30" % (w, h))
t = datetime.now()
txt.set(time.strftime("%H:%M:%S"))
lbl1 = ttk.Label(root, textvariable=txt, font=fnt, foreground="black", background="white")
lbl1.place(relx=0.53, rely=0.25, anchor=CENTER)
screen_action = "screen was tapped"
msg = Message(root, text=screen_action)
msg.config(bg='lightgreen', fg='red', font=('times', 24, 'italic'))
msg.bind('<Motion>', motion)
msg.pack()
mainloop()
root.mainloop()