aboutsummaryrefslogtreecommitdiff
path: root/src/avp/toolkit/common.py
diff options
context:
space:
mode:
authorBrianna Rainey2026-01-28 17:49:58 -0500
committerGitHub2026-01-28 17:49:58 -0500
commitf66eb99465c61232a7f649e66bee59504bb0e52c (patch)
tree40d4f2e4e7cea033e4a68da025c7d91295e71cfb /src/avp/toolkit/common.py
parent864898419e810055b51e3a32fccb00a62aab9a6b (diff)
v2.2.1 - fix #74, fix #92, add optional 64th bar to Classic Visualizer, improve Conway default (#93)
* update gitignore ignore profiling and coverage data * F1 opens help window, create appName variable, move undostack class * fix kaleidoscope effect, increase default Y values by +4 the increased y values allow the cells to continue animating for more than 60 minutes instead of 30 (at default 60f/t) * update version number * add minimumWidth to undo history window * Classic Visualizer: option to include 64th bar * Waveform component: fix #74 - new animation speed option * move shared visualizer code into toolkit * Waveform component: compress audio by default * Waveform component: fix 100% animation speed * new components receive random color * update to Qt 6 * fix pushbutton stylesheet * fix #92: replace ok/cancel with save/discard/cancel * remove obsolete PaintColor subclass * mv common shadow code into addShadow func * add 3rd option of ok/cancel back to showMessage the 3 options are: - ok - ok/cancel - save/discard/cancel * Image component: add shadow option * small test of rgbFromString * fix color tuple string * test another way to get comp names from CLI * rename component tests, add some more * Image component: scale shadow based on resolution * catch AttributeError if previewRender returns None * Text component: fix blur radius only able to increase the relativeWidgets system causes QDoubleSpinbox to only allow increases, because it really only works with integeres, so I changed the blur radius into a normal QSpinBox. I noted where the problem exists within component.py for future reference. This commit also removes an unneeded VerticalLayout from the ui file * remove unnecessary QVBoxLayout * paste shadow at x,y instead of using offset method * fix tests due to shadow change * don't print warning in connectWidget due to QFontComboBox
Diffstat (limited to 'src/avp/toolkit/common.py')
-rw-r--r--src/avp/toolkit/common.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/avp/toolkit/common.py b/src/avp/toolkit/common.py
index e35aba2..a6195ed 100644
--- a/src/avp/toolkit/common.py
+++ b/src/avp/toolkit/common.py
@@ -4,7 +4,7 @@ Common functions
from PyQt6 import QtWidgets
import string
-import os
+import random
import sys
import subprocess
import logging
@@ -135,7 +135,12 @@ def rgbFromString(string):
if i > 255 or i < 0:
raise ValueError
return tup
- except:
+ except Exception as e:
+ log.warning(
+ "Could not parse '%s' as a color (encountered %s).",
+ string,
+ type(e).__name__,
+ )
return (255, 255, 255)
@@ -150,6 +155,7 @@ def formatTraceback(tb=None):
def connectWidget(widget, func):
+ unsupportedWidgets = ["QtWidgets.QFontComboBox"]
if type(widget) == QtWidgets.QLineEdit:
widget.textChanged.connect(func)
elif type(widget) == QtWidgets.QSpinBox or type(widget) == QtWidgets.QDoubleSpinBox:
@@ -158,6 +164,10 @@ def connectWidget(widget, func):
widget.stateChanged.connect(func)
elif type(widget) == QtWidgets.QComboBox:
widget.currentIndexChanged.connect(func)
+ elif type(widget) in unsupportedWidgets:
+ log.info(
+ "Could not connect %s using connectWidget()", str(widget.__class__.__name__)
+ )
else:
log.warning("Failed to connect %s ", str(widget.__class__.__name__))
return False
@@ -190,3 +200,7 @@ def getWidgetValue(widget):
return widget.isChecked()
elif type(widget) == QtWidgets.QComboBox:
return widget.currentIndex()
+
+
+def randomColor():
+ return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))