Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checks: Flake8 F841 fixes in the wxpython directory part 3 #4261

Merged
merged 12 commits into from
Sep 18, 2024
Merged
17 changes: 7 additions & 10 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/g.gui.gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def main():

app = wx.App()

wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
GCPWizard(parent=None, giface=StandaloneGrassInterface())

app.MainLoop()

Expand Down
66 changes: 29 additions & 37 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1826,23 +1826,21 @@ def OnGeorect(self, event):
else:
flags = "a"

busy = wx.BusyInfo(_("Rectifying images, please wait..."), parent=self)
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down Expand Up @@ -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
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
)
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:
Expand Down Expand Up @@ -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'))

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/gcp/mapdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/gui_core/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved

def GetValues(self):
"""Get location, mapset"""
Expand Down
3 changes: 0 additions & 3 deletions gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 1 addition & 5 deletions gui/wxpython/gui_core/goutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,7 @@ def AddStyledMessage(self, message, style=None):
if c == "\b":
self.linePos -= 1
else:
if c == "\r":
pos = self.GetCurLine()[1]
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
# self.SetCurrentPos(pos)
else:
self.SetCurrentPos(self.linePos)
self.SetCurrentPos(self.linePos)
self.ReplaceSelection(c)
self.linePos = self.GetCurrentPos()
if c != " ":
Expand Down
6 changes: 0 additions & 6 deletions gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 0 additions & 15 deletions gui/wxpython/gui_core/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved

# 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):
Expand Down
2 changes: 0 additions & 2 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ def OnChar(self, event):
# complete command after pressing '.'
if event.GetKeyCode() == 46:
self.autoCompList = []
entry = self.GetTextLeft()
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
self.InsertText(pos, ".")
self.CharRight()
self.toComplete = self.EntityToComplete()
Expand All @@ -538,7 +537,7 @@ def OnChar(self, event):
or event.GetKeyCode() == wx.WXK_SUBTRACT
):
self.autoCompList = []
entry = self.GetTextLeft()
self.GetTextLeft()
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
self.InsertText(pos, "-")
self.CharRight()
self.toComplete = self.EntityToComplete()
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/gui_core/pystc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions gui/wxpython/gui_core/treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading