PySide6Plot 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ # from pyqtgraph import QtGui
2
+ from PySide6 import QtGui
3
+ from PySide6.QtWidgets import QWidget
4
+
5
+ # from dataclasses import dataclass,field
6
+ from .helpers import project_path_qfile, color_to_rbg_tuple, tuple_to_color, ConfigurationsHandler
7
+ from qfluentwidgets import StyleSheetBase, Theme, qconfig, FluentIconBase, getIconColor, isDarkTheme
8
+ from enum import Enum
9
+
10
+ LIGHT_BACKGROUND_COLOR = QtGui.QColor(251, 251, 251)
11
+ DARK_BACKGROUND_COLOR = QtGui.QColor(30, 30, 30)
12
+
13
+
14
+ def default_style_configs() -> ConfigurationsHandler:
15
+ configs_handler = ConfigurationsHandler()
16
+ configs_handler.add_config_item(
17
+ "positive_color",
18
+ default_value=(254, 109, 115),
19
+ value_type=tuple,
20
+ in_func=lambda x, other_config: tuple_to_color(x),
21
+ out_func=lambda x, other_config: color_to_rbg_tuple(x),
22
+ description="color of the positive bars",
23
+ )
24
+ configs_handler.add_config_item(
25
+ "volume_color",
26
+ default_value=(254, 109, 115),
27
+ value_type=tuple,
28
+ in_func=lambda x, other_config: tuple_to_color(x),
29
+ out_func=lambda x, other_config: color_to_rbg_tuple(x),
30
+ description="color of the positive bars",
31
+ )
32
+ configs_handler.add_config_item(
33
+ "negative_color",
34
+ default_value=(23, 195, 178),
35
+ value_type=tuple,
36
+ in_func=lambda x, other_config: tuple_to_color(x),
37
+ out_func=lambda x, other_config: color_to_rbg_tuple(x),
38
+ description="color of the negative bars",
39
+ )
40
+ configs_handler.add_config_item(
41
+ "bar_width",
42
+ default_value=0.3,
43
+ value_type=float,
44
+ description="width of the bars,the distance between two bars is 1",
45
+ )
46
+ configs_handler.add_config_item(
47
+ "shadow_width",
48
+ default_value=0.03,
49
+ value_type=float,
50
+ description="width of the shadowline,the distance between two shadowlines is 1",
51
+ )
52
+ configs_handler.add_config_item(
53
+ "line_width",
54
+ default_value=2.0,
55
+ value_type=float,
56
+ description="width of other lines, like average line. Note that the unit here is pixel",
57
+ )
58
+ configs_handler.add_config_item(
59
+ "average_line_color",
60
+ default_value={
61
+ 5: (76, 201, 240),
62
+ 20: (67, 97, 238),
63
+ 60: (58, 12, 163),
64
+ 120: (114, 9, 183),
65
+ 250: (247, 37, 133),
66
+ },
67
+ value_type=dict,
68
+ in_func=lambda x, other_config: {key_i: tuple_to_color(x[key_i]) for key_i in x.keys()},
69
+ out_func=lambda x, other_config: {key_i: color_to_rbg_tuple(x[key_i]) for key_i in x.keys()},
70
+ description="color of the average lines",
71
+ )
72
+ return configs_handler
73
+
74
+
75
+ def make_style(style_yaml_file="", **kwargs):
76
+ configs_handler = default_style_configs()
77
+ if style_yaml_file != "":
78
+ configs_handler.set_config_items_from_yaml(style_yaml_file)
79
+ configs_handler.set_config_items(**kwargs)
80
+ return configs_handler.configs()
81
+
82
+
83
+ class StyleSheet(StyleSheetBase, Enum):
84
+ """Style sheet"""
85
+
86
+ NAVIGATION_VIEW_INTERFACE = "navigation_view_interface"
87
+
88
+ def path(self, theme=Theme.AUTO):
89
+ theme = qconfig.theme if theme == Theme.AUTO else theme
90
+ return project_path_qfile() + "resources/qss/" + theme.value.lower() + "/" + self.value + ".qss"
91
+
92
+
93
+ class QStockIcon(FluentIconBase, Enum):
94
+ """Fluent icon"""
95
+
96
+ CHEVRON_LEFT = "ChevronLeft"
97
+
98
+ def path(self, theme=Theme.AUTO):
99
+ return project_path_qfile() + "resources/icons/" + f"{self.value}_{getIconColor(theme)}.svg"
100
+
101
+
102
+ def set_background_with_theme(widget: QWidget, theme=None):
103
+ def set_background_color(color):
104
+ palette = widget.palette()
105
+ palette.setColor(widget.backgroundRole(), color)
106
+ widget.setPalette(palette)
107
+
108
+ if theme == Theme.DARK:
109
+ set_background_color(DARK_BACKGROUND_COLOR)
110
+ elif theme == Theme.LIGHT:
111
+ set_background_color(LIGHT_BACKGROUND_COLOR)
112
+ else:
113
+ if isDarkTheme():
114
+ set_background_color(DARK_BACKGROUND_COLOR)
115
+ else:
116
+ set_background_color(LIGHT_BACKGROUND_COLOR)
117
+
118
+
119
+ DEFAULT_STYLE = make_style()
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ height="16"
4
+ width="16"
5
+ viewBox="0 0 16 16"
6
+ version="1.1"
7
+ id="svg5"
8
+ sodipodi:docname="ChevronLeft_black.svg"
9
+ inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ xmlns:svg="http://www.w3.org/2000/svg">
14
+ <defs
15
+ id="defs9" />
16
+ <sodipodi:namedview
17
+ id="namedview7"
18
+ pagecolor="#ffffff"
19
+ bordercolor="#000000"
20
+ borderopacity="0.25"
21
+ inkscape:showpageshadow="2"
22
+ inkscape:pageopacity="0.0"
23
+ inkscape:pagecheckerboard="0"
24
+ inkscape:deskcolor="#d1d1d1"
25
+ showgrid="false"
26
+ inkscape:zoom="14.75"
27
+ inkscape:cx="4.3728814"
28
+ inkscape:cy="8"
29
+ inkscape:window-width="2560"
30
+ inkscape:window-height="1494"
31
+ inkscape:window-x="-11"
32
+ inkscape:window-y="-11"
33
+ inkscape:window-maximized="1"
34
+ inkscape:current-layer="svg5" />
35
+ <g
36
+ id="g3"
37
+ transform="matrix(-1,0,0,1,16.057143,0)">
38
+ <path
39
+ id="path1"
40
+ transform="matrix(0.19047619,0,0,0.19047619,-1.4,-1.4)"
41
+ fill="#000000"
42
+ d="m 33,12 1.136719,0.222656 0.972656,0.667969 33,33 0.667969,0.97266 L 69,48 l -0.222656,1.136719 -0.667969,0.972656 -33,33 -0.972656,0.667969 L 33,84 31.863281,83.777344 30.890625,83.109375 30.222654,82.136719 30,81 30.222654,79.863281 30.890625,78.890625 61.734375,48 30.890625,17.109375 30.222654,16.136719 30,15 l 0.222654,-1.136719 0.667971,-0.972656 0.972656,-0.667969 z" />
43
+ </g>
44
+ </svg>
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ height="16"
4
+ width="16"
5
+ viewBox="0 0 16 16"
6
+ version="1.1"
7
+ id="svg5"
8
+ sodipodi:docname="ChevronLeft_white.svg"
9
+ inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ xmlns:svg="http://www.w3.org/2000/svg">
14
+ <defs
15
+ id="defs9" />
16
+ <sodipodi:namedview
17
+ id="namedview7"
18
+ pagecolor="#ffffff"
19
+ bordercolor="#000000"
20
+ borderopacity="0.25"
21
+ inkscape:showpageshadow="2"
22
+ inkscape:pageopacity="0.0"
23
+ inkscape:pagecheckerboard="0"
24
+ inkscape:deskcolor="#d1d1d1"
25
+ showgrid="false"
26
+ inkscape:zoom="14.75"
27
+ inkscape:cx="4.3728814"
28
+ inkscape:cy="8"
29
+ inkscape:window-width="2560"
30
+ inkscape:window-height="1494"
31
+ inkscape:window-x="-11"
32
+ inkscape:window-y="-11"
33
+ inkscape:window-maximized="1"
34
+ inkscape:current-layer="svg5" />
35
+ <g
36
+ id="g3"
37
+ transform="matrix(-1,0,0,1,16.057143,0)">
38
+ <path
39
+ id="path1"
40
+ transform="matrix(0.19047619,0,0,0.19047619,-1.4,-1.4)"
41
+ fill="#ffffff"
42
+ d="m 33,12 1.136719,0.222656 0.972656,0.667969 33,33 0.667969,0.97266 L 69,48 l -0.222656,1.136719 -0.667969,0.972656 -33,33 -0.972656,0.667969 L 33,84 31.863281,83.777344 30.890625,83.109375 30.222654,82.136719 30,81 30.222654,79.863281 30.890625,78.890625 61.734375,48 30.890625,17.109375 30.222654,16.136719 30,15 l 0.222654,-1.136719 0.667971,-0.972656 0.972656,-0.667969 z" />
43
+ </g>
44
+ </svg>
@@ -0,0 +1,16 @@
1
+ PivotInterface QLabel,
2
+ TabInterface QLabel {
3
+ padding-left: 10px;
4
+ font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
5
+ color: white;
6
+ }
7
+
8
+ #controlPanel BodyLabel {
9
+ padding-left: 0px;
10
+ }
11
+
12
+ #controlPanel {
13
+ background-color: rgb(43, 43, 43);
14
+ border-left: 1px solid rgb(50, 50, 50);
15
+ border-top-right-radius: 10px;
16
+ }
@@ -0,0 +1,16 @@
1
+ PivotInterface QLabel,
2
+ TabInterface QLabel {
3
+ padding-left: 10px;
4
+ font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang SC';
5
+ color: black;
6
+ }
7
+
8
+ #controlPanel BodyLabel {
9
+ padding-left: 0px;
10
+ }
11
+
12
+ #controlPanel {
13
+ background-color: white;
14
+ border-left: 1px solid rgb(229, 229, 229);
15
+ border-top-right-radius: 10px;
16
+ }
@@ -0,0 +1,3 @@
1
+ """
2
+ widgets package for qstock_plotter
3
+ """
@@ -0,0 +1,131 @@
1
+ from qfluentwidgets import ToggleButton, isDarkTheme, FluentIconBase, qconfig, FluentStyleSheet
2
+ from qfluentwidgets.common.overload import singledispatchmethod
3
+ from PySide6.QtGui import QColor, QIcon
4
+ from PySide6.QtWidgets import QWidget
5
+ from enum import Enum
6
+ from ..libs.helpers import color_to_rbg_tuple
7
+
8
+
9
+ # modified from pyqtgraph.style_sheet
10
+ class CustomThemeColor(Enum):
11
+ """Theme color type"""
12
+
13
+ PRIMARY = "ThemeColorPrimary"
14
+ DARK_1 = "ThemeColorDark1"
15
+ DARK_2 = "ThemeColorDark2"
16
+ DARK_3 = "ThemeColorDark3"
17
+ LIGHT_1 = "ThemeColorLight1"
18
+ LIGHT_2 = "ThemeColorLight2"
19
+ LIGHT_3 = "ThemeColorLight3"
20
+
21
+ def name(self):
22
+ return self.color().name()
23
+
24
+ def color(self, color):
25
+ # transform color into hsv space
26
+ h, s, v, _ = color.getHsvF()
27
+
28
+ if isDarkTheme():
29
+ s *= 0.84
30
+ v = 1
31
+ if self == self.DARK_1:
32
+ v *= 0.9
33
+ elif self == self.DARK_2:
34
+ s *= 0.977
35
+ v *= 0.82
36
+ elif self == self.DARK_3:
37
+ s *= 0.95
38
+ v *= 0.7
39
+ elif self == self.LIGHT_1:
40
+ s *= 0.92
41
+ elif self == self.LIGHT_2:
42
+ s *= 0.78
43
+ elif self == self.LIGHT_3:
44
+ s *= 0.65
45
+ else:
46
+ if self == self.DARK_1:
47
+ v *= 0.75
48
+ elif self == self.DARK_2:
49
+ s *= 1.05
50
+ v *= 0.5
51
+ elif self == self.DARK_3:
52
+ s *= 1.1
53
+ v *= 0.4
54
+ elif self == self.LIGHT_1:
55
+ v *= 1.05
56
+ elif self == self.LIGHT_2:
57
+ s *= 0.75
58
+ v *= 1.05
59
+ elif self == self.LIGHT_3:
60
+ s *= 0.65
61
+ v *= 1.05
62
+
63
+ return QColor.fromHsvF(h, min(s, 1), min(v, 1))
64
+
65
+
66
+ class ColorfulToggleButton(ToggleButton):
67
+ """
68
+ A custom toggle button with colorful styling.
69
+
70
+ Inherits from ToggleButton class.
71
+
72
+ Attributes:
73
+ color (QColor): The color of the button.
74
+
75
+ Methods:
76
+ set_color(): Sets the color of the button based on the current theme.
77
+ """
78
+
79
+ def set_color(self):
80
+ """
81
+ Sets the color of the button based on the current theme.
82
+ """
83
+ if self.color is not None:
84
+ style_sheet = (
85
+ "ColorfulToggleButton:checked {background-color: rgb"
86
+ + f"{color_to_rbg_tuple(CustomThemeColor.PRIMARY.color(self.color))}"
87
+ + ";border: 1px solid rgb"
88
+ + f"{color_to_rbg_tuple(CustomThemeColor.LIGHT_1.color(self.color))}"
89
+ + ";border-bottom: 1px solid rgb"
90
+ + f"{color_to_rbg_tuple(CustomThemeColor.DARK_1.color(self.color))}"
91
+ + ";}"
92
+ )
93
+ style_sheet += (
94
+ "ColorfulToggleButton:checked:hover {background-color: rgb"
95
+ + f"{color_to_rbg_tuple(CustomThemeColor.LIGHT_1.color(self.color))}"
96
+ + ";border: 1px solid rgb"
97
+ + f"{color_to_rbg_tuple(CustomThemeColor.LIGHT_2.color(self.color))}"
98
+ + ";border-bottom: 1px solid rgb"
99
+ + f"{color_to_rbg_tuple(CustomThemeColor.DARK_1.color(self.color))}"
100
+ + ";}"
101
+ )
102
+ style_sheet += (
103
+ "ColorfulToggleButton:checked:pressed {background-color: rgb"
104
+ + f"{color_to_rbg_tuple(CustomThemeColor.LIGHT_3.color(self.color))}"
105
+ + ";border: 1px solid rgb"
106
+ + f"{color_to_rbg_tuple(CustomThemeColor.LIGHT_3.color(self.color))}"
107
+ + ";}"
108
+ )
109
+ self.setStyleSheet(FluentStyleSheet.BUTTON.content() + style_sheet)
110
+
111
+ @singledispatchmethod
112
+ def __init__(self, parent: QWidget = None):
113
+ super().__init__(parent)
114
+ self.color = None
115
+ qconfig.themeChangedFinished.connect(self.set_color)
116
+
117
+ @__init__.register
118
+ def _(self, color: QColor, text: str, parent: QWidget = None, icon: QIcon | FluentIconBase | str = None):
119
+ self.__init__(parent)
120
+ self.setText(text)
121
+ self.setIcon(icon)
122
+ self.color = color
123
+ self.set_color()
124
+
125
+ @__init__.register
126
+ def _(self, icon: QIcon, color: QColor, text: str, parent: QWidget = None):
127
+ self.__init__(color, text, parent, icon)
128
+
129
+ @__init__.register
130
+ def _(self, icon: FluentIconBase, color: QColor, text: str, parent: QWidget = None):
131
+ self.__init__(color, text, parent, icon)