bec-widgets 0.109.0__py3-none-any.whl → 0.109.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.
- CHANGELOG.md +6 -6
- PKG-INFO +1 -1
- bec_widgets/cli/client.py +5 -15
- bec_widgets/widgets/text_box/text_box.py +80 -74
- {bec_widgets-0.109.0.dist-info → bec_widgets-0.109.1.dist-info}/METADATA +1 -1
- {bec_widgets-0.109.0.dist-info → bec_widgets-0.109.1.dist-info}/RECORD +10 -10
- pyproject.toml +1 -1
- {bec_widgets-0.109.0.dist-info → bec_widgets-0.109.1.dist-info}/WHEEL +0 -0
- {bec_widgets-0.109.0.dist-info → bec_widgets-0.109.1.dist-info}/entry_points.txt +0 -0
- {bec_widgets-0.109.0.dist-info → bec_widgets-0.109.1.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v0.109.1 (2024-09-09)
|
4
|
+
|
5
|
+
### Fix
|
6
|
+
|
7
|
+
* fix: refactor textbox widget, remove inheritance, adhere to bec style; closes #324 ([`b0d786b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b0d786b991677c0846a0c6ba3f2252d48d94ccaa))
|
8
|
+
|
3
9
|
## v0.109.0 (2024-09-06)
|
4
10
|
|
5
11
|
### Feature
|
@@ -154,12 +160,6 @@
|
|
154
160
|
|
155
161
|
* docs(becwidget): improvements to the bec widget base class docs; fixed type hint import for sphinx ([`99d5e8e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/99d5e8e71c7f89a53d7967126f4056dde005534c))
|
156
162
|
|
157
|
-
### Feature
|
158
|
-
|
159
|
-
* feat(theme): added theme handler to bec widget base class; added tests ([`7fb938a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7fb938a8506685278ee5eeb6fe9a03f74b713cf8))
|
160
|
-
|
161
163
|
### Fix
|
162
164
|
|
163
165
|
* fix(pyqt slot): removed slot decorator to avoid problems with pyqt6 ([`6c1f89a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/6c1f89ad39b7240ab1d1c1123422b99ae195bf01))
|
164
|
-
|
165
|
-
## v0.99.15 (2024-08-31)
|
PKG-INFO
CHANGED
bec_widgets/cli/client.py
CHANGED
@@ -2914,31 +2914,21 @@ class StopButton(RPCBase):
|
|
2914
2914
|
|
2915
2915
|
class TextBox(RPCBase):
|
2916
2916
|
@rpc_call
|
2917
|
-
def
|
2917
|
+
def set_plain_text(self, text: str) -> None:
|
2918
2918
|
"""
|
2919
|
-
Set the
|
2920
|
-
|
2921
|
-
Args:
|
2922
|
-
background_color (str): The color to set the background in HEX.
|
2923
|
-
font_color (str): The color to set the font in HEX.
|
2924
|
-
"""
|
2925
|
-
|
2926
|
-
@rpc_call
|
2927
|
-
def set_text(self, text: str) -> None:
|
2928
|
-
"""
|
2929
|
-
Set the text of the widget.
|
2919
|
+
Set the plain text of the widget.
|
2930
2920
|
|
2931
2921
|
Args:
|
2932
2922
|
text (str): The text to set.
|
2933
2923
|
"""
|
2934
2924
|
|
2935
2925
|
@rpc_call
|
2936
|
-
def
|
2926
|
+
def set_html_text(self, text: str) -> None:
|
2937
2927
|
"""
|
2938
|
-
Set the
|
2928
|
+
Set the HTML text of the widget.
|
2939
2929
|
|
2940
2930
|
Args:
|
2941
|
-
|
2931
|
+
text (str): The text to set.
|
2942
2932
|
"""
|
2943
2933
|
|
2944
2934
|
|
@@ -1,39 +1,47 @@
|
|
1
|
+
"""Module for a text box widget that displays text in plain and HTML format and adheres to the BECWidget interface & style."""
|
2
|
+
|
1
3
|
import re
|
4
|
+
from html.parser import HTMLParser
|
2
5
|
|
3
|
-
from
|
4
|
-
from
|
6
|
+
from bec_lib.logger import bec_logger
|
7
|
+
from pydantic import Field
|
8
|
+
from qtpy.QtCore import Property, Slot
|
9
|
+
from qtpy.QtWidgets import QTextEdit, QVBoxLayout, QWidget
|
5
10
|
|
6
11
|
from bec_widgets.utils.bec_connector import ConnectionConfig
|
7
12
|
from bec_widgets.utils.bec_widget import BECWidget
|
8
|
-
|
13
|
+
|
14
|
+
logger = bec_logger.logger
|
15
|
+
|
16
|
+
DEFAULT_TEXT = "<h1>Welcome to the BEC Widget TextBox</h1><p>A widget that allows user to display text in plain and HTML format.</p><p>This is an example of displaying HTML text.</p>"
|
9
17
|
|
10
18
|
|
11
19
|
class TextBoxConfig(ConnectionConfig):
|
20
|
+
"""Configuration for the TextBox widget.
|
12
21
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
text: str = Field("", description="The text to display in the widget.")
|
22
|
+
Args:
|
23
|
+
text (str, optional): The text to display in the widget. Defaults to None.
|
24
|
+
is_html (bool, optional): Whether the text is in HTML format or not. Defaults to False.
|
25
|
+
"""
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
def validate_theme(cls, v):
|
22
|
-
"""Validate the theme of the figure widget."""
|
23
|
-
if v not in ["dark", "light"]:
|
24
|
-
raise ValueError("Theme must be either 'dark' or 'light'")
|
25
|
-
return v
|
27
|
+
text: str | None = Field(None, description="The text to display in the widget.")
|
28
|
+
is_html: bool = Field(False, description="Whether the text is in HTML format or not.")
|
26
29
|
|
27
|
-
_validate_font_color = field_validator("font_color")(Colors.validate_color)
|
28
|
-
_validate_background_color = field_validator("background_color")(Colors.validate_color)
|
29
30
|
|
31
|
+
class TextBox(BECWidget, QWidget):
|
32
|
+
"""A widget that displays text in plain and HTML format
|
30
33
|
|
31
|
-
|
34
|
+
Args:
|
35
|
+
parent (QWidget, optional): The parent widget. Defaults to None.
|
36
|
+
client ([type], optional): The client to use. Defaults to None.
|
37
|
+
config ([type], optional): The config to use. Defaults to None.
|
38
|
+
gui_id ([type], optional): The gui_id to use. Defaults to None.
|
39
|
+
"""
|
32
40
|
|
33
|
-
USER_ACCESS = ["
|
41
|
+
USER_ACCESS = ["set_plain_text", "set_html_text"]
|
34
42
|
ICON_NAME = "chat"
|
35
43
|
|
36
|
-
def __init__(self, parent=None,
|
44
|
+
def __init__(self, parent=None, client=None, config=None, gui_id=None):
|
37
45
|
if config is None:
|
38
46
|
config = TextBoxConfig(widget_class=self.__class__.__name__)
|
39
47
|
else:
|
@@ -41,80 +49,79 @@ class TextBox(BECWidget, QTextEdit):
|
|
41
49
|
config = TextBoxConfig(**config)
|
42
50
|
self.config = config
|
43
51
|
super().__init__(client=client, config=config, gui_id=gui_id)
|
44
|
-
|
45
|
-
|
52
|
+
QWidget.__init__(self, parent)
|
53
|
+
self.layout = QVBoxLayout(self)
|
54
|
+
self.text_box_text_edit = QTextEdit(parent=self)
|
55
|
+
self.layout.addWidget(self.text_box_text_edit)
|
56
|
+
self.setLayout(self.layout)
|
57
|
+
self.layout.setContentsMargins(0, 0, 0, 0)
|
46
58
|
self.config = config
|
47
|
-
self.setReadOnly(True)
|
48
|
-
self.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
def change_theme(self) -> None:
|
55
|
-
"""
|
56
|
-
Change the theme of the figure widget.
|
57
|
-
"""
|
58
|
-
if self.config.theme == "dark":
|
59
|
-
theme = "light"
|
60
|
-
font_color = "#000"
|
61
|
-
background_color = "#FFF"
|
59
|
+
self.text_box_text_edit.setReadOnly(True)
|
60
|
+
if self.config.text is not None:
|
61
|
+
if self.config.is_html:
|
62
|
+
self.set_html_text(self.config.text)
|
63
|
+
else:
|
64
|
+
self.set_plain_text(self.config.text)
|
62
65
|
else:
|
63
|
-
|
64
|
-
font_color = "#FFF"
|
65
|
-
background_color = "#000"
|
66
|
-
self.config.theme = theme
|
67
|
-
self.set_color(background_color, font_color)
|
66
|
+
self.set_html_text(DEFAULT_TEXT)
|
68
67
|
|
69
|
-
|
70
|
-
|
68
|
+
@Slot(str)
|
69
|
+
def set_plain_text(self, text: str) -> None:
|
70
|
+
"""Set the plain text of the widget.
|
71
71
|
|
72
72
|
Args:
|
73
|
-
|
74
|
-
font_color (str): The color to set the font in HEX.
|
75
|
-
|
73
|
+
text (str): The text to set.
|
76
74
|
"""
|
77
|
-
self.
|
78
|
-
self.config.
|
79
|
-
self.
|
75
|
+
self.text_box_text_edit.setPlainText(text)
|
76
|
+
self.config.text = text
|
77
|
+
self.config.is_html = False
|
80
78
|
|
81
|
-
|
82
|
-
|
79
|
+
@Slot(str)
|
80
|
+
def set_html_text(self, text: str) -> None:
|
81
|
+
"""Set the HTML text of the widget.
|
83
82
|
|
84
83
|
Args:
|
85
|
-
|
84
|
+
text (str): The text to set.
|
86
85
|
"""
|
87
|
-
self.
|
88
|
-
self.
|
86
|
+
self.text_box_text_edit.setHtml(text)
|
87
|
+
self.config.text = text
|
88
|
+
self.config.is_html = True
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
f"background-color: {self.config.background_color}; color: {self.config.font_color}; font-size: {self.config.font_size}px"
|
94
|
-
)
|
90
|
+
@Property(str)
|
91
|
+
def plain_text(self) -> str:
|
92
|
+
"""Get the text of the widget.
|
95
93
|
|
96
|
-
|
94
|
+
Returns:
|
95
|
+
str: The text of the widget.
|
96
|
+
"""
|
97
|
+
return self.text_box_text_edit.toPlainText()
|
98
|
+
|
99
|
+
@plain_text.setter
|
100
|
+
def plain_text(self, text: str) -> None:
|
97
101
|
"""Set the text of the widget.
|
98
102
|
|
99
103
|
Args:
|
100
104
|
text (str): The text to set.
|
101
105
|
"""
|
102
|
-
|
103
|
-
self.setHtml(text)
|
104
|
-
else:
|
105
|
-
self.setPlainText(text)
|
106
|
-
self.config.text = text
|
107
|
-
|
108
|
-
def is_html(self, text: str) -> bool:
|
109
|
-
"""Check if the text contains HTML tags.
|
106
|
+
self.set_plain_text(text)
|
110
107
|
|
111
|
-
|
112
|
-
|
108
|
+
@Property(str)
|
109
|
+
def html_text(self) -> str:
|
110
|
+
"""Get the HTML text of the widget.
|
113
111
|
|
114
112
|
Returns:
|
115
|
-
|
113
|
+
str: The HTML text of the widget.
|
116
114
|
"""
|
117
|
-
return
|
115
|
+
return self.text_box_text_edit.toHtml()
|
116
|
+
|
117
|
+
@html_text.setter
|
118
|
+
def html_text(self, text: str) -> None:
|
119
|
+
"""Set the HTML text of the widget.
|
120
|
+
|
121
|
+
Args:
|
122
|
+
text (str): The HTML text to set.
|
123
|
+
"""
|
124
|
+
self.set_html_text(text)
|
118
125
|
|
119
126
|
|
120
127
|
if __name__ == "__main__":
|
@@ -123,7 +130,6 @@ if __name__ == "__main__":
|
|
123
130
|
from qtpy.QtWidgets import QApplication
|
124
131
|
|
125
132
|
app = QApplication(sys.argv)
|
126
|
-
|
127
133
|
widget = TextBox()
|
128
134
|
widget.show()
|
129
135
|
sys.exit(app.exec())
|
@@ -2,11 +2,11 @@
|
|
2
2
|
.gitlab-ci.yml,sha256=Dc1iDjsc72UxdUtihx4uSZU0lrTQeR8hZwGx1MQBfKE,8432
|
3
3
|
.pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
|
4
4
|
.readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
|
5
|
-
CHANGELOG.md,sha256=
|
5
|
+
CHANGELOG.md,sha256=83toIm-bLOmMXqLc9D_TuEkaAmajXcVh2gp_jSZ0N1o,7266
|
6
6
|
LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
7
|
-
PKG-INFO,sha256=
|
7
|
+
PKG-INFO,sha256=zZkCksUj3vS0F-9_qaUXWatTcIGMUxtUYALlYIAmQeo,1334
|
8
8
|
README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
|
9
|
-
pyproject.toml,sha256=
|
9
|
+
pyproject.toml,sha256=Acf6n5A69AFyAgZ3AJrP3hmbHsi7XEZNGXe0ic-zuDE,2544
|
10
10
|
.git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
|
11
11
|
.gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
|
12
12
|
.gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
|
@@ -22,7 +22,7 @@ bec_widgets/assets/status_icons/running.svg,sha256=nlc6rKh_f-uOxQSk0BkBNyWnPAJU5
|
|
22
22
|
bec_widgets/assets/status_icons/warning.svg,sha256=CNx88p9kbDG51s9ztKf-cfYan4JdDBbk3-IFKfOOFlI,364
|
23
23
|
bec_widgets/cli/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
|
24
24
|
bec_widgets/cli/auto_updates.py,sha256=DwzRChcFIWPH2kCYvp8H7dXvyYSKGYv6LwCmK2sDR2E,5676
|
25
|
-
bec_widgets/cli/client.py,sha256=
|
25
|
+
bec_widgets/cli/client.py,sha256=_sgO24vbZnc-dRPZjH_sDfvYHHvR-OeYkQmr_oGuSbU,81230
|
26
26
|
bec_widgets/cli/client_utils.py,sha256=EdDfo3uuYAWtZiDGGu3_GPnl94FSLkNG2N_4I9FNfMc,11809
|
27
27
|
bec_widgets/cli/generate_cli.py,sha256=zRhhcErjHqnNymoxu9oqeUZUfwLX84De1RIeGiZGUyY,6602
|
28
28
|
bec_widgets/cli/rpc_register.py,sha256=QxXUZu5XNg00Yf5O3UHWOXg3-f_pzKjjoZYMOa-MOJc,2216
|
@@ -226,7 +226,7 @@ bec_widgets/widgets/stop_button/stop_button.pyproject,sha256=Cc_xbv-zfzNVpsdg_1Q
|
|
226
226
|
bec_widgets/widgets/stop_button/stop_button_plugin.py,sha256=VT-WVLq89fw7PwML7JDMCF1bqfopLCZIgMA4yetl65M,1365
|
227
227
|
bec_widgets/widgets/text_box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
228
228
|
bec_widgets/widgets/text_box/register_text_box.py,sha256=UwrmCoYjAAtJJK8BwC0P_wSb-lOlOvxPe3-Bemg_9nw,459
|
229
|
-
bec_widgets/widgets/text_box/text_box.py,sha256=
|
229
|
+
bec_widgets/widgets/text_box/text_box.py,sha256=S1VQwTkZje2x4iwjTEzd6zPP_wcHtIcx8o9KuCtsSbY,4247
|
230
230
|
bec_widgets/widgets/text_box/text_box.pyproject,sha256=XohO1BIe2hrpU-z_KHKRgjcUkXru7jeFte31j2TPbNk,26
|
231
231
|
bec_widgets/widgets/text_box/text_box_plugin.py,sha256=rjRxqqovggpiI3gfQrXU-uc7TEjugIameQBrFD6s9hY,1302
|
232
232
|
bec_widgets/widgets/toggle/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -255,8 +255,8 @@ bec_widgets/widgets/website/register_website_widget.py,sha256=LIQJpV9uqcBiPR9cEA
|
|
255
255
|
bec_widgets/widgets/website/website.py,sha256=42pncCc_zI2eqeMArIurVmPUukRo5bTxa2h1Skah-io,3012
|
256
256
|
bec_widgets/widgets/website/website_widget.pyproject,sha256=scOiV3cV1_BjbzpPzy2N8rIJL5P2qIZz8ObTJ-Uvdtg,25
|
257
257
|
bec_widgets/widgets/website/website_widget_plugin.py,sha256=pz38_C2cZ0yvPPS02wdIPcmhFo_yiwUhflsASocAPQQ,1341
|
258
|
-
bec_widgets-0.109.
|
259
|
-
bec_widgets-0.109.
|
260
|
-
bec_widgets-0.109.
|
261
|
-
bec_widgets-0.109.
|
262
|
-
bec_widgets-0.109.
|
258
|
+
bec_widgets-0.109.1.dist-info/METADATA,sha256=zZkCksUj3vS0F-9_qaUXWatTcIGMUxtUYALlYIAmQeo,1334
|
259
|
+
bec_widgets-0.109.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
260
|
+
bec_widgets-0.109.1.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
|
261
|
+
bec_widgets-0.109.1.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
262
|
+
bec_widgets-0.109.1.dist-info/RECORD,,
|
pyproject.toml
CHANGED
File without changes
|
File without changes
|
File without changes
|