I try to use the "Tween / Easing Functions" in pyautogui
drag. I understand that it is supported to have the option in a mouse drag. I use Python 3.11.2 on a Raspberry4.
I try in various (I think all) orders the parameter without success:
pyautogui.drag(xOffset=0, yOffset=-20, button='left', pyautogui.easeOutQuad ,duration=2)
my Error msg :
SyntaxError: positional argument follows keyword argument
the drag function work fine without the pyautogui.easeOutQuad
parameter.
pyauto gui docs for reference: https://pyautogui.readthedocs.io/en/latest/mouse.html
any help to get it running is welcome. Thanks a lot for looking into my issue.
If in function you use "keyword parameter" (name=value
) in some place then next parameters (after "keyword parameter") also have to be "keyword parameter" but you use positional parameter pyautogui.easeOutQuad
after "keyword parameter" button='left'
and this gives error "positional argument follows keyword argument"
In documentation I can't find what name it should use for pyautogui.easeOutQuad
but using help(pyautogui.drag)
I got
dragRel(
xOffset=0,
yOffset=0,
duration=0.0,
tween=<function linear at 0x7c7b361ad3a0>,
button='primary',
logScreenshot=None,
_pause=True,
mouseDownUp=True
)
Performs a mouse drag (mouse movement while a button is held down) to a
point on the screen, relative to its current position.
The x and y parameters detail where the mouse event happens. If None, the
current mouse position is used. If a float value, it is rounded down. If
outside the boundaries of the screen, the event happens at edge of the
screen.
Args:
x (int, float, None, tuple, optional): How far left (for negative values) or
right (for positive values) to move the cursor. 0 by default. If tuple, this is used for xOffset and yOffset.
y (int, float, None, optional): How far up (for negative values) or
down (for positive values) to move the cursor. 0 by default.
duration (float, optional): The amount of time it takes to move the mouse
cursor to the new xy coordinates. If 0, then the mouse cursor is moved
instantaneously. 0.0 by default.
tween (func, optional): The tweening function used if the duration is not
0. A linear tween is used by default.
button (str, int, optional): The mouse button released. TODO
mouseDownUp (True, False): When true, the mouseUp/Down actions are not performed.
Which allows dragging over multiple (small) actions. 'True' by default.
Returns:
None
So I expect it has to use tween=pyautogui.easeOutQuad
pyautogui.drag(xOffset=0, yOffset=-20, button='left', tween=pyautogui.easeOutQuad, duration=2)
or you have to use positional parameters in correct order like in documentation - duration, tween, button
instead of button, tween, duration
.
pyautogui.drag(0, -20, 2, pyautogui.easeOutQuad, 'left')
evetually
pyautogui.drag(0, -20, 2, pyautogui.easeOutQuad, button='left')