ms-components 0.7.0__tar.gz → 0.7.2__tar.gz

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.
Files changed (150) hide show
  1. {ms_components-0.7.0 → ms_components-0.7.2}/PKG-INFO +1 -1
  2. ms_components-0.7.2/src/ms_components/icons.py +40 -0
  3. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_dockwidget/resources/icons/__init__.py +2 -0
  4. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/jobs.py +14 -0
  5. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/models.py +1 -0
  6. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/polling.py +1 -0
  7. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/resources.py +3 -9
  8. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/widget.py +5 -18
  9. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/action_header.py +3 -15
  10. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/cell_delegate.py +22 -15
  11. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/smart_table_view.py +30 -22
  12. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/table_config.py +5 -2
  13. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/table_interaction.py +4 -3
  14. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/table_model.py +19 -13
  15. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/theme.py +5 -2
  16. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/PKG-INFO +1 -1
  17. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/SOURCES.txt +1 -0
  18. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/scm_file_list.json +1 -0
  19. ms_components-0.7.2/src/ms_components.egg-info/scm_version.json +8 -0
  20. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_molsuite_monitor_widgets.py +15 -0
  21. ms_components-0.7.0/src/ms_components.egg-info/scm_version.json +0 -8
  22. {ms_components-0.7.0 → ms_components-0.7.2}/.github/workflows/docs.yml +0 -0
  23. {ms_components-0.7.0 → ms_components-0.7.2}/.github/workflows/publish.yml +0 -0
  24. {ms_components-0.7.0 → ms_components-0.7.2}/.gitignore +0 -0
  25. {ms_components-0.7.0 → ms_components-0.7.2}/LICENSE +0 -0
  26. {ms_components-0.7.0 → ms_components-0.7.2}/MANIFEST.in +0 -0
  27. {ms_components-0.7.0 → ms_components-0.7.2}/README.md +0 -0
  28. {ms_components-0.7.0 → ms_components-0.7.2}/examples/tutorial_demo.py +0 -0
  29. {ms_components-0.7.0 → ms_components-0.7.2}/examples/tutorial_demo.toml +0 -0
  30. {ms_components-0.7.0 → ms_components-0.7.2}/licenses/lucide-LICENSE.txt +0 -0
  31. {ms_components-0.7.0 → ms_components-0.7.2}/licenses/qt-themes-LICENSE.txt +0 -0
  32. {ms_components-0.7.0 → ms_components-0.7.2}/pyproject.toml +0 -0
  33. {ms_components-0.7.0 → ms_components-0.7.2}/setup.cfg +0 -0
  34. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/__init__.py +0 -0
  35. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/backdrop.py +0 -0
  36. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/base.qss +0 -0
  37. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/chips.py +0 -0
  38. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ketcher.py +0 -0
  39. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/labels.py +0 -0
  40. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/listview.py +0 -0
  41. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_dockwidget/__init__.py +0 -0
  42. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_dockwidget/resources/__init__.py +0 -0
  43. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_dockwidget/resources/icons/folder.svg +0 -0
  44. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_dockwidget/widget.py +0 -0
  45. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_executors.py +0 -0
  46. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/__init__.py +0 -0
  47. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/bridge.py +0 -0
  48. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/config.py +0 -0
  49. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/detail.py +0 -0
  50. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/formatting.py +0 -0
  51. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/icons/cpu.svg +0 -0
  52. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/icons/gpu.svg +0 -0
  53. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/icons/memory.svg +0 -0
  54. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/palette.py +0 -0
  55. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_monitor/widget.py +0 -0
  56. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/__init__.py +0 -0
  57. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/app.py +0 -0
  58. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/backend.py +0 -0
  59. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/browser.py +0 -0
  60. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/scratch.py +0 -0
  61. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_projects/widget.py +0 -0
  62. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/__init__.py +0 -0
  63. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/command_line.py +0 -0
  64. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/actions.svg +0 -0
  65. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/box.svg +0 -0
  66. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/center.svg +0 -0
  67. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/display.svg +0 -0
  68. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/export.svg +0 -0
  69. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/hide.svg +0 -0
  70. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/hydrogens-polar.svg +0 -0
  71. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/hydrogens.svg +0 -0
  72. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/menu.svg +0 -0
  73. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/orient.svg +0 -0
  74. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/presets.svg +0 -0
  75. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/rock.svg +0 -0
  76. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/save.svg +0 -0
  77. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/selection.svg +0 -0
  78. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/settings.svg +0 -0
  79. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/style.svg +0 -0
  80. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/icons/zoom.svg +0 -0
  81. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/plugins.py +0 -0
  82. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_pymol/scene.py +0 -0
  83. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_settings/__init__.py +0 -0
  84. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_settings/panel.py +0 -0
  85. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_stepper.py +0 -0
  86. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/__init__.py +0 -0
  87. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/column_panel.py +0 -0
  88. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/example_usage.py +0 -0
  89. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/filter_panel.py +0 -0
  90. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/columns.svg +0 -0
  91. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/export.svg +0 -0
  92. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/filter.svg +0 -0
  93. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/menu.svg +0 -0
  94. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/reload.svg +0 -0
  95. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/search.svg +0 -0
  96. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/settings.svg +0 -0
  97. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/sort-asc.svg +0 -0
  98. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/sort-desc.svg +0 -0
  99. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/icons/sort.svg +0 -0
  100. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/metric_filter_bar.py +0 -0
  101. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/pagination_control.py +0 -0
  102. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/query_builder.py +0 -0
  103. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/session_provider.py +0 -0
  104. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/sort_panel.py +0 -0
  105. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/test_external_filters.py +0 -0
  106. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_table/test_toolbar.py +0 -0
  107. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_tutorial/__init__.py +0 -0
  108. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_tutorial/bindings.py +0 -0
  109. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_tutorial/controller.py +0 -0
  110. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_tutorial/models.py +0 -0
  111. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/ms_tutorial/overlay.py +0 -0
  112. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/opengl.py +0 -0
  113. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/pagination.py +0 -0
  114. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/palettes.py +0 -0
  115. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/step_dialog.py +0 -0
  116. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/tool_panel.py +0 -0
  117. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components/wheel.py +0 -0
  118. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/dependency_links.txt +0 -0
  119. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/requires.txt +0 -0
  120. {ms_components-0.7.0 → ms_components-0.7.2}/src/ms_components.egg-info/top_level.txt +0 -0
  121. {ms_components-0.7.0 → ms_components-0.7.2}/tests/conftest.py +0 -0
  122. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_app_settings.py +0 -0
  123. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_chips.py +0 -0
  124. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_dock_window.py +0 -0
  125. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_executors_ui.py +0 -0
  126. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_ketcher.py +0 -0
  127. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_molsuite_monitor_bridge.py +0 -0
  128. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_monitor_config.py +0 -0
  129. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_ms_projects_widget.py +0 -0
  130. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_opengl.py +0 -0
  131. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_optional_integrations.py +0 -0
  132. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_progress_column.py +0 -0
  133. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_project_browser.py +0 -0
  134. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_pymol_command_line.py +0 -0
  135. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_pymol_grid.py +0 -0
  136. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_pymol_scene.py +0 -0
  137. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_pymol_toolbar.py +0 -0
  138. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_query_builder_keyset.py +0 -0
  139. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_shift_hscroll.py +0 -0
  140. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_split_button_style.py +0 -0
  141. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_step_dialog.py +0 -0
  142. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_table_autofill_lifecycle.py +0 -0
  143. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_table_interaction.py +0 -0
  144. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_table_toolbar.py +0 -0
  145. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_table_view_state.py +0 -0
  146. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_theme_contrast.py +0 -0
  147. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_theme_menu.py +0 -0
  148. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_tool_panel.py +0 -0
  149. {ms_components-0.7.0 → ms_components-0.7.2}/tests/test_tutorial.py +0 -0
  150. {ms_components-0.7.0 → ms_components-0.7.2}/zensical.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ms_components
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: PySide6 UI components for MolSuite: smart table, project browser, job monitor, PyMOL dock, steppers.
5
5
  Author: Mario S. Valdés-Tresanco, Mario E. Valdés-Tresanco
