5
5
from PyQt5 .QtGui import (QColor , QCursor , QIcon , QImage , QPainter ,
6
6
QPen , QPixmap )
7
7
from PyQt5 .QtWidgets import (QAction , QApplication , QFileDialog ,
8
- QMainWindow , QPushButton ,)
8
+ QMainWindow , QPushButton , )
9
9
10
10
"""
11
11
Hover on QPaint detection
@@ -70,11 +70,11 @@ def setWindowCursor(cls, currentTool):
70
70
71
71
for obj in cls .objs :
72
72
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
+ )
78
78
79
79
80
80
class Tool :
@@ -132,6 +132,7 @@ def create_button(self):
132
132
133
133
class PalletteButton :
134
134
"""Class for color pallete; allows for mixing colors"""
135
+
135
136
def __init__ (self , parentBtn ):
136
137
self .parentBtn = parentBtn
137
138
self .r = randint (0 , 255 )
@@ -196,9 +197,9 @@ def mixColor(self, tool):
196
197
197
198
self .parentBtn .setStyleSheet (
198
199
"background-color: rgba{0}; border-radius:20px" .format (
199
- self .palletteColor
200
- )
200
+ self .palletteColor
201
201
)
202
+ )
202
203
203
204
204
205
class PaintBoard (QMainWindow ):
@@ -350,10 +351,8 @@ def colorBoxRun(self):
350
351
geo .moveLeft (geo .right ()) # moves window right
351
352
self .colorBox .setGeometry (geo )
352
353
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 ))
357
356
358
357
c1 = PalletteButton (p1 )
359
358
c2 = PalletteButton (p2 )
@@ -411,15 +410,15 @@ def colorBoxRun(self):
411
410
p9 .clicked .connect (lambda : c9 .mixColor (self .currentTool ))
412
411
self .colorBox .addPallette (p9 )
413
412
p10 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
414
- .format (c10 .palletteColor ))
413
+ .format (c10 .palletteColor ))
415
414
p10 .clicked .connect (lambda : c10 .mixColor (self .currentTool ))
416
415
self .colorBox .addPallette (p10 )
417
416
p11 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
418
- .format (c11 .palletteColor ))
417
+ .format (c11 .palletteColor ))
419
418
p11 .clicked .connect (lambda : c11 .mixColor (self .currentTool ))
420
419
self .colorBox .addPallette (p11 )
421
420
p12 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
422
- .format (c12 .palletteColor ))
421
+ .format (c12 .palletteColor ))
423
422
p12 .clicked .connect (lambda : c12 .mixColor (self .currentTool ))
424
423
self .colorBox .addPallette (p12 )
425
424
p13 .setStyleSheet ("background-color: rgba{0}; border-radius:20px"
@@ -483,7 +482,7 @@ def mouseMoveEvent(self, event):
483
482
self .mousePos = event .pos ()
484
483
if (event .buttons () and Qt .LeftButton ) and \
485
484
self .drawing and self .currentTool is not None :
486
-
485
+
487
486
Pen = QPen ()
488
487
if self .currentTool .toolName != "Sunbathing Eraser" :
489
488
if self .currentTool .duration <= 0.0 :
@@ -496,7 +495,8 @@ def mouseMoveEvent(self, event):
496
495
self .currentTool .opacityDuration -= 0.0125
497
496
# perhaps divide in class object
498
497
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
500
500
if self .currentTool .duration <= 0.2 :
501
501
dots = QPen ()
502
502
broken_tools = QPen ()
@@ -516,14 +516,19 @@ def mouseMoveEvent(self, event):
516
516
dots .setDashPattern ([25 , 50 , 25 , 50 ])
517
517
dots .setStyle (Qt .DashDotDotLine )
518
518
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 )))
521
525
522
526
if self .currentTool .toolName == "Pointy Pen" :
523
527
# QSound(SoundEffects['pen write']).play()
524
528
Pen .setCapStyle (Qt .RoundCap )
525
529
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' :
527
532
if self .currentTool .toolName == "Solid Brush" :
528
533
Pen .setCapStyle (Qt .RoundCap )
529
534
Pen .setJoinStyle (Qt .BevelJoin )
@@ -633,4 +638,4 @@ def run(self):
633
638
app .setStyleSheet ("QMainWindow{background-color:white}" )
634
639
myGUI = PaintBoard ()
635
640
636
- sys .exit (app .exec_ ())
641
+ sys .exit (app .exec_ ())
0 commit comments