author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 15 May 2024 18:50:26 +0200 | |
changeset 3944 | ebd25bbe5a73 |
parent 3789 | 8def429216ca |
child 3970 | d73a477237ef |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1550
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1836
diff
changeset
|
25 |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
3546
diff
changeset
|
26 |
|
814 | 27 |
import wx |
28 |
||
29 |
from dialogs.BrowseLocationsDialog import BrowseLocationsDialog |
|
30 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
31 |
|
3789
8def429216ca
fix wxPyDeprecationWarnings
GP Orcullo <kinsamanka@gmail.com>
parents:
3765
diff
changeset
|
32 |
class LocationCellControl(wx.Control): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
33 |
|
814 | 34 |
''' |
35 |
Custom cell editor control with a text box and a button that launches |
|
36 |
the BrowseLocationsDialog. |
|
37 |
''' |
|
38 |
def __init__(self, parent): |
|
3789
8def429216ca
fix wxPyDeprecationWarnings
GP Orcullo <kinsamanka@gmail.com>
parents:
3765
diff
changeset
|
39 |
wx.Control.__init__(self, parent) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
40 |
|
814 | 41 |
main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) |
42 |
main_sizer.AddGrowableCol(0) |
|
43 |
main_sizer.AddGrowableRow(0) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
44 |
|
814 | 45 |
# create location text control |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
46 |
self.Location = wx.TextCtrl(self, size=wx.Size(0, -1), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
47 |
style=wx.TE_PROCESS_ENTER) |
814 | 48 |
self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2579
diff
changeset
|
49 |
main_sizer.Add(self.Location, flag=wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
50 |
|
814 | 51 |
# create browse button |
52 |
self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, -1)) |
|
53 |
self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2579
diff
changeset
|
54 |
main_sizer.Add(self.BrowseButton, flag=wx.GROW) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
55 |
|
814 | 56 |
self.Bind(wx.EVT_SIZE, self.OnSize) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
57 |
|
814 | 58 |
self.SetSizer(main_sizer) |
59 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
60 |
self.Controller = None |
814 | 61 |
self.VarType = None |
62 |
self.Default = False |
|
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
63 |
self.VariableName = None |
814 | 64 |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
65 |
def SetController(self, controller): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
66 |
self.Controller = controller |
814 | 67 |
|
68 |
def SetVarType(self, vartype): |
|
69 |
self.VarType = vartype |
|
70 |
||
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
71 |
def GetVarType(self): |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
72 |
return self.VarType |
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
73 |
|
814 | 74 |
def SetValue(self, value): |
75 |
self.Default = value |
|
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
76 |
self.VariableName = None |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
77 |
self.VarType = None |
814 | 78 |
self.Location.SetValue(value) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
79 |
|
814 | 80 |
def GetValue(self): |
81 |
return self.Location.GetValue() |
|
82 |
||
2573
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
1881
diff
changeset
|
83 |
def GetName(self): |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
1881
diff
changeset
|
84 |
return self.VariableName |
2579
8fb5c6eddc72
Conform to pep8 and pylint :
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2575
diff
changeset
|
85 |
|
814 | 86 |
def OnSize(self, event): |
87 |
self.Layout() |
|
88 |
||
89 |
def OnBrowseButtonClick(self, event): |
|
90 |
# pop up the location browser dialog |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
91 |
dialog = BrowseLocationsDialog(self, self.VarType, self.Controller) |
814 | 92 |
if dialog.ShowModal() == wx.ID_OK: |
93 |
infos = dialog.GetValues() |
|
1004
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
94 |
else: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
95 |
infos = None |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
96 |
dialog.Destroy() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
97 |
|
1004
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
98 |
if infos is not None: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
99 |
location = infos["location"] |
814 | 100 |
# set the location |
1004
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
101 |
if not infos["location"].startswith("%"): |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
102 |
dialog = wx.SingleChoiceDialog( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
103 |
self, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
104 |
_("Select a variable class:"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
105 |
_("Variable class"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
106 |
[_("Input"), _("Output"), _("Memory")], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
107 |
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL) |
1004
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
108 |
if dialog.ShowModal() == wx.ID_OK: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
109 |
selected = dialog.GetSelection() |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
110 |
else: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
111 |
selected = None |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
112 |
dialog.Destroy() |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
113 |
if selected is None: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
114 |
self.Location.SetFocus() |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
115 |
return |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
116 |
if selected == 0: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
117 |
location = "%I" + location |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
118 |
elif selected == 1: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
119 |
location = "%Q" + location |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
120 |
else: |
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
121 |
location = "%M" + location |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
122 |
|
1004
bf3b6998f7b6
Added support in LocationCellEditor for locations with undefined direction
Laurent Bessard
parents:
855
diff
changeset
|
123 |
self.Location.SetValue(location) |
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
124 |
self.VariableName = infos["var_name"] |
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
125 |
self.VarType = infos["IEC_type"] |
814 | 126 |
|
2575 | 127 |
# when user selected something, end editing immediately |
128 |
# so that changes over multiple colums appear |
|
129 |
wx.CallAfter(self.Parent.Parent.CloseEditControl) |
|
130 |
||
814 | 131 |
self.Location.SetFocus() |
132 |
||
133 |
def OnLocationChar(self, event): |
|
134 |
keycode = event.GetKeyCode() |
|
135 |
if keycode in [wx.WXK_RETURN, wx.WXK_TAB]: |
|
136 |
self.Parent.Parent.ProcessEvent(event) |
|
137 |
elif keycode == wx.WXK_ESCAPE: |
|
138 |
self.Location.SetValue(self.Default) |
|
139 |
self.Parent.Parent.CloseEditControl() |
|
140 |
else: |
|
141 |
event.Skip() |
|
142 |
||
143 |
def SetInsertionPoint(self, i): |
|
144 |
self.Location.SetInsertionPoint(i) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
145 |
|
814 | 146 |
def SetFocus(self): |
147 |
self.Location.SetFocus() |
|
148 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
149 |
|
3305
ca11385ea5e9
Depricated PyGridCellEditor becomes GridCellEditor
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3303
diff
changeset
|
150 |
class LocationCellEditor(wx.grid.GridCellEditor): |
814 | 151 |
''' |
152 |
Grid cell editor that uses LocationCellControl to display a browse button. |
|
153 |
''' |
|
154 |
def __init__(self, table, controller): |
|
3305
ca11385ea5e9
Depricated PyGridCellEditor becomes GridCellEditor
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3303
diff
changeset
|
155 |
wx.grid.GridCellEditor.__init__(self) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
156 |
|
814 | 157 |
self.Table = table |
158 |
self.Controller = controller |
|
159 |
||
160 |
def Create(self, parent, id, evt_handler): |
|
161 |
self.CellControl = LocationCellControl(parent) |
|
162 |
self.SetControl(self.CellControl) |
|
163 |
if evt_handler: |
|
164 |
self.CellControl.PushEventHandler(evt_handler) |
|
165 |
||
166 |
def BeginEdit(self, row, col, grid): |
|
167 |
self.CellControl.Enable() |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
168 |
self.CellControl.SetController(self.Controller) |
814 | 169 |
self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location')) |
170 |
if isinstance(self.CellControl, LocationCellControl): |
|
855
b30421d07e8c
Adding support for selecting variable type filtering in BrowseLocationsDialog and modify variable type when validated
Laurent Bessard
parents:
814
diff
changeset
|
171 |
self.CellControl.SetVarType(self.Table.GetValueByName(row, 'Type')) |
814 | 172 |
self.CellControl.SetFocus() |
173 |
||
3546
ee51d1deadfd
wxPython4 sequels: fix Wx exceptions ignored because no traceback
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3305
diff
changeset
|
174 |
def EndEdit(self, row, col, grid, old_loc): |
814 | 175 |
loc = self.CellControl.GetValue() |
176 |
changed = loc != old_loc |
|
177 |
if changed: |
|
2573
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
1881
diff
changeset
|
178 |
name = self.CellControl.GetName() |
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
179 |
if name is not None: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
180 |
message = self.Table.Parent.CheckVariableName(name, row) |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
181 |
if message is not None: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
182 |
wx.CallAfter(self.Table.Parent.ShowErrorMessage, message) |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
183 |
return None |
2579
8fb5c6eddc72
Conform to pep8 and pylint :
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2575
diff
changeset
|
184 |
old_name = self.Table.GetValueByName(row, 'Name') |
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
185 |
self.Table.SetValueByName(row, 'Name', name) |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
186 |
self.Table.Parent.OnVariableNameChange(old_name, name) |
814 | 187 |
self.Table.SetValueByName(row, 'Location', loc) |
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
188 |
var_type = self.CellControl.GetVarType() |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
189 |
if var_type is not None: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
190 |
self.Table.SetValueByName(row, 'Type', var_type) |
2575 | 191 |
else: |
192 |
wx.CallAfter(self.Table.Parent.ShowErrorMessage, |
|
2579
8fb5c6eddc72
Conform to pep8 and pylint :
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2575
diff
changeset
|
193 |
_("Selected location is identical to previous one")) |
814 | 194 |
self.CellControl.Disable() |
195 |
return changed |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
196 |
|
3546
ee51d1deadfd
wxPython4 sequels: fix Wx exceptions ignored because no traceback
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3305
diff
changeset
|
197 |
def ApplyEdit(self, row, col, grid): |
ee51d1deadfd
wxPython4 sequels: fix Wx exceptions ignored because no traceback
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3305
diff
changeset
|
198 |
pass |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1578
diff
changeset
|
199 |
|
814 | 200 |
def SetSize(self, rect): |
3789
8def429216ca
fix wxPyDeprecationWarnings
GP Orcullo <kinsamanka@gmail.com>
parents:
3765
diff
changeset
|
201 |
self.CellControl.SetSize(rect.x + 1, rect.y, |
8def429216ca
fix wxPyDeprecationWarnings
GP Orcullo <kinsamanka@gmail.com>
parents:
3765
diff
changeset
|
202 |
rect.width, rect.height, |
8def429216ca
fix wxPyDeprecationWarnings
GP Orcullo <kinsamanka@gmail.com>
parents:
3765
diff
changeset
|
203 |
wx.SIZE_ALLOW_MINUS_ONE) |
814 | 204 |
|
205 |
def Clone(self): |
|
206 |
return LocationCellEditor(self.Table, self.Controller) |