Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

Combining Mouse Event Monitoring and Listener Programs: Python Multi-threading Exploration

$
0
0

I hope that while running Listener.py, Monitor.py can also be executed simultaneously. I want to modify Monitor.py to create an array with a maximum size of 10. When the number of mouse signals received reaches 10, it should automatically terminate and print out the signals stored in the array. If the number of signals received is less than 10 but a mouse scroll is detected, it should terminate and output directly. I would like to know how can I combine Listener.py and Monitor.py since Listener.py can only be executed with python3 command, while Monitor.py can only be executed with python command.

Listner.py

from pynput.mouse import Listener# Listen for mouse eventsdef on_click(x, y, button, pressed):    # Do stuff here    passwith Listener(on_click=on_click, suppress=True) as listener:    listener.join()    enter code here

Monitor.py:

from pymouse import PyMouseEventdef fibo():    a = 0    yield a    b = 1    yield b    while True:        a, b = b, a + b        yield bclass Clickonacci(PyMouseEvent):    def __init__(self):        PyMouseEvent.__init__(self)        self.fibo = fibo()    def click(self, x, y, button, press):        if press:            if button == 1:                print("left QAQp")            elif button == 2:                print("right owOb")C = Clickonacci()C.run()

Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>