jbqt 0.1.13__py3-none-any.whl → 0.1.15__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.

Potentially problematic release.


This version of jbqt might be problematic. Click here for more details.

jbqt/models/__init__.py CHANGED
@@ -2,5 +2,13 @@
2
2
 
3
3
  from jbqt.models.chips import IChipsWidget
4
4
  from jbqt.models.chip_button import IChipButton
5
+ from jbqt.models.model_consts import RegisteredFunctions
6
+ from jbqt.models.model_utils import get_fct, register_fct
5
7
 
6
- __all__ = ["IChipButton", "IChipsWidget"]
8
+ __all__ = [
9
+ "get_fct",
10
+ "IChipButton",
11
+ "IChipsWidget",
12
+ "register_fct",
13
+ "RegisteredFunctions",
14
+ ]
@@ -0,0 +1,9 @@
1
+ """Constant values local to the models package"""
2
+
3
+ from jbutils.types import Function
4
+
5
+
6
+ RegisteredFunctions: dict[str, Function] = {}
7
+
8
+
9
+ __all__ = ["RegisteredFunctions"]
@@ -0,0 +1,24 @@
1
+ """Collection of utility functions local to the models package"""
2
+
3
+ from jbutils.types import Function
4
+ from rich import print
5
+
6
+ from jbqt.models.model_consts import RegisteredFunctions
7
+
8
+
9
+ def register_fct(name: str, fct: Function, override: bool = False) -> None:
10
+ if name not in RegisteredFunctions:
11
+ RegisteredFunctions[name] = fct
12
+ if override and name in RegisteredFunctions:
13
+ # TODO improve logging
14
+ print(
15
+ f"[yellow][Warning][/yellow]: Function '{name}' already defined and was overwritten"
16
+ )
17
+ print(f"[yellow][Warning][/yellow]: Function '{name}' already defined")
18
+
19
+
20
+ def get_fct(name: str, fallback: Function | None = None) -> Function | None:
21
+ return RegisteredFunctions.get(name, fallback)
22
+
23
+
24
+ __all__ = ["register_fct", "get_fct"]
@@ -0,0 +1,58 @@
1
+ """Collection of models for PyQt6"""
2
+
3
+ from collections.abc import Callable
4
+ from dataclasses import dataclass
5
+
6
+ from PyQt6.QtCore import QSize, QObject
7
+ from PyQt6.QtGui import QIcon, QColor, QAction
8
+
9
+ from jbconsts import COLORS
10
+ from jbqt.consts import ICONS, QtIconSizes
11
+ from jbqt.models import model_utils
12
+
13
+
14
+ @dataclass
15
+ class ToolbarButton:
16
+ name: str = ""
17
+ icon: QIcon | str = ""
18
+ color: QColor | str = COLORS.BLUE_GRAY
19
+ checkable: bool = False
20
+ checked: bool = False
21
+ status_tip: str = ""
22
+ size: QSize | str = QtIconSizes.ICON_MD
23
+ function: Callable[..., None] | str | None = None
24
+ text: str = ""
25
+
26
+ def __post_init__(self) -> None:
27
+ if isinstance(self.function, str):
28
+ fct = model_utils.get_fct(self.function)
29
+ print("fct:", fct)
30
+ self.function = fct if fct else None
31
+
32
+ def to_action(self, parent: QObject | None = None) -> QAction:
33
+ color: QColor | str = self.color
34
+ if isinstance(color, str):
35
+ color = COLORS.get(color, color)
36
+
37
+ size = self.size
38
+ if isinstance(size, str):
39
+ size = QtIconSizes.get(size)
40
+
41
+ icon = self.icon
42
+ if isinstance(icon, str):
43
+ icon_getter = ICONS.get(icon)
44
+ if callable(icon_getter):
45
+ icon = icon_getter(color, size)
46
+
47
+ icon = QIcon() if isinstance(icon, str) else icon
48
+
49
+ action = QAction(icon=icon, text=self.text, parent=parent)
50
+ if self.checkable:
51
+ action.setCheckable(True)
52
+ action.setChecked(self.checkable)
53
+ if self.status_tip:
54
+ action.setStatusTip(self.status_tip)
55
+ if self.function:
56
+ action.triggered.connect(self.function)
57
+
58
+ return action
jbqt/view_icons.py CHANGED
@@ -45,8 +45,9 @@ args = parser.parse_args()
45
45
  THEMES_DIR = "/usr/share/icons"
46
46
 
47
47
 
48
+ # TODO: fix type checking
48
49
  class Toast(QLabel):
49
- def __init__(self, text: str, parent: QWidget = None, duration_ms: int = 1500):
50
+ def __init__(self, text: str, parent: QWidget = None, duration_ms: int = 1500): # type: ignore
50
51
  super().__init__(parent)
51
52
 
