aboutsummaryrefslogtreecommitdiff
path: root/components/__base__.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/__base__.py')
-rw-r--r--components/__base__.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/components/__base__.py b/components/__base__.py
new file mode 100644
index 0000000..87440bb
--- /dev/null
+++ b/components/__base__.py
@@ -0,0 +1,57 @@
+from PyQt4 import QtGui
+
+class Component:
+ def __str__(self):
+ return self.__doc__
+
+ def preFrameRender(self, **kwargs):
+ for kwarg, value in kwargs.items():
+ exec('self.%s = value' % kwarg)
+
+ def pickColor(self):
+ color = QtGui.QColorDialog.getColor()
+ if color.isValid():
+ RGBstring = '%s,%s,%s' % (str(color.red()), str(color.green()), str(color.blue()))
+ btnStyle = "QPushButton { background-color : %s; outline: none; }" % color.name()
+ return RGBstring, btnStyle
+
+ def RGBFromString(self, string):
+ ''' turns an RGB string like "255, 255, 255" into a tuple '''
+ try:
+ tup = tuple([int(i) for i in string.split(',')])
+ if len(tup) != 3:
+ raise ValueError
+ for i in tup:
+ if i > 255 or i < 0:
+ raise ValueError
+ return tup
+ except:
+ return (255, 255, 255)
+
+ '''
+ ### Reference methods for creating a new component
+ ### (Inherit from this class and define these)
+
+ def widget(self, parent):
+ self.parent = parent
+ page = uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'example.ui'))
+ # connect widgets signals
+ self.page = page
+ return page
+
+ def update(self):
+ # read widget values
+ self.parent.drawPreview()
+
+ def previewRender(self, previewWorker):
+ width = int(previewWorker.core.settings.value('outputWidth'))
+ height = int(previewWorker.core.settings.value('outputHeight'))
+ image = Image.new("RGBA", (width, height), (0,0,0,0))
+ return image
+
+ def frameRender(self, moduleNo, frameNo):
+ width = int(self.worker.core.settings.value('outputWidth'))
+ height = int(self.worker.core.settings.value('outputHeight'))
+ image = Image.new("RGBA", (width, height), (0,0,0,0))
+ return image
+ '''