6
6
  License-Expression: MIT
@@ -0,0 +1,40 @@
1
+ """SVG icons recoloured (currentColor → a palette colour) and rendered once per (file, colour, size, dpr).
2
+
3
+ A theme change asks for a new colour, so it is a new key: nothing to invalidate.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from functools import lru_cache
9
+ from pathlib import Path
10
+
11
+ from PySide6.QtCore import QByteArray, QSize, Qt
12
+ from PySide6.QtGui import QIcon, QPainter, QPixmap
13
+ from PySide6.QtSvg import QSvgRenderer
14
+
15
+
16
+ # ponytail: unbounded in practice (icons x themes x sizes is a few hundred); maxsize caps a leak.
17
+ @lru_cache(maxsize=1024)
18
+ def svg_pixmap(path: str | Path, color_hex: str, width: int, height: int, dpr: float) -> QPixmap:
19
+ svg = Path(path).read_bytes().replace(b"currentColor", color_hex.encode())
20
+ pixmap = QPixmap(max(1, round(width * dpr)), max(1, round(height * dpr)))
21
+ pixmap.fill(Qt.GlobalColor.transparent)
22
+ with QPainter(pixmap) as painter:
23
+ QSvgRenderer(QByteArray(svg)).render(painter)
24
+ pixmap.setDevicePixelRatio(dpr)
25
+ return pixmap
26
+
27
+
28
+ @lru_cache(maxsize=1024)
29
+ def svg_icon(path: str | Path, color_hex: str, width: int, height: int, dpr: float) -> QIcon:
30
+ return QIcon(svg_pixmap(path, color_hex, width, height, dpr))
31
+
32
+
33
+ def widget_svg_icon(widget, path: str | Path, size: QSize | None = None) -> QIcon:
34
+ """`path` in the widget's button-text colour at its device pixel ratio (16 px by default)."""
35
+ size = size or QSize(16, 16)
36
+ return svg_icon(str(path), widget.palette().buttonText().color().name(), size.width(), size.height(),
37
+ max(1.0, widget.devicePixelRatioF()))
38
+
39
+
40
+ __all__ = ["svg_icon", "svg_pixmap", "widget_svg_icon"]
@@ -1,8 +1,10 @@
1
+ from functools import lru_cache
1
2
  from importlib.resources import files
