11import os
2- import numpy as np
32from typing import Optional
43
4+ import numpy as np
55from PyQt5 import uic
66from PyQt5 .QtCore import pyqtSignal
77from PyQt5 .QtWidgets import QWidget
@@ -27,26 +27,28 @@ def __init__(
2727 self ._name = name if name is not None else ""
2828 # Convert colour from RGB tuple or string to Qt-compatible hex string
2929 if colour is not None :
30- if (isinstance (colour , tuple ) or isinstance (colour , list ) or isinstance (colour , np .ndarray )) and len (colour ) == 3 :
30+ if (
31+ isinstance (colour , tuple )
32+ or isinstance (colour , list )
33+ or isinstance (colour , np .ndarray )
34+ ) and len (colour ) == 3 :
3135 # Convert (r, g, b) to "#RRGGBB"
3236 if all (isinstance (c , float ) and 0.0 <= c <= 1.0 for c in colour ):
3337 rgb = [int (c * 255 ) for c in colour ]
3438 else :
3539 rgb = [int (c ) for c in colour ]
36- self .colour = "#{:02x}{:02x}{:02x}" .format (* rgb )
40+ self .colour = "#{:02x}{:02x}{:02x}" .format (* rgb )
3741 else :
3842 self .colour = str (colour )
3943 else :
4044 self .colour = ""
4145 self .thickness = thickness # Optional thickness attribute
42- print ("color is" , self .colour )
4346 # Add delete button
4447 self .buttonDelete .clicked .connect (self .request_delete )
4548 self .lineEditName .editingFinished .connect (self .onNameChanged )
4649 self .spinBoxThickness .valueChanged .connect (self .onThicknessChanged )
4750 self .setStyleSheet (f"background-color: { self .colour } ;" if self .colour else "" )
4851
49- print (self .styleSheet ())
5052 @property
5153 def name (self ):
5254 return str (self ._name )
@@ -74,7 +76,6 @@ def onColourSelectClicked(self):
7476 color = QColorDialog .getColor ()
7577 if color .isValid ():
7678 self .colour = color .name ()
77- print ("Selected colour:" , self .colour )
7879 self .setStyleSheet (f"background-color: { self .colour } ;" )
7980 self .colourChanged .emit (self .colour )
8081
0 commit comments