| 1 |
# (C) Copyright 2004-2023 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
|
| 11 |
""" Traits UI MS Flash editor. |
| 12 |
""" |
| 13 |
|
| 14 |
|
| 15 |
import wx |
| 16 |
|
| 17 |
if wx.Platform == "__WXMSW__": |
| 18 |
from wx.lib.flashwin import FlashWindow |
| 19 |
|
| 20 |
from traitsui.wx.editor import Editor |
| 21 |
|
| 22 |
from traitsui.basic_editor_factory import BasicEditorFactory |
| 23 |
|
| 24 |
|
| 25 |
class _FlashEditor(Editor): |
| 26 |
"""Traits UI Flash editor.""" |
| 27 |
|
| 28 |
# ------------------------------------------------------------------------- |
| 29 |
# Trait definitions: |
| 30 |
# ------------------------------------------------------------------------- |
| 31 |
|
| 32 |
#: Is the table editor is scrollable? This value overrides the default. |
| 33 |
scrollable = True |
| 34 |
|
| 35 |
def init(self, parent): |
| 36 |
"""Finishes initializing the editor by creating the underlying toolkit |
| 37 |
widget. |
| 38 |
""" |
| 39 |
self.control = FlashWindow(parent) |
| 40 |
self.set_tooltip() |
| 41 |
|
| 42 |
def update_editor(self): |
| 43 |
"""Updates the editor when the object trait changes externally to the |
| 44 |
editor. |
| 45 |
""" |
| 46 |
value = self.str_value.strip() |
| 47 |
if value.find("://") < 0: |
| 48 |
value = "file://" + value |
| 49 |
|
| 50 |
wx.BeginBusyCursor() |
| 51 |
self.control.LoadMovie(0, value) |
| 52 |
wx.EndBusyCursor() |
| 53 |
|
| 54 |
|
| 55 |
# ------------------------------------------------------------------------- |
| 56 |
# Create the editor factory object: |
| 57 |
# ------------------------------------------------------------------------- |
| 58 |
|
| 59 |
# wxPython editor factory for Flash editors: |
| 60 |
|
| 61 |
|
| 62 |
class FlashEditor(BasicEditorFactory): |
| 63 |
|
| 64 |
#: The editor class to be created: |
| 65 |
klass = _FlashEditor |