2
3
 
3
4
  from PySide6.QtGui import QIcon
4
5
 
5
6
 
7
+ @lru_cache(maxsize=None)
6
8
  def icon(name: str) -> QIcon:
7
9
  return QIcon(str(files(__package__) / name))
8
10
 
@@ -5,6 +5,8 @@ apart) and the time left at the speed of the last minutes. Active jobs come firs
5
5
  """
6
6
  from __future__ import annotations
7
7
 
8
+ from dataclasses import replace
9
+
8
10
  from PySide6.QtCore import QEasingCurve, Property, QPropertyAnimation, QRectF, QSize, Qt, Signal
9
11
  from PySide6.QtGui import QBrush, QColor, QFont, QFontMetricsF, QLinearGradient, QPainter, QPalette, QPen
10
12
  from PySide6.QtWidgets import QAbstractItemView, QApplication, QListWidget, QListWidgetItem, QStyle, QStyledItemDelegate, QWidget
@@ -223,6 +225,17 @@ class _JobRow(QStyledItemDelegate):
223
225
  p.restore()
224
226
 
225
227
 
228
+ def _with_what_they_wait_for(jobs: list[JobMonitorState]) -> list[JobMonitorState]:
229
+ """A waiting job that came after listed jobs still going says it waits for them, by name."""
230
+ going = {job.job_id: job.title or job.name for job in jobs if not job.is_terminal}
231
+ said = []
232
+ for job in jobs:
233
+ names = [going[key] for key in job.after if key in going and key != job.job_id]
234
+ waits = job.status == "waiting" and names and not job.note
235
+ said.append(replace(job, note="waits for " + ", ".join(dict.fromkeys(names))) if waits else job)
236
+ return said
237
+
238
+
226
239
  class JobList(QListWidget):
227
240
  """The jobs, as polled, active first. `job_selected` says the job picked by the user."""
228
241
 
@@ -244,6 +257,7 @@ class JobList(QListWidget):
244
257
  def set_jobs(self, jobs: list[JobMonitorState]) -> None:
245
258
  """The rows follow `jobs`; the selected one stays selected while it is listed."""
246
259
  chosen = self.selected_job_id()
260
+ jobs = _with_what_they_wait_for(jobs)
247
261
  if [self.item(i).data(_ROLE).job_id for i in range(self.count())] != [job.job_id for job in jobs]:
248
262
  self.blockSignals(True)
249
263
  self.clear()
@@ -54,6 +54,7 @@ class JobMonitorState:
54
54
  note: str = "" # what its source says it is at, while it runs (a campaign: in the queue, how far there)
55
55
  canceling: bool = False # canceled, waiting for its other machine to stop it there
56
56
  steps: tuple = () # every step its source went through, (epoch seconds, line), quick ones too
57
+ after: tuple = () # the job_ids of the jobs it was submitted after: the list says which it waits for
57
58
  chunks_retried: int = 0
58
59
  peak_mem_mb: int = 0
59
60
  usage: dict = field(default_factory=dict) # what it used, kept once it ended: see ms_flow's JobSnapshot.usage
@@ -36,6 +36,7 @@ def job_state(job, now: float) -> JobMonitorState:
36
36
  note=getattr(job, "note", None) or "", # an older ms_flow does not say
37
37
  canceling=getattr(job, "canceling", False),
38
38
  steps=tuple(getattr(job, "steps", ())),
39
+ after=tuple(getattr(job, "after", None) or ()), # an older ms_flow does not say
39
40
  chunks_retried=job.chunks_retried,
40
41
  peak_mem_mb=job.peak_mem_mb,
41
42
  usage=getattr(job, "usage", None) or {}, # ms_flow < 0.8 does not keep it
@@ -24,12 +24,12 @@ from dataclasses import dataclass, field
24
24
 
25
25
  from pathlib import Path
26
26
 
27
- from PySide6.QtCore import QByteArray, QObject, QPointF, QRectF, Qt, Signal
27
+ from PySide6.QtCore import QObject, QPointF, QRectF, Qt, Signal
28
28
  from PySide6.QtGui import QColor, QPainter, QPainterPath, QPalette, QPen, QPixmap
29
- from PySide6.QtSvg import QSvgRenderer
30
29
  from PySide6.QtWidgets import (QFrame, QGridLayout, QHBoxLayout, QLabel, QScrollArea, QStackedWidget, QToolButton,
31
30
  QToolTip, QVBoxLayout, QWidget)
32
31
 
32
+ from ms_components.icons import svg_pixmap
33
33
  from ms_components.labels import ElidedLabel
34
34
  from ms_components.theme import color
35
35
 
@@ -517,13 +517,7 @@ class _Asked(QWidget):
517
517
 
518
518
 
519
519
  def _icon(name: str, color_hex: str, size: int, dpr: float) -> QPixmap:
520
- svg = (_ICONS / f"{name}.svg").read_bytes().replace(b"currentColor", color_hex.encode())
521
- pixmap = QPixmap(round(size * dpr), round(size * dpr))
522
- pixmap.fill(Qt.transparent)
523
- with QPainter(pixmap) as painter:
524
- QSvgRenderer(QByteArray(svg)).render(painter)
525
- pixmap.setDevicePixelRatio(dpr)
526
- return pixmap
520
+ return svg_pixmap(str(_ICONS / f"{name}.svg"), color_hex, size, size, dpr)
527
521
 
528
522
 
529
523
  def queue_asked(jobs) -> dict:
@@ -8,15 +8,15 @@ from dataclasses import dataclass, field, replace
8
8
  from pathlib import Path
9
9
  from typing import Any
10
10
 
11
+ from ms_components.icons import widget_svg_icon
11
12
  from ms_components.labels import ElidedLabel
12
13
  from ms_components.ms_dockwidget.widget import MSDockWidget
13
14
  from ms_components.opengl import pymol_context_error, pymol_surface_format
14
15
 
15
16
  os.environ.setdefault("QT_API", "pyside6")
16
17
 
17
- from PySide6.QtCore import QByteArray, QEvent, QSize, Qt, QTimer, Signal
18
- from PySide6.QtGui import QAction, QActionGroup, QGuiApplication, QIcon, QPainter, QPixmap
19
- from PySide6.QtSvg import QSvgRenderer
18
+ from PySide6.QtCore import QEvent, QSize, Qt, QTimer, Signal
19
+ from PySide6.QtGui import QAction, QActionGroup, QGuiApplication, QIcon
20
20
  from PySide6.QtWidgets import (
21
21
  QFileDialog,
22
22
  QFrame,
@@ -451,22 +451,9 @@ class PymolControlBar(QFrame):
451
451
  return action
452
452
 
453
453
  def _toolbar_icon(self, name: str) -> QIcon:
454
- svg = (_TOOLBAR_ICONS / name).read_bytes().replace(
455
- b"currentColor", self.palette().buttonText().color().name().encode()
456
- )
457
- dpr = max(1.0, self.devicePixelRatioF())
458
454
  toolbar = self.toolbar
459
- size = toolbar.iconSize() if toolbar is not None and isValid(toolbar) else QSize(16, 16)
460
- pixmap = QPixmap(
461
- max(1, round(size.width() * dpr)),
462
- max(1, round(size.height() * dpr)),
463
- )
464
- pixmap.setDevicePixelRatio(dpr)
465
- pixmap.fill(Qt.GlobalColor.transparent)
466
- painter = QPainter(pixmap)
467
- QSvgRenderer(QByteArray(svg)).render(painter)
468
- painter.end()
469
- return QIcon(pixmap)
455
+ return widget_svg_icon(self, _TOOLBAR_ICONS / name,
456
+ toolbar.iconSize() if toolbar is not None and isValid(toolbar) else None)
470
457
 
471
458
  def _refresh_toolbar_icons(self) -> None:
472
459
  for action, icon_name in tuple(self._toolbar_action_icons.items()):
@@ -8,19 +8,18 @@ Requires PySide6.QtSvg.
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
- from functools import lru_cache
12
11
  from pathlib import Path
13
12
  from typing import Any
14
13
 
15
- from PySide6.QtCore import QByteArray, QPoint, QRect, Qt, Signal
14
+ from PySide6.QtCore import QPoint, QRect, Qt, Signal
16
15
  from PySide6.QtGui import QDoubleValidator, QPainter, QPixmap
17
- from PySide6.QtSvg import QSvgRenderer
18
16
  from PySide6.QtWidgets import (
19
17
  QCheckBox, QComboBox, QFrame, QHBoxLayout,
20
18
  QHeaderView, QLabel, QLineEdit, QPushButton, QStyle, QStyleOptionHeader,
21
19
  QVBoxLayout, QWidget,
22
20
  )
23
21
 
22
+ from ..icons import svg_pixmap
24
23
  from .table_config import ColumnDef, ColumnKind, FilterOperator, FilterSpec, SortSpec, TableConfig
25
24
 
26
25
  _ICONS = Path(__file__).parent / "icons"
@@ -34,19 +33,8 @@ _ICON_FILES: dict[str, str] = {
34
33
  }
35
34
 
36
35
 
37
- @lru_cache(maxsize=128)
38
36
  def _svg_pixmap(name: str, color_hex: str, size: int, dpr: float) -> QPixmap:
39
- """SVG → QPixmap, recolored (currentColor → color_hex), cached."""
40
- svg = (_ICONS / _ICON_FILES[name]).read_bytes().replace(b"currentColor", color_hex.encode())
41
- renderer = QSvgRenderer(QByteArray(svg))
42
- actual = max(1, int(size * dpr))
43
- pixmap = QPixmap(actual, actual)
44
- pixmap.setDevicePixelRatio(dpr)
45
- pixmap.fill(Qt.GlobalColor.transparent)
46
- p = QPainter(pixmap)
47
- renderer.render(p)
48
- p.end()
49
- return pixmap
37
+ return svg_pixmap(str(_ICONS / _ICON_FILES[name]), color_hex, size, size, dpr)
50
38
 
51
39
 
52
40
  # ── ActionHeader ──────────────────────────────────────────────────────────────
@@ -56,6 +56,7 @@ Every factory receives `row_data: dict` with the full row
56
56
 
57
57
  from __future__ import annotations
58
58
 
59
+ from functools import lru_cache
59
60
  from typing import Any, Callable, Optional
60
61
 
61
62
  from PySide6.QtCore import QModelIndex, QPoint, QRect, QRectF, QSize, Qt
@@ -74,6 +75,26 @@ from .table_config import ColumnKind
74
75
  # Rendering helpers
75
76
  # ──────────────────────────────────────────────────────────────────────────────
76
77
 
78
+ # ponytail: keyed by the SVG bytes, so a paint_factory that builds the same SVG for every row renders
79
+ # it once; one that bakes per-row data into it fills the cache (maxsize) and gains nothing.
80
+ @lru_cache(maxsize=512)
81
+ def _svg_to_pixmap(svg_bytes: bytes, width: int, height: int) -> Optional[QPixmap]:
82
+ try:
83
+ from PySide6.QtSvg import QSvgRenderer
84
+ size = QSize(width, height)
85
+ renderer = QSvgRenderer(svg_bytes)
86
+ default_size = renderer.defaultSize()
87
+ render_size = default_size.scaled(size, Qt.KeepAspectRatio) if default_size.isValid() else size
88
+ pixmap = QPixmap(render_size)
89
+ pixmap.fill(Qt.transparent)
90
+ painter = QPainter(pixmap)
91
+ renderer.render(painter, QRectF(0, 0, render_size.width(), render_size.height()))
92
+ painter.end()
93
+ return pixmap
94
+ except Exception:
95
+ return None
96
+
97
+
77
98
  def _to_pixmap(source: Any, size: QSize) -> Optional[QPixmap]:
78
99
  """
79
100
  Convert several source types into a QPixmap ready to paint.
@@ -100,21 +121,7 @@ def _to_pixmap(source: Any, size: QSize) -> Optional[QPixmap]:
100
121
  )
101
122
 
102
123
  if isinstance(source, (bytes, str)):
103
- # Treat it as SVG
104
- try:
105
- from PySide6.QtSvg import QSvgRenderer
106
- svg_bytes = source.encode() if isinstance(source, str) else source
107
- renderer = QSvgRenderer(svg_bytes)
108
- default_size = renderer.defaultSize()
109
- render_size = default_size.scaled(size, Qt.KeepAspectRatio) if default_size.isValid() else size
110
- pixmap = QPixmap(render_size)
111
- pixmap.fill(Qt.transparent)
112
- painter = QPainter(pixmap)
113
- renderer.render(painter, QRectF(0, 0, render_size.width(), render_size.height()))
114
- painter.end()
115
- return pixmap
116
- except Exception:
117
- return None
124
+ return _svg_to_pixmap(source.encode() if isinstance(source, str) else source, size.width(), size.height())
118
125
 
119
126
  # QSvgRenderer, or any object with .render(QPainter)
120
127
  if hasattr(source, "render"):
@@ -47,17 +47,17 @@ from pathlib import Path
47
47
  from typing import Any, Optional
48
48
 
49
49
  from PySide6.QtCore import (
50
- QByteArray, QEvent, QItemSelectionModel, QObject, QRunnable, QSize,
50
+ QEvent, QItemSelectionModel, QObject, QRunnable, QSize,
51
51
  QSortFilterProxyModel, Qt, QThreadPool, QTimer, Signal,
52
52
  )
53
- from PySide6.QtGui import QAction, QIcon, QPainter, QPixmap
54
- from PySide6.QtSvg import QSvgRenderer
53
+ from PySide6.QtGui import QAction, QIcon
55
54
  from PySide6.QtWidgets import (
56
55
  QAbstractItemView, QApplication, QFileDialog, QHBoxLayout,
57
- QHeaderView, QLabel, QMenu, QPushButton, QSizePolicy, QFrame,
56
+ QHeaderView, QLabel, QMenu, QPushButton, QSizePolicy, QFrame, QStyle, QStyleOptionHeader,
58
57
  QTableView, QToolBar, QToolButton, QVBoxLayout, QWidget
59
58
  )
60
59
  from ..backdrop import Backdrop
60
+ from ..icons import widget_svg_icon
61
61
  from .action_header import ActionHeader, FilterPopup, SearchPopup
62
62
  from .cell_delegate import CellWidgetDelegate
