Browse Source

wxGUI/nviz: fix output format in simple animation

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58801 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 years ago
parent
commit
93e7083248
1 changed files with 14 additions and 2 deletions
  1. 14 2
      gui/wxpython/nviz/animation.py

+ 14 - 2
gui/wxpython/nviz/animation.py

@@ -48,7 +48,7 @@ class Animation:
         self.mapWindow = mapWindow
         self.actions = {'record': self.Record,
                         'play': self.Play}
-        self.formats = ['ppm', 'tif']   # currently supported formats
+        self.formats = ['tif', 'ppm']   # currently supported formats
         self.mode = 'record'            # current mode (record, play, save)
         self.paused = False             # recording/replaying paused
         self.currentFrame = 0           # index of current frame
@@ -180,12 +180,24 @@ class Animation:
         w, h = self.mapWindow.GetClientSizeTuple()
         toolWin = self.mapWindow.GetToolWin()
         
+        formatter = ':04.0f'
+        n = len(self.animationList)
+        if n < 10:
+            formatter = ':01.0f'
+        elif n < 100:
+            formatter = ':02.0f'
+        elif n < 1000:
+            formatter = ':03.0f'
+
         self.currentFrame = 0
         self.mode = 'save'
         for params in self.animationList:
             if not self.stopSaving:
                 self.UpdateView(params)
-                filename = prefix + "_" + str(self.currentFrame) + '.' + self.formats[format]
+                number = ('{frame' + formatter +'}').format(frame=self.currentFrame)
+                filename = "{prefix}_{number}.{ext}".format(prefix=prefix,
+                                                            number=number,
+                                                            ext=self.formats[format])
                 filepath = os.path.join(path, filename)
                 self.mapWindow.SaveToFile(FileName = filepath, FileType = self.formats[format],
                                                   width = w, height = h)