statstudio 0.1.0__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.
- statstudio/__init__.py +9 -0
- statstudio/__main__.py +3 -0
- statstudio/app.py +83 -0
- statstudio/cli.py +116 -0
- statstudio/core/__init__.py +3 -0
- statstudio/core/archive.py +27 -0
- statstudio/core/commands.py +67 -0
- statstudio/core/formula_catalog.py +74 -0
- statstudio/core/formulas.py +605 -0
- statstudio/core/joins.py +123 -0
- statstudio/core/project.py +358 -0
- statstudio/core/runtime.py +321 -0
- statstudio/core/scripting.py +594 -0
- statstudio/core/table.py +796 -0
- statstudio/core/transform.py +450 -0
- statstudio/feature_help.py +595 -0
- statstudio/io/__init__.py +3 -0
- statstudio/io/docx.py +201 -0
- statstudio/io/export.py +99 -0
- statstudio/io/file_import.py +199 -0
- statstudio/io/odbc.py +334 -0
- statstudio/io/sample_data.py +164 -0
- statstudio/io/table_io.py +118 -0
- statstudio/plots/__init__.py +19 -0
- statstudio/plots/advanced.py +651 -0
- statstudio/plots/basic.py +957 -0
- statstudio/plots/bayesian_plots.py +94 -0
- statstudio/plots/common.py +334 -0
- statstudio/plots/diagnostics.py +214 -0
- statstudio/plots/doe_plots.py +235 -0
- statstudio/plots/plotly_builders.py +719 -0
- statstudio/plots/predictive_plots.py +72 -0
- statstudio/plots/registry.py +251 -0
- statstudio/plugins.py +111 -0
- statstudio/resources/help_topics.json +13195 -0
- statstudio/resources/logo.ico +0 -0
- statstudio/resources/logo.png +0 -0
- statstudio/resources/statstudio.svg +8 -0
- statstudio/stats/__init__.py +42 -0
- statstudio/stats/bayesian.py +1094 -0
- statstudio/stats/bayesian_optimization.py +590 -0
- statstudio/stats/common.py +140 -0
- statstudio/stats/correlation.py +135 -0
- statstudio/stats/custom_doe.py +1714 -0
- statstudio/stats/descriptive.py +200 -0
- statstudio/stats/desirability.py +132 -0
- statstudio/stats/distributions.py +331 -0
- statstudio/stats/doe.py +1070 -0
- statstudio/stats/hypothesis.py +1305 -0
- statstudio/stats/multivariate.py +307 -0
- statstudio/stats/optimal_doe.py +264 -0
- statstudio/stats/power.py +194 -0
- statstudio/stats/predictive.py +605 -0
- statstudio/stats/profiler.py +379 -0
- statstudio/stats/quality.py +1218 -0
- statstudio/stats/regression.py +1600 -0
- statstudio/stats/results.py +235 -0
- statstudio/stats/simulator.py +95 -0
- statstudio/stats/survival.py +637 -0
- statstudio/stats/timeseries.py +643 -0
- statstudio/stats/tolerance.py +154 -0
- statstudio/ui/__init__.py +0 -0
- statstudio/ui/analysis_hub.py +271 -0
- statstudio/ui/command_catalog.py +460 -0
- statstudio/ui/command_palette.py +55 -0
- statstudio/ui/console.py +239 -0
- statstudio/ui/dialogs/__init__.py +0 -0
- statstudio/ui/dialogs/advanced_dialogs.py +392 -0
- statstudio/ui/dialogs/base.py +537 -0
- statstudio/ui/dialogs/bayesian_dialogs.py +488 -0
- statstudio/ui/dialogs/bayesian_optimization_dialog.py +299 -0
- statstudio/ui/dialogs/custom_doe_dialog.py +467 -0
- statstudio/ui/dialogs/doe_dialogs.py +220 -0
- statstudio/ui/dialogs/extended_dialogs.py +665 -0
- statstudio/ui/dialogs/graph_builder.py +139 -0
- statstudio/ui/dialogs/help_dialog.py +207 -0
- statstudio/ui/dialogs/help_topics.py +280 -0
- statstudio/ui/dialogs/lazy.py +184 -0
- statstudio/ui/dialogs/odbc_dialog.py +311 -0
- statstudio/ui/dialogs/plot_dialog.py +1385 -0
- statstudio/ui/dialogs/report_composer.py +218 -0
- statstudio/ui/dialogs/script_dialogs.py +267 -0
- statstudio/ui/dialogs/stats_dialogs.py +1688 -0
- statstudio/ui/dialogs/table_dialogs.py +997 -0
- statstudio/ui/dialogs/window.py +58 -0
- statstudio/ui/docks/__init__.py +0 -0
- statstudio/ui/formula_editor.py +121 -0
- statstudio/ui/icons.py +257 -0
- statstudio/ui/jobs.py +179 -0
- statstudio/ui/main_window.py +3934 -0
- statstudio/ui/plot_interaction.py +178 -0
- statstudio/ui/profiler_widget.py +437 -0
- statstudio/ui/recent.py +82 -0
- statstudio/ui/reports/__init__.py +0 -0
- statstudio/ui/reports/report_view.py +1632 -0
- statstudio/ui/script_jobs.py +35 -0
- statstudio/ui/scripts_panel.py +271 -0
- statstudio/ui/table_document.py +233 -0
- statstudio/ui/table_model.py +285 -0
- statstudio/ui/table_view.py +285 -0
- statstudio/ui/theme.py +645 -0
- statstudio/ui/welcome.py +453 -0
- statstudio/ui/window_controls.py +53 -0
- statstudio/ui/workers.py +53 -0
- statstudio-0.1.0.dist-info/METADATA +261 -0
- statstudio-0.1.0.dist-info/RECORD +110 -0
- statstudio-0.1.0.dist-info/WHEEL +5 -0
- statstudio-0.1.0.dist-info/entry_points.txt +5 -0
- statstudio-0.1.0.dist-info/licenses/LICENSE +674 -0
- statstudio-0.1.0.dist-info/top_level.txt +1 -0
statstudio/ui/welcome.py
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from PySide6.QtCore import Qt, Signal
|
|
6
|
+
from PySide6.QtGui import QKeyEvent, QMouseEvent
|
|
7
|
+
from PySide6.QtWidgets import (
|
|
8
|
+
QFrame,
|
|
9
|
+
QGridLayout,
|
|
10
|
+
QHBoxLayout,
|
|
11
|
+
QLabel,
|
|
12
|
+
QLineEdit,
|
|
13
|
+
QPushButton,
|
|
14
|
+
QScrollArea,
|
|
15
|
+
QVBoxLayout,
|
|
16
|
+
QWidget,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from statstudio.io.sample_data import sample_names
|
|
20
|
+
from statstudio.ui import icons
|
|
21
|
+
from statstudio.ui.recent import recent_projects
|
|
22
|
+
|
|
23
|
+
_QUICK_ACTIONS = (
|
|
24
|
+
("analyze.descriptive", "analyze", "Explore Data", "Summaries, distributions, and normality checks."),
|
|
25
|
+
("analyze.ttest", "analyze", "Compare Groups", "t tests, ANOVA, and nonparametric comparisons."),
|
|
26
|
+
("analyze.regression", "graph", "Fit a Model", "Simple or multiple regression models."),
|
|
27
|
+
("graph.builder", "graph", "Build a Graph", "Create linked, interactive graphs."),
|
|
28
|
+
("analyze.quality", "quality", "Quality / SPC", "Control charts, capability, and Gage R&R."),
|
|
29
|
+
("doe.custom", "doe", "Design DOE", "Create a custom or factorial experiment."),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class DropZone(QFrame):
|
|
34
|
+
files_dropped = Signal(list)
|
|
35
|
+
|
|
36
|
+
def __init__(self, parent: QWidget | None = None) -> None:
|
|
37
|
+
super().__init__(parent)
|
|
38
|
+
self.setObjectName("dropZone")
|
|
39
|
+
self.setAcceptDrops(True)
|
|
40
|
+
self.setMinimumSize(250, 170)
|
|
41
|
+
layout = QVBoxLayout(self)
|
|
42
|
+
layout.setContentsMargins(18, 18, 18, 18)
|
|
43
|
+
layout.setSpacing(7)
|
|
44
|
+
icon_label = QLabel()
|
|
45
|
+
icon_label.setPixmap(icons.icon("import").pixmap(32, 32))
|
|
46
|
+
icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
47
|
+
layout.addWidget(icon_label)
|
|
48
|
+
self.icon_label = icon_label
|
|
49
|
+
title = QLabel("Drop data to begin")
|
|
50
|
+
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
51
|
+
title.setProperty("role", "h3")
|
|
52
|
+
layout.addWidget(title)
|
|
53
|
+
hint = QLabel("CSV, Excel, Parquet, JSON, or text files")
|
|
54
|
+
hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
55
|
+
hint.setWordWrap(True)
|
|
56
|
+
hint.setProperty("role", "muted")
|
|
57
|
+
layout.addWidget(hint)
|
|
58
|
+
browse = QPushButton("Choose files")
|
|
59
|
+
browse.setProperty("quiet", "true")
|
|
60
|
+
browse.setCursor(Qt.CursorShape.PointingHandCursor)
|
|
61
|
+
browse.clicked.connect(self._browse)
|
|
62
|
+
layout.addWidget(browse, 0, Qt.AlignmentFlag.AlignHCenter)
|
|
63
|
+
|
|
64
|
+
def _browse(self) -> None:
|
|
65
|
+
window = self.window()
|
|
66
|
+
handler = getattr(window, "_import_file", None)
|
|
67
|
+
if callable(handler):
|
|
68
|
+
handler()
|
|
69
|
+
|
|
70
|
+
def refresh_icons(self) -> None:
|
|
71
|
+
self.icon_label.setPixmap(icons.icon("import").pixmap(32, 32))
|
|
72
|
+
|
|
73
|
+
def _set_active(self, active: bool) -> None:
|
|
74
|
+
self.setProperty("dragActive", active)
|
|
75
|
+
self.style().unpolish(self)
|
|
76
|
+
self.style().polish(self)
|
|
77
|
+
|
|
78
|
+
def dragEnterEvent(self, event) -> None: # type: ignore[override]
|
|
79
|
+
if event.mimeData().hasUrls():
|
|
80
|
+
self._set_active(True)
|
|
81
|
+
event.acceptProposedAction()
|
|
82
|
+
else:
|
|
83
|
+
super().dragEnterEvent(event)
|
|
84
|
+
|
|
85
|
+
def dragLeaveEvent(self, event) -> None: # type: ignore[override]
|
|
86
|
+
self._set_active(False)
|
|
87
|
+
super().dragLeaveEvent(event)
|
|
88
|
+
|
|
89
|
+
def dropEvent(self, event) -> None: # type: ignore[override]
|
|
90
|
+
self._set_active(False)
|
|
91
|
+
paths = [url.toLocalFile() for url in event.mimeData().urls() if url.isLocalFile()]
|
|
92
|
+
if paths:
|
|
93
|
+
self.files_dropped.emit(paths)
|
|
94
|
+
event.acceptProposedAction()
|
|
95
|
+
else:
|
|
96
|
+
super().dropEvent(event)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class HomeActionCard(QFrame):
|
|
100
|
+
activated = Signal(str)
|
|
101
|
+
|
|
102
|
+
def __init__(
|
|
103
|
+
self,
|
|
104
|
+
command_id: str,
|
|
105
|
+
icon_name: str,
|
|
106
|
+
title: str,
|
|
107
|
+
description: str,
|
|
108
|
+
parent: QWidget | None = None,
|
|
109
|
+
) -> None:
|
|
110
|
+
super().__init__(parent)
|
|
111
|
+
self.command_id = command_id
|
|
112
|
+
self.setProperty("cardAction", True)
|
|
113
|
+
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
|
114
|
+
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
|
115
|
+
self.setMinimumHeight(104)
|
|
116
|
+
layout = QVBoxLayout(self)
|
|
117
|
+
layout.setContentsMargins(13, 11, 13, 11)
|
|
118
|
+
layout.setSpacing(5)
|
|
119
|
+
top = QHBoxLayout()
|
|
120
|
+
top.setSpacing(8)
|
|
121
|
+
image = QLabel()
|
|
122
|
+
image.setPixmap(icons.icon(icon_name).pixmap(20, 20))
|
|
123
|
+
image.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
|
124
|
+
top.addWidget(image)
|
|
125
|
+
self.icon_name = icon_name
|
|
126
|
+
self.image_label = image
|
|
127
|
+
title_label = QLabel(title)
|
|
128
|
+
title_label.setProperty("role", "h3")
|
|
129
|
+
title_label.setWordWrap(True)
|
|
130
|
+
title_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
|
131
|
+
top.addWidget(title_label, 1)
|
|
132
|
+
layout.addLayout(top)
|
|
133
|
+
description_label = QLabel(description)
|
|
134
|
+
description_label.setWordWrap(True)
|
|
135
|
+
description_label.setProperty("role", "muted")
|
|
136
|
+
description_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
|
137
|
+
layout.addWidget(description_label, 1)
|
|
138
|
+
self.setToolTip(description)
|
|
139
|
+
|
|
140
|
+
def _activate(self) -> None:
|
|
141
|
+
self.activated.emit(self.command_id)
|
|
142
|
+
|
|
143
|
+
def refresh_icons(self) -> None:
|
|
144
|
+
self.image_label.setPixmap(icons.icon(self.icon_name).pixmap(20, 20))
|
|
145
|
+
|
|
146
|
+
def mouseReleaseEvent(self, event: QMouseEvent) -> None: # type: ignore[override]
|
|
147
|
+
if event.button() == Qt.MouseButton.LeftButton:
|
|
148
|
+
self._activate()
|
|
149
|
+
event.accept()
|
|
150
|
+
return
|
|
151
|
+
super().mouseReleaseEvent(event)
|
|
152
|
+
|
|
153
|
+
def keyPressEvent(self, event: QKeyEvent) -> None: # type: ignore[override]
|
|
154
|
+
if event.key() in {Qt.Key.Key_Return, Qt.Key.Key_Enter, Qt.Key.Key_Space}:
|
|
155
|
+
self._activate()
|
|
156
|
+
event.accept()
|
|
157
|
+
return
|
|
158
|
+
super().keyPressEvent(event)
|
|
159
|
+
|
|
160
|
+
def enterEvent(self, event) -> None: # type: ignore[override]
|
|
161
|
+
self.setProperty("active", True)
|
|
162
|
+
self.style().unpolish(self)
|
|
163
|
+
self.style().polish(self)
|
|
164
|
+
super().enterEvent(event)
|
|
165
|
+
|
|
166
|
+
def leaveEvent(self, event) -> None: # type: ignore[override]
|
|
167
|
+
self.setProperty("active", False)
|
|
168
|
+
self.style().unpolish(self)
|
|
169
|
+
self.style().polish(self)
|
|
170
|
+
super().leaveEvent(event)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class WelcomePage(QWidget):
|
|
174
|
+
open_project_requested = Signal()
|
|
175
|
+
new_project_requested = Signal()
|
|
176
|
+
import_requested = Signal()
|
|
177
|
+
new_table_requested = Signal()
|
|
178
|
+
sample_requested = Signal(str)
|
|
179
|
+
recent_project_requested = Signal(str)
|
|
180
|
+
search_requested = Signal(str)
|
|
181
|
+
command_requested = Signal(str)
|
|
182
|
+
files_dropped = Signal(list)
|
|
183
|
+
|
|
184
|
+
def __init__(self, parent: QWidget | None = None) -> None:
|
|
185
|
+
super().__init__(parent)
|
|
186
|
+
self.setObjectName("homePage")
|
|
187
|
+
self.setAcceptDrops(True)
|
|
188
|
+
self._recent_commands: list[tuple[str, str]] = []
|
|
189
|
+
self._icon_buttons: list[tuple[QPushButton, str]] = []
|
|
190
|
+
self._action_cards: list[HomeActionCard] = []
|
|
191
|
+
|
|
192
|
+
outer = QVBoxLayout(self)
|
|
193
|
+
outer.setContentsMargins(0, 0, 0, 0)
|
|
194
|
+
outer.setSpacing(0)
|
|
195
|
+
scroll = QScrollArea()
|
|
196
|
+
scroll.setWidgetResizable(True)
|
|
197
|
+
scroll.setFrameShape(QFrame.Shape.NoFrame)
|
|
198
|
+
outer.addWidget(scroll)
|
|
199
|
+
|
|
200
|
+
page = QWidget()
|
|
201
|
+
page.setObjectName("homePage")
|
|
202
|
+
page_layout = QHBoxLayout(page)
|
|
203
|
+
page_layout.setContentsMargins(26, 22, 26, 26)
|
|
204
|
+
page_layout.addStretch(1)
|
|
205
|
+
content = QWidget()
|
|
206
|
+
content.setMaximumWidth(1180)
|
|
207
|
+
content.setMinimumWidth(720)
|
|
208
|
+
layout = QVBoxLayout(content)
|
|
209
|
+
layout.setContentsMargins(4, 4, 4, 4)
|
|
210
|
+
layout.setSpacing(16)
|
|
211
|
+
page_layout.addWidget(content, 1)
|
|
212
|
+
page_layout.addStretch(1)
|
|
213
|
+
scroll.setWidget(page)
|
|
214
|
+
|
|
215
|
+
layout.addWidget(self._build_hero())
|
|
216
|
+
columns = QHBoxLayout()
|
|
217
|
+
columns.setSpacing(16)
|
|
218
|
+
columns.addWidget(self._build_recent_card(), 3)
|
|
219
|
+
columns.addWidget(self._build_quick_card(), 4)
|
|
220
|
+
layout.addLayout(columns)
|
|
221
|
+
layout.addWidget(self._build_samples_card())
|
|
222
|
+
self.recent_commands_card = self._build_recent_commands_card()
|
|
223
|
+
layout.addWidget(self.recent_commands_card)
|
|
224
|
+
footer = QLabel("Tip: press F1 for searchable help, or Ctrl+/ to find any command.")
|
|
225
|
+
footer.setProperty("role", "muted")
|
|
226
|
+
footer.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
227
|
+
layout.addWidget(footer)
|
|
228
|
+
layout.addStretch(1)
|
|
229
|
+
self.refresh()
|
|
230
|
+
|
|
231
|
+
def _icon_button(self, text: str, icon_name: str, **properties) -> QPushButton:
|
|
232
|
+
button = QPushButton(text)
|
|
233
|
+
icons.set_button_icon(button, icon_name)
|
|
234
|
+
for key, value in properties.items():
|
|
235
|
+
button.setProperty(key, value)
|
|
236
|
+
self._icon_buttons.append((button, icon_name))
|
|
237
|
+
return button
|
|
238
|
+
|
|
239
|
+
def _build_hero(self) -> QWidget:
|
|
240
|
+
hero = QFrame()
|
|
241
|
+
hero.setObjectName("homeHero")
|
|
242
|
+
row = QHBoxLayout(hero)
|
|
243
|
+
row.setContentsMargins(26, 24, 24, 24)
|
|
244
|
+
row.setSpacing(24)
|
|
245
|
+
|
|
246
|
+
left = QVBoxLayout()
|
|
247
|
+
left.setSpacing(9)
|
|
248
|
+
eyebrow = QLabel("STATSTUDIO ANALYST WORKSPACE")
|
|
249
|
+
eyebrow.setProperty("role", "eyebrow")
|
|
250
|
+
left.addWidget(eyebrow)
|
|
251
|
+
title = QLabel("Make sense of your data.")
|
|
252
|
+
title.setProperty("role", "heroTitle")
|
|
253
|
+
title.setWordWrap(True)
|
|
254
|
+
left.addWidget(title)
|
|
255
|
+
subtitle = QLabel(
|
|
256
|
+
"Import data, run rigorous analyses, design experiments, and share clear, rerunnable reports."
|
|
257
|
+
)
|
|
258
|
+
subtitle.setProperty("role", "heroSubtitle")
|
|
259
|
+
subtitle.setWordWrap(True)
|
|
260
|
+
left.addWidget(subtitle)
|
|
261
|
+
|
|
262
|
+
actions = QHBoxLayout()
|
|
263
|
+
actions.setSpacing(7)
|
|
264
|
+
open_button = self._icon_button("Open Project", "open", primary="true")
|
|
265
|
+
open_button.clicked.connect(self.open_project_requested.emit)
|
|
266
|
+
actions.addWidget(open_button)
|
|
267
|
+
import_button = self._icon_button("Import Data", "import")
|
|
268
|
+
import_button.clicked.connect(self.import_requested.emit)
|
|
269
|
+
actions.addWidget(import_button)
|
|
270
|
+
new_button = self._icon_button("New Table", "table")
|
|
271
|
+
new_button.clicked.connect(self.new_table_requested.emit)
|
|
272
|
+
actions.addWidget(new_button)
|
|
273
|
+
actions.addStretch(1)
|
|
274
|
+
left.addLayout(actions)
|
|
275
|
+
|
|
276
|
+
search_row = QHBoxLayout()
|
|
277
|
+
search_row.setSpacing(6)
|
|
278
|
+
self.search_edit = QLineEdit()
|
|
279
|
+
self.search_edit.setPlaceholderText("Search analyses and commands, e.g. t test, control chart, DOE")
|
|
280
|
+
self.search_edit.setClearButtonEnabled(True)
|
|
281
|
+
self.search_edit.returnPressed.connect(self._search)
|
|
282
|
+
search_row.addWidget(self.search_edit, 1)
|
|
283
|
+
search_button = self._icon_button("Search", "search", primary="true")
|
|
284
|
+
search_button.clicked.connect(self._search)
|
|
285
|
+
search_row.addWidget(search_button)
|
|
286
|
+
left.addLayout(search_row)
|
|
287
|
+
row.addLayout(left, 1)
|
|
288
|
+
|
|
289
|
+
self.drop_zone = DropZone()
|
|
290
|
+
self.drop_zone.files_dropped.connect(self.files_dropped.emit)
|
|
291
|
+
row.addWidget(self.drop_zone, 0)
|
|
292
|
+
return hero
|
|
293
|
+
|
|
294
|
+
def _section_title(self, title: str, subtitle: str = "") -> QWidget:
|
|
295
|
+
holder = QWidget()
|
|
296
|
+
layout = QVBoxLayout(holder)
|
|
297
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
298
|
+
layout.setSpacing(2)
|
|
299
|
+
label = QLabel(title)
|
|
300
|
+
label.setProperty("role", "h2")
|
|
301
|
+
layout.addWidget(label)
|
|
302
|
+
if subtitle:
|
|
303
|
+
detail = QLabel(subtitle)
|
|
304
|
+
detail.setProperty("role", "muted")
|
|
305
|
+
layout.addWidget(detail)
|
|
306
|
+
return holder
|
|
307
|
+
|
|
308
|
+
def _build_recent_card(self) -> QWidget:
|
|
309
|
+
card = QFrame()
|
|
310
|
+
card.setProperty("card", True)
|
|
311
|
+
layout = QVBoxLayout(card)
|
|
312
|
+
layout.setContentsMargins(15, 13, 15, 13)
|
|
313
|
+
layout.setSpacing(8)
|
|
314
|
+
layout.addWidget(self._section_title("Recent projects", "Continue where you left off."))
|
|
315
|
+
self.recent_layout = QVBoxLayout()
|
|
316
|
+
self.recent_layout.setSpacing(2)
|
|
317
|
+
layout.addLayout(self.recent_layout)
|
|
318
|
+
self.recent_empty = QLabel("No recent projects yet. Open a project or start with sample data below.")
|
|
319
|
+
self.recent_empty.setWordWrap(True)
|
|
320
|
+
self.recent_empty.setProperty("role", "muted")
|
|
321
|
+
layout.addWidget(self.recent_empty)
|
|
322
|
+
layout.addStretch(1)
|
|
323
|
+
new_project = self._icon_button("New Project", "plus", quiet="true")
|
|
324
|
+
new_project.clicked.connect(self.new_project_requested.emit)
|
|
325
|
+
layout.addWidget(new_project, 0, Qt.AlignmentFlag.AlignLeft)
|
|
326
|
+
return card
|
|
327
|
+
|
|
328
|
+
def _build_quick_card(self) -> QWidget:
|
|
329
|
+
card = QFrame()
|
|
330
|
+
card.setProperty("card", True)
|
|
331
|
+
layout = QVBoxLayout(card)
|
|
332
|
+
layout.setContentsMargins(15, 13, 15, 13)
|
|
333
|
+
layout.setSpacing(10)
|
|
334
|
+
layout.addWidget(self._section_title("Start something", "Common analyst workflows, one click away."))
|
|
335
|
+
grid = QGridLayout()
|
|
336
|
+
grid.setHorizontalSpacing(8)
|
|
337
|
+
grid.setVerticalSpacing(8)
|
|
338
|
+
for index, (command_id, icon_name, title, description) in enumerate(_QUICK_ACTIONS):
|
|
339
|
+
item = HomeActionCard(command_id, icon_name, title, description)
|
|
340
|
+
item.activated.connect(self.command_requested.emit)
|
|
341
|
+
self._action_cards.append(item)
|
|
342
|
+
grid.addWidget(item, index // 2, index % 2)
|
|
343
|
+
layout.addLayout(grid)
|
|
344
|
+
return card
|
|
345
|
+
|
|
346
|
+
def _build_samples_card(self) -> QWidget:
|
|
347
|
+
card = QFrame()
|
|
348
|
+
card.setProperty("card", True)
|
|
349
|
+
layout = QVBoxLayout(card)
|
|
350
|
+
layout.setContentsMargins(15, 13, 15, 13)
|
|
351
|
+
layout.setSpacing(9)
|
|
352
|
+
layout.addWidget(self._section_title("Explore sample data", "Ready-to-use datasets and examples."))
|
|
353
|
+
grid = QGridLayout()
|
|
354
|
+
grid.setHorizontalSpacing(8)
|
|
355
|
+
grid.setVerticalSpacing(7)
|
|
356
|
+
for index, name in enumerate(sample_names()):
|
|
357
|
+
button = self._icon_button(name, "table", sample="true")
|
|
358
|
+
button.setToolTip(f"Load the {name} sample dataset")
|
|
359
|
+
button.clicked.connect(lambda _checked=False, sample=name: self.sample_requested.emit(sample))
|
|
360
|
+
grid.addWidget(button, index // 3, index % 3)
|
|
361
|
+
layout.addLayout(grid)
|
|
362
|
+
return card
|
|
363
|
+
|
|
364
|
+
def _build_recent_commands_card(self) -> QWidget:
|
|
365
|
+
card = QFrame()
|
|
366
|
+
card.setProperty("card", True)
|
|
367
|
+
layout = QHBoxLayout(card)
|
|
368
|
+
layout.setContentsMargins(15, 11, 15, 11)
|
|
369
|
+
layout.setSpacing(10)
|
|
370
|
+
label = QLabel("Recently used")
|
|
371
|
+
label.setProperty("role", "h3")
|
|
372
|
+
layout.addWidget(label)
|
|
373
|
+
self.recent_commands_layout = QHBoxLayout()
|
|
374
|
+
self.recent_commands_layout.setSpacing(6)
|
|
375
|
+
layout.addLayout(self.recent_commands_layout, 1)
|
|
376
|
+
card.setVisible(False)
|
|
377
|
+
return card
|
|
378
|
+
|
|
379
|
+
def set_recent_commands(self, commands: list[tuple[str, str]]) -> None:
|
|
380
|
+
self._recent_commands = list(commands)
|
|
381
|
+
self.refresh_recent_commands()
|
|
382
|
+
|
|
383
|
+
def refresh_recent_commands(self) -> None:
|
|
384
|
+
while self.recent_commands_layout.count():
|
|
385
|
+
item = self.recent_commands_layout.takeAt(0)
|
|
386
|
+
widget = item.widget()
|
|
387
|
+
if widget is not None:
|
|
388
|
+
widget.deleteLater()
|
|
389
|
+
for command_id, title in self._recent_commands[:8]:
|
|
390
|
+
button = QPushButton(title)
|
|
391
|
+
button.setProperty("commandChip", "true")
|
|
392
|
+
button.setCursor(Qt.CursorShape.PointingHandCursor)
|
|
393
|
+
button.clicked.connect(lambda _checked=False, cid=command_id: self.command_requested.emit(cid))
|
|
394
|
+
self.recent_commands_layout.addWidget(button)
|
|
395
|
+
self.recent_commands_layout.addStretch(1)
|
|
396
|
+
self.recent_commands_card.setVisible(bool(self._recent_commands))
|
|
397
|
+
|
|
398
|
+
def refresh_icons(self) -> None:
|
|
399
|
+
self.drop_zone.refresh_icons()
|
|
400
|
+
for card in self._action_cards:
|
|
401
|
+
card.refresh_icons()
|
|
402
|
+
for button, icon_name in self._icon_buttons:
|
|
403
|
+
button.setIcon(icons.action_icon(icon_name))
|
|
404
|
+
|
|
405
|
+
def refresh(self) -> None:
|
|
406
|
+
while self.recent_layout.count():
|
|
407
|
+
item = self.recent_layout.takeAt(0)
|
|
408
|
+
widget = item.widget()
|
|
409
|
+
if widget is not None:
|
|
410
|
+
widget.deleteLater()
|
|
411
|
+
projects = recent_projects()
|
|
412
|
+
self.recent_empty.setVisible(not projects)
|
|
413
|
+
for path in projects:
|
|
414
|
+
project_path = Path(path)
|
|
415
|
+
exists = project_path.exists()
|
|
416
|
+
name = project_path.name or path
|
|
417
|
+
label = f"{name} (missing)" if not exists else name
|
|
418
|
+
button = QPushButton(label)
|
|
419
|
+
button.setProperty("recentProject", "true")
|
|
420
|
+
button.setToolTip(path)
|
|
421
|
+
button.setMinimumHeight(36)
|
|
422
|
+
button.clicked.connect(
|
|
423
|
+
lambda _checked=False, value=path: self.recent_project_requested.emit(value)
|
|
424
|
+
)
|
|
425
|
+
self.recent_layout.addWidget(button)
|
|
426
|
+
self.set_recent_commands(
|
|
427
|
+
[
|
|
428
|
+
(command_id, title)
|
|
429
|
+
for command_id, title in self._recent_commands
|
|
430
|
+
if command_id and title
|
|
431
|
+
]
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
def _search(self) -> None:
|
|
435
|
+
self.search_requested.emit(self.search_edit.text().strip())
|
|
436
|
+
|
|
437
|
+
def focus_search(self) -> None:
|
|
438
|
+
self.search_edit.setFocus(Qt.FocusReason.ShortcutFocusReason)
|
|
439
|
+
self.search_edit.selectAll()
|
|
440
|
+
|
|
441
|
+
def dragEnterEvent(self, event) -> None: # type: ignore[override]
|
|
442
|
+
if event.mimeData().hasUrls():
|
|
443
|
+
event.acceptProposedAction()
|
|
444
|
+
else:
|
|
445
|
+
super().dragEnterEvent(event)
|
|
446
|
+
|
|
447
|
+
def dropEvent(self, event) -> None: # type: ignore[override]
|
|
448
|
+
paths = [url.toLocalFile() for url in event.mimeData().urls() if url.isLocalFile()]
|
|
449
|
+
if paths:
|
|
450
|
+
self.files_dropped.emit(paths)
|
|
451
|
+
event.acceptProposedAction()
|
|
452
|
+
else:
|
|
453
|
+
super().dropEvent(event)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from PySide6.QtCore import Signal
|
|
4
|
+
from PySide6.QtWidgets import QHBoxLayout, QToolButton, QWidget
|
|
5
|
+
|
|
6
|
+
from statstudio.ui import icons
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class WindowControls(QWidget):
|
|
10
|
+
"""Minimize/maximize/close window controls for MDI documents.
|
|
11
|
+
|
|
12
|
+
The minimize button closes the view without deleting, the middle button
|
|
13
|
+
toggles maximize/restore, and the X button deletes the underlying document.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
minimize_requested = Signal()
|
|
17
|
+
maximize_requested = Signal()
|
|
18
|
+
delete_requested = Signal()
|
|
19
|
+
|
|
20
|
+
def __init__(self, parent: QWidget | None = None) -> None:
|
|
21
|
+
super().__init__(parent)
|
|
22
|
+
layout = QHBoxLayout(self)
|
|
23
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
24
|
+
layout.setSpacing(1)
|
|
25
|
+
self.minimize_button = QToolButton()
|
|
26
|
+
icons.set_button_icon(self.minimize_button, "minimize")
|
|
27
|
+
self.minimize_button.setToolTip("Close view; the table stays in the project")
|
|
28
|
+
self.minimize_button.setProperty("windowControl", "true")
|
|
29
|
+
self.minimize_button.setAutoRaise(True)
|
|
30
|
+
self.minimize_button.clicked.connect(self.minimize_requested.emit)
|
|
31
|
+
layout.addWidget(self.minimize_button)
|
|
32
|
+
|
|
33
|
+
self.maximize_button = QToolButton()
|
|
34
|
+
self._maximized = False
|
|
35
|
+
icons.set_button_icon(self.maximize_button, "maximize")
|
|
36
|
+
self.maximize_button.setToolTip("Maximize")
|
|
37
|
+
self.maximize_button.setProperty("windowControl", "true")
|
|
38
|
+
self.maximize_button.setAutoRaise(True)
|
|
39
|
+
self.maximize_button.clicked.connect(self.maximize_requested.emit)
|
|
40
|
+
layout.addWidget(self.maximize_button)
|
|
41
|
+
|
|
42
|
+
self.delete_button = QToolButton()
|
|
43
|
+
icons.set_button_icon(self.delete_button, "trash")
|
|
44
|
+
self.delete_button.setToolTip("Delete this table or report")
|
|
45
|
+
self.delete_button.setProperty("windowControl", "true")
|
|
46
|
+
self.delete_button.setAutoRaise(True)
|
|
47
|
+
self.delete_button.clicked.connect(self.delete_requested.emit)
|
|
48
|
+
layout.addWidget(self.delete_button)
|
|
49
|
+
|
|
50
|
+
def set_maximized(self, maximized: bool) -> None:
|
|
51
|
+
self._maximized = maximized
|
|
52
|
+
icons.set_button_icon(self.maximize_button, "restore" if maximized else "maximize")
|
|
53
|
+
self.maximize_button.setToolTip("Restore" if maximized else "Maximize")
|
statstudio/ui/workers.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from PySide6.QtCore import QEventLoop
|
|
7
|
+
from PySide6.QtWidgets import QWidget
|
|
8
|
+
|
|
9
|
+
from statstudio.ui.jobs import FunctionJob
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def run_with_progress(
|
|
13
|
+
parent: QWidget | None,
|
|
14
|
+
title: str,
|
|
15
|
+
function: Callable[[Callable[[], bool]], Any],
|
|
16
|
+
) -> tuple[bool, Any, str]:
|
|
17
|
+
"""Compatibility helper for CLI/tests; GUI actions should use jobs.start_job."""
|
|
18
|
+
from PySide6.QtWidgets import QProgressDialog
|
|
19
|
+
|
|
20
|
+
job = FunctionJob(lambda token, _progress: function(token.is_cancelled))
|
|
21
|
+
progress = QProgressDialog(title, "Cancel", 0, 0, parent)
|
|
22
|
+
progress.setWindowTitle(title)
|
|
23
|
+
progress.setMinimumDuration(0)
|
|
24
|
+
progress.setAutoClose(False)
|
|
25
|
+
progress.setAutoReset(False)
|
|
26
|
+
state: dict[str, Any] = {"result": None, "error": "", "cancelled": False}
|
|
27
|
+
loop = QEventLoop()
|
|
28
|
+
|
|
29
|
+
def completed(result) -> None:
|
|
30
|
+
state["result"] = result
|
|
31
|
+
loop.quit()
|
|
32
|
+
|
|
33
|
+
def failed(message: str, _details: str) -> None:
|
|
34
|
+
state["error"] = message
|
|
35
|
+
loop.quit()
|
|
36
|
+
|
|
37
|
+
def cancelled() -> None:
|
|
38
|
+
state["cancelled"] = True
|
|
39
|
+
loop.quit()
|
|
40
|
+
|
|
41
|
+
job.result_ready.connect(completed)
|
|
42
|
+
job.failed.connect(failed)
|
|
43
|
+
job.cancelled.connect(cancelled)
|
|
44
|
+
progress.canceled.connect(job.cancel)
|
|
45
|
+
job.start()
|
|
46
|
+
progress.show()
|
|
47
|
+
loop.exec()
|
|
48
|
+
progress.close()
|
|
49
|
+
if state["error"]:
|
|
50
|
+
return False, None, str(state["error"])
|
|
51
|
+
if state["cancelled"]:
|
|
52
|
+
return False, None, ""
|
|
53
|
+
return True, state["result"], ""
|