13
13
from plotpy .constants import ID_CONTRAST , ID_ITEMLIST , ID_XCS , ID_YCS
14
14
from plotpy .interfaces import IPlotManager
15
15
from plotpy .plot import BasePlot
16
- from plotpy .tools import (
17
- AboutTool ,
18
- AnnotatedCircleTool ,
19
- AnnotatedEllipseTool ,
20
- AnnotatedObliqueRectangleTool ,
21
- AnnotatedPointTool ,
22
- AnnotatedRectangleTool ,
23
- AnnotatedSegmentTool ,
24
- AntiAliasingTool ,
25
- AspectRatioTool ,
26
- AverageCrossSectionTool ,
27
- AxisScaleTool ,
28
- BasePlotMenuTool ,
29
- ColormapTool ,
30
- ContrastPanelTool ,
31
- CopyToClipboardTool ,
32
- CrossSectionTool ,
33
- CurveStatsTool ,
34
- DeleteItemTool ,
35
- DisplayCoordsTool ,
36
- DoAutoscaleTool ,
37
- DownSamplingTool ,
38
- DummySeparatorTool ,
39
- EditItemDataTool ,
40
- ExportItemDataTool ,
41
- HelpTool ,
42
- ImageStatsTool ,
43
- ItemCenterTool ,
44
- ItemListPanelTool ,
45
- LabelTool ,
46
- PrintTool ,
47
- RectangularSelectionTool ,
48
- RectZoomTool ,
49
- ReverseColormapTool ,
50
- ReverseXAxisTool ,
51
- ReverseYAxisTool ,
52
- SaveAsTool ,
53
- SelectTool ,
54
- SnapshotTool ,
55
- XCSPanelTool ,
56
- YCSPanelTool ,
57
- ZAxisLogTool ,
58
- )
59
16
60
17
if TYPE_CHECKING :
61
18
from typing import Callable
@@ -241,12 +198,16 @@ def add_separator_tool(self, toolbar_id: str | None = None) -> None:
241
198
Args:
242
199
toolbar_id: toolbar's id (default to None)
243
200
"""
201
+ # This avoids circular imports (see Issue #39)
202
+ # pylint: disable=import-outside-toplevel
203
+ import plotpy .tools as tools
204
+
244
205
if toolbar_id is None :
245
206
for _id , toolbar in list (self .toolbars .items ()):
246
207
if toolbar is self .get_default_toolbar ():
247
208
toolbar_id = _id
248
209
break
249
- self .add_tool (DummySeparatorTool , toolbar_id )
210
+ self .add_tool (tools . DummySeparatorTool , toolbar_id )
250
211
251
212
def set_default_tool (self , tool : GuiTool ) -> None :
252
213
"""
@@ -547,22 +508,26 @@ def register_standard_tools(self) -> None:
547
508
Registering basic tools for standard plot dialog
548
509
--> top of the context-menu
549
510
"""
550
- t = self .add_tool (SelectTool )
511
+ # This avoids circular imports (see Issue #39)
512
+ # pylint: disable=import-outside-toplevel
513
+ import plotpy .tools as tools
514
+
515
+ t = self .add_tool (tools .SelectTool )
551
516
self .set_default_tool (t )
552
- self .add_tool (RectangularSelectionTool , intersect = False )
553
- self .add_tool (RectZoomTool )
554
- self .add_tool (DoAutoscaleTool )
555
- self .add_tool (BasePlotMenuTool , "item" )
556
- self .add_tool (ExportItemDataTool )
557
- self .add_tool (EditItemDataTool )
558
- self .add_tool (ItemCenterTool )
559
- self .add_tool (DeleteItemTool )
517
+ self .add_tool (tools . RectangularSelectionTool , intersect = False )
518
+ self .add_tool (tools . RectZoomTool )
519
+ self .add_tool (tools . DoAutoscaleTool )
520
+ self .add_tool (tools . BasePlotMenuTool , "item" )
521
+ self .add_tool (tools . ExportItemDataTool )
522
+ self .add_tool (tools . EditItemDataTool )
523
+ self .add_tool (tools . ItemCenterTool )
524
+ self .add_tool (tools . DeleteItemTool )
560
525
self .add_separator_tool ()
561
- self .add_tool (BasePlotMenuTool , "grid" )
562
- self .add_tool (BasePlotMenuTool , "axes" )
563
- self .add_tool (DisplayCoordsTool )
526
+ self .add_tool (tools . BasePlotMenuTool , "grid" )
527
+ self .add_tool (tools . BasePlotMenuTool , "axes" )
528
+ self .add_tool (tools . DisplayCoordsTool )
564
529
if self .get_itemlist_panel ():
565
- self .add_tool (ItemListPanelTool )
530
+ self .add_tool (tools . ItemListPanelTool )
566
531
567
532
def register_curve_tools (self ) -> None :
568
533
"""
@@ -580,10 +545,14 @@ def register_curve_tools(self) -> None:
580
545
581
546
:py:meth:`.plot.manager.PlotManager.register_all_tools`
582
547
"""
583
- self .add_tool (CurveStatsTool )
584
- self .add_tool (AntiAliasingTool )
585
- self .add_tool (AxisScaleTool )
586
- self .add_tool (DownSamplingTool )
548
+ # This avoids circular imports (see Issue #39)
549
+ # pylint: disable=import-outside-toplevel
550
+ import plotpy .tools as tools
551
+
552
+ self .add_tool (tools .CurveStatsTool )
553
+ self .add_tool (tools .AntiAliasingTool )
554
+ self .add_tool (tools .AxisScaleTool )
555
+ self .add_tool (tools .DownSamplingTool )
587
556
588
557
def register_image_tools (self ) -> None :
589
558
"""
@@ -601,21 +570,25 @@ def register_image_tools(self) -> None:
601
570
602
571
:py:meth:`.plot.manager.PlotManager.register_all_tools`
603
572
"""
604
- self .add_tool (ColormapTool )
605
- self .add_tool (ReverseColormapTool )
606
- self .add_tool (ReverseXAxisTool )
607
- self .add_tool (ReverseYAxisTool )
608
- self .add_tool (ZAxisLogTool )
609
- self .add_tool (AspectRatioTool )
573
+ # This avoids circular imports (see Issue #39)
574
+ # pylint: disable=import-outside-toplevel
575
+ import plotpy .tools as tools
576
+
577
+ self .add_tool (tools .ColormapTool )
578
+ self .add_tool (tools .ReverseColormapTool )
579
+ self .add_tool (tools .ReverseXAxisTool )
580
+ self .add_tool (tools .ReverseYAxisTool )
581
+ self .add_tool (tools .ZAxisLogTool )
582
+ self .add_tool (tools .AspectRatioTool )
610
583
if self .get_contrast_panel ():
611
- self .add_tool (ContrastPanelTool )
612
- self .add_tool (SnapshotTool )
613
- self .add_tool (ImageStatsTool )
584
+ self .add_tool (tools . ContrastPanelTool )
585
+ self .add_tool (tools . SnapshotTool )
586
+ self .add_tool (tools . ImageStatsTool )
614
587
if self .get_xcs_panel () and self .get_ycs_panel ():
615
- self .add_tool (XCSPanelTool )
616
- self .add_tool (YCSPanelTool )
617
- self .add_tool (CrossSectionTool )
618
- self .add_tool (AverageCrossSectionTool )
588
+ self .add_tool (tools . XCSPanelTool )
589
+ self .add_tool (tools . YCSPanelTool )
590
+ self .add_tool (tools . CrossSectionTool )
591
+ self .add_tool (tools . AverageCrossSectionTool )
619
592
620
593
def register_other_tools (self ) -> None :
621
594
"""
@@ -633,11 +606,15 @@ def register_other_tools(self) -> None:
633
606
634
607
:py:meth:`.plot.manager.PlotManager.register_all_tools`
635
608
"""
636
- self .add_tool (SaveAsTool )
637
- self .add_tool (CopyToClipboardTool )
638
- self .add_tool (PrintTool )
639
- self .add_tool (HelpTool )
640
- self .add_tool (AboutTool )
609
+ # This avoids circular imports (see Issue #39)
610
+ # pylint: disable=import-outside-toplevel
611
+ import plotpy .tools as tools
612
+
613
+ self .add_tool (tools .SaveAsTool )
614
+ self .add_tool (tools .CopyToClipboardTool )
615
+ self .add_tool (tools .PrintTool )
616
+ self .add_tool (tools .HelpTool )
617
+ self .add_tool (tools .AboutTool )
641
618
642
619
def register_all_curve_tools (self ) -> None :
643
620
"""
@@ -732,23 +709,31 @@ def register_all_annotation_tools(self) -> None:
732
709
"""
733
710
Register all annotation tools for the plot
734
711
"""
712
+ # This avoids circular imports (see Issue #39)
713
+ # pylint: disable=import-outside-toplevel
714
+ import plotpy .tools as tools
715
+
735
716
self .add_separator_tool ()
736
- self .add_tool (AnnotatedPointTool )
737
- self .add_tool (AnnotatedSegmentTool )
738
- self .add_tool (AnnotatedRectangleTool )
739
- self .add_tool (AnnotatedObliqueRectangleTool )
740
- self .add_tool (AnnotatedCircleTool )
741
- self .add_tool (AnnotatedEllipseTool )
742
- self .add_tool (LabelTool )
717
+ self .add_tool (tools . AnnotatedPointTool )
718
+ self .add_tool (tools . AnnotatedSegmentTool )
719
+ self .add_tool (tools . AnnotatedRectangleTool )
720
+ self .add_tool (tools . AnnotatedObliqueRectangleTool )
721
+ self .add_tool (tools . AnnotatedCircleTool )
722
+ self .add_tool (tools . AnnotatedEllipseTool )
723
+ self .add_tool (tools . LabelTool )
743
724
744
725
def register_curve_annotation_tools (self ) -> None :
745
726
"""
746
727
Register all curve friendly annotation tools for the plot
747
728
"""
729
+ # This avoids circular imports (see Issue #39)
730
+ # pylint: disable=import-outside-toplevel
731
+ import plotpy .tools as tools
732
+
748
733
self .add_separator_tool ()
749
- self .add_tool (AnnotatedPointTool )
750
- self .add_tool (AnnotatedSegmentTool )
751
- self .add_tool (LabelTool )
734
+ self .add_tool (tools . AnnotatedPointTool )
735
+ self .add_tool (tools . AnnotatedSegmentTool )
736
+ self .add_tool (tools . LabelTool )
752
737
753
738
def register_image_annotation_tools (self ) -> None :
754
739
"""
0 commit comments