55from PyQt5 .QtGui import (QColor , QCursor , QIcon , QImage , QPainter ,
66 QPen , QPixmap )
77from PyQt5 .QtWidgets import (QAction , QApplication , QFileDialog ,
8- QMainWindow , QPushButton ,)
8+ QMainWindow , QPushButton , )
99
1010"""
1111Hover on QPaint detection
@@ -70,11 +70,11 @@ def setWindowCursor(cls, currentTool):
7070
7171 for obj in cls .objs :
7272 obj .setCursor (QCursor (QPixmap ("Design/icons/{}.png" .format (
73- currentTool .toolName
74- if currentTool else None )
75- )
76- )
77- )
73+ currentTool .toolName
74+ if currentTool else None )
75+ )
76+ )
77+ )
7878
7979
8080class Tool :
@@ -132,6 +132,7 @@ def create_button(self):
132132
133133class PalletteButton :
134134 """Class for color pallete; allows for mixing colors"""
135+
135136 def __init__ (self , parentBtn ):
136137 self .parentBtn = parentBtn
137138 self .r = randint (0 , 255 )
@@ -196,9 +197,9 @@ def mixColor(self, tool):
196197
197198 self .parentBtn .setStyleSheet (
198199 "background-color: rgba{0}; border-radius:20px" .format (
199- self .palletteColor
200- )
200+ self .palletteColor
201201 )
202+ )
202203
203204
204205class PaintBoard (QMainWindow ):
@@ -350,10 +351,8 @@ def colorBoxRun(self):
350351 geo .moveLeft (geo .right ()) # moves window right
351352 self .colorBox .setGeometry (geo )
352353
353- p1 , p2 , p3 , p4 , p5 ,\
354- p6 , p7 , p8 , p9 , p10 ,\
355- p11 , p12 , p13 , p14 ,\
356- p15 , p16 , p17 , p18 = (QPushButton () for _ in range (18 ))
354+ p1 , p2 , p3 , p4 , p5 , p6 , p7 , p8 , p9 , p10 , p11 , p12 , p13 , p14 , p15 , p16 ,\
355+ p17 , p18 = (QPushButton () for _ in range (18 ))
357356
358357 c1 = PalletteButton (p1 )
359358 c2 = PalletteButton (p2 )
@@ -411,15 +410,15 @@ def colorBoxRun(self):
411410 p9 .clicked .connect (lambda : c9 .mixColor (self .currentTool ))
412411 self .colorBox .addPallette (p9 )
413412 p10 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
414- .format (c10 .palletteColor ))
413+ .format (c10 .palletteColor ))
415414 p10 .clicked .connect (lambda : c10 .mixColor (self .currentTool ))
416415 self .colorBox .addPallette (p10 )
417416 p11 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
418- .format (c11 .palletteColor ))
417+ .format (c11 .palletteColor ))
419418 p11 .clicked .connect (lambda : c11 .mixColor (self .currentTool ))
420419 self .colorBox .addPallette (p11 )
421420 p12 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
422- .format (c12 .palletteColor ))
421+ .format (c12 .palletteColor ))
423422 p12 .clicked .connect (lambda : c12 .mixColor (self .currentTool ))
424423 self .colorBox .addPallette (p12 )
425424 p13 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
@@ -483,7 +482,7 @@ def mouseMoveEvent(self, event):
483482 self .mousePos = event .pos ()
484483 if (event .buttons () and Qt .LeftButton ) and \
485484 self .drawing and self .currentTool is not None :
486-
485+
487486 Pen = QPen ()
488487 if self .currentTool .toolName != "Sunbathing Eraser" :
489488 if self .currentTool .duration <= 0.0 :
@@ -496,7 +495,8 @@ def mouseMoveEvent(self, event):
496495 self .currentTool .opacityDuration -= 0.0125
497496 # perhaps divide in class object
498497
499- # this here is to add more realism to the point when its breaking
498+ # this here is to add more realism
499+ # to the point when its breaking
500500 if self .currentTool .duration <= 0.2 :
501501 dots = QPen ()
502502 broken_tools = QPen ()
@@ -516,14 +516,19 @@ def mouseMoveEvent(self, event):
516516 dots .setDashPattern ([25 , 50 , 25 , 50 ])
517517 dots .setStyle (Qt .DashDotDotLine )
518518 self .painter .setPen (dots )
519- self .painter .drawLine (self .lastPoint + QPoint (randint (10 , 15 ), randint (1 , 5 )),
520- self .lastPoint + QPoint (randint (5 , 10 ), randint (1 , 10 )))
519+ self .painter .drawLine (self .lastPoint +
520+ QPoint (randint (10 , 15 ),
521+ randint (1 , 5 )),
522+ self .lastPoint +
523+ QPoint (randint (5 , 10 ),
524+ randint (1 , 10 )))
521525
522526 if self .currentTool .toolName == "Pointy Pen" :
523527 # QSound(SoundEffects['pen write']).play()
524528 Pen .setCapStyle (Qt .RoundCap )
525529 Pen .setJoinStyle (Qt .MiterJoin )
526- elif self .currentTool .toolName == 'Straggly Paintbrush' or 'Solid Brush' :
530+ elif self .currentTool .toolName == \
531+ 'Straggly Paintbrush' or 'Solid Brush' :
527532 if self .currentTool .toolName == "Solid Brush" :
528533 Pen .setCapStyle (Qt .RoundCap )
529534 Pen .setJoinStyle (Qt .BevelJoin )
@@ -633,4 +638,4 @@ def run(self):
633638 app .setStyleSheet ("QMainWindow{background-color:white}" )
634639 myGUI = PaintBoard ()
635640
636- sys .exit (app .exec_ ())
641+ sys .exit (app .exec_ ())
0 commit comments