1313from plotpy .constants import ID_CONTRAST , ID_ITEMLIST , ID_XCS , ID_YCS
1414from plotpy .interfaces import IPlotManager
1515from 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- )
5916
6017if TYPE_CHECKING :
6118 from typing import Callable
@@ -241,12 +198,16 @@ def add_separator_tool(self, toolbar_id: str | None = None) -> None:
241198 Args:
242199 toolbar_id: toolbar's id (default to None)
243200 """
201+ # This avoids circular imports (see Issue #39)
202+ # pylint: disable=import-outside-toplevel
203+ import plotpy .tools as tools
204+
244205 if toolbar_id is None :
245206 for _id , toolbar in list (self .toolbars .items ()):
246207 if toolbar is self .get_default_toolbar ():
247208 toolbar_id = _id
248209 break
249- self .add_tool (DummySeparatorTool , toolbar_id )
210+ self .add_tool (tools . DummySeparatorTool , toolbar_id )
250211
251212 def set_default_tool (self , tool : GuiTool ) -> None :
252213 """
@@ -547,22 +508,26 @@ def register_standard_tools(self) -> None:
547508 Registering basic tools for standard plot dialog
548509 --> top of the context-menu
549510 """
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 )
551516 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 )
560525 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 )
564529 if self .get_itemlist_panel ():
565- self .add_tool (ItemListPanelTool )
530+ self .add_tool (tools . ItemListPanelTool )
566531
567532 def register_curve_tools (self ) -> None :
568533 """
@@ -580,10 +545,14 @@ def register_curve_tools(self) -> None:
580545
581546 :py:meth:`.plot.manager.PlotManager.register_all_tools`
582547 """
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 )
587556
588557 def register_image_tools (self ) -> None :
589558 """
@@ -601,21 +570,25 @@ def register_image_tools(self) -> None:
601570
602571 :py:meth:`.plot.manager.PlotManager.register_all_tools`
603572 """
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 )
610583 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 )
614587 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 )
619592
620593 def register_other_tools (self ) -> None :
621594 """
@@ -633,11 +606,15 @@ def register_other_tools(self) -> None:
633606
634607 :py:meth:`.plot.manager.PlotManager.register_all_tools`
635608 """
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 )
641618
642619 def register_all_curve_tools (self ) -> None :
643620 """
@@ -732,23 +709,31 @@ def register_all_annotation_tools(self) -> None:
732709 """
733710 Register all annotation tools for the plot
734711 """
712+ # This avoids circular imports (see Issue #39)
713+ # pylint: disable=import-outside-toplevel
714+ import plotpy .tools as tools
715+
735716 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 )
743724
744725 def register_curve_annotation_tools (self ) -> None :
745726 """
746727 Register all curve friendly annotation tools for the plot
747728 """
729+ # This avoids circular imports (see Issue #39)
730+ # pylint: disable=import-outside-toplevel
731+ import plotpy .tools as tools
732+
748733 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 )
752737
753738 def register_image_annotation_tools (self ) -> None :
754739 """
0 commit comments