I have a tkinter GUI running on a Pi 3B+ with a 5" tft touch screen display. I am writing my own touch screen driver. The GUI works when I mouse click on a button that is bound to Button-1.

self.ButtonEnter = tk.Button(top)
self.ButtonEnter.bind('<Button-1>',lambda e:KeyPad_support.Benterevent(e))

touchThread is the touch screen driver object.

   class touchThread:
        self.queue.put([posX, posY])

The touch screen driver gives me the x, y coord of a touch. I want to create a mouse event which passes the x,y values in the event. I am using a queue to thread safe pass [x,y] to my GUI instance.

class myGUI:
    def  __init__ (self, qqueue):   
        self.queue = qqueue
        self.root = tk.TK()

    def processIncoming(self):
        touch = self.queue.get(0)
        # send button-1 event to GUI
        self.root.event_generate('<Button-1>', x=touch[0],y=touch[1])

The touch mechanism works as expected and [x,y] is correctly passed to the GUI object. The issue is that the event_generate('Button-1',...) is ignored.

What do I need to do to get the root window to respond to the simulated mouse click event? Like I said, real mouse clicks events work correctly (the button widget changes to depressed and the event handler prints "button pressed").

Thanks ahead of time.

  • have you done any research? – jsotola Jul 1 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.