sciwidgets 0.1.2__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.
- sciwidgets/__init__.py +8 -0
- sciwidgets/dialogs/__init__.py +31 -0
- sciwidgets/dialogs/__main__.py +128 -0
- sciwidgets/dialogs/message_dialogs.py +553 -0
- sciwidgets/formatting.py +161 -0
- sciwidgets/labels/__init__.py +3 -0
- sciwidgets/labels/__main__.py +124 -0
- sciwidgets/labels/math_label.py +505 -0
- sciwidgets/params/__init__.py +18 -0
- sciwidgets/params/__main__.py +81 -0
- sciwidgets/params/base.py +220 -0
- sciwidgets/params/combo_box.py +106 -0
- sciwidgets/params/line_edit.py +132 -0
- sciwidgets/params/numeric_line_edit.py +680 -0
- sciwidgets/params/sliders/__init__.py +36 -0
- sciwidgets/params/sliders/__main__.py +215 -0
- sciwidgets/params/sliders/_defaults.py +36 -0
- sciwidgets/params/sliders/_dialogs.py +174 -0
- sciwidgets/params/sliders/_right_click_overlay.py +115 -0
- sciwidgets/params/sliders/base.py +592 -0
- sciwidgets/params/sliders/multi.py +660 -0
- sciwidgets/params/sliders/range.py +1841 -0
- sciwidgets/params/sliders/single.py +2042 -0
- sciwidgets/params/toggle.py +116 -0
- sciwidgets/style.py +175 -0
- sciwidgets-0.1.2.dist-info/METADATA +173 -0
- sciwidgets-0.1.2.dist-info/RECORD +30 -0
- sciwidgets-0.1.2.dist-info/WHEEL +5 -0
- sciwidgets-0.1.2.dist-info/licenses/LICENSE +21 -0
- sciwidgets-0.1.2.dist-info/top_level.txt +1 -0
sciwidgets/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from .message_dialogs import (
|
|
2
|
+
AboutDialog,
|
|
3
|
+
AskDialog,
|
|
4
|
+
AskResult,
|
|
5
|
+
DialogIcon,
|
|
6
|
+
InfoDialog,
|
|
7
|
+
MessageDialog,
|
|
8
|
+
TitledDialogBase,
|
|
9
|
+
ask_question,
|
|
10
|
+
show_about_dialog,
|
|
11
|
+
show_critical,
|
|
12
|
+
show_information,
|
|
13
|
+
show_rich_information,
|
|
14
|
+
show_warning,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"AboutDialog",
|
|
19
|
+
"AskDialog",
|
|
20
|
+
"AskResult",
|
|
21
|
+
"DialogIcon",
|
|
22
|
+
"InfoDialog",
|
|
23
|
+
"MessageDialog",
|
|
24
|
+
"TitledDialogBase",
|
|
25
|
+
"ask_question",
|
|
26
|
+
"show_about_dialog",
|
|
27
|
+
"show_critical",
|
|
28
|
+
"show_information",
|
|
29
|
+
"show_rich_information",
|
|
30
|
+
"show_warning",
|
|
31
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Demo for the dialogs subpackage: ``python -m sciwidgets.dialogs``."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from PySide6.QtWidgets import (
|
|
6
|
+
QApplication, QHBoxLayout, QPushButton, QStyle, QVBoxLayout, QWidget,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from sciwidgets.dialogs.message_dialogs import (
|
|
10
|
+
ask_question,
|
|
11
|
+
show_about_dialog,
|
|
12
|
+
show_critical,
|
|
13
|
+
show_information,
|
|
14
|
+
show_rich_information,
|
|
15
|
+
show_warning,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _demo_main() -> int:
|
|
20
|
+
"""Run a window with one button per dialog helper.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
int: Qt application exit code.
|
|
24
|
+
"""
|
|
25
|
+
app = QApplication(sys.argv)
|
|
26
|
+
win = QWidget()
|
|
27
|
+
win.setWindowTitle("Dialogs demo")
|
|
28
|
+
|
|
29
|
+
# --- Questions --------------------------------------------------------
|
|
30
|
+
def ask_save() -> None:
|
|
31
|
+
r = ask_question(
|
|
32
|
+
"Unsaved Changes",
|
|
33
|
+
"Do you want to save your changes before closing?",
|
|
34
|
+
"Your modifications will be lost if you close without saving.",
|
|
35
|
+
yes_btn_label="Save", no_btn_label="Don't Save", parent=win,
|
|
36
|
+
)
|
|
37
|
+
print("ask (save):", r)
|
|
38
|
+
|
|
39
|
+
def ask_yes_no() -> None:
|
|
40
|
+
r = ask_question(
|
|
41
|
+
"Continue", "Do you want to continue?",
|
|
42
|
+
"Yes continues the operation.\nNo stops without changes.",
|
|
43
|
+
no_btn_label="No", parent=win,
|
|
44
|
+
)
|
|
45
|
+
print("ask (yes/no):", r)
|
|
46
|
+
|
|
47
|
+
def ask_two_buttons() -> None:
|
|
48
|
+
r = ask_question(
|
|
49
|
+
"Delete File", "Do you want to delete this file?",
|
|
50
|
+
"This action cannot be undone.",
|
|
51
|
+
yes_btn_label="Delete", parent=win,
|
|
52
|
+
)
|
|
53
|
+
print("ask (two buttons):", r)
|
|
54
|
+
|
|
55
|
+
# --- Messages ---------------------------------------------------------
|
|
56
|
+
def info() -> None:
|
|
57
|
+
show_information(
|
|
58
|
+
"Data Information", "The data file was loaded successfully.",
|
|
59
|
+
"128 rows were read and validated.\nNo missing values were found.",
|
|
60
|
+
parent=win,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def warning() -> None:
|
|
64
|
+
show_warning(
|
|
65
|
+
"Overwrite File", "A file with this name already exists.",
|
|
66
|
+
"Saving now will replace the existing file.", parent=win,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def critical() -> None:
|
|
70
|
+
show_critical(
|
|
71
|
+
"Load Error", "The selected file could not be opened.",
|
|
72
|
+
"Check that the file exists and that you can read it.", parent=win,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def rich_info() -> None:
|
|
76
|
+
show_rich_information(
|
|
77
|
+
"Notes",
|
|
78
|
+
"<b>Rich information dialog</b><br><br>"
|
|
79
|
+
"Useful for longer help text, with selectable text, a copy "
|
|
80
|
+
"button, and links: "
|
|
81
|
+
'<a href="https://doc.qt.io/qtforpython-6/">Qt for Python docs</a>',
|
|
82
|
+
parent=win,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# --- About ------------------------------------------------------------
|
|
86
|
+
about_html = (
|
|
87
|
+
"A demo application for <b>sciwidgets</b>.<br><br>"
|
|
88
|
+
"<b>Version:</b> 0.1.0<br>"
|
|
89
|
+
'<b>Docs:</b> <a href="https://doc.qt.io/qtforpython-6/">Qt for Python</a>'
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def about_default() -> None:
|
|
93
|
+
# No app icon is set in this demo, so the information icon is used.
|
|
94
|
+
show_about_dialog("About Demo", about_html, parent=win)
|
|
95
|
+
|
|
96
|
+
def about_custom_icon() -> None:
|
|
97
|
+
icon = win.style().standardIcon(QStyle.SP_ComputerIcon)
|
|
98
|
+
show_about_dialog("About Demo", about_html, parent=win, icon=icon)
|
|
99
|
+
|
|
100
|
+
# --- Layout -----------------------------------------------------------
|
|
101
|
+
columns = [
|
|
102
|
+
[("Ask: Save / Don't Save / Cancel", ask_save),
|
|
103
|
+
("Ask: Yes / No / Cancel", ask_yes_no),
|
|
104
|
+
("Ask: Delete / Cancel", ask_two_buttons)],
|
|
105
|
+
[("Information", info),
|
|
106
|
+
("Warning", warning),
|
|
107
|
+
("Critical", critical),
|
|
108
|
+
("Rich information", rich_info)],
|
|
109
|
+
[("About (default icon)", about_default),
|
|
110
|
+
("About (custom icon)", about_custom_icon)],
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
row = QHBoxLayout(win)
|
|
114
|
+
for buttons in columns:
|
|
115
|
+
col = QVBoxLayout()
|
|
116
|
+
for text, slot in buttons:
|
|
117
|
+
btn = QPushButton(text)
|
|
118
|
+
btn.clicked.connect(slot)
|
|
119
|
+
col.addWidget(btn)
|
|
120
|
+
col.addStretch(1)
|
|
121
|
+
row.addLayout(col)
|
|
122
|
+
|
|
123
|
+
win.show()
|
|
124
|
+
return app.exec()
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if __name__ == "__main__":
|
|
128
|
+
raise SystemExit(_demo_main())
|