| 1 | #---------------------------------------------------------------------- |
| 2 | # Name: wx.lib.ticker_xrc |
| 3 | # Purpose: A XRC handler for wx.lib.ticker |
| 4 | # |
| 5 | # Author: Chris Mellon |
| 6 | # |
| 7 | # Created: 17-May-2005 |
| 8 | # RCS-ID: $Id$ |
| 9 | # Copyright: (c) 2005 by Chris Mellon |
| 10 | # Licence: wxWindows license |
| 11 | #---------------------------------------------------------------------- |
| 12 | |
| 13 | import wx |
| 14 | import wx.xrc as xrc |
| 15 | from wx.lib.ticker import Ticker |
| 16 | |
| 17 | class wxTickerXmlHandler(xrc.XmlResourceHandler): |
| 18 | def __init__(self): |
| 19 | xrc.XmlResourceHandler.__init__(self) |
| 20 | self.AddWindowStyles() |
| 21 | |
| 22 | def CanHandle(self, node): |
| 23 | return self.IsOfClass(node, "wxTicker") |
| 24 | |
| 25 | def DoCreateResource(self): |
| 26 | t = Ticker( |
| 27 | self.GetParentAsWindow(), |
| 28 | self.GetID(), |
| 29 | pos = self.GetPosition(), |
| 30 | size = self.GetSize(), |
| 31 | style=self.GetStyle() |
| 32 | ) |
| 33 | if self.HasParam("text"): |
| 34 | t.SetText(self.GetText("text")) |
| 35 | if self.HasParam("start"): |
| 36 | if self.GetBool("start"): |
| 37 | t.Start() |
| 38 | else: |
| 39 | t.Stop() |
| 40 | if self.HasParam("ppf"): |
| 41 | t.SetPPF(self.GetLong("ppf")) |
| 42 | if self.HasParam("fps"): |
| 43 | t.SetFPS(self.GetLong("fps")) |
| 44 | if self.HasParam("direction"): |
| 45 | t.SetDirection(self.GetText("direction")) |
| 46 | |
| 47 | self.SetupWindow(t) # handles font, bg/fg color |
| 48 | return t |
| 49 | |