|
5 | 5 | import abc
|
6 | 6 | import warnings
|
7 | 7 | from dataclasses import dataclass
|
8 |
| -from typing import TYPE_CHECKING |
| 8 | +from typing import TYPE_CHECKING, Any |
9 | 9 |
|
10 | 10 | from guidata.configtools import get_icon
|
11 | 11 | from guidata.qthelpers import win32_fix_title_bar_background
|
@@ -115,10 +115,12 @@ class BasePlotWidget(QW.QSplitter):
|
115 | 115 | def __init__(
|
116 | 116 | self,
|
117 | 117 | parent: QWidget = None,
|
118 |
| - options: PlotOptions | None = None, |
| 118 | + options: PlotOptions | dict[str, Any] | None = None, |
119 | 119 | ) -> None:
|
120 | 120 | super().__init__(parent)
|
121 | 121 | self.manager: PlotManager | None = None
|
| 122 | + if isinstance(options, dict): |
| 123 | + options = PlotOptions(**options) |
122 | 124 | self.options = options = options if options is not None else PlotOptions()
|
123 | 125 | self.setSizePolicy(QW.QSizePolicy.Expanding, QW.QSizePolicy.Expanding)
|
124 | 126 | self.plot = self.create_plot()
|
@@ -304,7 +306,7 @@ def __init__(
|
304 | 306 | self,
|
305 | 307 | parent: QWidget | None = None,
|
306 | 308 | toolbar: bool = False,
|
307 |
| - options: PlotOptions | None = None, |
| 309 | + options: PlotOptions | dict[str, Any] | None = None, |
308 | 310 | panels: tuple[PanelWidget] | None = None,
|
309 | 311 | auto_tools: bool = True,
|
310 | 312 | ) -> None:
|
@@ -456,7 +458,7 @@ def get_manager(self) -> PlotManager:
|
456 | 458 | def setup_widget(
|
457 | 459 | self,
|
458 | 460 | toolbar: bool = False,
|
459 |
| - options: dict | None = None, |
| 461 | + options: PlotOptions | dict[str, Any] | None = None, |
460 | 462 | panels: list[PanelWidget] | None = None,
|
461 | 463 | auto_tools: bool = False,
|
462 | 464 | ) -> None:
|
@@ -539,7 +541,7 @@ def __init__(
|
539 | 541 | self,
|
540 | 542 | parent: QWidget | None = None,
|
541 | 543 | toolbar: bool = False,
|
542 |
| - options: PlotOptions | None = None, |
| 544 | + options: PlotOptions | dict[str, Any] | None = None, |
543 | 545 | panels: list[PanelWidget] | None = None,
|
544 | 546 | auto_tools: bool = True,
|
545 | 547 | title: str = "PlotPy",
|
@@ -590,7 +592,7 @@ def get_manager(self) -> PlotManager:
|
590 | 592 | def setup_widget(
|
591 | 593 | self,
|
592 | 594 | toolbar: bool = False,
|
593 |
| - options: PlotOptions | None = None, |
| 595 | + options: PlotOptions | dict[str, Any] | None = None, |
594 | 596 | panels: list[PanelWidget] | None = None,
|
595 | 597 | auto_tools: bool = False,
|
596 | 598 | ) -> None:
|
@@ -696,7 +698,7 @@ def __init__(
|
696 | 698 | self,
|
697 | 699 | parent: QWidget | None = None,
|
698 | 700 | toolbar: bool = False,
|
699 |
| - options: PlotOptions | None = None, |
| 701 | + options: PlotOptions | dict[str, Any] | None = None, |
700 | 702 | panels: list[PanelWidget] | None = None,
|
701 | 703 | auto_tools: bool = True,
|
702 | 704 | title: str = "PlotPy",
|
@@ -742,7 +744,7 @@ def get_manager(self) -> PlotManager:
|
742 | 744 | def setup_widget(
|
743 | 745 | self,
|
744 | 746 | toolbar: bool = False,
|
745 |
| - options: PlotOptions | None = None, |
| 747 | + options: PlotOptions | dict[str, Any] | None = None, |
746 | 748 | panels: list[PanelWidget] | None = None,
|
747 | 749 | auto_tools: bool = False,
|
748 | 750 | ) -> None:
|
@@ -843,7 +845,7 @@ def __init__(
|
843 | 845 | self,
|
844 | 846 | manager: PlotManager,
|
845 | 847 | parent: QWidget | None = None,
|
846 |
| - options: PlotOptions | None = None, |
| 848 | + options: PlotOptions | dict[str, Any] | None = None, |
847 | 849 | ) -> None:
|
848 | 850 | self.plotlayout: QW.QGridLayout | None = None
|
849 | 851 | super().__init__(parent, options=options)
|
@@ -914,7 +916,7 @@ def __init__(
|
914 | 916 | self,
|
915 | 917 | parent: QWidget | None = None,
|
916 | 918 | toolbar: bool = True,
|
917 |
| - options: PlotOptions | None = None, |
| 919 | + options: PlotOptions | dict[str, Any] | None = None, |
918 | 920 | auto_tools: bool = True,
|
919 | 921 | title: str = "PlotPy",
|
920 | 922 | icon: str = "plotpy.svg",
|
|
0 commit comments