コード例 #1
0
	class Frame(wx.Frame):
		def __init__(self, parent, id, title):
			wx.Frame.__init__(self, None, id, title, wx.DefaultPosition, wx.Size(500, 400))

			self.panel = GIFAnimationCtrl(self, -1)
			self.panel.LoadFile("barren1.gif")
			self.panel.Play()
コード例 #2
0
 def init(self, parent):
     """ Finishes initializing the editor by creating the underlying toolkit
         widget.
     """
     self.control = GIFAnimationCtrl(parent, -1)
     self.control.GetPlayer().UseBackgroundColour(True)
     self.sync_value(self.factory.playing, "playing", "from")
     self.set_tooltip()
コード例 #3
0
class _AnimatedGIFEditor(Editor):
    """ Editor that displays an animated GIF file.
    """

    # -------------------------------------------------------------------------
    #  Trait definitions:
    # -------------------------------------------------------------------------

    #: Is the animated GIF file currently playing?
    playing = Bool(True)

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = GIFAnimationCtrl(parent, -1)
        self.control.GetPlayer().UseBackgroundColour(True)
        self.sync_value(self.factory.playing, "playing", "from")
        self.set_tooltip()

    def update_editor(self):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        control = self.control
        if self.playing:
            control.Stop()

        control.LoadFile(self.value)
        self._file_loaded = True

        # Note: It seems to be necessary to Play/Stop the control to avoid a
        # hard wx crash when 'PlayNextFrame' is called the first time (must be
        # some kind of internal initialization issue):
        control.Play()
        control.Stop()

        if self.playing or self._not_first:
            self._playing_changed()
        else:
            do_after(300, self._frame_changed)

        self._not_first = True

    def _playing_changed(self):
        """ Handles the editor 'playing' trait being changed.
        """
        if self._file_loaded:
            try:
                if self.playing:
                    self.control.Play()
                else:
                    player = self.control.GetPlayer()
                    player.SetCurrentFrame(0)
                    player.PlayNextFrame()
                    player.Stop()
            except:
                pass
コード例 #4
0
ファイル: Menu.py プロジェクト: CrazyPython/SPE
 def __init__(self,statusBar,fileName,position=0):
     GIFAnimationCtrl.__init__(self,statusBar,-1,info.imageFile(fileName))
     self._statusBar = statusBar
     self._fileName  = fileName
     self._position  = position
     self._running   = False
     #backgroundcolour
     player          = self.GetPlayer()
     player.UseBackgroundColour(True)
     #position
     rect            = statusBar.GetFieldRect(0)
     self.SetPosition((rect.x+(rect.width-16)/2, rect.y+(rect.height-16)/2))
コード例 #5
0
ファイル: GIFAnimationCtrl.py プロジェクト: wangdyna/wxPython
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1)

        sizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        for name in GIFNames:
            ani = GIFAnimationCtrl(self, -1, opj(name))
            ani.GetPlayer().UseBackgroundColour(True)
            ani.Play()
            sizer.Add(ani, 0, wx.ALL, 10)

        border = wx.BoxSizer()
        border.Add(sizer, 1, wx.EXPAND | wx.ALL, 20)
        self.SetSizer(border)
コード例 #6
0
	def LoadFile(self, file):
		dc = wx.ClientDC(self)
		dc.Clear()
		del dc

		if not file.endswith(".gif"):
			new = file[:file.rfind('.')]+'.gif'
			if os.path.exists(new):
				print "Using low quality version", new + ". Install PIL for better version."
				file = new
			else:
				print "Unable to display file", file + ". Install PIL to have it displayed."
				return
		GIFAnimationCtrl.__LoadFile(self, file)
コード例 #7
0
	def DoCreateResource(self):
		# The simple method assumes that there is no existing
		# instance.  Be sure of that with an assert.
		assert self.GetInstance() is None

		ctrl = GIFAnimationCtrl(self.GetParentAsWindow(),
								self.GetID(),
								"",
								self.GetPosition(),
								self.GetSize(),
								self.GetStyle(),
								self.GetName(),
								)

		# These two things should be done in either case:
		# Set standard window attributes
		self.SetupWindow(ctrl)
		# Create any child windows of this node
		self.CreateChildren(ctrl)

		return ctrl