How to use on_mouse method in ATX

Best Python code snippet using ATX

sample6.py

Source:sample6.py Github

copy

Full Screen

...17 return 1;18 cv2.DestroyWindow ("Image");19 cv2.ReleaseImage (img);20# コールバック関数21def on_mouse(event, x, y, flags, param):22 global img23 # char str[64];24 max_line = 1525 w = 1526 h = 3027 str = ''28 if event == cv2.EVENT_MOUSEMOVE:29 str = "(%d,%d) %s" % (x, y, "MOUSE_MOVE")30 elif event == cv2.EVENT_LBUTTONDOWN:31 str = "(%d,%d) %s" % (x, y, "LBUTTON_DOWN")32 elif event == cv2.EVENT_RBUTTONDOWN:33 str = "(%d,%d) %s" % (x, y, "RBUTTON_DOWN")34 elif event == cv2.EVENT_MBUTTONDOWN:35 str = "(%d,%d) %s" % (x, y, "MBUTTON_DOWN")...

Full Screen

Full Screen

base.py

Source:base.py Github

copy

Full Screen

1import pyglet2import time3class BaseViewer(pyglet.window.Window):4 def __init__(self, width, height, caption, on_mouse=False, show_fps=False, fps=-1):5 super().__init__(width=width, height=height, resizable=False, caption=caption, vsync=False)6 pyglet.gl.glClearColor(1, 1, 1, 1)7 pyglet.gl.glEnable(pyglet.gl.GL_BLEND)8 pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA, pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)9 self.batch = pyglet.graphics.Batch()10 self.labels = {}11 self.on_mouse = on_mouse12 self.on_mouse = on_mouse13 self.fps = fps14 self.show_fps = show_fps15 self.fps_display = pyglet.window.FPSDisplay(window=self)16 self.keyboard = pyglet.window.key.KeyStateHandler()17 self.push_handlers(self.keyboard)18 def render(self, *args, **kwargs):19 t0 = time.time()20 self.update(*args, **kwargs)21 self.switch_to()22 self.dispatch_events()23 self.dispatch_event('on_draw')24 self.flip()25 if self.fps > 0:26 duration = time.time()-t027 default_duration = 1/self.fps28 if default_duration > duration:29 time.sleep(default_duration - duration)30 def update(self, *args, **kwargs):31 raise NotImplemented32 def on_draw(self):33 self.clear()34 self.batch.draw()35 [v.draw() for v in self.labels.values()]36 if self.show_fps:...

Full Screen

Full Screen

mouse_event_show_info.py

Source:mouse_event_show_info.py Github

copy

Full Screen

1import sys2from matplotlib import pyplot as plt3fig, ax = plt.subplots()4text = ax.text(0.5, 0.5, "event", ha="center", va="center", fontdict={"size": 20})5def on_mouse(event):6 global e7 e = event8 info = "{}\nButton:{}\nFig x,y:{}, {}\nData x,y:{:3.2f}, {:3.2f}".format(9 event.name, event.button, event.x, event.y, event.xdata, event.ydata)10 text.set_text(info)11 fig.canvas.draw()12fig.canvas.mpl_connect('button_press_event', on_mouse)13fig.canvas.mpl_connect('button_release_event', on_mouse)14fig.canvas.mpl_connect('motion_notify_event', on_mouse)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful