Skip to content

Commit

Permalink
wxGUI Manage color rules interactively (vector map): fix number of Lo…
Browse files Browse the repository at this point in the history
…adTable method calls (#444)
  • Loading branch information
tmszi committed Mar 23, 2020
1 parent bb9b935 commit 9b7398c
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions gui/wxpython/modules/colorrules.py
Expand Up @@ -1090,9 +1090,7 @@ def __init__(self, parent, attributeType, **kwargs):
# additional bindings for vector color management
self.Bind(wx.EVT_COMBOBOX, self.OnLayerSelection, self.layerSelect)

self.sourceColumn.Bind(wx.EVT_TEXT, self.OnSourceColumnSelection)
self.fromColumn.Bind(wx.EVT_TEXT, self.OnFromColSelection)
self.toColumn.Bind(wx.EVT_TEXT, self.OnToColSelection)
self._columnWidgetEvtHandler()
self.Bind(wx.EVT_BUTTON, self.OnAddColumn, self.addColumn)

self._initLayer()
Expand Down Expand Up @@ -1396,8 +1394,8 @@ def UpdateDialog(self):
self.useColumn.SetValue(False)
self.OnCheckColumn(event=None)
self.useColumn.Enable(self.CheckMapset())

self.LoadTable()
else:
self.LoadTable()

self.btnPreview.Enable(enable)
self.btnOK.Enable(enable)
Expand Down Expand Up @@ -1447,6 +1445,7 @@ def DeleteTemporaryColumn(self):
def OnLayerSelection(self, event):
# reset choices in column selection comboboxes if layer changes
vlayer = int(self.layerSelect.GetStringSelection())
self._columnWidgetEvtHandler(bind=False)
self.sourceColumn.InsertColumns(
vector=self.inmap, layer=vlayer,
type=['integer', 'double precision'],
Expand Down Expand Up @@ -1485,6 +1484,8 @@ def OnLayerSelection(self, event):
self.properties['loadColumn'] = ''
self.properties['storeColumn'] = ''

self._columnWidgetEvtHandler()

if event:
self.LoadTable()
self.Update()
Expand Down Expand Up @@ -1867,6 +1868,33 @@ def _apply(self, updatePreview=True):

return ColorTable._apply(self, updatePreview)

def _columnWidgetEvtHandler(self, bind=True):
"""Bind/Unbind Column widgets handlers"""
widgets = [
{
'widget': self.sourceColumn,
'event': wx.EVT_TEXT,
'handler': self.OnSourceColumnSelection,
},
{
'widget': self.fromColumn,
'event': wx.EVT_TEXT,
'handler': self.OnFromColSelection,
},
{
'widget': self.toColumn,
'event': wx.EVT_TEXT,
'handler': self.OnToColSelection,
},
]
for widget in widgets:
if bind is True:
getattr(widget['widget'], 'Bind')(
widget['event'], widget['handler'],
)
else:
getattr(widget['widget'], 'Unbind')(widget['event'])


class ThematicVectorTable(VectorColorTable):

Expand Down

0 comments on commit 9b7398c

Please sign in to comment.