diff --git a/.flake8 b/.flake8 index 573debabe1c..83d5e6251ae 100644 --- a/.flake8 +++ b/.flake8 @@ -58,17 +58,14 @@ per-file-ignores = gui/wxpython/dbmgr/manager.py: E722 gui/wxpython/dbmgr/vinfo.py: F841 gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291 - gui/wxpython/gcp/g.gui.gcp.py: F841 - gui/wxpython/gcp/manager.py: F841, E722 - gui/wxpython/gcp/mapdisplay.py: F841 - gui/wxpython/gui_core/*: F841, E266, E722 - gui/wxpython/gui_core/dialogs.py: E722, F841 - gui/wxpython/gui_core/forms.py: E722, F841 + gui/wxpython/gcp/manager.py: E722 + gui/wxpython/gui_core/*: E266, E722 + gui/wxpython/gui_core/dialogs.py: E722 + gui/wxpython/gui_core/forms.py: E722 gui/wxpython/gui_core/ghelp.py: E722 - gui/wxpython/gui_core/gselect.py: F841, E266, E722 - gui/wxpython/gui_core/preferences.py: E266, F841 - gui/wxpython/gui_core/treeview.py: F841 - gui/wxpython/gui_core/widgets.py: F841, E722, E266 + gui/wxpython/gui_core/gselect.py: E266, E722 + gui/wxpython/gui_core/preferences.py: E266 + gui/wxpython/gui_core/widgets.py: E722, E266 gui/wxpython/image2target/*: F841, E722, E265 gui/wxpython/image2target/g.gui.image2target.py: E501, E265, F841 gui/wxpython/iscatt/*: F841, E722, F405, F403 diff --git a/gui/wxpython/gcp/g.gui.gcp.py b/gui/wxpython/gcp/g.gui.gcp.py index 32ef2c4fc0d..12f0a152090 100755 --- a/gui/wxpython/gcp/g.gui.gcp.py +++ b/gui/wxpython/gcp/g.gui.gcp.py @@ -65,7 +65,7 @@ def main(): app = wx.App() - wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface()) + GCPWizard(parent=None, giface=StandaloneGrassInterface()) app.MainLoop() diff --git a/gui/wxpython/gcp/manager.py b/gui/wxpython/gcp/manager.py index ac006a95cbf..2d89d8312cc 100644 --- a/gui/wxpython/gcp/manager.py +++ b/gui/wxpython/gcp/manager.py @@ -1826,23 +1826,21 @@ def OnGeorect(self, event): else: flags = "a" - busy = wx.BusyInfo(_("Rectifying images, please wait..."), parent=self) - wx.GetApp().Yield() - - ret, msg = RunCommand( - "i.rectify", - parent=self, - getErrorMsg=True, - quiet=True, - group=self.xygroup, - extension=self.extension, - order=self.gr_order, - method=self.gr_method, - flags=flags, - overwrite=overwrite, - ) + with wx.BusyInfo(_("Rectifying images, please wait..."), parent=self): + wx.GetApp().Yield() - del busy + ret, msg = RunCommand( + "i.rectify", + parent=self, + getErrorMsg=True, + quiet=True, + group=self.xygroup, + extension=self.extension, + order=self.gr_order, + method=self.gr_method, + flags=flags, + overwrite=overwrite, + ) # provide feedback on failure if ret != 0: @@ -1886,24 +1884,22 @@ def OnGeorect(self, event): ) ret = msg = "" - busy = wx.BusyInfo( + with wx.BusyInfo( _("Rectifying vector map <%s>, please wait...") % vect, parent=self - ) - wx.GetApp().Yield() - - ret, msg = RunCommand( - "v.rectify", - parent=self, - getErrorMsg=True, - quiet=True, - input=vect, - output=self.outname, - group=self.xygroup, - order=self.gr_order, - overwrite=overwrite, - ) - - del busy + ): + wx.GetApp().Yield() + + ret, msg = RunCommand( + "v.rectify", + parent=self, + getErrorMsg=True, + quiet=True, + input=vect, + output=self.outname, + group=self.xygroup, + order=self.gr_order, + overwrite=overwrite, + ) # provide feedback on failure if ret != 0: @@ -2028,7 +2024,6 @@ def OnGROrder(self, event): elif self.gr_order == 2: minNumOfItems = 6 - diff = 6 - numOfItems # self.SetStatusText( # _('Insufficient points, 6+ points needed for 2nd order')) @@ -2331,7 +2326,6 @@ def OnZoomToTarget(self, event): def OnZoomMenuGCP(self, event): """Popup Zoom menu""" - point = wx.GetMousePosition() zoommenu = Menu() # Add items to the menu @@ -3433,7 +3427,6 @@ def UpdateSettings(self): srcrenderVector = False tgtrender = False tgtrenderVector = False - reload_target = False if self.new_src_map != src_map: # remove old layer layers = self.parent.grwiz.SrcMap.GetListOfLayers() @@ -3471,7 +3464,6 @@ def UpdateSettings(self): del layers[0] layers = self.parent.grwiz.TgtMap.GetListOfLayers() # self.parent.grwiz.TgtMap.DeleteAllLayers() - reload_target = True tgt_map["raster"] = self.new_tgt_map["raster"] tgt_map["vector"] = self.new_tgt_map["vector"] diff --git a/gui/wxpython/gcp/mapdisplay.py b/gui/wxpython/gcp/mapdisplay.py index 13872b807cf..66daa70d2ca 100644 --- a/gui/wxpython/gcp/mapdisplay.py +++ b/gui/wxpython/gcp/mapdisplay.py @@ -484,7 +484,6 @@ def PrintMenu(self, event): """ Print options and output menu for map display """ - point = wx.GetMousePosition() printmenu = Menu() # Add items to the menu setup = wx.MenuItem(printmenu, wx.ID_ANY, _("Page setup")) @@ -528,7 +527,6 @@ def SaveDisplayRegion(self, event): def OnZoomMenu(self, event): """Popup Zoom menu""" - point = wx.GetMousePosition() zoommenu = Menu() # Add items to the menu diff --git a/gui/wxpython/gui_core/dialogs.py b/gui/wxpython/gui_core/dialogs.py index c31939312a7..f7c7711cadf 100644 --- a/gui/wxpython/gui_core/dialogs.py +++ b/gui/wxpython/gui_core/dialogs.py @@ -180,7 +180,6 @@ def OnLocation(self, event): dbase = grass.gisenv()["GISDBASE"] self.element2.UpdateItems(dbase=dbase, location=location) self.element2.SetSelection(0) - mapset = self.element2.GetStringSelection() def GetValues(self): """Get location, mapset""" diff --git a/gui/wxpython/gui_core/forms.py b/gui/wxpython/gui_core/forms.py index 4ff6f0ee0ee..8ecc4feb995 100644 --- a/gui/wxpython/gui_core/forms.py +++ b/gui/wxpython/gui_core/forms.py @@ -307,8 +307,6 @@ def run(self): pTable = self.task.get_param( "dbtable", element="element", raiseError=False ) - if pTable: - table = pTable.get("value", "") if name == "LayerSelect": # determine format @@ -1546,7 +1544,6 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar if value: selection.SetValue(value) - formatSelector = True # A gselect.Select is a combobox with two children: a textctl # and a popupwindow; we target the textctl here textWin = selection.GetTextCtrl() diff --git a/gui/wxpython/gui_core/goutput.py b/gui/wxpython/gui_core/goutput.py index 6aca497f365..3c8927f2233 100644 --- a/gui/wxpython/gui_core/goutput.py +++ b/gui/wxpython/gui_core/goutput.py @@ -619,11 +619,7 @@ def AddStyledMessage(self, message, style=None): if c == "\b": self.linePos -= 1 else: - if c == "\r": - pos = self.GetCurLine()[1] - # self.SetCurrentPos(pos) - else: - self.SetCurrentPos(self.linePos) + self.SetCurrentPos(self.linePos) self.ReplaceSelection(c) self.linePos = self.GetCurrentPos() if c != " ": diff --git a/gui/wxpython/gui_core/gselect.py b/gui/wxpython/gui_core/gselect.py index 7dc51b75935..9a16c36e08e 100644 --- a/gui/wxpython/gui_core/gselect.py +++ b/gui/wxpython/gui_core/gselect.py @@ -1373,12 +1373,6 @@ def Insert(self, group): """Insert subgroups for defined group""" if not group: return - gisenv = gs.gisenv() - try: - name, mapset = group.split("@", 1) - except ValueError: - name = group - mapset = gisenv["MAPSET"] mlist = RunCommand("i.group", group=group, read=True, flags="sg").splitlines() try: diff --git a/gui/wxpython/gui_core/menu.py b/gui/wxpython/gui_core/menu.py index 71d6d153f8b..de6b49b7e93 100644 --- a/gui/wxpython/gui_core/menu.py +++ b/gui/wxpython/gui_core/menu.py @@ -68,8 +68,6 @@ def _createMenu(self, node): self._createMenuItem(menu, label=child.label, **data) - self.parent.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight) - return menu def _createMenuItem( @@ -136,19 +134,6 @@ def GetCmd(self): """ return self.menucmd - def OnMenuHighlight(self, event): - """ - Default menu help handler - """ - # Show how to get menu item info from this event handler - id = event.GetMenuId() - item = self.FindItemById(id) - if item: - help = item.GetHelp() - - # but in this case just call Skip so the default is done - event.Skip() - class Menu(MenuBase, wx.MenuBar): def __init__(self, parent, model, class_handler=None): diff --git a/gui/wxpython/gui_core/preferences.py b/gui/wxpython/gui_core/preferences.py index 3c3df8e8e42..c2020b2ffba 100644 --- a/gui/wxpython/gui_core/preferences.py +++ b/gui/wxpython/gui_core/preferences.py @@ -2021,8 +2021,6 @@ def OnCheckColorTable(self, event): def OnLoadEpsgCodes(self, event): """Load EPSG codes from the file""" - win = self.FindWindowById(self.winId["projection:statusbar:projFile"]) - path = win.GetValue() epsgCombo = self.FindWindowById(self.winId["projection:statusbar:epsg"]) wx.BeginBusyCursor() try: diff --git a/gui/wxpython/gui_core/prompt.py b/gui/wxpython/gui_core/prompt.py index 6ac9219f827..6734de169a9 100644 --- a/gui/wxpython/gui_core/prompt.py +++ b/gui/wxpython/gui_core/prompt.py @@ -511,7 +511,6 @@ def OnChar(self, event): # complete command after pressing '.' if event.GetKeyCode() == 46: self.autoCompList = [] - entry = self.GetTextLeft() self.InsertText(pos, ".") self.CharRight() self.toComplete = self.EntityToComplete() @@ -538,7 +537,6 @@ def OnChar(self, event): or event.GetKeyCode() == wx.WXK_SUBTRACT ): self.autoCompList = [] - entry = self.GetTextLeft() self.InsertText(pos, "-") self.CharRight() self.toComplete = self.EntityToComplete() diff --git a/gui/wxpython/gui_core/pystc.py b/gui/wxpython/gui_core/pystc.py index a1dfc543320..d2df651a387 100644 --- a/gui/wxpython/gui_core/pystc.py +++ b/gui/wxpython/gui_core/pystc.py @@ -98,7 +98,6 @@ def __init__(self, parent, id=wx.ID_ANY, statusbar=None): 9, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL ) face = font.GetFaceName() - size = font.GetPointSize() # setting the monospace here to not mess with the rest of the code # TODO: review the whole styling diff --git a/gui/wxpython/gui_core/treeview.py b/gui/wxpython/gui_core/treeview.py index 4c20885599c..b5ee50a7822 100644 --- a/gui/wxpython/gui_core/treeview.py +++ b/gui/wxpython/gui_core/treeview.py @@ -303,17 +303,19 @@ def main(): root = tree.root n1 = tree.AppendNode(parent=root, data={"label": "node1"}) n2 = tree.AppendNode(parent=root, data={"label": "node2"}) - n3 = tree.AppendNode(parent=root, data={"label": "node3"}) # pylint: disable=W0612 + n3 = tree.AppendNode( # noqa: F841 # pylint: disable=W0612 + parent=root, data={"label": "node3"} + ) n11 = tree.AppendNode(parent=n1, data={"label": "node11", "xxx": "A"}) - n12 = tree.AppendNode( + n12 = tree.AppendNode( # noqa: F841 # pylint: disable=W0612 parent=n1, data={"label": "node12", "xxx": "B"} - ) # pylint: disable=W0612 - n21 = tree.AppendNode( + ) + n21 = tree.AppendNode( # noqa: F841 # pylint: disable=W0612 parent=n2, data={"label": "node21", "xxx": "A"} - ) # pylint: disable=W0612 - n111 = tree.AppendNode( + ) + n111 = tree.AppendNode( # noqa: F841 # pylint: disable=W0612 parent=n11, data={"label": "node111", "xxx": "A"} - ) # pylint: disable=W0612 + ) app = wx.App() frame = TreeFrame(model=tree) diff --git a/gui/wxpython/gui_core/widgets.py b/gui/wxpython/gui_core/widgets.py index 035c70e6fbd..0ec50553114 100644 --- a/gui/wxpython/gui_core/widgets.py +++ b/gui/wxpython/gui_core/widgets.py @@ -170,7 +170,7 @@ def InsertPage(self, *args, **kwargs): self.classObject.InsertPage(self.widget, *args, **kwargs) except ( TypeError - ) as e: # documentation says 'index', but certain versions of wx require 'n' + ): # documentation says 'index', but certain versions of wx require 'n' kwargs["n"] = kwargs["index"] del kwargs["index"] self.classObject.InsertPage(self.widget, *args, **kwargs)