63
63
  from .column_panel import ColumnConfigDialog
@@ -89,6 +89,25 @@ class _Query(QRunnable):
89
89
  self._delivery.done.emit(self._finish, result)
90
90
 
91
91
 
92
+ class _RowNumberHeader(QHeaderView):
93
+ """The vertical header: row numbers only, at a fixed row height.
94
+
95
+ QHeaderView.sizeHint() measures up to 200 sections, asking the model for five roles each:
96
+ ~1000 calls into Python per relayout, a third of the time a tool switch took. The widest
97
+ number is the last row's, so one section is measured instead.
98
+ """
99
+
100
+ def sizeHint(self) -> QSize:
101
+ model = self.model()
102
+ rows = model.rowCount() if model is not None else 0
103
+ option = QStyleOptionHeader()
104
+ self.initStyleOption(option)
105
+ option.orientation = Qt.Vertical
106
+ option.text = str(model.headerData(rows - 1, Qt.Vertical) or rows) if rows else "0"
107
+ hint = self.style().sizeFromContents(QStyle.CT_HeaderSection, option, QSize(), self)
108
+ return QSize(hint.width(), self.defaultSectionSize())
109
+
110
+
92
111
  class SmartTableView(QWidget):
93
112
  """
94
113
  Smart table with pagination, filtering, sorting and column configuration.
@@ -359,7 +378,10 @@ class SmartTableView(QWidget):
359
378
  if self._config.allow_column_reorder:
360
379
  self._header.setSectionsMovable(True)
361
380
 
362
- v_header = self._table.verticalHeader()
381
+ v_header = _RowNumberHeader(Qt.Vertical, self._table)
382
+ v_header.setSectionsClickable(True) # as QTableView's own: a click selects the row
383
+ v_header.setHighlightSections(True)
384
+ self._table.setVerticalHeader(v_header)
363
385
  if self._config.row_height:
364
386
  v_header.setDefaultSectionSize(self._config.row_height)
365
387
  v_header.setVisible(self._config.show_vertical_header)
@@ -979,23 +1001,9 @@ class SmartTableView(QWidget):
979
1001
  return action, button
980
1002
 
981
1003
  def _toolbar_icon(self, name: str) -> QIcon:
982
- """Render a currentColor SVG using the live palette."""
983
- icon_path = _TOOLBAR_ICONS / name
984
- svg = icon_path.read_bytes().replace(
985
- b"currentColor", self.palette().buttonText().color().name().encode()
986
- )
987
- dpr = max(1.0, self.devicePixelRatioF())
988
- logical_size = self._toolbar.iconSize() if self._toolbar is not None else QSize(16, 16)
989
- pixmap = QPixmap(
990
- max(1, round(logical_size.width() * dpr)),
991
- max(1, round(logical_size.height() * dpr)),
992
- )
993
- pixmap.setDevicePixelRatio(dpr)
994
- pixmap.fill(Qt.GlobalColor.transparent)
995
- painter = QPainter(pixmap)
996
- QSvgRenderer(QByteArray(svg)).render(painter)
997
- painter.end()
998
- return QIcon(pixmap)
1004
+ """A currentColor SVG in the live palette (rendered once per colour and size)."""
1005
+ return widget_svg_icon(self, _TOOLBAR_ICONS / name,
1006
+ self._toolbar.iconSize() if self._toolbar is not None else None)
999
1007
 
1000
1008
  def _refresh_toolbar_icons(self) -> None:
1001
1009
  for action, icon_name in self._builtin_action_icons.items():
@@ -176,8 +176,11 @@ class ColumnDef:
176
176
 
177
177
  @property
178
178
  def display_key(self) -> str:
179
- """Unique key used internally (dots replaced)."""
180
- return self.field.replace(".", "__")
179
+ """Unique key used internally (dots replaced). Asked per cell and role on every paint."""
180
+ cached = self.__dict__.get("_display_key")
181
+ if cached is None or cached[0] != self.field:
182
+ cached = self.__dict__["_display_key"] = (self.field, self.field.replace(".", "__"))
183
+ return cached[1]
181
184
 
182
185
  @property
183
186
  def is_joined(self) -> bool:
@@ -23,7 +23,8 @@ class TableInteraction(QObject):
23
23
  QApplication.instance().installEventFilter(self)
24
24
 
25
25
  def eventFilter(self, watched, event):
26
- if (event.type() == QEvent.Type.MouseButtonPress
26
+ kind = event.type() # read once: window-wide, this runs for every event in the app
27
+ if (kind == QEvent.Type.MouseButtonPress
27
28
  and event.button() == Qt.MouseButton.LeftButton
28
29
  and isinstance(watched, QWidget)):
29
30
  view = watched.parentWidget()
@@ -33,10 +34,10 @@ class TableInteraction(QObject):
33
34
  if index.isValid():
34
35
  self._pressed = (view, index, event.modifiers(), view.selectionModel().isSelected(index))
35
36
  self.pressed.emit(view, index, event.modifiers())
36
- elif event.type() == QEvent.Type.MouseButtonRelease and self._pressed is not None:
37
+ elif kind == QEvent.Type.MouseButtonRelease and self._pressed is not None:
37
38
  view, index, modifiers, was_selected = self._pressed
38
39
  self._pressed = None
39
40
  if (event.button() == Qt.MouseButton.LeftButton and watched is view.viewport()
40
41
  and was_selected and view.indexAt(event.position().toPoint()) == index):
41
42
  self.reselected.emit(view, index, modifiers)
42
- return super().eventFilter(watched, event)
43
+ return False # never touch a deleted `watched` (teardown re-enters filters; errors chain and balloon)
@@ -27,11 +27,21 @@ RAW_OBJECT_ROLE = Qt.UserRole + 1 # Original SQLModel object
27
27
  COLUMN_DEF_ROLE = Qt.UserRole + 2 # ColumnDef of the column
28
28
 
29
29
 
30
+ # Precomputed as ints: data()/flags() run per cell and role on every paint, and OR-ing Qt flag
31
+ # enums in Python costs more than the rest of the call.
32
+ _DEFAULT_ALIGN = int(Qt.AlignVCenter | Qt.AlignLeft)
30
33
  _ALIGN_MAP = {
31
- AlignHint.LEFT: Qt.AlignVCenter | Qt.AlignLeft,
32
- AlignHint.CENTER: Qt.AlignVCenter | Qt.AlignHCenter,
33
- AlignHint.RIGHT: Qt.AlignVCenter | Qt.AlignRight,
34
+ AlignHint.LEFT: _DEFAULT_ALIGN,
35
+ AlignHint.CENTER: int(Qt.AlignVCenter | Qt.AlignHCenter),
36
+ AlignHint.RIGHT: int(Qt.AlignVCenter | Qt.AlignRight),
34
37
  }
38
+ _BASE_FLAGS = Qt.ItemIsEnabled | Qt.ItemIsSelectable
39
+ _EDITABLE_FLAGS = _BASE_FLAGS | Qt.ItemIsEditable
40
+ # The roles data() answers; Qt asks for ~10 per cell, the rest return None before any work.
41
+ _DATA_ROLES = frozenset(int(r) for r in (
42
+ Qt.DisplayRole, Qt.EditRole, Qt.TextAlignmentRole, Qt.ToolTipRole, Qt.BackgroundRole,
43
+ RAW_OBJECT_ROLE, COLUMN_DEF_ROLE,
44
+ ))
35
45
 
36
46
 
37
47
  class SmartTableModel(QAbstractTableModel):
@@ -217,7 +227,7 @@ class SmartTableModel(QAbstractTableModel):
217
227
  index: QModelIndex,
218
228
  role: int = Qt.DisplayRole
219
229
  ) -> Any:
220
- if not index.isValid():
230
+ if int(role) not in _DATA_ROLES or not index.isValid():
221
231
  return None
222
232
 
223
233
  row_idx = index.row()
@@ -250,7 +260,7 @@ class SmartTableModel(QAbstractTableModel):
250
260
  return str(value)
251
261
 
252
262
  case Qt.TextAlignmentRole:
253
- return int(_ALIGN_MAP.get(col_def.align, Qt.AlignVCenter | Qt.AlignLeft))
263
+ return _ALIGN_MAP.get(col_def.align, _DEFAULT_ALIGN)
254
264
 
255
265
  case Qt.ToolTipRole:
256
266
  if col_def.tooltip is None:
@@ -288,19 +298,15 @@ class SmartTableModel(QAbstractTableModel):
288
298
  if not index.isValid() or self.get_row_data(index.row()) is None:
289
299
  return Qt.NoItemFlags
290
300
 
291
- base = Qt.ItemIsEnabled | Qt.ItemIsSelectable
292
-
293
301
  col_idx = index.column()
294
302
  if self._config.show_row_numbers:
295
303
  if col_idx == 0:
296
- return base
304
+ return _BASE_FLAGS
297
305
  col_idx -= 1
298
306
 
299
- if 0 <= col_idx < len(self._visible_cols):
300
- if self._visible_cols[col_idx].editable:
301
- base |= Qt.ItemIsEditable
302
-
303
- return base
307
+ if 0 <= col_idx < len(self._visible_cols) and self._visible_cols[col_idx].editable:
308
+ return _EDITABLE_FLAGS
309
+ return _BASE_FLAGS
304
310
 
305
311
  def setData(
306
312
  self,
@@ -269,10 +269,13 @@ class _EdgedFusion(QProxyStyle):
269
269
  def __init__(self):
270
270
  super().__init__("Fusion")
271
271
 
272
+ # Every table cell's background passes here: the enum lookups are done once, not per call.
273
+ _INDICATORS = frozenset((QStyle.PrimitiveElement.PE_IndicatorCheckBox,
274
+ QStyle.PrimitiveElement.PE_IndicatorRadioButton))
275
+
272
276
  def drawPrimitive(self, element, option, painter, widget=None):
273
277
  super().drawPrimitive(element, option, painter, widget)
274
- if element not in (QStyle.PrimitiveElement.PE_IndicatorCheckBox,
275
- QStyle.PrimitiveElement.PE_IndicatorRadioButton):
278
+ if element not in self._INDICATORS:
276
279
  return
277
280
  if not option.state & QStyle.StateFlag.State_Enabled:
278
281
  return # disabled keeps Fusion's faint edge: it should read as "off"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ms_components
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: PySide6 UI components for MolSuite: smart table, project browser, job monitor, PyMOL dock, steppers.
5
5
  Author: Mario S. Valdés-Tresanco, Mario E. Valdés-Tresanco
6
6
  License-Expression: MIT
@@ -14,6 +14,7 @@ src/ms_components/__init__.py
14
14
  src/ms_components/backdrop.py
15
15
  src/ms_components/base.qss
16
16
  src/ms_components/chips.py
17
+ src/ms_components/icons.py
17
18
  src/ms_components/ketcher.py
18
19
  src/ms_components/labels.py
19
20
  src/ms_components/listview.py
@@ -25,6 +25,7 @@
25
25
  "src/ms_components/backdrop.py",
26
26
  "src/ms_components/base.qss",
27
27
  "src/ms_components/chips.py",
28
+ "src/ms_components/icons.py",
28
29
  "src/ms_components/ketcher.py",
29
30
  "src/ms_components/labels.py",
30
31
  "src/ms_components/listview.py",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.7.2",
3
+ "distance": 0,
4
+ "node": "ga8b435d2af4c04c9df439a8da4702b8b66f920bc",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-16"
8
+ }
@@ -448,3 +448,18 @@ def test_a_titled_job_shows_its_title_and_keeps_its_name_in_the_tooltip():
448
448
  assert detail._name.text() == "Docking · gnina (CNN)" and detail._name.toolTip() == "amdock_docking_job"
449
449
  detail.set_job(_job(name="amdock_docking_job"))
450
450
  assert detail._name.text() == "amdock_docking_job" and detail._name.toolTip() == ""
451
+
452
+
453
+ def test_a_job_submitted_after_others_still_going_says_it_waits_for_them_by_name():
454
+ from ms_components.ms_monitor.jobs import counts_label
455
+
456
+ QApplication.instance() or QApplication([])
457
+ widget = MolSuiteMonitorWidget()
458
+ prep = _job(job_id="prep", name="prepare", title="Prepare receptors")
459
+ ended = _job(job_id="ended", name="import", status="completed")
460
+ dock = _job(job_id="dock", name="dock", status="waiting", chunks_done=0, chunks_failed=0, after=("prep", "ended", "gone"))
461
+ free = _job(job_id="free", name="score", status="waiting", chunks_done=0, chunks_failed=0, after=("ended",))
462
+ widget.update_snapshot(ProjectMonitorState(project_id="p", has_project=True, jobs=[prep, ended, dock, free]))
463
+ said = {job.job_id: counts_label(job) for job in widget._jobs_view.jobs()}
464
+ assert said["dock"].endswith("· waits for Prepare receptors")
465
+ assert "waits for" not in said["free"] # what it came after has ended: it waits for room, not for a job
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "0.7.0",
3
- "distance": 0,
4
- "node": "ga2431bfb6f30f9560a4f94696120ebe35eb2c354",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-11-14"
8
- }
File without changes
File without changes
File without changes
File without changes
File without changes