[GRASS-SVN] r58190 - grass/trunk/gui/wxpython/animation
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 10 18:48:24 PST 2013
Author: annakrat
Date: 2013-11-10 18:48:24 -0800 (Sun, 10 Nov 2013)
New Revision: 58190
Modified:
grass/trunk/gui/wxpython/animation/anim.py
grass/trunk/gui/wxpython/animation/frame.py
Log:
wxGUI/animation: fix case when there is only one map
Modified: grass/trunk/gui/wxpython/animation/anim.py
===================================================================
--- grass/trunk/gui/wxpython/animation/anim.py 2013-11-10 21:36:49 UTC (rev 58189)
+++ grass/trunk/gui/wxpython/animation/anim.py 2013-11-11 02:48:24 UTC (rev 58190)
@@ -51,6 +51,8 @@
def GetFrame(self, index):
"""!Returns animation frame"""
+ if len(self.frames) <= 1: # special case handling (only 1 map)
+ return self.frames[0]
return self.frames[index]
def GetCount(self):
@@ -100,7 +102,7 @@
if not self.IsActive():
return
self.currentIndex = 0
- self.callbackEndAnimation(self.currentIndex, self.frames[self.currentIndex])
+ self.callbackEndAnimation(self.currentIndex, self.GetFrame(self.currentIndex))
def _arrivedToEnd(self):
"""!Decides which action to do after animation end (stop, repeat)."""
@@ -129,7 +131,7 @@
if not self.IsActive():
return
- self.callbackUpdateFrame(self.currentIndex, self.frames[self.currentIndex])
+ self.callbackUpdateFrame(self.currentIndex, self.GetFrame(self.currentIndex))
if self.orientation == Orientation.FORWARD:
self.currentIndex += 1
if self.currentIndex == self.count:
@@ -144,7 +146,7 @@
if not self.IsActive():
return
self.currentIndex = index
- self.callbackUpdateFrame(self.currentIndex, self.frames[self.currentIndex])
+ self.callbackUpdateFrame(self.currentIndex, self.GetFrame(self.currentIndex))
def PreviousFrameIndex(self):
if not self.IsActive():
Modified: grass/trunk/gui/wxpython/animation/frame.py
===================================================================
--- grass/trunk/gui/wxpython/animation/frame.py 2013-11-10 21:36:49 UTC (rev 58189)
+++ grass/trunk/gui/wxpython/animation/frame.py 2013-11-11 02:48:24 UTC (rev 58190)
@@ -347,6 +347,8 @@
self.callbackFrameIndexChanged = callback
def EnableSlider(self, enable = True):
+ if enable and self.framesCount <= 1:
+ enable = False # we don't want to enable it
self.enable = enable
self.slider.Enable(enable)
self.indexField.Enable(enable)
@@ -401,7 +403,10 @@
def _setFrames(self, count):
self.framesCount = count
- self.slider.SetRange(0, self.framesCount - 1)
+ if self.framesCount > 1:
+ self.slider.SetRange(0, self.framesCount - 1)
+ else:
+ self.EnableSlider(False)
self._setLabel()
def _setLabel(self):
@@ -460,7 +465,10 @@
def _setFrames(self, timeLabels):
self.timeLabels = timeLabels
self.framesCount = len(timeLabels)
- self.slider.SetRange(0, self.framesCount - 1)
+ if self.framesCount > 1:
+ self.slider.SetRange(0, self.framesCount - 1)
+ else:
+ self.EnableSlider(False)
self._setLabel()
# TODO: fix setting index values, until then:
self.indexField.Disable()
More information about the grass-commit
mailing list