52
53
  self.setText(text)
@@ -97,8 +98,8 @@ class Window(QMainWindow):
97
98
  central_widget = QWidget()
98
99
  self.setCentralWidget(central_widget)
99
100
 
100
- self.layout = QVBoxLayout()
101
- central_widget.setLayout(self.layout)
101
+ self.layout = QVBoxLayout() # type: ignore
102
+ central_widget.setLayout(self.layout) # type: ignore
102
103
 
103
104
  self.search_bar = QLineEdit()
104
105
  self.search_bar.setPlaceholderText("Search icons...")
@@ -106,8 +107,8 @@ class Window(QMainWindow):
106
107
 
107
108
  self.table = QTableWidget()
108
109
  self.table.setColumnCount(4) # 4 columns of icons
109
- self.table.horizontalHeader().setVisible(False)
110
- self.table.verticalHeader().setVisible(False)
110
+ self.table.horizontalHeader().setVisible(False) # type: ignore
111
+ self.table.verticalHeader().setVisible(False) # type: ignore
111
112
  self.table.setIconSize(QSize(64, 64))
112
113
  self.table.setShowGrid(False)
113
114
  self.table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
@@ -122,8 +123,8 @@ class Window(QMainWindow):
122
123
  """
123
124
  )
124
125
 
125
- self.layout.addWidget(self.search_bar)
126
- self.layout.addWidget(self.table)
126
+ self.layout.addWidget(self.search_bar) # type: ignore
127
+ self.layout.addWidget(self.table) # type: ignore
127
128
 
128
129
  cur_theme = QIcon.themeName()
129
130
  self.icon_src = "standard"
@@ -154,7 +155,7 @@ class Window(QMainWindow):
154
155
  item = self.table.item(row, column)
155
156
  if item and item.text():
156
157
  text = f'"{item.text()}"' if args.add_quotes else item.text()
157
- QApplication.clipboard().setText(text)
158
+ QApplication.clipboard().setText(text) # type: ignore
158
159
  print(f"Copied '{item.text()}' to clipboard")
159
160
  Toast(f"Copied '{item.text()}'", parent=self).show()
160
161
 
@@ -191,7 +192,7 @@ class Window(QMainWindow):
191
192
  case _:
192
193
 
193
194
  pixmapi = getattr(QStyle.StandardPixmap, name)
194
- icon = self.style().standardIcon(pixmapi)
195
+ icon = self.style().standardIcon(pixmapi) # type: ignore
195
196
 
196
197
  item = QTableWidgetItem(name)
197
198
  item.setIcon(icon)
@@ -11,13 +11,14 @@ def debug_scroll_pos(func: Callable):
11
11
  if QtGlobalRefs.main_window:
12
12
  focus = QtGlobalRefs.main_window.focusWidget()
13
13
  print(f"scroll pos {func.__name__}")
14
- print("before", QtGlobalRefs.scroll_area.verticalScrollBar().value(), focus)
14
+ # TODO: fix type checking
15
+ print("before", QtGlobalRefs.scroll_area.verticalScrollBar().value(), focus) # type: ignore
15
16
  result = func(self, *args, **kwargs)
16
17
 
17
18
  if QtGlobalRefs.main_window:
18
19
  focus = QtGlobalRefs.main_window.focusWidget()
19
20
  print(
20
- f"after {QtGlobalRefs.scroll_area.verticalScrollBar().value()} {focus}\n"
21
+ f"after {QtGlobalRefs.scroll_area.verticalScrollBar().value()} {focus}\n" # type: ignore
21
22
  )
22
23
 
23
24
  return result
@@ -32,13 +33,14 @@ def debug_scroll_pos_no_args(func: Callable):
32
33
  focus = None
33
34
  if QtGlobalRefs.main_window:
34
35
  focus = QtGlobalRefs.main_window.focusWidget()
36
+ # TODO: fix type checking
35
37
  print(f"scroll pos {func.__name__}")
36
- print("before", QtGlobalRefs.scroll_area.verticalScrollBar().value(), focus)
38
+ print("before", QtGlobalRefs.scroll_area.verticalScrollBar().value(), focus) # type: ignore
37
39
  result = func(self)
38
40
  if QtGlobalRefs.main_window:
39
41
  focus = QtGlobalRefs.main_window.focusWidget()
40
42
  print(
41
- f"after {QtGlobalRefs.scroll_area.verticalScrollBar().value()} {focus}\n"
43
+ f"after {QtGlobalRefs.scroll_area.verticalScrollBar().value()} {focus}\n" # type: ignore
42
44
  )
43
45
 
44
46
  return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jbqt
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary:
5
5
  Author: Joseph Bochinski
6
6
  Author-email: stirgejr@gmail.com
@@ -12,6 +12,7 @@ Requires-Dist: jbconsts (>=0.1.1,<0.2.0)
12
12
  Requires-Dist: jbutils (>=0.1.23,<0.2.0)
13
13
  Requires-Dist: pyqt6 (>=6.9.0,<7.0.0)
14
14
  Requires-Dist: python-levenshtein (>=0.27.1,<0.28.0)
15
+ Requires-Dist: rich (>=14.0.0,<15.0.0)
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
 
@@ -6,18 +6,21 @@ jbqt/dialogs/__init__.py,sha256=DZi-qwW75JKfTLk33bowjt9Nhn1mpOO6kmP7mSMGz0o,245
6
6
  jbqt/dialogs/file_dialog.py,sha256=QMUxgSNt1IGLqgPgKqrEwlPjKIQ7D5qrY2cJCXmW654,1830
7
7
  jbqt/dialogs/input_form.py,sha256=pJVuP5fYc9USiwLmaSm66hrr-iW8XeZSY3eqxIUnVd0,2456
8
8
  jbqt/dialogs/text_preview.py,sha256=5rZjMvvMPq0jenPQkxKTFsGzuebdH_EnjKsdgNzv93o,1244
9
- jbqt/models/__init__.py,sha256=aQUYSr2bL9uRVdmEh_3s5pHbzM0MyKXEiO2Bqe16I8A,155
9
+ jbqt/models/__init__.py,sha256=MGQEAEoN6qi3N-lARWjsL3XeBxtPX6WICWgxSDwoC7E,343
10
10
  jbqt/models/chip_button.py,sha256=lG76aNgnrZcSw5QzAJ6UUHMbNNkDI-yZAp3iJlKr0Ms,220
11
11
  jbqt/models/chips.py,sha256=Qil50f1DcmYDHxiQgf0qs0kqERb-PTH37eOLHCuWA2o,625
12
+ jbqt/models/model_consts.py,sha256=84xPj4RNCGib7d4dBOOybzD3z0_uav37jrzqGfZkAQ8,170
13
+ jbqt/models/model_utils.py,sha256=Tf8QwJKHj3vpAkSTn-qP3XdihKnPqJvr5gq2c-8cCJM,809
14
+ jbqt/models/toolbar_button.py,sha256=5jQisgsFaQ7_b0D-bV9jiHDIMOO6-j_H8qgA2Qdn7NU,1736
12
15
  jbqt/types/__init__.py,sha256=er6dhNIqsfQr8mdpA2f7LIvX2CPmRG2Xyqj0cneitpg,407
13
- jbqt/view_icons.py,sha256=dwAAtDbqs3mwtmUxsjlFYdTsD2mi5m9BRmBQm6HpU9E,6389
16
+ jbqt/view_icons.py,sha256=Jy_o5dFSzKZGUX7oBq0sEi8jTrI5eI4COu5e4bWKT9o,6559
14
17
  jbqt/widgets/__init__.py,sha256=WxDWM5MDnB9NkvaYxE4AiT7tFjGB9fBirEx2iZUujeU,523
15
18
  jbqt/widgets/chip_button.py,sha256=mmh9EZfYY-d0hiQbGIZDvmi6RrBfKgGein_f_69gnCY,6362
16
19
  jbqt/widgets/chips.py,sha256=DH6Y1xr7vydq7dNOlETcXaOPy6rTu8IfrdUO8BAKjmg,8123
17
20
  jbqt/widgets/multiselect.py,sha256=ucL6QeFHs12DnHAHASMwdOD9YFYu4x4NDCYa6Pl41HM,7328
18
21
  jbqt/widgets/simple.py,sha256=pj2PBdR1am7VtPi4jGxsKm5nOLyTwiZV4jCuTd58rpk,1841
19
22
  jbqt/widgets/toast.py,sha256=S85PgcydbmICnjSY5VR6KUG_UZv4UERjvE_mP_zE9GA,1179
20
- jbqt/widgets/widget_utils.py,sha256=zJMFt1S3cp2TgSGiveNfjSQ3kNztcDnpWdn9JSXR4Sk,2393
21
- jbqt-0.1.13.dist-info/METADATA,sha256=ZWDjHOfz21ulC77YnFeMlGbZjDbZ3sxFdqoFOnbv9-E,505
22
- jbqt-0.1.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
23
- jbqt-0.1.13.dist-info/RECORD,,
23
+ jbqt/widgets/widget_utils.py,sha256=IEVg60rJ6hL0_9wre7j-_aprg-fccNZhwwOtbVEmHvw,2525
24
+ jbqt-0.1.15.dist-info/METADATA,sha256=dG2lwkAM1UGYNG1HntkDcL2-ZN00TtSYmGVh9b2Qi5M,544
25
+ jbqt-0.1.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
26
+ jbqt-0.1.15.dist-info/RECORD,,
File without changes