@@ -27,6 +27,7 @@ def __init__(self, parent=None):
2727 self .toolsX = 5
2828 self .toolsY = 0
2929 self .tools_holder = 1
30+ self .exists = True
3031 self .Setup ()
3132
3233 def Setup (self ):
@@ -48,16 +49,19 @@ def showColorBox(self):
4849 print ('Showing ToolBox' )
4950 self .show ()
5051
52+ def closeEvent (self , * args , ** kwargs ):
53+ self .exists = False
54+ print ("Closing color pallet window" )
55+
5156
5257class PalletteButton :
5358 def __init__ (self ):
5459 self .r = randint (0 , 255 )
5560 self .g = randint (0 , 255 )
5661 self .b = randint (0 , 255 )
57- self .t = 255 # no transparancy now
58- self .color = (self .r , self .g , self .b )
62+ self .t = 1.0 # no transparancy now, it goes from 0.0 to 1.0
63+ self .color = (self .r , self .g , self .b , self . t )
5964 # self.color = QColor(self.r, self.g, self.b, self.t)
60- print (self .color )
6165
6266 def mixColor (self , tool ):
6367 if tool .toolName in ["fill_empty" , "straggly_paintbrush" ,
@@ -245,8 +249,11 @@ def changePaintBoardVars(self, curToolName=None,
245249
246250 # TODO: make a variable self.currentTool
247251 # that'll hold the current selected tool, i fixed the class
252+ # TODO: check if window already exists if not make one
248253 def colorBoxRun (self ):
254+
249255 colorBox = ColorBox (self )
256+
250257 geo = self .geometry ()
251258 geo .moveLeft (geo .right ()) # moves window right
252259 colorBox .setGeometry (geo )
@@ -260,27 +267,27 @@ def colorBoxRun(self):
260267 c5 = PalletteButton ()
261268 c6 = PalletteButton ()
262269
263- p1 .setStyleSheet ("background-color: rgb {0}"
270+ p1 .setStyleSheet ("background-color: rgba {0}"
264271 .format (c1 .color ))
265272 p1 .clicked .connect (lambda : c1 .mixColor (self .currentTool ))
266273 colorBox .addPallette (p1 )
267- p2 .setStyleSheet ("background-color: rgb {0}"
274+ p2 .setStyleSheet ("background-color: rgba {0}"
268275 .format (c2 .color ))
269276 p2 .clicked .connect (lambda : c2 .mixColor (self .currentTool ))
270277 colorBox .addPallette (p2 )
271- p3 .setStyleSheet ("background-color: rgb {0}"
278+ p3 .setStyleSheet ("background-color: rgba {0}"
272279 .format (c3 .color ))
273280 p3 .clicked .connect (lambda : c3 .mixColor (self .currentTool ))
274281 colorBox .addPallette (p3 )
275- p4 .setStyleSheet ("background-color: rgb {0};"
282+ p4 .setStyleSheet ("background-color: rgba {0};"
276283 .format (c4 .color ))
277284 p4 .clicked .connect (lambda : c4 .mixColor (self .currentTool ))
278285 colorBox .addPallette (p4 )
279- p5 .setStyleSheet ("background-color: rgb {0}"
286+ p5 .setStyleSheet ("background-color: rgba {0}"
280287 .format (c5 .color ))
281288 p5 .clicked .connect (lambda : c5 .mixColor (self .currentTool ))
282289 colorBox .addPallette (p5 )
283- p6 .setStyleSheet ("background-color: rgb {0}"
290+ p6 .setStyleSheet ("background-color: rgba {0}"
284291 .format (c6 .color ))
285292 p6 .clicked .connect (lambda : c6 .mixColor (self .currentTool ))
286293 colorBox .addPallette (p6 )
0 commit comments