Skip to content

Commit 3340c19

Browse files
committed
EditPointTool: review/ok
1 parent f1342d8 commit 3340c19

3 files changed

Lines changed: 151 additions & 149 deletions

File tree

plotpy/locale/fr/LC_MESSAGES/plotpy.po

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,10 +1427,9 @@ msgstr "Résolution MAX"
14271427
msgid "Select one point then press OK to accept"
14281428
msgstr "Sélectionner un point puis cliquer sur OK pour valider"
14291429

1430-
#: plotpy\tests\tools\test_edit_point.py:41
1431-
#, fuzzy
1430+
#: plotpy\tests\tools\test_edit_point.py:45 plotpy\tools\curve.py:814
14321431
msgid "Insert point"
1433-
msgstr "Insérer"
1432+
msgstr "Insérer un point"
14341433

14351434
#: plotpy\tests\widgets\test_simple_dialog.py:26
14361435
#: plotpy\tests\widgets\test_simple_window.py:47
@@ -1617,7 +1616,10 @@ msgstr "Nouvelle valeur"
16171616
msgid "Location"
16181617
msgstr "Position"
16191618

1620-
#: plotpy\tools\curve.py:674
1619+
1620+
#: plotpy\tools\curve.py:815
1621+
msgid "Before inserting a new point, please select an existing curve point."
1622+
msgstr "Avant d'insérer un nouveau point, sélectionner un point existant."
16211623
msgid "Insert new value"
16221624
msgstr "Insérer une nouvelle valeur"
16231625

plotpy/tests/tools/test_edit_point.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@
1111

1212
# guitest: show
1313

14-
from typing import TYPE_CHECKING
15-
16-
import qtpy.QtWidgets as QW
14+
import numpy as np
1715
from guidata.qthelpers import exec_dialog, qt_app_context
18-
from numpy import linspace, sin
16+
from qtpy import QtWidgets as QW
1917

2018
from plotpy.builder import make
2119
from plotpy.config import _
2220
from plotpy.interfaces.items import ICurveItemType
2321
from plotpy.plot.plotwidget import PlotDialog
2422
from plotpy.tools import EditPointTool
2523

26-
if TYPE_CHECKING:
27-
from plotpy.items.curve.base import CurveItem
28-
2924

3025
def callback_function(tool: EditPointTool):
3126
"""Callback function to be called by the tool after a point has moved
@@ -47,9 +42,9 @@ def make_new_bbox(dialog: PlotDialog):
4742
and dialog.button_layout is not None
4843
and (tool := dialog.manager.get_tool(EditPointTool)) is not None
4944
):
50-
custom_button = QW.QPushButton(_("Insert point"), dialog)
51-
custom_button.clicked.connect(tool.trigger_insert_point_at_selection)
52-
dialog.button_layout.insertWidget(0, custom_button)
45+
insert_btn = QW.QPushButton(_("Insert point"), dialog)
46+
insert_btn.clicked.connect(tool.trigger_insert_point_at_selection)
47+
dialog.button_layout.insertWidget(0, insert_btn)
5348

5449

5550
def edit_curve(*args):
@@ -69,7 +64,7 @@ def edit_curve(*args):
6964
default.activate()
7065
plot = win.manager.get_plot()
7166
for cx, cy in args[:-1]:
72-
item: CurveItem = make.mcurve(cx, cy)
67+
item = make.mcurve(cx, cy)
7368
plot.add_item(item)
7469
item = make.mcurve(*args[-1], "r-+")
7570
plot.add_item(item)
@@ -82,12 +77,12 @@ def edit_curve(*args):
8277

8378
def test_edit_curve():
8479
"""Test"""
85-
with qt_app_context(exec_loop=False):
86-
x = linspace(-10, 10, num=100)
87-
y = 0.25 * sin(sin(sin(x * 0.5)))
88-
x2 = linspace(-10, 10, num=100)
89-
y2 = sin(sin(sin(x2)))
90-
edited_args = edit_curve((x, y), (x2, y2), (x, sin(2 * y)))
80+
with qt_app_context():
81+
x = np.linspace(-10, 10, num=100)
82+
y = 0.25 * np.sin(np.sin(np.sin(x * 0.5)))
83+
x2 = np.linspace(-10, 10, num=100)
84+
y2 = np.sin(np.sin(np.sin(x2)))
85+
edited_args = edit_curve((x, y), (x2, y2), (x, np.sin(2 * y)))
9186
edit_curve(*edited_args)
9287
print((y2 == edited_args[1][1]).all())
9388

0 commit comments

Comments
 (0)