Python Forum
Press on touchscreen area.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Press on touchscreen area.
#1
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!!
Reply
#2
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.
Reply
#3
(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
Reply
#4
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  tkinter - touchscreen, push the button like click the mouse John64 5 740 Jan-06-2024, 03:45 PM
Last Post: deanhystad
  tkinter touchscreen scrolling - button press makes unwanted scrolling nanok66 1 3,921 Dec-28-2020, 10:00 PM
Last Post: nanok66

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020