Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit 2e12d0a

Browse files
author
Leterax
committed
less code lol
1 parent 05a90d5 commit 2e12d0a

File tree

1 file changed

+14
-94
lines changed

1 file changed

+14
-94
lines changed

project/ArtiQule.py

Lines changed: 14 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -351,100 +351,20 @@ def colorBoxRun(self):
351351
geo.moveLeft(geo.right()) # moves window right
352352
self.colorBox.setGeometry(geo)
353353

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))
356-
357-
c1 = PalletteButton(p1)
358-
c2 = PalletteButton(p2)
359-
c3 = PalletteButton(p3)
360-
c4 = PalletteButton(p4)
361-
c5 = PalletteButton(p5)
362-
c6 = PalletteButton(p6)
363-
c7 = PalletteButton(p7)
364-
c8 = PalletteButton(p8)
365-
c9 = PalletteButton(p9)
366-
c10 = PalletteButton(p10)
367-
c11 = PalletteButton(p11)
368-
c12 = PalletteButton(p12)
369-
c13 = PalletteButton(p13)
370-
c14 = PalletteButton(p14)
371-
c15 = PalletteButton(p15)
372-
c16 = PalletteButton(p16)
373-
c17 = PalletteButton(p17)
374-
c18 = PalletteButton(p18)
375-
376-
p1.setStyleSheet("background-color: rgba{0}; border-radius:20px"
377-
.format(c1.palletteColor))
378-
p1.clicked.connect(lambda: c1.mixColor(self.currentTool))
379-
self.colorBox.addPallette(p1)
380-
p2.setStyleSheet("background-color: rgba{0}; border-radius:20px"
381-
.format(c2.palletteColor))
382-
p2.clicked.connect(lambda: c2.mixColor(self.currentTool))
383-
self.colorBox.addPallette(p2)
384-
p3.setStyleSheet("background-color: rgba{0}; border-radius:20px"
385-
.format(c3.palletteColor))
386-
p3.clicked.connect(lambda: c3.mixColor(self.currentTool))
387-
self.colorBox.addPallette(p3)
388-
p4.setStyleSheet("background-color: rgba{0}; border-radius:20px;"
389-
.format(c4.palletteColor))
390-
p4.clicked.connect(lambda: c4.mixColor(self.currentTool))
391-
self.colorBox.addPallette(p4)
392-
p5.setStyleSheet("background-color: rgba{0}; border-radius:20px"
393-
.format(c5.palletteColor))
394-
p5.clicked.connect(lambda: c5.mixColor(self.currentTool))
395-
self.colorBox.addPallette(p5)
396-
p6.setStyleSheet("background-color: rgba{0}; border-radius:20px"
397-
.format(c6.palletteColor))
398-
p6.clicked.connect(lambda: c6.mixColor(self.currentTool))
399-
self.colorBox.addPallette(p6)
400-
p7.setStyleSheet("background-color: rgba{0}; border-radius:20px"
401-
.format(c7.palletteColor))
402-
p7.clicked.connect(lambda: c7.mixColor(self.currentTool))
403-
self.colorBox.addPallette(p7)
404-
p8.setStyleSheet("background-color: rgba{0}; border-radius:20px"
405-
.format(c8.palletteColor))
406-
p8.clicked.connect(lambda: c8.mixColor(self.currentTool))
407-
self.colorBox.addPallette(p8)
408-
p9.setStyleSheet("background-color: rgba{0}; border-radius:20px"
409-
.format(c9.palletteColor))
410-
p9.clicked.connect(lambda: c9.mixColor(self.currentTool))
411-
self.colorBox.addPallette(p9)
412-
p10.setStyleSheet("background-color: rgba{0}; border-radius:20px"
413-
.format(c10.palletteColor))
414-
p10.clicked.connect(lambda: c10.mixColor(self.currentTool))
415-
self.colorBox.addPallette(p10)
416-
p11.setStyleSheet("background-color: rgba{0}; border-radius:20px"
417-
.format(c11.palletteColor))
418-
p11.clicked.connect(lambda: c11.mixColor(self.currentTool))
419-
self.colorBox.addPallette(p11)
420-
p12.setStyleSheet("background-color: rgba{0}; border-radius:20px"
421-
.format(c12.palletteColor))
422-
p12.clicked.connect(lambda: c12.mixColor(self.currentTool))
423-
self.colorBox.addPallette(p12)
424-
p13.setStyleSheet("background-color: rgba{0}; border-radius:20px"
425-
.format(c13.palletteColor))
426-
p13.clicked.connect(lambda: c13.mixColor(self.currentTool))
427-
self.colorBox.addPallette(p13)
428-
p14.setStyleSheet("background-color: rgba{0}; border-radius:20px"
429-
.format(c14.palletteColor))
430-
p14.clicked.connect(lambda: c14.mixColor(self.currentTool))
431-
self.colorBox.addPallette(p14)
432-
p15.setStyleSheet("background-color: rgba{0}; border-radius:20px"
433-
.format(c15.palletteColor))
434-
p15.clicked.connect(lambda: c15.mixColor(self.currentTool))
435-
self.colorBox.addPallette(p15)
436-
p16.setStyleSheet("background-color: rgba{0}; border-radius:20px"
437-
.format(c16.palletteColor))
438-
p16.clicked.connect(lambda: c16.mixColor(self.currentTool))
439-
self.colorBox.addPallette(p16)
440-
p17.setStyleSheet("background-color: rgba{0}; border-radius:20px"
441-
.format(c17.palletteColor))
442-
p17.clicked.connect(lambda: c17.mixColor(self.currentTool))
443-
self.colorBox.addPallette(p17)
444-
p18.setStyleSheet("background-color: rgba{0}; border-radius:20px"
445-
.format(c18.palletteColor))
446-
p18.clicked.connect(lambda: c18.mixColor(self.currentTool))
447-
self.colorBox.addPallette(p18)
354+
number_of_buttons = 18
355+
PalletteButtons = {PalletteButton(button): button for button in[
356+
QPushButton() for _ in range(number_of_buttons)
357+
]
358+
}
359+
360+
style_sheet_str = "background-color: rgba{0}; border-radius:20px"
361+
362+
for button_index in range(number_of_buttons):
363+
c = list(PalletteButtons.keys())[button_index]
364+
p = PalletteButtons[list(PalletteButtons.keys())[button_index]]
365+
p.setStyleSheet(style_sheet_str.format(c.palletteColor))
366+
p.clicked.connect(lambda: c.mixColor(self.currentTool))
367+
self.colorBox.addPallette(p)
448368

449369
# showing toolBox
450370
self.colorBox.showColorBox()

0 commit comments

Comments
 (0)