author | Laurent Bessard |
Wed, 08 May 2013 23:31:12 +0200 | |
changeset 1101 | 5a0b439cf576 |
parent 1082 | 5a08404d5dda |
child 1107 | 9303f6b900fe |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
7 |
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
import wx |
|
26 |
import wx.lib.buttons |
|
27 |
import wx.lib.agw.customtreectrl as CT |
|
28 |
||
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
29 |
try: |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
30 |
import matplotlib |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
31 |
matplotlib.use('WX') |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
32 |
USE_MPL = True |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
33 |
except: |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
34 |
USE_MPL = False |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
35 |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
36 |
from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION |
814 | 37 |
from util.BitmapLibrary import GetBitmap |
38 |
||
39 |
class PouInstanceVariablesPanel(wx.Panel): |
|
40 |
||
41 |
def __init__(self, parent, window, controller, debug): |
|
42 |
wx.Panel.__init__(self, name='PouInstanceTreePanel', |
|
43 |
parent=parent, pos=wx.Point(0, 0), |
|
44 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
45 |
||
46 |
self.ParentButton = wx.lib.buttons.GenBitmapButton(self, |
|
47 |
bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
48 |
self.ParentButton.SetToolTipString(_("Parent instance")) |
|
49 |
self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick, |
|
50 |
self.ParentButton) |
|
51 |
||
821
3667bb14aeca
Fix bug debug instance button not visible in PouInstanceVariablesPanel when instance path is too long
laurent
parents:
814
diff
changeset
|
52 |
self.InstanceChoice = wx.ComboBox(self, size=wx.Size(0, 0), style=wx.CB_READONLY) |
814 | 53 |
self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged, |
54 |
self.InstanceChoice) |
|
55 |
self.InstanceChoice.Bind(wx.EVT_LEFT_DOWN, self.OnInstanceChoiceLeftDown) |
|
56 |
||
57 |
self.DebugButton = wx.lib.buttons.GenBitmapButton(self, |
|
58 |
bitmap=GetBitmap("debug_instance"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
1082
5a08404d5dda
Fixed bug in PouInstanceVariablesPanel buttons tooltips
Laurent Bessard
parents:
1031
diff
changeset
|
59 |
self.DebugButton.SetToolTipString(_("Debug instance")) |
814 | 60 |
self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick, |
61 |
self.DebugButton) |
|
62 |
||
63 |
self.VariablesList = CT.CustomTreeCtrl(self, |
|
64 |
style=wx.SUNKEN_BORDER, |
|
65 |
agwStyle=CT.TR_NO_BUTTONS| |
|
66 |
CT.TR_SINGLE| |
|
67 |
CT.TR_HAS_VARIABLE_ROW_HEIGHT| |
|
68 |
CT.TR_HIDE_ROOT| |
|
69 |
CT.TR_NO_LINES| |
|
70 |
getattr(CT, "TR_ALIGN_WINDOWS_RIGHT", CT.TR_ALIGN_WINDOWS)) |
|
71 |
self.VariablesList.SetIndent(0) |
|
72 |
self.VariablesList.SetSpacing(5) |
|
73 |
self.VariablesList.DoSelectItem = lambda *x,**y:True |
|
74 |
self.VariablesList.Bind(CT.EVT_TREE_ITEM_ACTIVATED, |
|
75 |
self.OnVariablesListItemActivated) |
|
76 |
self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown) |
|
1031
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
77 |
self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown) |
814 | 78 |
|
79 |
buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0) |
|
80 |
buttons_sizer.AddWindow(self.ParentButton) |
|
81 |
buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW) |
|
82 |
buttons_sizer.AddWindow(self.DebugButton) |
|
83 |
buttons_sizer.AddGrowableCol(1) |
|
84 |
buttons_sizer.AddGrowableRow(0) |
|
85 |
||
86 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
87 |
main_sizer.AddSizer(buttons_sizer, flag=wx.GROW) |
|
88 |
main_sizer.AddWindow(self.VariablesList, flag=wx.GROW) |
|
89 |
main_sizer.AddGrowableCol(0) |
|
90 |
main_sizer.AddGrowableRow(1) |
|
91 |
||
92 |
self.SetSizer(main_sizer) |
|
93 |
||
94 |
self.ParentWindow = window |
|
95 |
self.Controller = controller |
|
96 |
self.Debug = debug |
|
97 |
if not self.Debug: |
|
98 |
self.DebugButton.Hide() |
|
99 |
||
100 |
self.PouTagName = None |
|
101 |
self.PouInfos = None |
|
102 |
self.PouInstance = None |
|
103 |
||
104 |
def __del__(self): |
|
105 |
self.Controller = None |
|
106 |
||
107 |
def SetTreeImageList(self, tree_image_list): |
|
108 |
self.VariablesList.SetImageList(tree_image_list) |
|
109 |
||
110 |
def SetController(self, controller): |
|
111 |
self.Controller = controller |
|
112 |
||
113 |
self.RefreshView() |
|
114 |
||
115 |
def SetPouType(self, tagname, pou_instance=None): |
|
915 | 116 |
if self.Controller is not None: |
117 |
self.PouTagName = tagname |
|
118 |
if self.PouTagName == "Project": |
|
119 |
config_name = self.Controller.GetProjectMainConfigurationName() |
|
120 |
if config_name is not None: |
|
121 |
self.PouTagName = self.Controller.ComputeConfigurationName(config_name) |
|
122 |
if pou_instance is not None: |
|
123 |
self.PouInstance = pou_instance |
|
814 | 124 |
|
125 |
self.RefreshView() |
|
126 |
||
127 |
def ResetView(self): |
|
128 |
self.Controller = None |
|
129 |
||
130 |
self.PouTagName = None |
|
131 |
self.PouInfos = None |
|
132 |
self.PouInstance = None |
|
133 |
||
134 |
self.RefreshView() |
|
135 |
||
136 |
def RefreshView(self): |
|
137 |
self.VariablesList.DeleteAllItems() |
|
138 |
self.InstanceChoice.Clear() |
|
139 |
self.InstanceChoice.SetValue("") |
|
140 |
||
141 |
if self.Controller is not None and self.PouTagName is not None: |
|
142 |
self.PouInfos = self.Controller.GetPouVariables(self.PouTagName, self.Debug) |
|
143 |
else: |
|
144 |
self.PouInfos = None |
|
145 |
if self.PouInfos is not None: |
|
146 |
root = self.VariablesList.AddRoot("") |
|
147 |
for var_infos in self.PouInfos["variables"]: |
|
148 |
if var_infos.get("type", None) is not None: |
|
149 |
text = "%(name)s (%(type)s)" % var_infos |
|
150 |
else: |
|
151 |
text = var_infos["name"] |
|
152 |
||
153 |
panel = wx.Panel(self.VariablesList) |
|
154 |
||
155 |
buttons = [] |
|
156 |
if var_infos["class"] in ITEMS_VARIABLE: |
|
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
157 |
if (not USE_MPL and var_infos["debug"] and self.Debug and |
814 | 158 |
(self.Controller.IsOfType(var_infos["type"], "ANY_NUM", True) or |
159 |
self.Controller.IsOfType(var_infos["type"], "ANY_BIT", True))): |
|
160 |
graph_button = wx.lib.buttons.GenBitmapButton(panel, |
|
161 |
bitmap=GetBitmap("instance_graph"), |
|
162 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
163 |
self.Bind(wx.EVT_BUTTON, self.GenGraphButtonCallback(var_infos), graph_button) |
|
164 |
buttons.append(graph_button) |
|
165 |
elif var_infos["edit"]: |
|
166 |
edit_button = wx.lib.buttons.GenBitmapButton(panel, |
|
167 |
bitmap=GetBitmap("edit"), |
|
168 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
169 |
self.Bind(wx.EVT_BUTTON, self.GenEditButtonCallback(var_infos), edit_button) |
|
170 |
buttons.append(edit_button) |
|
171 |
||
172 |
if var_infos["debug"] and self.Debug: |
|
173 |
debug_button = wx.lib.buttons.GenBitmapButton(panel, |
|
174 |
bitmap=GetBitmap("debug_instance"), |
|
175 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
176 |
self.Bind(wx.EVT_BUTTON, self.GenDebugButtonCallback(var_infos), debug_button) |
|
177 |
buttons.append(debug_button) |
|
178 |
||
179 |
button_num = len(buttons) |
|
180 |
if button_num > 0: |
|
181 |
panel.SetSize(wx.Size(button_num * 32, 28)) |
|
182 |
panel.SetBackgroundColour(self.VariablesList.GetBackgroundColour()) |
|
183 |
panel_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
184 |
panel.SetSizer(panel_sizer) |
|
185 |
||
186 |
for button in buttons: |
|
187 |
panel_sizer.AddWindow(button, 0, border=4, flag=wx.LEFT) |
|
188 |
panel_sizer.Layout() |
|
189 |
||
190 |
else: |
|
191 |
panel.Destroy() |
|
192 |
panel = None |
|
193 |
||
194 |
item = self.VariablesList.AppendItem(root, text, wnd=panel) |
|
195 |
self.VariablesList.SetItemImage(item, self.ParentWindow.GetTreeImage(var_infos["class"])) |
|
196 |
self.VariablesList.SetPyData(item, var_infos) |
|
197 |
||
198 |
instances = self.Controller.SearchPouInstances(self.PouTagName, self.Debug) |
|
199 |
for instance in instances: |
|
200 |
self.InstanceChoice.Append(instance) |
|
201 |
if len(instances) == 1: |
|
202 |
self.PouInstance = instances[0] |
|
203 |
if self.PouInfos["class"] in [ITEM_CONFIGURATION, ITEM_RESOURCE]: |
|
204 |
self.PouInstance = None |
|
205 |
self.InstanceChoice.SetSelection(0) |
|
206 |
elif self.PouInstance in instances: |
|
207 |
self.InstanceChoice.SetStringSelection(self.PouInstance) |
|
208 |
else: |
|
209 |
self.PouInstance = None |
|
210 |
self.InstanceChoice.SetValue(_("Select an instance")) |
|
211 |
||
212 |
self.RefreshButtons() |
|
213 |
||
214 |
def RefreshButtons(self): |
|
215 |
enabled = self.InstanceChoice.GetSelection() != -1 |
|
216 |
self.ParentButton.Enable(enabled and self.PouInfos["class"] != ITEM_CONFIGURATION) |
|
217 |
self.DebugButton.Enable(enabled and self.PouInfos["debug"] and self.Debug) |
|
218 |
||
219 |
root = self.VariablesList.GetRootItem() |
|
220 |
if root is not None and root.IsOk(): |
|
221 |
item, item_cookie = self.VariablesList.GetFirstChild(root) |
|
222 |
while item is not None and item.IsOk(): |
|
223 |
panel = self.VariablesList.GetItemWindow(item) |
|
224 |
if panel is not None: |
|
225 |
for child in panel.GetChildren(): |
|
226 |
if child.GetName() != "edit": |
|
227 |
child.Enable(enabled) |
|
228 |
item, item_cookie = self.VariablesList.GetNextChild(root, item_cookie) |
|
229 |
||
230 |
def GenEditButtonCallback(self, infos): |
|
231 |
def EditButtonCallback(event): |
|
232 |
var_class = infos["class"] |
|
233 |
if var_class == ITEM_RESOURCE: |
|
234 |
tagname = self.Controller.ComputeConfigurationResourceName( |
|
235 |
self.InstanceChoice.GetStringSelection(), |
|
236 |
infos["name"]) |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
237 |
elif var_class == ITEM_TRANSITION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
238 |
tagname = self.Controller.ComputePouTransitionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
239 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
240 |
infos["name"]) |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
241 |
elif var_class == ITEM_ACTION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
242 |
tagname = self.Controller.ComputePouActionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
243 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
244 |
infos["name"]) |
814 | 245 |
else: |
246 |
var_class = ITEM_POU |
|
247 |
tagname = self.Controller.ComputePouName(infos["type"]) |
|
248 |
self.ParentWindow.EditProjectElement(var_class, tagname) |
|
249 |
event.Skip() |
|
250 |
return EditButtonCallback |
|
251 |
||
252 |
def GenDebugButtonCallback(self, infos): |
|
253 |
def DebugButtonCallback(event): |
|
254 |
if self.InstanceChoice.GetSelection() != -1: |
|
255 |
var_class = infos["class"] |
|
256 |
var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
|
257 |
infos["name"]) |
|
258 |
if var_class in ITEMS_VARIABLE: |
|
259 |
self.ParentWindow.AddDebugVariable(var_path, force=True) |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
260 |
elif var_class == ITEM_TRANSITION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
261 |
self.ParentWindow.OpenDebugViewer( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
262 |
var_class, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
263 |
var_path, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
264 |
self.Controller.ComputePouTransitionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
265 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
266 |
infos["name"])) |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
267 |
elif var_class == ITEM_ACTION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
268 |
self.ParentWindow.OpenDebugViewer( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
269 |
var_class, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
270 |
var_path, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
271 |
self.Controller.ComputePouActionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
272 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
273 |
infos["name"])) |
814 | 274 |
else: |
275 |
self.ParentWindow.OpenDebugViewer( |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
276 |
var_class, |
814 | 277 |
var_path, |
278 |
self.Controller.ComputePouName(infos["type"])) |
|
279 |
event.Skip() |
|
280 |
return DebugButtonCallback |
|
281 |
||
282 |
def GenGraphButtonCallback(self, infos): |
|
283 |
def GraphButtonCallback(event): |
|
284 |
if self.InstanceChoice.GetSelection() != -1: |
|
285 |
if infos["class"] in ITEMS_VARIABLE: |
|
286 |
var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
|
287 |
infos["name"]) |
|
885
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
826
diff
changeset
|
288 |
self.ParentWindow.OpenDebugViewer(infos["class"], var_path, infos["type"]) |
814 | 289 |
event.Skip() |
290 |
return GraphButtonCallback |
|
291 |
||
292 |
def ShowInstanceChoicePopup(self): |
|
293 |
self.InstanceChoice.SetFocusFromKbd() |
|
294 |
size = self.InstanceChoice.GetSize() |
|
295 |
event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) |
|
296 |
event.m_x = size.width / 2 |
|
297 |
event.m_y = size.height / 2 |
|
298 |
event.SetEventObject(self.InstanceChoice) |
|
299 |
#event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) |
|
300 |
#event.m_keyCode = wx.WXK_SPACE |
|
301 |
self.InstanceChoice.GetEventHandler().ProcessEvent(event) |
|
302 |
||
303 |
def OnParentButtonClick(self, event): |
|
304 |
if self.InstanceChoice.GetSelection() != -1: |
|
305 |
parent_path = self.InstanceChoice.GetStringSelection().rsplit(".", 1)[0] |
|
306 |
tagname = self.Controller.GetPouInstanceTagName(parent_path, self.Debug) |
|
307 |
if tagname is not None: |
|
308 |
wx.CallAfter(self.SetPouType, tagname, parent_path) |
|
309 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname) |
|
310 |
event.Skip() |
|
311 |
||
312 |
def OnInstanceChoiceChanged(self, event): |
|
313 |
self.RefreshButtons() |
|
314 |
event.Skip() |
|
315 |
||
316 |
def OnDebugButtonClick(self, event): |
|
317 |
if self.InstanceChoice.GetSelection() != -1: |
|
318 |
self.ParentWindow.OpenDebugViewer( |
|
319 |
self.PouInfos["class"], |
|
320 |
self.InstanceChoice.GetStringSelection(), |
|
321 |
self.PouTagName) |
|
322 |
event.Skip() |
|
323 |
||
324 |
def OnVariablesListItemActivated(self, event): |
|
325 |
if self.InstanceChoice.GetSelection() != -1: |
|
326 |
instance_path = self.InstanceChoice.GetStringSelection() |
|
327 |
selected_item = event.GetItem() |
|
328 |
if selected_item is not None and selected_item.IsOk(): |
|
329 |
item_infos = self.VariablesList.GetPyData(selected_item) |
|
330 |
if item_infos is not None and item_infos["class"] not in ITEMS_VARIABLE: |
|
331 |
if item_infos["class"] == ITEM_RESOURCE: |
|
332 |
tagname = self.Controller.ComputeConfigurationResourceName( |
|
333 |
instance_path, |
|
334 |
item_infos["name"]) |
|
335 |
else: |
|
336 |
tagname = self.Controller.ComputePouName(item_infos["type"]) |
|
337 |
item_path = "%s.%s" % (instance_path, item_infos["name"]) |
|
338 |
wx.CallAfter(self.SetPouType, tagname, item_path) |
|
339 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname) |
|
340 |
event.Skip() |
|
341 |
||
342 |
def OnVariablesListLeftDown(self, event): |
|
343 |
if self.InstanceChoice.GetSelection() == -1: |
|
344 |
wx.CallAfter(self.ShowInstanceChoicePopup) |
|
898
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
345 |
else: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
346 |
instance_path = self.InstanceChoice.GetStringSelection() |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
347 |
item, flags = self.VariablesList.HitTest(event.GetPosition()) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
348 |
if item is not None and flags & CT.TREE_HITTEST_ONITEMLABEL: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
349 |
item_infos = self.VariablesList.GetPyData(item) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
350 |
if item_infos is not None and item_infos["class"] in ITEMS_VARIABLE: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
351 |
item_path = "%s.%s" % (instance_path, item_infos["name"]) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
352 |
data = wx.TextDataObject(str((item_path, "debug"))) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
353 |
dragSource = wx.DropSource(self.VariablesList) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
354 |
dragSource.SetData(data) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
355 |
dragSource.DoDragDrop() |
814 | 356 |
event.Skip() |
1031
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
357 |
|
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
358 |
def OnVariablesListKeyDown(self, event): |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
359 |
keycode = event.GetKeyCode() |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
360 |
if keycode != wx.WXK_LEFT: |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
361 |
event.Skip() |
814 | 362 |
|
363 |
def OnInstanceChoiceLeftDown(self, event): |
|
364 |
event.Skip() |