dabo Commit
Revision 6304
Date: 2011-01-02 17:17:30 -0800 (Sun, 02 Jan 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6304
Changed:
U trunk/dabo/ui/uiwx/dMediaControl.py
Log:
Added the ability to clear the control by setting Source = None.
Abstracted out the behavior that handles failure when setting the Source
property so that it can be changed as needed.
Diff:
Modified: trunk/dabo/ui/uiwx/dMediaControl.py
===================================================================
--- trunk/dabo/ui/uiwx/dMediaControl.py 2011-01-03 00:51:01 UTC (rev 6303)
+++ trunk/dabo/ui/uiwx/dMediaControl.py 2011-01-03 01:17:30 UTC (rev 6304)
@@ -158,6 +158,20 @@
self.play()
+ def handleLoadFailure(self, val):
+ """This method contains the default behavior when an attempt to
load
+ content into the control by setting the Source property fails.
If you want
+ your app to handle things differently, override this method.
+ """
+ if dabo.ui.areYouSure(_("Could not load '%s'. Try again?") %
val,
+ title=_("Media Load Fail"), defaultNo=True,
+ cancelButton=False):
+ dabo.ui.setAfterInterval(500, self, "Source", val)
+ return
+ self._source = None
+ self.clear()
+
+
def _getContentDimensions(self):
sc = self.ShowControls
ret = self.GetBestSize().Get()
@@ -229,6 +243,10 @@
def _setSource(self, val):
if self._constructed():
+ if val is None:
+ self.Load("")
+ self.clear()
+ return
if val.startswith("http:"):
success = self.LoadURI(val)
else:
@@ -236,13 +254,7 @@
if success:
self._source = val
else:
- if dabo.ui.areYouSure(_("Could not load '%s'.
Try again?") % val,
- title=_("Media Load Fail"),
defaultNo=True,
- cancelButton=False):
- dabo.ui.setAfterInterval(500, self,
"Source", val)
- return
- self._source = None
- self.clear()
+ self.handleLoadFailure(val)
else:
self._properties["Source"] = val
@@ -308,7 +320,7 @@
Source = property(_getSource, _setSource, None,
_("""This can be either a file path or a URI for the
content displayed in this
control. If the value begins with 'http', it is assumed
to be a URI rather than
- a local file path. (str)"""))
+ a local file path. Setting the source to None will
clear the control. (str)"""))
Status = property(_getStatus, None, None,
_("""The current playback status. One of 'Playing',
'Paused', or 'Stopped'.
@@ -340,5 +352,6 @@
else:
self.Sizer.append1x(self.player)
+
app = dabo.dApp(MainFormClass=MediaForm)
app.start()
\ No newline at end of file
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]