diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2007-07-19 23:48:55 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2007-07-19 23:48:55 +0000 |
| commit | c479beea7cc338380a38e29ae041c03b2c299ac1 (patch) | |
| tree | 54a2173395f0f15d27f54ed3e9cf5efa9fc136c9 /lib/python/Components | |
| parent | 4a8afa26612c40ba5c9c48d42e15abe8bcec2b98 (diff) | |
| download | enigma2-c479beea7cc338380a38e29ae041c03b2c299ac1.tar.gz enigma2-c479beea7cc338380a38e29ae041c03b2c299ac1.zip | |
add 'canvas' gui element where you can draw into a pixmap from python
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/Renderer/Canvas.py | 40 | ||||
| -rw-r--r-- | lib/python/Components/Renderer/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Components/Sources/CanvasSource.py | 20 | ||||
| -rw-r--r-- | lib/python/Components/Sources/Makefile.am | 2 |
4 files changed, 62 insertions, 2 deletions
diff --git a/lib/python/Components/Renderer/Canvas.py b/lib/python/Components/Renderer/Canvas.py new file mode 100644 index 00000000..01b05fb0 --- /dev/null +++ b/lib/python/Components/Renderer/Canvas.py @@ -0,0 +1,40 @@ +from Renderer import Renderer + +from enigma import eCanvas, eRect, gRGB + +class Canvas(Renderer): + GUI_WIDGET = eCanvas + + def __init__(self): + Renderer.__init__(self) + self.sequence = None + self.draw_count = 0 + + def pull_updates(self): + if self.instance is None: + return + + # do an incremental update + list = self.source.drawlist + if list is None: + return + + # if the lists sequence count changed, re-start from begin + if list[0] != self.sequence: + self.sequence = list[0] + self.draw_count = 0 + + self.draw(list[1][self.draw_count:]) + self.draw_count = len(list[1]) + + def draw(self, list): + for l in list: + print "drawing ..", l + self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5])) + + def changed(self, what): + self.pull_updates() + + def postWidgetCreate(self, instance): + self.sequence = None + self.pull_updates() diff --git a/lib/python/Components/Renderer/Makefile.am b/lib/python/Components/Renderer/Makefile.am index ba082d48..31439c7c 100644 --- a/lib/python/Components/Renderer/Makefile.am +++ b/lib/python/Components/Renderer/Makefile.am @@ -2,4 +2,4 @@ installdir = $(LIBDIR)/enigma2/python/Components/Renderer install_PYTHON = \ __init__.py Label.py Progress.py Listbox.py Renderer.py Pixmap.py \ - FixedLabel.py PositionGauge.py + FixedLabel.py PositionGauge.py Canvas.py diff --git a/lib/python/Components/Sources/CanvasSource.py b/lib/python/Components/Sources/CanvasSource.py new file mode 100644 index 00000000..4fd0e02a --- /dev/null +++ b/lib/python/Components/Sources/CanvasSource.py @@ -0,0 +1,20 @@ +from Source import Source + +class CanvasSource(Source): + def __init__(self): + Source.__init__(self) + self.sequence = 0 + self.clear() + + def clear(self): + self.sequence += 1 + self._drawlist = (self.sequence, [ ]) + + def get_drawlist(self): + return self._drawlist + + drawlist = property(get_drawlist) + + def fill(self, x, y, width, height, color): + self.drawlist[1].append( (1, x, y, width, height, color) ) + self.changed() diff --git a/lib/python/Components/Sources/Makefile.am b/lib/python/Components/Sources/Makefile.am index 6deb423d..2e0dd449 100644 --- a/lib/python/Components/Sources/Makefile.am +++ b/lib/python/Components/Sources/Makefile.am @@ -3,4 +3,4 @@ installdir = $(LIBDIR)/enigma2/python/Components/Sources install_PYTHON = \ __init__.py Clock.py EventInfo.py Source.py List.py CurrentService.py \ FrontendStatus.py Boolean.py Config.py ServiceList.py RdsDecoder.py StreamService.py \ - StaticText.py + StaticText.py CanvasSource.py |
