jbqt 0.1.7__tar.gz → 0.1.9__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.

Potentially problematic release.


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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jbqt
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary:
5
5
  Author: Joseph Bochinski
6
6
  Author-email: stirgejr@gmail.com
@@ -1,12 +1,15 @@
1
1
  import os
2
2
  import re
3
3
 
4
+
4
5
  import jbutils
5
6
 
6
7
  from PyQt6.QtWidgets import QApplication, QMainWindow, QScrollArea, QWidget
7
8
  from PyQt6.QtCore import Qt, QSize
8
9
  from PyQt6.QtGui import QIcon, QPixmap, QPainter, QColor
9
10
 
11
+ from jbqt.types import IconGetter
12
+
10
13
  TAG_RE = re.compile(r"^\((.+)\)(\d+\.\d+)$")
11
14
  LIST_ITEM_ROLE = Qt.ItemDataRole.UserRole - 1
12
15
 
@@ -15,16 +18,16 @@ COLORS = jbutils.COLORS
15
18
 
16
19
 
17
20
  class GlobalRefs:
18
- app: QApplication = None
19
- main_window: QMainWindow = None
20
- scroll_area: QScrollArea = None
21
+ app: QApplication | None = None
22
+ main_window: QMainWindow | None = None
23
+ scroll_area: QScrollArea | None = None
21
24
  server_active: bool = False
22
25
  debug_set: bool = False
23
- seed_widget: QWidget = None
26
+ seed_widget: QWidget | None = None
24
27
 
25
28
 
26
29
  class QtPaths:
27
- icon_dir: str = None
30
+ icon_dir: str | None = None
28
31
 
29
32
 
30
33
  THEME_ICONS: dict[str, QIcon] = {
@@ -91,14 +94,14 @@ def icon_dir(file_name: str) -> str:
91
94
 
92
95
 
93
96
  def recolor_icon(
94
- image_path: str, color: str | QColor, scale: QSize = None
97
+ image_path: str, color: str | QColor, scale: QSize | None = None
95
98
  ) -> QIcon:
96
99
  if not color:
97
100
  color = QColor("black")
98
101
  if isinstance(color, str):
99
102
  color = QColor(color)
100
103
 
101
- if not scale:
104
+ if scale is None:
102
105
  scale = SIZES.ICON_MD
103
106
  pixmap = QPixmap(image_path)
104
107
  icon_key = os.path.splitext(os.path.basename(image_path))[0]
@@ -127,12 +130,11 @@ def recolor_icon(
127
130
  return QIcon(recolored_pixmap.scaled(scale, Qt.AspectRatioMode.KeepAspectRatio))
128
131
 
129
132
 
130
- def get_icon(file_name: str) -> QIcon:
131
- def getter(color: str = "", size: QSize | int = None):
133
+ def get_icon(file_name: str) -> IconGetter:
134
+ def getter(color: str | QColor = "", size: QSize | int | None = None) -> QIcon:
132
135
  if isinstance(size, int):
133
136
  size = QSize(size, size)
134
137
 
135
- # return QIcon(QPixmap(_icon_dir(file_name)))
136
138
  return recolor_icon(icon_dir(file_name), color, size)
137
139
 
138
140
  return getter
@@ -160,7 +162,7 @@ class ICONS:
160
162
  SYNC = get_icon("sync.png")
161
163
 
162
164
  @classmethod
163
- def get(cls, name: str, default: str = "") -> QIcon | str:
165
+ def get(cls, name: str, default: str = "") -> IconGetter | str:
164
166
  if hasattr(cls, name):
165
167
  return getattr(cls, name)
166
168
  else:
@@ -0,0 +1,8 @@
1
+ from collections.abc import Callable
2
+ from typing import Optional
3
+
4
+ from PyQt6.QtCore import QSize
5
+ from PyQt6.QtGui import QIcon
6
+
7
+
8
+ IconGetter = Callable[[str, QSize | int | None], QIcon]
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "jbqt"
7
- version = "0.1.7"
7
+ version = "0.1.9"
8
8
  description = ""
9
9
  authors = [ "Joseph Bochinski <stirgejr@gmail.com>",]
10
10
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes