aboutsummaryrefslogtreecommitdiff
path: root/src/components/color.py
diff options
context:
space:
mode:
authortassaron2017-08-01 17:57:39 -0400
committertassaron2017-08-01 17:57:39 -0400
commit3c1b52205f183e9a2c943c5f666ed2c01db3aaf5 (patch)
tree0b92d6d2a1a21b87bd9f2f19181da15c09a1408b /src/components/color.py
parenta472246dab69d0676c3c78ecd61659e432c960b4 (diff)
component class now tracks colorwidgets
so adding new color-selection widgets is now simple
Diffstat (limited to 'src/components/color.py')
-rw-r--r--src/components/color.py58
1 files changed, 8 insertions, 50 deletions
diff --git a/src/components/color.py b/src/components/color.py
index 2abd79a..d6fffc6 100644
--- a/src/components/color.py
+++ b/src/components/color.py
@@ -6,7 +6,6 @@ import os
from component import Component
from toolkit.frame import BlankFrame, FloodFrame, FramePainter, PaintColor
-from toolkit import rgbFromString, pickColor
class Component(Component):
@@ -14,25 +13,12 @@ class Component(Component):
version = '1.0.0'
def widget(self, *args):
- self.color1 = (0, 0, 0)
- self.color2 = (133, 133, 133)
self.x = 0
self.y = 0
super().widget(*args)
- self.page.lineEdit_color1.setText('%s,%s,%s' % self.color1)
- self.page.lineEdit_color2.setText('%s,%s,%s' % self.color2)
-
- btnStyle1 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color1).name()
-
- btnStyle2 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*self.color2).name()
-
- self.page.pushButton_color1.setStyleSheet(btnStyle1)
- self.page.pushButton_color2.setStyleSheet(btnStyle2)
- self.page.pushButton_color1.clicked.connect(lambda: self.pickColor(1))
- self.page.pushButton_color2.clicked.connect(lambda: self.pickColor(2))
+ self.page.lineEdit_color1.setText('0,0,0')
+ self.page.lineEdit_color2.setText('133,133,133')
# disable color #2 until non-default 'fill' option gets changed
self.page.lineEdit_color2.setDisabled(True)
@@ -66,16 +52,18 @@ class Component(Component):
'LG_end': self.page.spinBox_linearGradient_end,
'RG_centre': self.page.spinBox_radialGradient_spread,
'fillType': self.page.comboBox_fill,
+ 'color1': self.page.lineEdit_color1,
+ 'color2': self.page.lineEdit_color2,
}, presetNames={
'sizeWidth': 'width',
'sizeHeight': 'height',
- }
+ }, colorWidgets={
+ 'color1': self.page.pushButton_color1,
+ 'color2': self.page.pushButton_color2,
+ },
)
def update(self):
- self.color1 = rgbFromString(self.page.lineEdit_color1.text())
- self.color2 = rgbFromString(self.page.lineEdit_color2.text())
-
fillType = self.page.comboBox_fill.currentIndex()
if fillType == 0:
self.page.lineEdit_color2.setEnabled(False)
@@ -161,36 +149,6 @@ class Component(Component):
return image.finalize()
- def loadPreset(self, pr, *args):
- super().loadPreset(pr, *args)
-
- self.page.lineEdit_color1.setText('%s,%s,%s' % pr['color1'])
- self.page.lineEdit_color2.setText('%s,%s,%s' % pr['color2'])
-
- btnStyle1 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*pr['color1']).name()
- btnStyle2 = "QPushButton { background-color : %s; outline: none; }" \
- % QColor(*pr['color2']).name()
- self.page.pushButton_color1.setStyleSheet(btnStyle1)
- self.page.pushButton_color2.setStyleSheet(btnStyle2)
-
- def savePreset(self):
- saveValueStore = super().savePreset()
- saveValueStore['color1'] = self.color1
- saveValueStore['color2'] = self.color2
- return saveValueStore
-
- def pickColor(self, num):
- RGBstring, btnStyle = pickColor()
- if not RGBstring:
- return
- if num == 1:
- self.page.lineEdit_color1.setText(RGBstring)
- self.page.pushButton_color1.setStyleSheet(btnStyle)
- else:
- self.page.lineEdit_color2.setText(RGBstring)
- self.page.pushButton_color2.setStyleSheet(btnStyle)
-
def commandHelp(self):
print('Specify a color:\n color=255,255,255')