Package teamwork :: Package examples :: Package Thespian :: Module flash
[hide private]
[frames] | no frames]

Source Code for Module teamwork.examples.Thespian.flash

  1  
 
  2  """
 
  3  __version__ = "$Revision: 1.24 $"
 
  4  __date__ = "$Date: 2004/08/11 01:58:03 $"
 
  5  """ 
  6  
 
  7  import wx 
  8  import wx.animate 
  9  
 
 10  from PythonCard import event, graphic, widget 
 11  
 
 12  USE_GENERIC = wx.Platform == '__WXGTK__' 
 13  
 
 14  from wx.lib.flashwin import FlashWindow 
 15  
 
16 -class FlashSpec(widget.WidgetSpec):
17 - def __init__(self):
18 events = [] 19 attributes = { 20 'file' : { 'presence' : 'optional', 'default':'' }, 21 # KEA shouldn't there be a 'file' attribute here 22 # could call it 'image' to match background above 23 # but it is mandatory 24 #'bitmap' : { 'presence' : 'optional', 'default' : None }, 25 # KEA kill border for now, until variations of what is possible are worked out 26 # use ImageButton if you want images with transparent border 27 #'border' : { 'presence' : 'optional', 'default' : '3d', 'values' : [ '3d', 'transparent', 'none' ] }, 28 'size' : { 'presence' : 'optional', 'default' : [ -1, -1 ] }, 29 } 30 widget.WidgetSpec.__init__( self, 'Flash', 'Widget', events, attributes )
31 32
33 -class Flash(widget.Widget, FlashWindow):
34 """ 35 show flash. 36 """ 37 38 _spec = FlashSpec() 39
40 - def __init__(self, aParent, aResource):
41 self._file = aResource.file 42 43 self._size = tuple(aResource.size) 44 w = aResource.size[0] 45 if w == -2: 46 w = self._bitmap.getWidth() 47 h = aResource.size[1] 48 if h == -2: 49 h = self._bitmap.getHeight() 50 size = (w, h) 51 #size = wx.Size( self._bitmap.GetWidth(), self._bitmap.GetHeight() ) 52 53 ##if aResource.border == 'transparent': 54 ## mask = wx.MaskColour(self._bitmap, wxBLACK) 55 ## self._bitmap.SetMask(mask) 56 57 ## StaticBitmap.__init__( 58 ## self, 59 ## aParent, 60 ## widget.makeNewId(aResource.id), 61 ## self._bitmap.getBits(), 62 ## aResource.position, 63 ## size, 64 ## style = wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS, 65 ## name = aResource.name 66 ## ) 67 ## FlashWindow(self, style=wx.SUNKEN_BORDER) 68 69 ## self, parent, ID=-1, pos=wx.DefaultPosition, 70 ## size=wx.DefaultSize, style=0, name='FlashWindow' 71 ## 72 FlashWindow.__init__( 73 self, 74 aParent, 75 widget.makeNewId(aResource.id), 76 aResource.position, 77 size, 78 style = wx.SUNKEN_BORDER, 79 name = aResource.name, 80 ) 81 82 self.LoadMovie(0, self._file) 83 self.Play() 84 ## GIFAnimationCtrl(self, id, ag_fname, pos=(10, 10)) 85 86 widget.Widget.__init__( self, aParent, aResource ) 87 88 wx.EVT_WINDOW_DESTROY(self, self._OnDestroy) 89 90 self._bindEvents(event.WIDGET_EVENTS)
91
92 - def _OnDestroy(self, event):
93 # memory leak cleanup 94 self._bitmap = None 95 event.Skip()
96 97 98 99 # KEA special handling for -2 size option
100 - def _setSize(self, aSize):
101 self._size = tuple(aSize) 102 w = aSize[0] 103 if w == -2: 104 w = self._bitmap.getWidth() 105 h = aSize[1] 106 if h == -2: 107 h = self._bitmap.getHeight() 108 self.SetSize((w, h))
109 110 # KEA 2001-08-02 111 # right now the image is loaded from a filename 112 # during initialization 113 # but later these might not make any sense 114 # if setBitmap is used directly in user code
115 - def _getFile( self ) :
116 return self._file
117 118 # KEA 2001-08-14 119 # if we're going to support setting the file 120 # after initialization, then this will need to handle the bitmap loading 121 # overhead
122 - def _setFile( self, aFile ) :
123 self._file = aFile 124 self._setBitmap(graphic.Bitmap(aFile))
125 126 127 128 ## backgroundColor = property(widget.Widget._getBackgroundColor, _setBackgroundColor) 129 file = property(_getFile, _setFile) 130 size = property(widget.Widget._getSize, _setSize)
131 132 133 import sys 134 from PythonCard import registry 135 registry.Registry.getInstance().register(sys.modules[__name__].Flash) 136