Press on touchscreen area. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Press on touchscreen area. (/thread-29995.html) |
Press on touchscreen area. - ATARI_LIVE - Sep-29-2020 I looked up google and seem not same what I am looking for. Here what I am looking for to get position such area on the touchscreen by the finger like 'mousetouch(0,0,100,100)' something with X1,Y1,X2,X2 as from to end area. I need something with code. But not want use any such button or image or else. just screen area. Thanks!! RE: Press on touchscreen area. - deanhystad - Sep-29-2020 Why not a button? A button is just a window that has event handlers that will tell you when the screen is touched. I suppose you could do that by yourself, but why when somebody much better at programming than you or I has already written and tested that code. RE: Press on touchscreen area. - ATARI_LIVE - Sep-29-2020 (Sep-29-2020, 02:31 AM)deanhystad Wrote: Why not a button? A button is just a window that has event handlers that will tell you when the screen is touched. I suppose you could do that by yourself, but why when somebody much better at programming than you or I has already written and tested that code. Yeah, I know, I did use button... But I need to read the touchscreen while the screen is blank for secret like the password. I am a rookie for python but will learn quickly. I am looking for freestyle no matter what screen going on image, game, text, window, etc... I just want the respond to the boolean when touching in the expected area. Thanks! RAM RE: Press on touchscreen area. - ATARI_LIVE - Sep-29-2020 I got good code from other forum! THANK YOU SOCTTY101! here what it's works! import tkinter as tk def pressedInArea(x, y, x1, y1 ,x2 ,y2): return x > x1 and x < x2 and y > y1 and y < y2 def checkPosition(event): print(event.x,event.y) print(pressedInArea(event.x,event.y,0,0,100,100)) root = tk.Tk() c = tk.Canvas(root,width=400,height=400) c.grid() c.bind("<Button-1>", checkPosition) |