Skip to content

Commit

Permalink
wxGUI Graphical Modeler: fix wx.ImageFromBitmap widget deprecation wa…
Browse files Browse the repository at this point in the history
…rning (#442)
  • Loading branch information
tmszi committed Mar 21, 2020
1 parent 3e94abc commit ae5f058
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions gui/wxpython/gmodeler/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
else:
import wx.lib.flatnotebook as FN
from wx.lib.newevent import NewEvent

from gui_core.widgets import GNotebook
from core.gconsole import GConsole, \
EVT_CMD_RUN, EVT_CMD_DONE, EVT_CMD_PREPARE
Expand All @@ -63,8 +63,10 @@
from gmodeler.giface import GraphicalModelerGrassInterface
from gmodeler.model import *
from gmodeler.dialogs import *
from gui_core.wrap import Button, StaticText, StaticBox, TextCtrl, \
Menu, StockCursor, EmptyBitmap, NewId
from gui_core.wrap import (
Button, EmptyBitmap, ImageFromBitmap, Menu, NewId, StaticBox,
StaticText, StockCursor, TextCtrl,
)
from gui_core.wrap import TextEntryDialog as wxTextEntryDialog

wxModelDone, EVT_MODEL_DONE = NewEvent()
Expand Down Expand Up @@ -158,7 +160,7 @@ def __init__(self, parent, giface, id=wx.ID_ANY,
self._gconsole.Bind(EVT_CMD_DONE, self.OnCmdDone)
self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
self.Bind(EVT_MODEL_DONE, self.OnModelDone)

self.notebook.AddPage(page=self.canvas, text=_('Model'), name='model')
self.notebook.AddPage(
page=self.itemPanel,
Expand Down Expand Up @@ -312,8 +314,8 @@ def time_elapsed(etime):
stime = _("unknown")

return stime
self.goutput.GetProgressBar().SetValue(0)

self.goutput.GetProgressBar().SetValue(0)
self.goutput.WriteCmdLog('({}) {} ({})'.format(
str(time.ctime()), _("Command finished"), time_elapsed(event.time)),
notification=event.notification)
Expand All @@ -328,7 +330,7 @@ def time_elapsed(etime):
notification=event.notification)
event = wxModelDone()
wx.PostEvent(self, event)

except IndexError:
pass

Expand Down Expand Up @@ -405,7 +407,7 @@ def _deleteIntermediateData(self):
if vect:
self._gconsole.RunCmd(['g.remove', '-f', 'type=vector',
'name=%s' % ','.join(vect)])

self.SetStatusText(_("%d intermediate maps deleted from current mapset") %
int(len(rast) + len(rast3d) + len(vect)))

Expand Down Expand Up @@ -624,7 +626,7 @@ def OnModelDone(self, event):
"""Computation finished
"""
self.SetStatusText('', 0)

# restore original files
if hasattr(self.model, "fileInput"):
for finput in self.model.fileInput:
Expand Down Expand Up @@ -652,7 +654,7 @@ def OnModelDone(self, event):
if layers:
for layer in layers:
self._giface.GetLayerList().DeleteLayer(layer)

# add new map layer
self._giface.GetLayerList().AddLayer(
ltype=data.GetPrompt(), name=data.GetValue(), checked=True,
Expand Down Expand Up @@ -706,7 +708,7 @@ def OnExportImage(self, event):
int(ymaxImg - yminImg) + 50)
bitmap = EmptyBitmap(width=size.width, height=size.height)

filetype, ltype = GetImageHandlers(wx.ImageFromBitmap(bitmap))
filetype, ltype = GetImageHandlers(ImageFromBitmap(bitmap))

dlg = wx.FileDialog(
parent=self,
Expand Down Expand Up @@ -1703,7 +1705,7 @@ def OnHasDisplay(self, event):
layers = self.frame._giface.GetLayerList().GetLayersByName(shape.GetValue())
for layer in layers:
self.frame._giface.GetLayerList().DeleteLayer(layer)

except GException as e:
GError(parent=self,
message='{}'.format(e))
Expand Down

0 comments on commit ae5f058

Please sign in to comment.