@@ -48,7 +48,7 @@ def setStatus(self, s: FilamentStates):
4848 self .status = s
4949 self .update ()
5050
51- def setSlotId (self , s : str ):
51+ def setGateId (self , s : str ):
5252 self .slot_id = s
5353 self .update ()
5454
@@ -58,54 +58,51 @@ def paintEvent(self, e: QtGui.QPaintEvent | None) -> None:
5858 painter .setRenderHint (painter .RenderHint .SmoothPixmapTransform )
5959 painter .setRenderHint (painter .RenderHint .LosslessImageRendering )
6060
61- # # Selected: draw a colored border
62- # if self.isChecked():
63- # border_pen = QtGui.QPen(QtGui.QColor(255, 255, 255))
64- # border_pen.setWidth(2)
65- # painter.setPen(border_pen)
66-
67- # Gradient background
68- gradient = QtGui .QLinearGradient (
69- QtCore .QPointF (self .rect ().bottomLeft ()),
70- QtCore .QPointF (self .rect ().topLeft ()),
71- )
7261
62+ color = QtGui .QColor (self .color )
7363 white = QtGui .QColor (255 , 255 , 255 )
74- color1 = QtGui .QColor (white )
75- color1 .setAlpha (165 )
76- color2 = QtGui .QColor (white )
77- color2 .setAlpha (165 )
78- color3 = QtGui .QColor (white )
79- color3 .setAlpha (0 )
80-
81- gradient .setColorAt (0.0 , color1 )
82- gradient .setColorAt (0.1 , color2 )
83- gradient .setColorAt (0.11 , color3 )
84- painter .setBrush (gradient )
85- painter .drawRect (self .rect ())
86-
87- color1 = QtGui .QColor (self .color )
88- color1 .setAlpha (255 )
89- color2 = QtGui .QColor (self .color )
90- color2 .setAlpha (255 )
91- color3 = QtGui .QColor (self .color )
92- color3 .setAlpha (0 )
93-
94- gradient .setColorAt (0.0 , color1 )
95- gradient .setColorAt (0.1 , color2 )
96- gradient .setColorAt (0.11 , color3 )
97- painter .setBrush (gradient )
98- painter .drawRect (self .rect ().adjusted (1 , 1 , - 1 , - 1 ))
99-
100- gradient2 = QtGui .QLinearGradient (
101- QtCore .QPointF (self .rect ().bottomLeft ()),
102- QtCore .QPointF (self .rect ().topLeft ()),
64+
65+
66+ pen = QtGui .QPen (white )
67+ pen .setWidth (2 )
68+ painter .setPen (pen )
69+
70+ font = painter .font ()
71+ font .setPointSize (12 )
72+ font .setBold (True )
73+ painter .setFont (font )
74+
75+ _text_rect = self .rect ()
76+ _text_rect .setTop (int (self .rect ().height () / 9 ))
77+
78+ _text_rect .setBottom (int (self .rect ().height () / 4 ))
79+
80+ _text_rect .setLeft (int (self .rect ().width () - self .rect ().width () * 1.6 ))
81+ _text_rect .setRight (int (self .rect ().width ()))
82+
83+ painter .drawText (
84+ _text_rect ,
85+ QtCore .Qt .TextFlag .TextShowMnemonic | QtCore .Qt .AlignmentFlag .AlignCenter ,
86+ str (self .slot_id ),
10387 )
10488
105- gradient2 .setColorAt (0.0 , color1 )
106- color2 = QtGui .QColor (QtGui .QColor (255 , 255 , 255 ))
107- color2 .setAlpha (255 )
108- gradient2 .setColorAt (1 , color2 )
89+
90+ if not self .isChecked ():
91+ white .setAlpha (130 )
92+ color .setAlpha (130 )
93+
94+
95+ rect = self .rect ().adjusted (1 , 1 , - 1 , - 1 )
96+ rect .setY (int (rect .height ()- rect .height () * 0.15 ))
97+ painter .fillRect (rect , color )
98+
99+
100+ pen = QtGui .QPen (white )
101+ pen .setWidth (2 )
102+ painter .setPen (pen )
103+ rect = self .rect ().adjusted (1 , 1 , - 1 , - 1 )
104+ rect .setY (int (rect .height ()- rect .height () * 0.15 ))
105+ painter .drawRect (rect )
109106
110107 # Draw icon centered
111108 icon_size = 80
@@ -123,41 +120,14 @@ def paintEvent(self, e: QtGui.QPaintEvent | None) -> None:
123120 p2 = QtGui .QPainter (tinted )
124121 p2 .drawPixmap (0 , 0 , scaled )
125122 p2 .setCompositionMode (QtGui .QPainter .CompositionMode .CompositionMode_SourceIn )
126- p2 .fillRect (tinted .rect (), gradient2 )
123+ p2 .fillRect (tinted .rect (), white )
127124 p2 .end ()
128125 painter .drawPixmap (x , y , tinted )
129126
130127 tinted = QtGui .QPixmap (scaled .size ())
131128 tinted .fill (QtCore .Qt .GlobalColor .transparent )
132129
133- p2 = QtGui .QPainter (tinted )
134- p2 .setCompositionMode (QtGui .QPainter .CompositionMode .CompositionMode_SourceIn )
135- p2 .fillRect (
136- tinted .rect (),
137- QtGui .QColor (255 , 255 , 255 ) if self .isChecked () else QtGui .QColor (0 , 0 , 0 ),
138- )
139- p2 .drawPixmap (x , y , scaled )
140-
141- font = painter .font ()
142- font .setPointSize (12 )
143- font .setBold (True )
144- painter .setFont (font )
145-
146- _text_rect = self .rect ()
147- _text_rect .setTop (int (self .rect ().height () / 9 ))
148-
149- _text_rect .setBottom (int (self .rect ().height () / 4 ))
150-
151- _text_rect .setLeft (int (self .rect ().width () - self .rect ().width () * 1.6 ))
152- _text_rect .setRight (int (self .rect ().width ()))
153-
154- painter .drawText (
155- _text_rect ,
156- QtCore .Qt .TextFlag .TextShowMnemonic | QtCore .Qt .AlignmentFlag .AlignCenter ,
157- str (self .slot_id ),
158- )
159130 painter .setPen (QtCore .Qt .PenStyle .NoPen )
160- p2 .end ()
161131 painter .end ()
162132
163133
@@ -264,7 +234,7 @@ def addSpool(
264234 ):
265235 btn = Spoll_button ()
266236 btn .setColor (color )
267- btn .setSlotId (slot_id )
237+ btn .setGateId (slot_id )
268238 btn .setStatus (status )
269239 self .button_group .addButton (btn , len (self .buttons ))
270240 btn .clicked .connect (lambda checked , b = btn : self ._on_btn_clicked (b ))
@@ -577,14 +547,14 @@ def selectFirst(self):
577547 layout .setSpacing (16 )
578548
579549 spools = [
580- (QtGui .QColor (10 , 10 , 10 ), "S01 " , FilamentStates .LOADED ),
581- (QtGui .QColor (46 , 196 , 160 ), "S02 " , FilamentStates .LOADED ),
582- (QtGui .QColor (255 , 186 , 8 ), "S03 " , FilamentStates .UNLOADED ),
583- (QtGui .QColor (255 , 255 , 255 ), "S04 " , FilamentStates .UNLOADED ),
584- (QtGui .QColor (232 , 68 , 90 ), "S05 " , FilamentStates .LOADED ),
585- (QtGui .QColor (80 , 120 , 220 ), "S06 " , FilamentStates .UNKNOWN ),
586- (QtGui .QColor (180 , 80 , 220 ), "S07 " , FilamentStates .UNKNOWN ),
587- (QtGui .QColor (220 , 130 , 60 ), "S08 " , FilamentStates .LOADED ),
550+ (QtGui .QColor (10 , 10 , 10 ), "Gate 1 " , FilamentStates .LOADED ),
551+ (QtGui .QColor (46 , 196 , 160 ), "Gate 2 " , FilamentStates .LOADED ),
552+ (QtGui .QColor (255 , 186 , 8 ), "Gate 3 " , FilamentStates .UNLOADED ),
553+ (QtGui .QColor (255 , 255 , 255 ), "Gate 4 " , FilamentStates .UNLOADED ),
554+ (QtGui .QColor (232 , 68 , 90 ), "Gate 5 " , FilamentStates .LOADED ),
555+ (QtGui .QColor (80 , 120 , 220 ), "Gate 6 " , FilamentStates .UNKNOWN ),
556+ (QtGui .QColor (180 , 80 , 220 ), "Gate 7 " , FilamentStates .UNKNOWN ),
557+ (QtGui .QColor (220 , 130 , 60 ), "Gate 8 " , FilamentStates .LOADED ),
588558 ]
589559
590560 amu = AMUWidget (amu_id = 1 , parent = window )
0 commit comments