Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/neteditTestFunctions/general/contextualMenu.py
169678 views
1
# -*- coding: utf-8 -*-
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file contextualMenu.py
15
# @author Pablo Alvarez Lopez
16
# @date 28-05-25
17
18
# imports
19
import time
20
import pyautogui
21
from ..constants import DELAY_MOUSE_MOVE, DELAY_KEY_TAB
22
from ..input.keyboard import typeKey
23
24
25
def contextualMenuOperation(referencePosition, position, contextualMenuOperation,
26
offsetX=0, offsetY=0):
27
# obtain clicked position
28
clickedPosition = [referencePosition[0] + position.x + offsetX,
29
referencePosition[1] + position.y + offsetY]
30
# move mouse to position
31
pyautogui.moveTo(clickedPosition)
32
# wait after move
33
time.sleep(DELAY_MOUSE_MOVE)
34
# click over position
35
pyautogui.click(button='right')
36
# place cursor over first operation
37
for _ in range(contextualMenuOperation.mainMenuPosition):
38
# wait before every down
39
time.sleep(DELAY_KEY_TAB)
40
# type down keys
41
pyautogui.hotkey('down')
42
# type space for select
43
typeKey('space')
44
# check if go to submenu A
45
if contextualMenuOperation.subMenuAPosition > 0:
46
# place cursor over second operation
47
for _ in range(contextualMenuOperation.subMenuAPosition):
48
# wait before every down
49
time.sleep(DELAY_KEY_TAB)
50
# type down keys
51
pyautogui.hotkey('down')
52
# type space for select
53
typeKey('space')
54
# check if go to submenu B
55
if contextualMenuOperation.subMenuBPosition > 0:
56
# place cursor over second operation
57
for _ in range(contextualMenuOperation.subMenuBPosition):
58
# wait before every down
59
time.sleep(DELAY_KEY_TAB)
60
# type down keys
61
pyautogui.hotkey('down')
62
# type space for select
63
typeKey('space')
64
65