Browse Source

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

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

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

@@ -42,6 +42,11 @@ def BitmapFromImage(image, depth=-1):
     else:
         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):
     if wxPythonPhoenix: