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 GIFAnimationCtrl = wx.animate.GIFAnimationCtrl
17 events = []
18 attributes = {
19 'file' : { 'presence' : 'optional', 'default':'' },
20
21
22
23
24
25
26
27 'size' : { 'presence' : 'optional', 'default' : [ -1, -1 ] },
28 }
29 widget.WidgetSpec.__init__( self, 'GifImage', 'Widget', events, attributes )
30
31
32 -class GifImage(widget.Widget, GIFAnimationCtrl):
33 """
34 gif image.
35 """
36
37 _spec = GifImageSpec()
38
40 self._file = aResource.file
41
42 self._size = tuple(aResource.size)
43 w = aResource.size[0]
44 if w == -2:
45 w = self._bitmap.getWidth()
46 h = aResource.size[1]
47 if h == -2:
48 h = self._bitmap.getHeight()
49 size = (w, h)
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 GIFAnimationCtrl.__init__(
68 self,
69 aParent,
70 widget.makeNewId(aResource.id),
71 self._file,
72 aResource.position,
73 size,
74 style = wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS,
75 name = aResource.name
76 )
77
78 self.Play()
79
80
81 widget.Widget.__init__( self, aParent, aResource )
82
83 wx.EVT_WINDOW_DESTROY(self, self._OnDestroy)
84
85 self._bindEvents(event.WIDGET_EVENTS)
86
88
89 self._bitmap = None
90 event.Skip()
91
92
93
94
96 self._size = tuple(aSize)
97 w = aSize[0]
98 if w == -2:
99 w = self._bitmap.getWidth()
100 h = aSize[1]
101 if h == -2:
102 h = self._bitmap.getHeight()
103 self.SetSize((w, h))
104
105
106
107
108
109
112
113
114
115
116
118 self._file = aFile
119 self._setBitmap(graphic.Bitmap(aFile))
120
121
122
123
124 file = property(_getFile, _setFile)
125 size = property(widget.Widget._getSize, _setSize)
126
127
128 import sys
129 from PythonCard import registry
130 registry.Registry.getInstance().register(sys.modules[__name__].GifImage)
131