Skip to content

Commit

Permalink
address issues reported by flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed Apr 5, 2024
1 parent 846a383 commit cd78874
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
28 changes: 21 additions & 7 deletions gui/wxpython/gmodeler/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@
from wx.lib import ogl

from gui_core.dialogs import TextEntryDialog as CustomTextEntryDialog
from gui_core.wrap import TextEntryDialog as wxTextEntryDialog

from gmodeler.model import *
from gmodeler.dialogs import *
from gui_core.wrap import TextEntryDialog as wxTextEntryDialog, NewId, Menu
from gui_core.forms import GUI
from core.gcmd import GException, GError

from gmodeler.model import (
ModelRelation,
ModelAction,
ModelData,
ModelLoop,
ModelCondition,
ModelComment,
)
from gmodeler.dialogs import (
ModelRelationDialog,
ModelDataDialog,
ModelLoopDialog,
ModelConditionDialog,
)
from gmodeler.giface import GraphicalModelerGrassInterface


class ModelCanvas(ogl.ShapeCanvas):
Expand Down Expand Up @@ -115,10 +130,10 @@ def __init__(self, log, frame):
def OnLeftClick(self, x, y, keys=0, attachment=0):
"""Left mouse button pressed -> select item & update statusbar"""
shape = self.GetShape()
canvas = shape.GetCanvas()
dc = wx.ClientDC(canvas)

# probably does nothing, removed from wxPython 2.9
# canvas = shape.GetCanvas()
# dc = wx.ClientDC(canvas)
# canvas.PrepareDC(dc)

if hasattr(self.frame, "defineRelation"):
Expand Down Expand Up @@ -424,7 +439,6 @@ def _onSelectShape(self, shape, append=False):
if shape.Selected():
shape.Select(False, dc)
else:
redraw = False
shapeList = canvas.GetDiagram().GetShapeList()
toUnselect = list()

Expand Down
3 changes: 1 addition & 2 deletions gui/wxpython/gmodeler/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from gui_core.dialogs import SimpleDialog, MapLayersDialogForModeler
from gui_core.prompt import GPromptSTC
from gui_core.gselect import Select, ElementSelect
from gmodeler.model import *
from lmgr.menudata import LayerManagerMenuData
from gui_core.wrap import (
Button,
Expand All @@ -47,6 +46,7 @@
NewId,
CheckListCtrlMixin,
)
from gmodeler.model import ModelData, ModelAction, ModelCondition


class ModelDataDialog(SimpleDialog):
Expand Down Expand Up @@ -885,7 +885,6 @@ def OnEndEdit(self, event):
"""Finish editing of item"""
itemIndex = event.GetIndex()
columnIndex = event.GetColumn()
nameOld = self.GetItem(itemIndex, 0).GetText()

if columnIndex == 0: # TODO
event.Veto()
Expand Down
10 changes: 4 additions & 6 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,6 @@ def LoadModel(self, filename):
Raise exception on error.
"""
dtdFilename = os.path.join(globalvar.WXGUIDIR, "xml", "grass-gxm.dtd")

# parse workspace file
try:
gxmXml = ProcessModelFile(etree.parse(filename))
Expand Down Expand Up @@ -1145,7 +1143,7 @@ def SetLabel(self, label=None):
else:
try:
label = self.task.get_cmd(ignoreErrors=True)[0]
except:
except IndexError:
label = _("unknown")

idx = self.GetId()
Expand Down Expand Up @@ -1999,7 +1997,7 @@ def __init__(self, tree):
if self.root is not None:
tagName = self.root.tag
else:
tabName = _("empty")
tagName = _("empty")
raise GException(_("Details: unsupported tag name '{0}'.").format(tagName))

# list of actions, data
Expand Down Expand Up @@ -2137,15 +2135,15 @@ def _getDim(self, node):
posVal = list(map(int, posAttr.split(",")))
try:
pos = (posVal[0], posVal[1])
except:
except IndexError:
pos = None

sizeAttr = node.get("size", None)
if sizeAttr:
sizeVal = list(map(int, sizeAttr.split(",")))
try:
size = (sizeVal[0], sizeVal[1])
except:
except IndexError:
size = None

return pos, size
Expand Down
26 changes: 22 additions & 4 deletions gui/wxpython/gmodeler/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,35 @@
)
from main_window.page import MainPageBase
from gmodeler.giface import GraphicalModelerGrassInterface
from gmodeler.model import *
from gmodeler.dialogs import *
from gmodeler.model import (
Model,
ModelAction,
ModelData,
ModelRelation,
ModelLoop,
ModelCondition,
ModelComment,
WriteModelFile,
ModelDataSeries,
ModelDataSingle,
WritePythonFile,
WritePyWPSFile,
)
from gmodeler.dialogs import (
ModelDataDialog,
ModelSearchDialog,
VariableListCtrl,
ItemListCtrl,
)
from gmodeler.canvas import ModelCanvas, ModelEvtHandler
from gmodeler.toolbars import ModelerToolbar
from gmodeler.preferences import PreferencesDialog, PropertiesDialog

wxModelDone, EVT_MODEL_DONE = NewEvent()

from grass.script.utils import try_remove
from grass.script import core as grass

wxModelDone, EVT_MODEL_DONE = NewEvent()


class ModelerPanel(wx.Panel, MainPageBase):
def __init__(
Expand Down
4 changes: 0 additions & 4 deletions gui/wxpython/gmodeler/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def __init__(self, parent):

def _toolbarData(self):
"""Toolbar data"""
# dockable window has no menu, so shortcuts doesn't work when
# window is dockable
show_shortcuts = not self.parent.IsDockable()

icons = {
"new": MetaIcon(
img="create",
Expand Down

0 comments on commit cd78874

Please sign in to comment.