Browse Source

wxGUI/animation: fix deprecation warnings (https://trac.osgeo.org/grass/ticket/3895)

Anna Petrasova 5 years ago
parent
commit
a5453ab873
2 changed files with 9 additions and 3 deletions
  1. 4 3
      gui/wxpython/animation/controller.py
  2. 5 0
      gui/wxpython/gui_core/wrap.py

+ 4 - 3
gui/wxpython/animation/controller.py

@@ -19,6 +19,7 @@ import wx
 from core.gcmd import GException, GError, GMessage
 from core.gcmd import GException, GError, GMessage
 from grass.imaging import writeAvi, writeGif, writeIms, writeSwf
 from grass.imaging import writeAvi, writeGif, writeIms, writeSwf
 from core.settings import UserSettings
 from core.settings import UserSettings
+from gui_core.wrap import EmptyImage, ImageFromBitmap
 
 
 from animation.temporal_manager import TemporalManager
 from animation.temporal_manager import TemporalManager
 from animation.dialogs import InputDialog, EditDialog, ExportDialog
 from animation.dialogs import InputDialog, EditDialog, ExportDialog
@@ -551,7 +552,7 @@ class AnimationController(wx.EvtHandler):
             key='font',
             key='font',
             subkey='bgcolor')
             subkey='bgcolor')
         for frameIndex in range(frameCount):
         for frameIndex in range(frameCount):
-            image = wx.EmptyImage(*size)
+            image = EmptyImage(*size)
             image.Replace(0, 0, 0, 255, 255, 255)
             image.Replace(0, 0, 0, 255, 255, 255)
             # collect bitmaps of all windows and paste them into the one
             # collect bitmaps of all windows and paste them into the one
             for i in animWinIndex:
             for i in animWinIndex:
@@ -568,14 +569,14 @@ class AnimationController(wx.EvtHandler):
                     bitmap = self.bitmapProvider.GetBitmap(frameId)
                     bitmap = self.bitmapProvider.GetBitmap(frameId)
                     lastBitmaps[i] = bitmap
                     lastBitmaps[i] = bitmap
 
 
-                im = wx.ImageFromBitmap(lastBitmaps[i])
+                im = ImageFromBitmap(lastBitmaps[i])
 
 
                 # add legend if used
                 # add legend if used
                 legend = legends[i]
                 legend = legends[i]
                 if legend:
                 if legend:
                     legendBitmap = self.bitmapProvider.LoadOverlay(legend)
                     legendBitmap = self.bitmapProvider.LoadOverlay(legend)
                     x, y = self.mapwindows[i].GetOverlayPos()
                     x, y = self.mapwindows[i].GetOverlayPos()
-                    legImage = wx.ImageFromBitmap(legendBitmap)
+                    legImage = ImageFromBitmap(legendBitmap)
                     # not so nice result, can we handle the transparency
                     # not so nice result, can we handle the transparency
                     # otherwise?
                     # otherwise?
                     legImage.ConvertAlphaToMask()
                     legImage.ConvertAlphaToMask()

+ 5 - 0
gui/wxpython/gui_core/wrap.py

@@ -42,6 +42,11 @@ def BitmapFromImage(image, depth=-1):
     else:
     else:
         return wx.BitmapFromImage(image, depth=depth)
         return wx.BitmapFromImage(image, depth=depth)
 
 
+def ImageFromBitmap(bitmap):
+    if wxPythonPhoenix:
+        return bitmap.ConvertToImage()
+    else:
+        return wx.ImageFromBitmap(bitmap)
 
 
 def EmptyBitmap(width, height, depth=-1):
 def EmptyBitmap(width, height, depth=-1):
     if wxPythonPhoenix:
     if wxPythonPhoenix: