author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Tue, 22 Dec 2020 18:05:05 +0100 | |
changeset 2711 | ecfb59e4ecb0 |
parent 2614 | 6b4061f6ced6 |
child 2737 | 38afed869ff6 |
permissions | -rw-r--r-- |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
1 |
#!/usr/bin/env python |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
3 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
6 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
8 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
10 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
15 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
19 |
# GNU General Public License for more details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
20 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
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:
1878
diff
changeset
|
25 |
from __future__ import absolute_import |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
26 |
from __future__ import division |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
27 |
import sys |
1783
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
28 |
import base64 |
2457
9deec258ab1a
python3 support: pylint, W1633 # (round-builtin) round built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2450
diff
changeset
|
29 |
from future.builtins import \ |
9deec258ab1a
python3 support: pylint, W1633 # (round-builtin) round built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2450
diff
changeset
|
30 |
round, \ |
9deec258ab1a
python3 support: pylint, W1633 # (round-builtin) round built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2450
diff
changeset
|
31 |
str as text |
814 | 32 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
33 |
import wx |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
34 |
import wx.grid |
814 | 35 |
import wx.aui |
2432
dbc065a2f7a5
python3 support: pylint, W1613 # (xrange-builtin) xrange built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2431
diff
changeset
|
36 |
from six.moves import cPickle, xrange |
814 | 37 |
|
38 |
from editors.EditorPanel import EditorPanel |
|
39 |
from editors.SFCViewer import SFC_Viewer |
|
40 |
from editors.LDViewer import LD_Viewer |
|
41 |
from editors.TextViewer import TextViewer |
|
42 |
from editors.Viewer import Viewer, ZOOM_FACTORS |
|
43 |
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor |
|
44 |
from editors.DataTypeEditor import DataTypeEditor |
|
45 |
from PLCControler import * |
|
1193
59c196884fec
Moved and start to rewrite DebugVariablePanel splitting it into multiple files
Laurent Bessard
parents:
1188
diff
changeset
|
46 |
from controls import CustomTree, LibraryPanel, PouInstanceVariablesPanel, SearchResultPanel |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1193
diff
changeset
|
47 |
from controls.DebugVariablePanel import DebugVariablePanel |
819 | 48 |
from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog |
814 | 49 |
from util.BitmapLibrary import GetBitmap |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
50 |
from plcopen.types_enums import * |
814 | 51 |
|
52 |
# Define PLCOpenEditor controls id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
53 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
54 |
ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
55 |
ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
56 |
ID_PLCOPENEDITORPROJECTTREE, ID_PLCOPENEDITORMAINSPLITTER, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
57 |
ID_PLCOPENEDITORSECONDSPLITTER, ID_PLCOPENEDITORTHIRDSPLITTER, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
58 |
ID_PLCOPENEDITORLIBRARYPANEL, ID_PLCOPENEDITORLIBRARYSEARCHCTRL, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
59 |
ID_PLCOPENEDITORLIBRARYTREE, ID_PLCOPENEDITORLIBRARYCOMMENT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
60 |
ID_PLCOPENEDITORTABSOPENED, ID_PLCOPENEDITORTABSOPENED, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
61 |
ID_PLCOPENEDITOREDITORMENUTOOLBAR, ID_PLCOPENEDITOREDITORTOOLBAR, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
62 |
ID_PLCOPENEDITORPROJECTPANEL, |
814 | 63 |
] = [wx.NewId() for _init_ctrls in range(17)] |
64 |
||
65 |
# Define PLCOpenEditor EditMenu extra items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
66 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
67 |
ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, ID_PLCOPENEDITOREDITMENUADDDATATYPE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
68 |
ID_PLCOPENEDITOREDITMENUADDFUNCTION, ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
69 |
ID_PLCOPENEDITOREDITMENUADDPROGRAM, ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
70 |
ID_PLCOPENEDITOREDITMENUFINDNEXT, ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
71 |
ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, ID_PLCOPENEDITOREDITMENUADDRESOURCE |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1364
diff
changeset
|
72 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(10)] |
814 | 73 |
|
74 |
# Define PLCOpenEditor DisplayMenu extra items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
75 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
76 |
ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
77 |
ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE, |
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
78 |
ID_PLCOPENEDITORDISPLAYMENUFULLSCREEN, |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
79 |
] = [wx.NewId() for _init_coll_DisplayMenu_Items in range(3)] |
814 | 80 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
81 |
# ------------------------------------------------------------------------------- |
814 | 82 |
# EditorToolBar definitions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
83 |
# ------------------------------------------------------------------------------- |
814 | 84 |
|
85 |
# Define PLCOpenEditor Toolbar items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
86 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
87 |
ID_PLCOPENEDITOREDITORTOOLBARSELECTION, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
88 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
89 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, ID_PLCOPENEDITOREDITORTOOLBARWIRE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
90 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, ID_PLCOPENEDITOREDITORTOOLBARRUNG, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
91 |
ID_PLCOPENEDITOREDITORTOOLBARCOIL, ID_PLCOPENEDITOREDITORTOOLBARCONTACT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
92 |
ID_PLCOPENEDITOREDITORTOOLBARBRANCH, ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
93 |
ID_PLCOPENEDITOREDITORTOOLBARSTEP, ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
94 |
ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
95 |
ID_PLCOPENEDITOREDITORTOOLBARJUMP, ID_PLCOPENEDITOREDITORTOOLBARMOTION, |
814 | 96 |
] = [wx.NewId() for _init_coll_DefaultEditorToolBar_Items in range(18)] |
97 |
||
98 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
99 |
# ------------------------------------------------------------------------------- |
814 | 100 |
# Helper Functions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
101 |
# ------------------------------------------------------------------------------- |
814 | 102 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
103 |
|
814 | 104 |
def EncodeFileSystemPath(path, use_base64=True): |
105 |
path = path.encode(sys.getfilesystemencoding()) |
|
106 |
if use_base64: |
|
107 |
return base64.encodestring(path) |
|
108 |
return path |
|
109 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
110 |
|
814 | 111 |
def DecodeFileSystemPath(path, is_base64=True): |
112 |
if is_base64: |
|
113 |
path = base64.decodestring(path) |
|
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
114 |
return text(path, sys.getfilesystemencoding()) |
814 | 115 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
116 |
|
814 | 117 |
def AppendMenu(parent, help, id, kind, text): |
2177
10aa87518401
Drop support for wxPython 2.6 and below
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2169
diff
changeset
|
118 |
parent.Append(help=help, id=id, kind=kind, text=text) |
814 | 119 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
120 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
121 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
122 |
TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
123 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
814 | 124 |
] = range(10) |
125 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
126 |
|
814 | 127 |
def GetShortcutKeyCallbackFunction(viewer_function): |
128 |
def ShortcutKeyFunction(self, event): |
|
129 |
control = self.FindFocus() |
|
130 |
if control is not None and control.GetName() in ["Viewer", "TextViewer"]: |
|
131 |
getattr(control.ParentWindow, viewer_function)() |
|
132 |
elif isinstance(control, wx.stc.StyledTextCtrl): |
|
133 |
getattr(control, viewer_function)() |
|
134 |
elif isinstance(control, wx.TextCtrl): |
|
135 |
control.ProcessEvent(event) |
|
136 |
return ShortcutKeyFunction |
|
137 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
138 |
|
814 | 139 |
def GetDeleteElementFunction(remove_function, parent_type=None, check_function=None): |
140 |
def DeleteElementFunction(self, selected): |
|
141 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
142 |
if check_function is None or check_function(name): |
814 | 143 |
if parent_type is not None: |
144 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
145 |
parent_name = item_infos["tagname"].split("::")[1] |
|
146 |
remove_function(self.Controler, parent_name, name) |
|
147 |
else: |
|
148 |
remove_function(self.Controler, name) |
|
149 |
return DeleteElementFunction |
|
150 |
||
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
151 |
|
814 | 152 |
if wx.Platform == '__WXMSW__': |
153 |
TAB_BORDER = 6 |
|
154 |
NOTEBOOK_BORDER = 6 |
|
155 |
else: |
|
156 |
TAB_BORDER = 7 |
|
157 |
NOTEBOOK_BORDER = 2 |
|
158 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
159 |
|
814 | 160 |
def SimplifyTabLayout(tabs, rect): |
161 |
for tab in tabs: |
|
162 |
if tab["pos"][0] == rect.x: |
|
163 |
others = [t for t in tabs if t != tab] |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
164 |
others.sort(lambda x, y: cmp(x["pos"][0], y["pos"][0])) |
814 | 165 |
for other in others: |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
166 |
if other["pos"][1] == tab["pos"][1] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
167 |
other["size"][1] == tab["size"][1] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
168 |
other["pos"][0] == tab["pos"][0] + tab["size"][0] + TAB_BORDER: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
169 |
|
814 | 170 |
tab["size"] = (tab["size"][0] + other["size"][0] + TAB_BORDER, tab["size"][1]) |
171 |
tab["pages"].extend(other["pages"]) |
|
172 |
tabs.remove(other) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
173 |
|
814 | 174 |
if tab["size"][0] == rect.width: |
175 |
return True |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
176 |
|
814 | 177 |
elif tab["pos"][1] == rect.y: |
178 |
others = [t for t in tabs if t != tab] |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
179 |
others.sort(lambda x, y: cmp(x["pos"][1], y["pos"][1])) |
814 | 180 |
for other in others: |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
181 |
if other["pos"][0] == tab["pos"][0] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
182 |
other["size"][0] == tab["size"][0] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
183 |
other["pos"][1] == tab["pos"][1] + tab["size"][1] + TAB_BORDER: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
184 |
|
814 | 185 |
tab["size"] = (tab["size"][0], tab["size"][1] + other["size"][1] + TAB_BORDER) |
186 |
tab["pages"].extend(other["pages"]) |
|
187 |
tabs.remove(other) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
188 |
|
814 | 189 |
if tab["size"][1] == rect.height: |
190 |
return True |
|
191 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
192 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
193 |
|
814 | 194 |
def ComputeTabsLayout(tabs, rect): |
195 |
if len(tabs) == 0: |
|
196 |
return tabs |
|
197 |
if len(tabs) == 1: |
|
198 |
return tabs[0] |
|
199 |
split = None |
|
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
200 |
split_id = None |
814 | 201 |
for idx, tab in enumerate(tabs): |
202 |
if len(tab["pages"]) == 0: |
|
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1763
diff
changeset
|
203 |
raise ValueError("Not possible") |
814 | 204 |
if tab["size"][0] == rect.width: |
205 |
if tab["pos"][1] == rect.y: |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
206 |
split = (wx.TOP, tab["size"][1] / rect.height) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
207 |
split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER, |
814 | 208 |
rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
209 |
elif tab["pos"][1] == rect.height + 1 - tab["size"][1]: |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
210 |
split = (wx.BOTTOM, 1.0 - tab["size"][1] / rect.height) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
211 |
split_rect = wx.Rect(rect.x, rect.y, |
814 | 212 |
rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
213 |
split_id = idx |
814 | 214 |
break |
215 |
elif tab["size"][1] == rect.height: |
|
216 |
if tab["pos"][0] == rect.x: |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
217 |
split = (wx.LEFT, tab["size"][0] / rect.width) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
218 |
split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y, |
814 | 219 |
rect.width - tab["size"][0] - TAB_BORDER, rect.height) |
220 |
elif tab["pos"][0] == rect.width + 1 - tab["size"][0]: |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
221 |
split = (wx.RIGHT, 1.0 - tab["size"][0] / rect.width) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
222 |
split_rect = wx.Rect(rect.x, rect.y, |
814 | 223 |
rect.width - tab["size"][0] - TAB_BORDER, rect.height) |
2169
baa0c5111457
fix type introduced by f33942053466 (fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'")
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2167
diff
changeset
|
224 |
split_id = idx |
814 | 225 |
break |
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
226 |
if split is not None: |
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
227 |
split_tab = tabs.pop(split_id) |
814 | 228 |
return {"split": split, |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
229 |
"tab": split_tab, |
814 | 230 |
"others": ComputeTabsLayout(tabs, split_rect)} |
231 |
else: |
|
232 |
if SimplifyTabLayout(tabs, rect): |
|
233 |
return ComputeTabsLayout(tabs, rect) |
|
234 |
return tabs |
|
235 |
||
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
236 |
|
814 | 237 |
class IDEFrame(wx.Frame): |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
238 |
"""IDEFrame Base Class""" |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
239 |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
240 |
def InitEditorToolbarItems(self): |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
241 |
""" |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
242 |
Initialize dictionary with lists of elements that need to be shown |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
243 |
if POU in particular programming language is edited. |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
244 |
""" |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
245 |
# Define behaviour of each Toolbar item according to current POU body type |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
246 |
# Informations meaning are in this order: |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
247 |
# - Item is toggled |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
248 |
# - PLCOpenEditor mode where item is displayed (could be more then one) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
249 |
# - Item id |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
250 |
# - Item callback function name |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
251 |
# - Item icon filename |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
252 |
# - Item tooltip text |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
253 |
self.EditorToolBarItems = { |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
254 |
"FBD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
255 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
256 |
"move", _("Move the view")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
257 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
258 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
259 |
"add_comment", _("Create a new comment")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
260 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
261 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
262 |
"add_variable", _("Create a new variable")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
263 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
264 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
265 |
"add_block", _("Create a new block")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
266 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
267 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
268 |
"add_connection", _("Create a new connection"))], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
269 |
"LD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
270 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
271 |
"move", _("Move the view")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
272 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
273 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
274 |
"add_comment", _("Create a new comment")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
275 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
276 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
277 |
"add_powerrail", _("Create a new power rail")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
278 |
(False, DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
279 |
ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
280 |
"add_rung", _("Create a new rung")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
281 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
282 |
ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
283 |
"add_coil", _("Create a new coil")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
284 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
285 |
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
286 |
"add_contact", _("Create a new contact")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
287 |
(False, DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
288 |
ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
289 |
"add_branch", _("Create a new branch")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
290 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
291 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
292 |
"add_variable", _("Create a new variable")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
293 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
294 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
295 |
"add_block", _("Create a new block")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
296 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
297 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
298 |
"add_connection", _("Create a new connection"))], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
299 |
"SFC": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
300 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
301 |
"move", _("Move the view")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
302 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
303 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
304 |
"add_comment", _("Create a new comment")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
305 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
306 |
ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
307 |
"add_initial_step", _("Create a new initial step")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
308 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
309 |
ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
310 |
"add_step", _("Create a new step")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
311 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
312 |
ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
313 |
"add_transition", _("Create a new transition")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
314 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
315 |
ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
316 |
"add_action", _("Create a new action block")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
317 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
318 |
ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
319 |
"add_divergence", _("Create a new divergence")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
320 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
321 |
ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
322 |
"add_jump", _("Create a new jump")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
323 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
324 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
325 |
"add_variable", _("Create a new variable")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
326 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
327 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
328 |
"add_block", _("Create a new block")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
329 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
330 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
331 |
"add_connection", _("Create a new connection")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
332 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
333 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
334 |
"add_powerrail", _("Create a new power rail")), |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
335 |
(True, FREEDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
336 |
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
337 |
"add_contact", _("Create a new contact"))], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
338 |
"ST": [], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
339 |
"IL": [], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
340 |
"debug": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
341 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
342 |
"move", _("Move the view"))], |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
343 |
} |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
344 |
|
814 | 345 |
def _init_coll_MenuBar_Menus(self, parent): |
346 |
parent.Append(menu=self.FileMenu, title=_(u'&File')) |
|
347 |
parent.Append(menu=self.EditMenu, title=_(u'&Edit')) |
|
348 |
parent.Append(menu=self.DisplayMenu, title=_(u'&Display')) |
|
349 |
parent.Append(menu=self.HelpMenu, title=_(u'&Help')) |
|
350 |
||
351 |
def _init_coll_FileMenu_Items(self, parent): |
|
352 |
pass |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
353 |
|
814 | 354 |
def _init_coll_AddMenu_Items(self, parent, add_config=True): |
355 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDDATATYPE, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
356 |
kind=wx.ITEM_NORMAL, text=_(u'&Data Type')) |
814 | 357 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTION, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
358 |
kind=wx.ITEM_NORMAL, text=_(u'&Function')) |
814 | 359 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
360 |
kind=wx.ITEM_NORMAL, text=_(u'Function &Block')) |
814 | 361 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDPROGRAM, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
362 |
kind=wx.ITEM_NORMAL, text=_(u'&Program')) |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1364
diff
changeset
|
363 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDRESOURCE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
364 |
kind=wx.ITEM_NORMAL, text=_(u'&Resource')) |
814 | 365 |
if add_config: |
366 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
367 |
kind=wx.ITEM_NORMAL, text=_(u'&Configuration')) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
368 |
|
814 | 369 |
def _init_coll_EditMenu_Items(self, parent): |
370 |
AppendMenu(parent, help='', id=wx.ID_UNDO, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
371 |
kind=wx.ITEM_NORMAL, text=_(u'Undo') + '\tCTRL+Z') |
814 | 372 |
AppendMenu(parent, help='', id=wx.ID_REDO, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
373 |
kind=wx.ITEM_NORMAL, text=_(u'Redo') + '\tCTRL+Y') |
814 | 374 |
parent.AppendSeparator() |
375 |
AppendMenu(parent, help='', id=wx.ID_CUT, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
376 |
kind=wx.ITEM_NORMAL, text=_(u'Cut') + '\tCTRL+X') |
814 | 377 |
AppendMenu(parent, help='', id=wx.ID_COPY, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
378 |
kind=wx.ITEM_NORMAL, text=_(u'Copy') + '\tCTRL+C') |
814 | 379 |
AppendMenu(parent, help='', id=wx.ID_PASTE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
380 |
kind=wx.ITEM_NORMAL, text=_(u'Paste') + '\tCTRL+V') |
814 | 381 |
parent.AppendSeparator() |
382 |
AppendMenu(parent, help='', id=wx.ID_FIND, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
383 |
kind=wx.ITEM_NORMAL, text=_(u'Find') + '\tCTRL+F') |
814 | 384 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUFINDNEXT, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
385 |
kind=wx.ITEM_NORMAL, text=_(u'Find Next') + '\tCTRL+K') |
814 | 386 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
387 |
kind=wx.ITEM_NORMAL, text=_(u'Find Previous') + '\tCTRL+SHIFT+K') |
814 | 388 |
parent.AppendSeparator() |
389 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
390 |
kind=wx.ITEM_NORMAL, text=_(u'Search in Project') + '\tCTRL+SHIFT+F') |
814 | 391 |
parent.AppendSeparator() |
392 |
add_menu = wx.Menu(title='') |
|
393 |
self._init_coll_AddMenu_Items(add_menu) |
|
394 |
parent.AppendMenu(wx.ID_ADD, _(u"&Add Element"), add_menu) |
|
395 |
AppendMenu(parent, help='', id=wx.ID_SELECTALL, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
396 |
kind=wx.ITEM_NORMAL, text=_(u'Select All') + '\tCTRL+A') |
814 | 397 |
AppendMenu(parent, help='', id=wx.ID_DELETE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
398 |
kind=wx.ITEM_NORMAL, text=_(u'&Delete')) |
814 | 399 |
self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
400 |
self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
401 |
# self.Bind(wx.EVT_MENU, self.OnEnableUndoRedoMenu, id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO) |
814 | 402 |
self.Bind(wx.EVT_MENU, self.OnCutMenu, id=wx.ID_CUT) |
403 |
self.Bind(wx.EVT_MENU, self.OnCopyMenu, id=wx.ID_COPY) |
|
404 |
self.Bind(wx.EVT_MENU, self.OnPasteMenu, id=wx.ID_PASTE) |
|
405 |
self.Bind(wx.EVT_MENU, self.OnFindMenu, id=wx.ID_FIND) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
406 |
self.Bind(wx.EVT_MENU, self.OnFindNextMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
407 |
id=ID_PLCOPENEDITOREDITMENUFINDNEXT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
408 |
self.Bind(wx.EVT_MENU, self.OnFindPreviousMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
409 |
id=ID_PLCOPENEDITOREDITMENUFINDPREVIOUS) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
410 |
self.Bind(wx.EVT_MENU, self.OnSearchInProjectMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
411 |
id=ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT) |
814 | 412 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
413 |
id=ID_PLCOPENEDITOREDITMENUADDDATATYPE) |
814 | 414 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("function"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
415 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTION) |
814 | 416 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("functionBlock"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
417 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK) |
814 | 418 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("program"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
419 |
id=ID_PLCOPENEDITOREDITMENUADDPROGRAM) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
420 |
self.Bind(wx.EVT_MENU, self.AddResourceMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
421 |
id=ID_PLCOPENEDITOREDITMENUADDRESOURCE) |
814 | 422 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
423 |
id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION) |
814 | 424 |
self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL) |
425 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
426 |
|
814 | 427 |
self.AddToMenuToolBar([(wx.ID_UNDO, "undo", _(u'Undo'), None), |
428 |
(wx.ID_REDO, "redo", _(u'Redo'), None), |
|
429 |
None, |
|
430 |
(wx.ID_CUT, "cut", _(u'Cut'), None), |
|
431 |
(wx.ID_COPY, "copy", _(u'Copy'), None), |
|
432 |
(wx.ID_PASTE, "paste", _(u'Paste'), None), |
|
433 |
None, |
|
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
434 |
(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find", _(u'Search in Project'), None), |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
435 |
(ID_PLCOPENEDITORDISPLAYMENUFULLSCREEN, "fullscreen", _(u'Toggle fullscreen mode'), None)]) |
814 | 436 |
|
437 |
def _init_coll_DisplayMenu_Items(self, parent): |
|
438 |
AppendMenu(parent, help='', id=wx.ID_REFRESH, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
439 |
kind=wx.ITEM_NORMAL, text=_(u'Refresh') + '\tCTRL+R') |
814 | 440 |
if self.EnableDebug: |
441 |
AppendMenu(parent, help='', id=wx.ID_CLEAR, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
442 |
kind=wx.ITEM_NORMAL, text=_(u'Clear Errors') + '\tCTRL+K') |
814 | 443 |
parent.AppendSeparator() |
444 |
zoommenu = wx.Menu(title='') |
|
445 |
parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu) |
|
446 |
for idx, value in enumerate(ZOOM_FACTORS): |
|
447 |
new_id = wx.NewId() |
|
448 |
AppendMenu(zoommenu, help='', id=new_id, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
449 |
kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%") |
814 | 450 |
self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
451 |
|
814 | 452 |
parent.AppendSeparator() |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
453 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE, |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
454 |
kind=wx.ITEM_NORMAL, text=_(u'Switch perspective') + '\tF12') |
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
455 |
self.Bind(wx.EVT_MENU, self.SwitchPerspective, id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE) |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
456 |
|
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
457 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUFULLSCREEN, |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
458 |
kind=wx.ITEM_NORMAL, text=_(u'Full screen') + '\tShift-F12') |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
459 |
self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=ID_PLCOPENEDITORDISPLAYMENUFULLSCREEN) |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
460 |
|
814 | 461 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
462 |
kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective')) |
814 | 463 |
self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
464 |
|
814 | 465 |
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
466 |
if self.EnableDebug: |
|
467 |
self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
468 |
|
814 | 469 |
def _init_coll_HelpMenu_Items(self, parent): |
470 |
pass |
|
471 |
||
472 |
def _init_utils(self): |
|
473 |
self.MenuBar = wx.MenuBar() |
|
474 |
||
475 |
self.FileMenu = wx.Menu(title='') |
|
476 |
self.EditMenu = wx.Menu(title='') |
|
477 |
self.DisplayMenu = wx.Menu(title='') |
|
478 |
self.HelpMenu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
479 |
|
814 | 480 |
self._init_coll_MenuBar_Menus(self.MenuBar) |
481 |
self._init_coll_FileMenu_Items(self.FileMenu) |
|
482 |
self._init_coll_EditMenu_Items(self.EditMenu) |
|
483 |
self._init_coll_DisplayMenu_Items(self.DisplayMenu) |
|
484 |
self._init_coll_HelpMenu_Items(self.HelpMenu) |
|
485 |
||
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
486 |
def _init_icon(self, parent): |
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
487 |
if self.icon: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
488 |
self.SetIcon(self.icon) |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
489 |
elif parent and parent.icon: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
490 |
self.SetIcon(parent.icon) |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
491 |
|
814 | 492 |
def _init_ctrls(self, prnt): |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
493 |
self._init_icon(prnt) |
814 | 494 |
self.SetClientSize(wx.Size(1000, 600)) |
495 |
self.Bind(wx.EVT_ACTIVATE, self.OnActivated) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
496 |
|
814 | 497 |
self.TabsImageList = wx.ImageList(31, 16) |
498 |
self.TabsImageListIndexes = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
499 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
500 |
# ----------------------------------------------------------------------- |
814 | 501 |
# Creating main structure |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
502 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
503 |
|
814 | 504 |
self.AUIManager = wx.aui.AuiManager(self) |
505 |
self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
|
506 |
self.Panes = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
507 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
508 |
self.LeftNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
509 |
self, ID_PLCOPENEDITORLEFTNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
510 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
511 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
512 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
513 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
514 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
515 |
self.LeftNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
516 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
517 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
518 |
self.LeftNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
519 |
wx.aui.AuiPaneInfo().Name("ProjectPane").Left().Layer(1). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
520 |
BestSize(wx.Size(300, 500)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
521 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
522 |
self.BottomNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
523 |
self, ID_PLCOPENEDITORBOTTOMNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
524 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
525 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
526 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
527 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
528 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
529 |
self.BottomNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
530 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
531 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
532 |
self.BottomNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
533 |
wx.aui.AuiPaneInfo().Name("ResultPane").Bottom().Layer(0). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
534 |
BestSize(wx.Size(800, 300)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
535 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
536 |
self.RightNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
537 |
self, ID_PLCOPENEDITORRIGHTNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
538 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
539 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
540 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
541 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
542 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
543 |
self.RightNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
544 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
545 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
546 |
self.RightNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
547 |
wx.aui.AuiPaneInfo().Name("LibraryPane").Right().Layer(0). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
548 |
BestSize(wx.Size(250, 400)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
549 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
550 |
self.TabsOpened = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
551 |
self, ID_PLCOPENEDITORTABSOPENED, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
552 |
style=(wx.aui.AUI_NB_DEFAULT_STYLE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
553 |
wx.aui.AUI_NB_WINDOWLIST_BUTTON)) |
814 | 554 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGING, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
555 |
self.OnPouSelectedChanging) |
814 | 556 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
557 |
self.OnPouSelectedChanged) |
814 | 558 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
559 |
self.OnPageClose) |
814 | 560 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_END_DRAG, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
561 |
self.OnPageDragged) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
562 |
self.AUIManager.AddPane(self.TabsOpened, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
563 |
wx.aui.AuiPaneInfo().CentrePane().Name("TabsPane")) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
564 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
565 |
# ----------------------------------------------------------------------- |
814 | 566 |
# Creating PLCopen Project Types Tree |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
567 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
568 |
|
814 | 569 |
self.MainTabs = {} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
570 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
571 |
self.ProjectPanel = wx.SplitterWindow( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
572 |
id=ID_PLCOPENEDITORPROJECTPANEL, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
573 |
name='ProjectPanel', parent=self.LeftNoteBook, point=wx.Point(0, 0), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
574 |
size=wx.Size(0, 0), style=wx.SP_3D) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
575 |
|
814 | 576 |
self.ProjectTree = CustomTree(id=ID_PLCOPENEDITORPROJECTTREE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
577 |
name='ProjectTree', |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
578 |
parent=self.ProjectPanel, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
579 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
580 |
style=wx.SUNKEN_BORDER, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
581 |
agwStyle=(wx.TR_HAS_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
582 |
wx.TR_SINGLE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
583 |
wx.TR_EDIT_LABELS)) |
814 | 584 |
self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
585 |
wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) |
814 | 586 |
add_menu = wx.Menu() |
587 |
self._init_coll_AddMenu_Items(add_menu) |
|
588 |
self.ProjectTree.SetAddMenu(add_menu) |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
589 |
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnProjectTreeRightUp, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
590 |
id=ID_PLCOPENEDITORPROJECTTREE) |
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
591 |
self.ProjectTree.Bind(wx.EVT_LEFT_UP, self.OnProjectTreeLeftUp) |
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
592 |
self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnProjectTreeItemChanging, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
593 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 594 |
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnProjectTreeBeginDrag, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
595 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 596 |
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnProjectTreeItemBeginEdit, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
597 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 598 |
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnProjectTreeItemEndEdit, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
599 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 600 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnProjectTreeItemActivated, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
601 |
id=ID_PLCOPENEDITORPROJECTTREE) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
602 |
self.ProjectTree.Bind(wx.EVT_MOTION, self.OnProjectTreeMotion) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
603 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
604 |
# ----------------------------------------------------------------------- |
814 | 605 |
# Creating PLCopen Project POU Instance Variables Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
606 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
607 |
|
814 | 608 |
self.PouInstanceVariablesPanel = PouInstanceVariablesPanel(self.ProjectPanel, self, self.Controler, self.EnableDebug) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
609 |
|
814 | 610 |
self.MainTabs["ProjectPanel"] = (self.ProjectPanel, _("Project")) |
611 |
self.LeftNoteBook.AddPage(*self.MainTabs["ProjectPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
612 |
|
814 | 613 |
self.ProjectPanel.SplitHorizontally(self.ProjectTree, self.PouInstanceVariablesPanel, 300) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
614 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
615 |
# ----------------------------------------------------------------------- |
814 | 616 |
# Creating Tool Bar |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
617 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
618 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
619 |
MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
620 |
wx.DefaultPosition, wx.DefaultSize, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
621 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
814 | 622 |
MenuToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
623 |
MenuToolBar.Realize() |
|
624 |
self.Panes["MenuToolBar"] = MenuToolBar |
|
625 |
self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo(). |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
626 |
Name("MenuToolBar").Caption(_("Menu ToolBar")). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
627 |
ToolbarPane().Top(). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
628 |
LeftDockable(False).RightDockable(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
629 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
630 |
EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
631 |
wx.DefaultPosition, wx.DefaultSize, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
632 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
814 | 633 |
EditorToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
634 |
EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
635 |
GetBitmap("select"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
636 |
wx.NullBitmap, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
637 |
_("Select an object")) |
814 | 638 |
EditorToolBar.Realize() |
639 |
self.Panes["EditorToolBar"] = EditorToolBar |
|
640 |
self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo(). |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
641 |
Name("EditorToolBar").Caption(_("Editor ToolBar")). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
642 |
ToolbarPane().Top().Position(1). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
643 |
LeftDockable(False).RightDockable(False)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
644 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
645 |
self.Bind(wx.EVT_MENU, self.OnSelectionTool, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
646 |
id=ID_PLCOPENEDITOREDITORTOOLBARSELECTION) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
647 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
648 |
# ----------------------------------------------------------------------- |
814 | 649 |
# Creating Search Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
650 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
651 |
|
814 | 652 |
self.SearchResultPanel = SearchResultPanel(self.BottomNoteBook, self) |
653 |
self.MainTabs["SearchResultPanel"] = (self.SearchResultPanel, _("Search")) |
|
654 |
self.BottomNoteBook.AddPage(*self.MainTabs["SearchResultPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
655 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
656 |
# ----------------------------------------------------------------------- |
814 | 657 |
# Creating Library Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
658 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
659 |
|
814 | 660 |
self.LibraryPanel = LibraryPanel(self, True) |
661 |
self.MainTabs["LibraryPanel"] = (self.LibraryPanel, _("Library")) |
|
662 |
self.RightNoteBook.AddPage(*self.MainTabs["LibraryPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
663 |
|
814 | 664 |
self._init_utils() |
665 |
self.SetMenuBar(self.MenuBar) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
666 |
|
814 | 667 |
if self.EnableDebug: |
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
897
diff
changeset
|
668 |
self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self.Controler, self) |
814 | 669 |
self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger")) |
670 |
self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
671 |
|
814 | 672 |
self.AUIManager.Update() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
673 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
674 |
def __init__(self, parent, enable_debug=False): |
1836
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
675 |
wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name='IDEFrame', |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
676 |
parent=parent, pos=wx.DefaultPosition, |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
677 |
size=wx.Size(1000, 600), |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
678 |
style=wx.DEFAULT_FRAME_STYLE) |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
679 |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
680 |
self.UNEDITABLE_NAMES_DICT = dict([(_(n), n) for n in UNEDITABLE_NAMES]) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
681 |
|
814 | 682 |
self.Controler = None |
683 |
self.Config = wx.ConfigBase.Get() |
|
684 |
self.EnableDebug = enable_debug |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
685 |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
686 |
self.InitEditorToolbarItems() |
814 | 687 |
self._init_ctrls(parent) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
688 |
|
814 | 689 |
# Define Tree item icon list |
690 |
self.TreeImageList = wx.ImageList(16, 16) |
|
691 |
self.TreeImageDict = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
692 |
|
814 | 693 |
# Icons for languages |
694 |
for language in LANGUAGES: |
|
695 |
self.TreeImageDict[language] = self.TreeImageList.Add(GetBitmap(language)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
696 |
|
814 | 697 |
# Icons for other items |
698 |
for imgname, itemtype in [ |
|
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
699 |
# editables |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
700 |
("PROJECT", ITEM_PROJECT), |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
701 |
# ("POU", ITEM_POU), |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
702 |
# ("VARIABLE", ITEM_VARIABLE), |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
703 |
("TRANSITION", ITEM_TRANSITION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
704 |
("ACTION", ITEM_ACTION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
705 |
("CONFIGURATION", ITEM_CONFIGURATION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
706 |
("RESOURCE", ITEM_RESOURCE), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
707 |
("DATATYPE", ITEM_DATATYPE), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
708 |
# uneditables |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
709 |
("DATATYPES", ITEM_DATATYPES), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
710 |
("FUNCTION", ITEM_FUNCTION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
711 |
("FUNCTIONBLOCK", ITEM_FUNCTIONBLOCK), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
712 |
("PROGRAM", ITEM_PROGRAM), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
713 |
("VAR_LOCAL", ITEM_VAR_LOCAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
714 |
("VAR_LOCAL", ITEM_VAR_GLOBAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
715 |
("VAR_LOCAL", ITEM_VAR_EXTERNAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
716 |
("VAR_LOCAL", ITEM_VAR_TEMP), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
717 |
("VAR_INPUT", ITEM_VAR_INPUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
718 |
("VAR_OUTPUT", ITEM_VAR_OUTPUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
719 |
("VAR_INOUT", ITEM_VAR_INOUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
720 |
("TRANSITIONS", ITEM_TRANSITIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
721 |
("ACTIONS", ITEM_ACTIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
722 |
("CONFIGURATIONS", ITEM_CONFIGURATIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
723 |
("RESOURCES", ITEM_RESOURCES), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
724 |
("PROPERTIES", ITEM_PROPERTIES)]: |
814 | 725 |
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
726 |
|
814 | 727 |
# Assign icon list to TreeCtrls |
728 |
self.ProjectTree.SetImageList(self.TreeImageList) |
|
729 |
self.PouInstanceVariablesPanel.SetTreeImageList(self.TreeImageList) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
730 |
|
814 | 731 |
self.CurrentEditorToolBar = [] |
732 |
self.CurrentMenu = None |
|
733 |
self.SelectedItem = None |
|
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
734 |
self.LastToolTipItem = None |
814 | 735 |
self.SearchParams = None |
736 |
self.Highlights = {} |
|
737 |
self.DrawingMode = FREEDRAWING_MODE |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
738 |
# self.DrawingMode = DRIVENDRAWING_MODE |
814 | 739 |
self.AuiTabCtrl = [] |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
740 |
|
980
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
741 |
# Save default perspective |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
742 |
notebooks = {} |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
743 |
for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
744 |
(self.BottomNoteBook, "bottomnotebook"), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
745 |
(self.RightNoteBook, "rightnotebook")]: |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
746 |
notebooks[entry_name] = self.SaveTabLayout(notebook) |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
747 |
self.DefaultPerspective = { |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
748 |
"perspective": self.AUIManager.SavePerspective(), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
749 |
"notebooks": notebooks, |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
750 |
} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
751 |
|
814 | 752 |
# Initialize Printing configuring elements |
753 |
self.PrintData = wx.PrintData() |
|
754 |
self.PrintData.SetPaperId(wx.PAPER_A4) |
|
755 |
self.PrintData.SetPrintMode(wx.PRINT_MODE_PRINTER) |
|
756 |
self.PageSetupData = wx.PageSetupDialogData(self.PrintData) |
|
757 |
self.PageSetupData.SetMarginTopLeft(wx.Point(10, 15)) |
|
758 |
self.PageSetupData.SetMarginBottomRight(wx.Point(10, 20)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
759 |
|
814 | 760 |
self.SetRefreshFunctions() |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
761 |
self.SetDeleteFunctions() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
762 |
|
1700
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
763 |
wx.CallAfter(self.InitFindDialog) |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
764 |
|
814 | 765 |
def __del__(self): |
766 |
self.FindDialog.Destroy() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
767 |
|
1700
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
768 |
def InitFindDialog(self): |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
769 |
self.FindDialog = FindInPouDialog(self) |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
770 |
self.FindDialog.Hide() |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
771 |
|
814 | 772 |
def Show(self): |
773 |
wx.Frame.Show(self) |
|
774 |
wx.CallAfter(self.RestoreLastState) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
775 |
|
814 | 776 |
def OnActivated(self, event): |
777 |
if event.GetActive(): |
|
778 |
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
779 |
event.Skip() |
|
780 |
||
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
781 |
def SelectTab(self, tab): |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
782 |
for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
783 |
idx = notebook.GetPageIndex(tab) |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
784 |
if idx != wx.NOT_FOUND and idx != notebook.GetSelection(): |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
785 |
notebook.SetSelection(idx) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
786 |
return |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
787 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
788 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
789 |
# Saving and restoring frame organization functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
790 |
# ------------------------------------------------------------------------------- |
814 | 791 |
|
792 |
def GetTabInfos(self, tab): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
793 |
for page_name, (page_ref, _page_title) in self.MainTabs.iteritems(): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
980
diff
changeset
|
794 |
if page_ref == tab: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
980
diff
changeset
|
795 |
return ("main", page_name) |
814 | 796 |
return None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
797 |
|
814 | 798 |
def SaveTabLayout(self, notebook): |
799 |
tabs = [] |
|
800 |
for child in notebook.GetChildren(): |
|
801 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
802 |
if child.GetPageCount() > 0: |
|
803 |
pos = child.GetPosition() |
|
804 |
tab = {"pos": (pos.x, pos.y), "pages": []} |
|
805 |
tab_size = child.GetSize() |
|
806 |
for page_idx in xrange(child.GetPageCount()): |
|
807 |
page = child.GetWindowFromIdx(page_idx) |
|
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
808 |
if "size" not in tab: |
814 | 809 |
tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1]) |
810 |
tab_infos = self.GetTabInfos(page) |
|
811 |
if tab_infos is not None: |
|
812 |
tab["pages"].append((tab_infos, page_idx == child.GetActivePage())) |
|
813 |
tabs.append(tab) |
|
814 |
tabs.sort(lambda x, y: cmp(x["pos"], y["pos"])) |
|
815 |
size = notebook.GetSize() |
|
816 |
return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
817 |
|
814 | 818 |
def LoadTab(self, notebook, page_infos): |
819 |
if page_infos[0] == "main": |
|
820 |
infos = self.MainTabs.get(page_infos[1]) |
|
821 |
if infos is not None: |
|
822 |
page_ref, page_title = infos |
|
823 |
notebook.AddPage(page_ref, page_title) |
|
824 |
return notebook.GetPageIndex(page_ref) |
|
825 |
elif page_infos[0] == "editor": |
|
826 |
tagname = page_infos[1] |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
827 |
page_ref = self.EditProjectElement(GetElementType(tagname), tagname) |
814 | 828 |
if page_ref is not None: |
829 |
page_ref.RefreshView() |
|
830 |
return notebook.GetPageIndex(page_ref) |
|
831 |
elif page_infos[0] == "debug": |
|
832 |
instance_path = page_infos[1] |
|
833 |
instance_infos = self.Controler.GetInstanceInfos(instance_path, self.EnableDebug) |
|
834 |
if instance_infos is not None: |
|
835 |
return notebook.GetPageIndex(self.OpenDebugViewer(instance_infos["class"], instance_path, instance_infos["type"])) |
|
836 |
return None |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
837 |
|
814 | 838 |
def LoadTabLayout(self, notebook, tabs, mode="all", first_index=None): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
839 |
if isinstance(tabs, list): |
814 | 840 |
if len(tabs) == 0: |
841 |
return |
|
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1763
diff
changeset
|
842 |
raise ValueError("Not supported") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
843 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
844 |
if "split" in tabs: |
814 | 845 |
self.LoadTabLayout(notebook, tabs["others"]) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
846 |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
847 |
split_dir, _split_ratio = tabs["split"] |
814 | 848 |
first_index = self.LoadTabLayout(notebook, tabs["tab"], mode="first") |
849 |
notebook.Split(first_index, split_dir) |
|
850 |
self.LoadTabLayout(notebook, tabs["tab"], mode="others", first_index=first_index) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
851 |
|
814 | 852 |
elif mode == "first": |
853 |
return self.LoadTab(notebook, tabs["pages"][0][0]) |
|
854 |
else: |
|
855 |
selected = first_index |
|
856 |
if mode == "others": |
|
857 |
add_tabs = tabs["pages"][1:] |
|
858 |
else: |
|
859 |
add_tabs = tabs["pages"] |
|
860 |
for page_infos, page_selected in add_tabs: |
|
861 |
page_idx = self.LoadTab(notebook, page_infos) |
|
862 |
if page_selected: |
|
863 |
selected = page_idx |
|
864 |
if selected is not None: |
|
865 |
wx.CallAfter(notebook.SetSelection, selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
866 |
|
814 | 867 |
def ResetPerspective(self): |
868 |
if self.DefaultPerspective is not None: |
|
869 |
self.AUIManager.LoadPerspective(self.DefaultPerspective["perspective"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
870 |
|
814 | 871 |
for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
872 |
for dummy in xrange(notebook.GetPageCount()): |
814 | 873 |
notebook.RemovePage(0) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
874 |
|
814 | 875 |
notebooks = self.DefaultPerspective["notebooks"] |
876 |
for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"), |
|
877 |
(self.BottomNoteBook, "bottomnotebook"), |
|
878 |
(self.RightNoteBook, "rightnotebook")]: |
|
879 |
self.LoadTabLayout(notebook, notebooks.get(entry_name)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
880 |
|
814 | 881 |
self._Refresh(EDITORTOOLBAR) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
882 |
|
814 | 883 |
def RestoreLastState(self): |
884 |
frame_size = None |
|
885 |
if self.Config.HasEntry("framesize"): |
|
886 |
frame_size = cPickle.loads(str(self.Config.Read("framesize"))) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
887 |
|
814 | 888 |
if frame_size is None: |
889 |
self.Maximize() |
|
890 |
else: |
|
891 |
self.SetClientSize(frame_size) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
892 |
|
814 | 893 |
def SaveLastState(self): |
894 |
if not self.IsMaximized(): |
|
895 |
self.Config.Write("framesize", cPickle.dumps(self.GetClientSize())) |
|
896 |
elif self.Config.HasEntry("framesize"): |
|
897 |
self.Config.DeleteEntry("framesize") |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
898 |
|
814 | 899 |
self.Config.Flush() |
900 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
901 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
902 |
# General Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
903 |
# ------------------------------------------------------------------------------- |
814 | 904 |
|
905 |
def SetRefreshFunctions(self): |
|
906 |
self.RefreshFunctions = { |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
907 |
TITLE: self.RefreshTitle, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
908 |
EDITORTOOLBAR: self.RefreshEditorToolBar, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
909 |
FILEMENU: self.RefreshFileMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
910 |
EDITMENU: self.RefreshEditMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
911 |
DISPLAYMENU: self.RefreshDisplayMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
912 |
PROJECTTREE: self.RefreshProjectTree, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
913 |
POUINSTANCEVARIABLESPANEL: self.RefreshPouInstanceVariablesPanel, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
914 |
LIBRARYTREE: self.RefreshLibraryPanel, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
915 |
SCALING: self.RefreshScaling, |
814 | 916 |
PAGETITLES: self.RefreshPageTitles} |
917 |
||
918 |
def _Refresh(self, *elements): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
919 |
"""Call Editor refresh functions. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
920 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
921 |
:param elements: List of elements to refresh. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
922 |
""" |
814 | 923 |
try: |
924 |
for element in elements: |
|
925 |
self.RefreshFunctions[element]() |
|
926 |
except wx.PyDeadObjectError: |
|
927 |
# ignore exceptions caused by refresh while quitting |
|
928 |
pass |
|
929 |
||
930 |
def OnPageClose(self, event): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
931 |
"""Callback function when AUINotebook Page closed with CloseButton |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
932 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
933 |
:param event: AUINotebook Event. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
934 |
""" |
814 | 935 |
selected = self.TabsOpened.GetSelection() |
936 |
if selected > -1: |
|
937 |
window = self.TabsOpened.GetPage(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
938 |
|
814 | 939 |
if window.CheckSaveBeforeClosing(): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
940 |
|
814 | 941 |
# Refresh all window elements that have changed |
942 |
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
943 |
wx.CallAfter(self.RefreshTabCtrlEvent) |
|
944 |
wx.CallAfter(self.CloseFindInPouDialog) |
|
945 |
event.Skip() |
|
946 |
else: |
|
947 |
event.Veto() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
948 |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
949 |
def GetCopyBuffer(self, primary_selection=False): |
814 | 950 |
data = None |
1028 | 951 |
if primary_selection and wx.Platform == '__WXMSW__': |
952 |
return data |
|
953 |
else: |
|
954 |
wx.TheClipboard.UsePrimarySelection(primary_selection) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
955 |
|
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
956 |
if not wx.TheClipboard.IsOpened(): |
814 | 957 |
dataobj = wx.TextDataObject() |
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
958 |
if wx.TheClipboard.Open(): |
2233
32445e3c9cfc
Catch 'clipboard already open' errors in editors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2177
diff
changeset
|
959 |
success = False |
32445e3c9cfc
Catch 'clipboard already open' errors in editors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2177
diff
changeset
|
960 |
try: |
32445e3c9cfc
Catch 'clipboard already open' errors in editors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2177
diff
changeset
|
961 |
success = wx.TheClipboard.GetData(dataobj) |
32445e3c9cfc
Catch 'clipboard already open' errors in editors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2177
diff
changeset
|
962 |
except wx._core.PyAssertionError: |
32445e3c9cfc
Catch 'clipboard already open' errors in editors
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2177
diff
changeset
|
963 |
pass |
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
964 |
wx.TheClipboard.Close() |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
965 |
if success: |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
966 |
data = dataobj.GetText() |
814 | 967 |
return data |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
968 |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
969 |
def SetCopyBuffer(self, text, primary_selection=False): |
1028 | 970 |
if primary_selection and wx.Platform == '__WXMSW__': |
971 |
return |
|
972 |
else: |
|
973 |
wx.TheClipboard.UsePrimarySelection(primary_selection) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
974 |
if not wx.TheClipboard.IsOpened(): |
814 | 975 |
data = wx.TextDataObject() |
976 |
data.SetText(text) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
977 |
if wx.TheClipboard.Open(): |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
978 |
wx.TheClipboard.SetData(data) |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
979 |
wx.TheClipboard.Flush() |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
980 |
wx.TheClipboard.Close() |
2167
b8f795bdfe9f
fix hangs on mouse selection in case if wxPython uses wxWidgets with GTK3+ support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2166
diff
changeset
|
981 |
wx.CallAfter(self.RefreshEditMenu) |
814 | 982 |
|
983 |
def GetDrawingMode(self): |
|
984 |
return self.DrawingMode |
|
985 |
||
986 |
def RefreshScaling(self): |
|
987 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
988 |
editor = self.TabsOpened.GetPage(i) |
|
989 |
editor.RefreshScaling() |
|
990 |
||
991 |
def EditProjectSettings(self): |
|
992 |
old_values = self.Controler.GetProjectProperties() |
|
993 |
dialog = ProjectDialog(self) |
|
994 |
dialog.SetValues(old_values) |
|
995 |
if dialog.ShowModal() == wx.ID_OK: |
|
996 |
new_values = dialog.GetValues() |
|
997 |
new_values["creationDateTime"] = old_values["creationDateTime"] |
|
998 |
if new_values != old_values: |
|
999 |
self.Controler.SetProjectProperties(None, new_values) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1000 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, |
814 | 1001 |
PROJECTTREE, POUINSTANCEVARIABLESPANEL, SCALING) |
1002 |
dialog.Destroy() |
|
1003 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1004 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1005 |
# Notebook Unified Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1006 |
# ------------------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1007 |
|
814 | 1008 |
def AddPage(self, window, text): |
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1009 |
"""Function that add a tab in Notebook, calling refresh for tab DClick event |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1010 |
for wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1011 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1012 |
:param window: Panel to display in tab. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1013 |
:param text: title for the tab ctrl. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1014 |
""" |
814 | 1015 |
self.TabsOpened.AddPage(window, text) |
1016 |
self.RefreshTabCtrlEvent() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1017 |
|
814 | 1018 |
def DeletePage(self, window): |
1019 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1020 |
if self.TabsOpened.GetPage(idx) == window: |
|
1021 |
self.TabsOpened.DeletePage(idx) |
|
1022 |
self.RefreshTabCtrlEvent() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1023 |
return |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1024 |
|
814 | 1025 |
def DeleteAllPages(self): |
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1026 |
"""Function that fix difference in deleting all tabs between |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1027 |
wx.Notebook and wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1028 |
""" |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
1029 |
for dummy in xrange(self.TabsOpened.GetPageCount()): |
814 | 1030 |
self.TabsOpened.DeletePage(0) |
1031 |
self.RefreshTabCtrlEvent() |
|
1032 |
||
1033 |
def SetPageBitmap(self, idx, bitmap): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1034 |
"""Function that fix difference in setting picture on tab between |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1035 |
wx.Notebook and wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1036 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1037 |
:param idx: Tab index. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1038 |
:param bitmap: wx.Bitmap to define on tab. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1039 |
:returns: True if operation succeeded |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1040 |
""" |
814 | 1041 |
return self.TabsOpened.SetPageBitmap(idx, bitmap) |
1042 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1043 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1044 |
# Dialog Message Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1045 |
# ------------------------------------------------------------------------------- |
814 | 1046 |
|
1047 |
def ShowErrorMessage(self, message): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1048 |
"""Function displaying an Error dialog in editor. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1049 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1050 |
:param message: The message to display. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1051 |
""" |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1052 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 1053 |
dialog.ShowModal() |
1054 |
dialog.Destroy() |
|
1055 |
||
1056 |
def CheckSaveBeforeClosing(self, title=_("Close Project")): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1057 |
"""Function displaying an question dialog if project is not saved" |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1058 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1059 |
:returns: False if closing cancelled. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1060 |
""" |
814 | 1061 |
if not self.Controler.ProjectIsSaved(): |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1062 |
dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION) |
814 | 1063 |
answer = dialog.ShowModal() |
1064 |
dialog.Destroy() |
|
1065 |
if answer == wx.ID_YES: |
|
1066 |
self.SaveProject() |
|
1067 |
elif answer == wx.ID_CANCEL: |
|
1068 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1069 |
|
814 | 1070 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
1071 |
window = self.TabsOpened.GetPage(idx) |
|
1072 |
if not window.CheckSaveBeforeClosing(): |
|
1073 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1074 |
|
814 | 1075 |
return True |
1076 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1077 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1078 |
# File Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1079 |
# ------------------------------------------------------------------------------- |
814 | 1080 |
|
1081 |
def RefreshFileMenu(self): |
|
1082 |
pass |
|
1083 |
||
1084 |
def ResetView(self): |
|
1085 |
self.DeleteAllPages() |
|
1086 |
self.ProjectTree.DeleteAllItems() |
|
1087 |
self.ProjectTree.Enable(False) |
|
1088 |
self.PouInstanceVariablesPanel.ResetView() |
|
1089 |
self.LibraryPanel.ResetTree() |
|
1090 |
self.LibraryPanel.SetController(None) |
|
1091 |
if self.EnableDebug: |
|
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
909
diff
changeset
|
1092 |
self.DebugVariablePanel.ResetView() |
814 | 1093 |
self.Controler = None |
1094 |
||
1095 |
def OnCloseTabMenu(self, event): |
|
1096 |
selected = self.TabsOpened.GetSelection() |
|
1097 |
if selected >= 0: |
|
1098 |
self.TabsOpened.DeletePage(selected) |
|
1099 |
if self.TabsOpened.GetPageCount() > 0: |
|
1100 |
new_index = min(selected, self.TabsOpened.GetPageCount() - 1) |
|
1101 |
self.TabsOpened.SetSelection(new_index) |
|
1102 |
# Refresh all window elements that have changed |
|
1103 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
1104 |
self.RefreshTabCtrlEvent() |
|
1105 |
||
1106 |
def OnPageSetupMenu(self, event): |
|
1107 |
dialog = wx.PageSetupDialog(self, self.PageSetupData) |
|
1108 |
if dialog.ShowModal() == wx.ID_OK: |
|
1109 |
self.PageSetupData = wx.PageSetupDialogData(dialog.GetPageSetupData()) |
|
1110 |
self.PrintData = wx.PrintData(self.PageSetupData.GetPrintData()) |
|
1111 |
dialog.Destroy() |
|
1112 |
||
1113 |
def OnPreviewMenu(self, event): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1114 |
selected = self.TabsOpened.GetSelection() |
814 | 1115 |
if selected != -1: |
1116 |
window = self.TabsOpened.GetPage(selected) |
|
1117 |
data = wx.PrintDialogData(self.PrintData) |
|
1118 |
properties = self.Controler.GetProjectProperties(window.IsDebugging()) |
|
1119 |
page_size = map(int, properties["pageSize"]) |
|
1120 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
1121 |
printout = GraphicPrintout(window, page_size, margins, True) |
|
1122 |
printout2 = GraphicPrintout(window, page_size, margins, True) |
|
1123 |
preview = wx.PrintPreview(printout, printout2, data) |
|
1124 |
||
1125 |
if preview.Ok(): |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1126 |
preview_frame = wx.PreviewFrame(preview, self, _("Print preview"), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT) |
814 | 1127 |
|
1128 |
preview_frame.Initialize() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1129 |
|
814 | 1130 |
preview_canvas = preview.GetCanvas() |
1131 |
preview_canvas.SetMinSize(preview_canvas.GetVirtualSize()) |
|
1132 |
preview_frame.Fit() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1133 |
|
814 | 1134 |
preview_frame.Show(True) |
1135 |
||
1136 |
def OnPrintMenu(self, event): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1137 |
selected = self.TabsOpened.GetSelection() |
814 | 1138 |
if selected != -1: |
1139 |
window = self.TabsOpened.GetPage(selected) |
|
1140 |
dialog_data = wx.PrintDialogData(self.PrintData) |
|
1141 |
dialog_data.SetToPage(1) |
|
1142 |
properties = self.Controler.GetProjectProperties(window.IsDebugging()) |
|
1143 |
page_size = map(int, properties["pageSize"]) |
|
1144 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
1145 |
printer = wx.Printer(dialog_data) |
|
1146 |
printout = GraphicPrintout(window, page_size, margins) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1147 |
|
814 | 1148 |
if not printer.Print(self, printout, True) and printer.GetLastError() != wx.PRINTER_CANCELLED: |
1149 |
self.ShowErrorMessage(_("There was a problem printing.\nPerhaps your current printer is not set correctly?")) |
|
1150 |
printout.Destroy() |
|
1151 |
||
1152 |
def OnPropertiesMenu(self, event): |
|
1153 |
self.EditProjectSettings() |
|
1154 |
||
1155 |
def OnQuitMenu(self, event): |
|
1156 |
self.Close() |
|
1157 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1158 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1159 |
# Edit Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1160 |
# ------------------------------------------------------------------------------- |
814 | 1161 |
|
1162 |
def RefreshEditMenu(self): |
|
1163 |
MenuToolBar = self.Panes["MenuToolBar"] |
|
1164 |
if self.Controler is not None: |
|
1165 |
selected = self.TabsOpened.GetSelection() |
|
1166 |
if selected > -1: |
|
1167 |
window = self.TabsOpened.GetPage(selected) |
|
1168 |
undo, redo = window.GetBufferState() |
|
1169 |
else: |
|
1170 |
undo, redo = self.Controler.GetBufferState() |
|
1171 |
self.EditMenu.Enable(wx.ID_UNDO, undo) |
|
1172 |
MenuToolBar.EnableTool(wx.ID_UNDO, undo) |
|
1173 |
self.EditMenu.Enable(wx.ID_REDO, redo) |
|
1174 |
MenuToolBar.EnableTool(wx.ID_REDO, redo) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1175 |
# self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, True) |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1176 |
# self.EditMenu.Check(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, |
814 | 1177 |
# self.Controler.IsProjectBufferEnabled()) |
1178 |
self.EditMenu.Enable(wx.ID_FIND, selected > -1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1179 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDNEXT, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1180 |
selected > -1 and self.SearchParams is not None) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1181 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1182 |
selected > -1 and self.SearchParams is not None) |
814 | 1183 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True) |
1184 |
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True) |
|
1185 |
self.EditMenu.Enable(wx.ID_ADD, True) |
|
1186 |
self.EditMenu.Enable(wx.ID_DELETE, True) |
|
1187 |
if self.TabsOpened.GetPageCount() > 0: |
|
1188 |
self.EditMenu.Enable(wx.ID_CUT, True) |
|
1189 |
MenuToolBar.EnableTool(wx.ID_CUT, True) |
|
1190 |
self.EditMenu.Enable(wx.ID_COPY, True) |
|
1191 |
MenuToolBar.EnableTool(wx.ID_COPY, True) |
|
1192 |
if self.GetCopyBuffer() is not None: |
|
1193 |
self.EditMenu.Enable(wx.ID_PASTE, True) |
|
1194 |
MenuToolBar.EnableTool(wx.ID_PASTE, True) |
|
1195 |
else: |
|
1196 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1197 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1198 |
self.EditMenu.Enable(wx.ID_SELECTALL, True) |
|
1199 |
else: |
|
1200 |
self.EditMenu.Enable(wx.ID_CUT, False) |
|
1201 |
MenuToolBar.EnableTool(wx.ID_CUT, False) |
|
1202 |
self.EditMenu.Enable(wx.ID_COPY, False) |
|
1203 |
MenuToolBar.EnableTool(wx.ID_COPY, False) |
|
1204 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1205 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1206 |
self.EditMenu.Enable(wx.ID_SELECTALL, False) |
|
1207 |
else: |
|
1208 |
self.EditMenu.Enable(wx.ID_UNDO, False) |
|
1209 |
MenuToolBar.EnableTool(wx.ID_UNDO, False) |
|
1210 |
self.EditMenu.Enable(wx.ID_REDO, False) |
|
1211 |
MenuToolBar.EnableTool(wx.ID_REDO, False) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1212 |
# self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, False) |
814 | 1213 |
self.EditMenu.Enable(wx.ID_CUT, False) |
1214 |
MenuToolBar.EnableTool(wx.ID_CUT, False) |
|
1215 |
self.EditMenu.Enable(wx.ID_COPY, False) |
|
1216 |
MenuToolBar.EnableTool(wx.ID_COPY, False) |
|
1217 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1218 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1219 |
self.EditMenu.Enable(wx.ID_SELECTALL, False) |
|
1220 |
self.EditMenu.Enable(wx.ID_FIND, False) |
|
1221 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDNEXT, False) |
|
1222 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, False) |
|
1223 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False) |
|
1224 |
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False) |
|
1225 |
self.EditMenu.Enable(wx.ID_ADD, False) |
|
1226 |
self.EditMenu.Enable(wx.ID_DELETE, False) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1227 |
|
814 | 1228 |
def CloseTabsWithoutModel(self, refresh=True): |
1229 |
idxs = range(self.TabsOpened.GetPageCount()) |
|
1230 |
idxs.reverse() |
|
1231 |
for idx in idxs: |
|
1232 |
window = self.TabsOpened.GetPage(idx) |
|
1233 |
if window.HasNoModel(): |
|
1234 |
self.TabsOpened.DeletePage(idx) |
|
1235 |
if refresh: |
|
1236 |
self.RefreshEditor() |
|
1237 |
||
1238 |
def OnUndoMenu(self, event): |
|
1239 |
selected = self.TabsOpened.GetSelection() |
|
1240 |
if selected != -1: |
|
1241 |
window = self.TabsOpened.GetPage(selected) |
|
1242 |
window.Undo() |
|
1243 |
else: |
|
1244 |
self.Controler.LoadPrevious() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1245 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1246 |
SCALING, PAGETITLES) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1247 |
|
814 | 1248 |
def OnRedoMenu(self, event): |
1249 |
selected = self.TabsOpened.GetSelection() |
|
1250 |
if selected != -1: |
|
1251 |
window = self.TabsOpened.GetPage(selected) |
|
1252 |
window.Redo() |
|
1253 |
else: |
|
1254 |
self.Controler.LoadNext() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1255 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, |
814 | 1256 |
SCALING, PAGETITLES) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1257 |
|
814 | 1258 |
def OnEnableUndoRedoMenu(self, event): |
1259 |
self.Controler.EnableProjectBuffer(event.IsChecked()) |
|
1260 |
self.RefreshEditMenu() |
|
1261 |
||
1262 |
OnCutMenu = GetShortcutKeyCallbackFunction("Cut") |
|
1263 |
OnCopyMenu = GetShortcutKeyCallbackFunction("Copy") |
|
1264 |
OnPasteMenu = GetShortcutKeyCallbackFunction("Paste") |
|
1265 |
||
1266 |
def OnSelectAllMenu(self, event): |
|
1267 |
control = self.FindFocus() |
|
1268 |
if control is not None and control.GetName() == "Viewer": |
|
1269 |
control.Parent.SelectAll() |
|
1270 |
elif isinstance(control, wx.stc.StyledTextCtrl): |
|
1271 |
control.SelectAll() |
|
1272 |
elif isinstance(control, wx.TextCtrl): |
|
1273 |
control.SetSelection(0, control.GetLastPosition()) |
|
1274 |
elif isinstance(control, wx.ComboBox): |
|
1275 |
control.SetMark(0, control.GetLastPosition() + 1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1276 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1277 |
def SetDeleteFunctions(self): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1278 |
self.DeleteFunctions = { |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1279 |
ITEM_DATATYPE: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1280 |
PLCControler.ProjectRemoveDataType, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1281 |
check_function=self.CheckDataTypeIsUsedBeforeDeletion), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1282 |
ITEM_POU: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1283 |
PLCControler.ProjectRemovePou, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1284 |
check_function=self.CheckPouIsUsedBeforeDeletion), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1285 |
ITEM_TRANSITION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1286 |
PLCControler.ProjectRemovePouTransition, ITEM_POU), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1287 |
ITEM_ACTION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1288 |
PLCControler.ProjectRemovePouAction, ITEM_POU), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1289 |
ITEM_CONFIGURATION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1290 |
PLCControler.ProjectRemoveConfiguration), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1291 |
ITEM_RESOURCE: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1292 |
PLCControler.ProjectRemoveConfigurationResource, ITEM_CONFIGURATION) |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1293 |
} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1294 |
|
814 | 1295 |
def OnDeleteMenu(self, event): |
1296 |
window = self.FindFocus() |
|
1297 |
if window == self.ProjectTree or window is None: |
|
1298 |
selected = self.ProjectTree.GetSelection() |
|
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1299 |
if selected is not None and selected.IsOk(): |
814 | 1300 |
function = self.DeleteFunctions.get(self.ProjectTree.GetPyData(selected)["type"], None) |
1301 |
if function is not None: |
|
1302 |
function(self, selected) |
|
1303 |
self.CloseTabsWithoutModel() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1304 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, |
814 | 1305 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
1306 |
elif isinstance(window, (Viewer, TextViewer)): |
|
1307 |
event = wx.KeyEvent(wx.EVT_CHAR._getEvtType()) |
|
1308 |
event.m_keyCode = wx.WXK_DELETE |
|
1309 |
window.ProcessEvent(event) |
|
1310 |
||
1311 |
def OnFindMenu(self, event): |
|
1312 |
if not self.FindDialog.IsShown(): |
|
1313 |
self.FindDialog.Show() |
|
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1314 |
self.FindDialog.FindPattern.SetFocus() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1315 |
|
814 | 1316 |
def CloseFindInPouDialog(self): |
1317 |
selected = self.TabsOpened.GetSelection() |
|
1318 |
if selected == -1 and self.FindDialog.IsShown(): |
|
1319 |
self.FindDialog.Hide() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1320 |
|
814 | 1321 |
def OnFindNextMenu(self, event): |
1322 |
self.FindInPou(1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1323 |
|
814 | 1324 |
def OnFindPreviousMenu(self, event): |
1325 |
self.FindInPou(-1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1326 |
|
814 | 1327 |
def FindInPou(self, direction, search_params=None): |
1328 |
if search_params is not None: |
|
1329 |
self.SearchParams = search_params |
|
1330 |
selected = self.TabsOpened.GetSelection() |
|
1331 |
if selected != -1: |
|
1332 |
window = self.TabsOpened.GetPage(selected) |
|
1333 |
window.Find(direction, self.SearchParams) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1334 |
|
814 | 1335 |
def OnSearchInProjectMenu(self, event): |
1336 |
dialog = SearchInProjectDialog(self) |
|
1337 |
if dialog.ShowModal() == wx.ID_OK: |
|
1338 |
criteria = dialog.GetCriteria() |
|
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1339 |
if len(criteria) > 0: |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1340 |
result = self.Controler.SearchInProject(criteria) |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1341 |
self.ClearSearchResults() |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1342 |
self.SearchResultPanel.SetSearchResults(criteria, result) |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1343 |
self.SelectTab(self.SearchResultPanel) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1344 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1345 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1346 |
# Display Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1347 |
# ------------------------------------------------------------------------------- |
814 | 1348 |
|
1349 |
def RefreshDisplayMenu(self): |
|
1350 |
if self.Controler is not None: |
|
1351 |
if self.TabsOpened.GetPageCount() > 0: |
|
1352 |
self.DisplayMenu.Enable(wx.ID_REFRESH, True) |
|
1353 |
selected = self.TabsOpened.GetSelection() |
|
1354 |
if selected != -1: |
|
1355 |
window = self.TabsOpened.GetPage(selected) |
|
1356 |
if isinstance(window, Viewer): |
|
1357 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, True) |
|
1358 |
zoommenu = self.DisplayMenu.FindItemById(wx.ID_ZOOM_FIT).GetSubMenu() |
|
1359 |
zoomitem = zoommenu.FindItemByPosition(window.GetScale()) |
|
1360 |
zoomitem.Check(True) |
|
1361 |
else: |
|
1362 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1363 |
else: |
|
1364 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1365 |
else: |
|
1366 |
self.DisplayMenu.Enable(wx.ID_REFRESH, False) |
|
1367 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1368 |
if self.EnableDebug: |
|
1369 |
self.DisplayMenu.Enable(wx.ID_CLEAR, True) |
|
1370 |
else: |
|
1371 |
self.DisplayMenu.Enable(wx.ID_REFRESH, False) |
|
1372 |
if self.EnableDebug: |
|
1373 |
self.DisplayMenu.Enable(wx.ID_CLEAR, False) |
|
1374 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1375 |
|
814 | 1376 |
def OnRefreshMenu(self, event): |
1377 |
self.RefreshEditor() |
|
1378 |
||
1379 |
def OnClearErrorsMenu(self, event): |
|
1380 |
self.ClearErrors() |
|
1381 |
||
1382 |
def GenerateZoomFunction(self, idx): |
|
1383 |
def ZoomFunction(event): |
|
1384 |
selected = self.TabsOpened.GetSelection() |
|
1385 |
if selected != -1: |
|
1386 |
window = self.TabsOpened.GetPage(selected) |
|
1387 |
window.SetScale(idx) |
|
1388 |
window.RefreshVisibleElements() |
|
1389 |
window.RefreshScrollBars() |
|
1390 |
event.Skip() |
|
1391 |
return ZoomFunction |
|
1392 |
||
1393 |
def OnResetPerspective(self, event): |
|
1394 |
self.ResetPerspective() |
|
1395 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1396 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1397 |
# Project Editor Panels Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1398 |
# ------------------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1399 |
|
814 | 1400 |
def OnPageDragged(self, event): |
1401 |
wx.CallAfter(self.RefreshTabCtrlEvent) |
|
1402 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1403 |
|
814 | 1404 |
def OnAllowNotebookDnD(self, event): |
1405 |
event.Allow() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1406 |
|
814 | 1407 |
def RefreshTabCtrlEvent(self): |
1408 |
auitabctrl = [] |
|
1409 |
for child in self.TabsOpened.GetChildren(): |
|
1410 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
1411 |
auitabctrl.append(child) |
|
1412 |
if child not in self.AuiTabCtrl: |
|
1413 |
child.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(child)) |
|
1414 |
self.AuiTabCtrl = auitabctrl |
|
1415 |
if self.TabsOpened.GetPageCount() == 0: |
|
1416 |
pane = self.AUIManager.GetPane(self.TabsOpened) |
|
1417 |
if pane.IsMaximized(): |
|
1418 |
self.AUIManager.RestorePane(pane) |
|
1419 |
self.AUIManager.Update() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1420 |
|
814 | 1421 |
def EnsureTabVisible(self, tab): |
1422 |
notebook = tab.GetParent() |
|
1423 |
notebook.SetSelection(notebook.GetPageIndex(tab)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1424 |
|
814 | 1425 |
def OnPouSelectedChanging(self, event): |
989 | 1426 |
selected = self.TabsOpened.GetSelection() |
1427 |
if selected >= 0: |
|
1428 |
window = self.TabsOpened.GetPage(selected) |
|
1429 |
if not window.IsDebugging(): |
|
1430 |
window.ResetBuffer() |
|
814 | 1431 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1432 |
|
814 | 1433 |
def OnPouSelectedChanged(self, event): |
989 | 1434 |
selected = self.TabsOpened.GetSelection() |
1435 |
if selected >= 0: |
|
1436 |
window = self.TabsOpened.GetPage(selected) |
|
1437 |
tagname = window.GetTagName() |
|
1438 |
if not window.IsDebugging(): |
|
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1439 |
self.SelectProjectTreeItem(tagname) |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
1440 |
self.PouInstanceVariablesPanel.SetPouType(tagname) |
989 | 1441 |
window.RefreshView() |
1442 |
self.EnsureTabVisible(self.LibraryPanel) |
|
1443 |
else: |
|
1444 |
instance_path = window.GetInstancePath() |
|
1445 |
if tagname == "": |
|
1446 |
instance_path = instance_path.rsplit(".", 1)[0] |
|
1447 |
tagname = self.Controler.GetPouInstanceTagName(instance_path, self.EnableDebug) |
|
1448 |
self.EnsureTabVisible(self.DebugVariablePanel) |
|
1449 |
wx.CallAfter(self.PouInstanceVariablesPanel.SetPouType, tagname, instance_path) |
|
1450 |
wx.CallAfter(self._Refresh, FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR) |
|
814 | 1451 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1452 |
|
814 | 1453 |
def RefreshEditor(self): |
1454 |
selected = self.TabsOpened.GetSelection() |
|
1455 |
if selected >= 0: |
|
1456 |
window = self.TabsOpened.GetPage(selected) |
|
1457 |
tagname = window.GetTagName() |
|
1458 |
if not window.IsDebugging(): |
|
1459 |
self.SelectProjectTreeItem(tagname) |
|
1460 |
self.PouInstanceVariablesPanel.SetPouType(tagname) |
|
1461 |
else: |
|
1462 |
instance_path = window.GetInstancePath() |
|
1463 |
if tagname == "": |
|
1464 |
instance_path = instance_path.rsplit(".", 1)[0] |
|
1465 |
tagname = self.Controler.GetPouInstanceTagName(instance_path, self.EnableDebug) |
|
1466 |
self.PouInstanceVariablesPanel.SetPouType(tagname, instance_path) |
|
1467 |
for child in self.TabsOpened.GetChildren(): |
|
1468 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
1469 |
active_page = child.GetActivePage() |
|
1470 |
if active_page >= 0: |
|
1471 |
window = child.GetWindowFromIdx(active_page) |
|
1472 |
window.RefreshView() |
|
1473 |
self._Refresh(FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1474 |
|
814 | 1475 |
def RefreshEditorNames(self, old_tagname, new_tagname): |
1476 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
1477 |
editor = self.TabsOpened.GetPage(i) |
|
1478 |
if editor.GetTagName() == old_tagname: |
|
1479 |
editor.SetTagName(new_tagname) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1480 |
|
814 | 1481 |
def IsOpened(self, tagname): |
1482 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1483 |
if self.TabsOpened.GetPage(idx).IsViewing(tagname): |
|
1484 |
return idx |
|
1485 |
return None |
|
1486 |
||
1487 |
def RefreshPageTitles(self): |
|
1488 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1489 |
window = self.TabsOpened.GetPage(idx) |
|
1490 |
icon = window.GetIcon() |
|
1491 |
if icon is not None: |
|
1492 |
self.SetPageBitmap(idx, icon) |
|
1493 |
self.TabsOpened.SetPageText(idx, window.GetTitle()) |
|
1494 |
||
1495 |
def GetTabsOpenedDClickFunction(self, tabctrl): |
|
1496 |
def OnTabsOpenedDClick(event): |
|
1497 |
pos = event.GetPosition() |
|
1498 |
if tabctrl.TabHitTest(pos.x, pos.y, None): |
|
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1499 |
self.SwitchPerspective(event) |
814 | 1500 |
event.Skip() |
1501 |
return OnTabsOpenedDClick |
|
1502 |
||
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1503 |
def SwitchPerspective(self, evt): |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1504 |
pane = self.AUIManager.GetPane(self.TabsOpened) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1505 |
if pane.IsMaximized(): |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1506 |
self.AUIManager.RestorePane(pane) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1507 |
else: |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1508 |
self.AUIManager.MaximizePane(pane) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1509 |
self.AUIManager.Update() |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1510 |
|
2242
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1511 |
def SwitchFullScrMode(self, evt): |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1512 |
show = not self.IsFullScreen() |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1513 |
self.ShowFullScreen(show) |
492c1c046c82
Add full screen mode (menu and title are hidden)
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2233
diff
changeset
|
1514 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1515 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1516 |
# Types Tree Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1517 |
# ------------------------------------------------------------------------------- |
814 | 1518 |
|
1519 |
def RefreshProjectTree(self): |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1520 |
# Extract current selected item tagname |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1521 |
selected = self.ProjectTree.GetSelection() |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1522 |
if selected is not None and selected.IsOk(): |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1523 |
item_infos = self.ProjectTree.GetPyData(selected) |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1524 |
tagname = item_infos.get("tagname", None) |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1525 |
else: |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1526 |
tagname = None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1527 |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1528 |
# Refresh treectrl items according to project infos |
1884
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1529 |
if self.Controler: |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1530 |
infos = self.Controler.GetProjectInfos() |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1531 |
root = self.ProjectTree.GetRootItem() |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1532 |
if root is None or not root.IsOk(): |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1533 |
root = self.ProjectTree.AddRoot(infos["name"]) |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1534 |
self.GenerateProjectTreeBranch(root, infos) |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1535 |
self.ProjectTree.Expand(root) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1536 |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1537 |
# Select new item corresponding to previous selected item |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1538 |
if tagname is not None: |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1539 |
self.SelectProjectTreeItem(tagname) |
814 | 1540 |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1541 |
def GenerateProjectTreeBranch(self, root, infos, item_alone=False): |
814 | 1542 |
to_delete = [] |
1543 |
item_name = infos["name"] |
|
1544 |
if infos["type"] in ITEMS_UNEDITABLE: |
|
1545 |
if len(infos["values"]) == 1: |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1546 |
return self.GenerateProjectTreeBranch(root, infos["values"][0], True) |
814 | 1547 |
item_name = _(item_name) |
1548 |
self.ProjectTree.SetItemText(root, item_name) |
|
1549 |
self.ProjectTree.SetPyData(root, infos) |
|
1635
25e3bf6e193d
change white background for project tree element to transparent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1610
diff
changeset
|
1550 |
highlight_colours = self.Highlights.get(infos.get("tagname", None), (wx.Colour(255, 255, 255, 0), wx.BLACK)) |
1978
526013d2d462
#2579 On showing search result, text color of tree item is set to white. We need to change back color to show the result.
dporopat <denis.poropat@smarteh.si>
parents:
1948
diff
changeset
|
1551 |
self.ProjectTree.SetItemBackgroundColour(root, highlight_colours[0]) |
814 | 1552 |
self.ProjectTree.SetItemTextColour(root, highlight_colours[1]) |
1188
63afb5833bd8
Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents:
1176
diff
changeset
|
1553 |
self.ProjectTree.SetItemExtraImage(root, None) |
814 | 1554 |
if infos["type"] == ITEM_POU: |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1555 |
self.ProjectTree.SetItemImage( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1556 |
root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])]) |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1557 |
if item_alone: |
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1558 |
self.ProjectTree.SetItemExtraImage(root, self.Controler.GetPouType(infos["name"])) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
1559 |
elif "icon" in infos and infos["icon"] is not None: |
814 | 1560 |
icon_name = infos["icon"] |
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
1561 |
if icon_name not in self.TreeImageDict: |
814 | 1562 |
self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name)) |
1563 |
self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name]) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
1564 |
elif infos["type"] in self.TreeImageDict: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1565 |
self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]]) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1566 |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1567 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
814 | 1568 |
for values in infos["values"]: |
1569 |
if values["type"] not in ITEMS_UNEDITABLE or len(values["values"]) > 0: |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1570 |
if item is None or not item.IsOk(): |
814 | 1571 |
item = self.ProjectTree.AppendItem(root, "") |
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1572 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
814 | 1573 |
self.GenerateProjectTreeBranch(item, values) |
1574 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1575 |
while item is not None and item.IsOk(): |
814 | 1576 |
to_delete.append(item) |
1577 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1578 |
for item in to_delete: |
|
1579 |
self.ProjectTree.Delete(item) |
|
1580 |
||
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1581 |
TagNamePartsItemTypes = { |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1582 |
"D": [ITEM_DATATYPE], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1583 |
"P": [ITEM_POU], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1584 |
"T": [ITEM_POU, ITEM_TRANSITION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1585 |
"A": [ITEM_POU, ITEM_ACTION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1586 |
"C": [ITEM_CONFIGURATION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1587 |
"R": [ITEM_CONFIGURATION, ITEM_RESOURCE]} |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1588 |
|
814 | 1589 |
def SelectProjectTreeItem(self, tagname): |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1590 |
result = False |
814 | 1591 |
if self.ProjectTree is not None: |
1592 |
root = self.ProjectTree.GetRootItem() |
|
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1593 |
if root is not None and root.IsOk(): |
814 | 1594 |
words = tagname.split("::") |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1595 |
result = self.RecursiveProjectTreeItemSelection( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1596 |
root, zip(words[1:], self.TagNamePartsItemTypes.get(words[0], []))) |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1597 |
return result |
814 | 1598 |
|
1599 |
def RecursiveProjectTreeItemSelection(self, root, items): |
|
1600 |
found = False |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1601 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1602 |
while item is not None and item.IsOk() and not found: |
814 | 1603 |
item_infos = self.ProjectTree.GetPyData(item) |
1604 |
if (item_infos["name"].split(":")[-1].strip(), item_infos["type"]) == items[0]: |
|
1605 |
if len(items) == 1: |
|
1606 |
self.SelectedItem = item |
|
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1607 |
self.ProjectTree.SelectItem(item) |
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1608 |
self.ResetSelectedItem() |
814 | 1609 |
return True |
1610 |
else: |
|
1611 |
found = self.RecursiveProjectTreeItemSelection(item, items[1:]) |
|
1612 |
else: |
|
1613 |
found = self.RecursiveProjectTreeItemSelection(item, items) |
|
1614 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1615 |
return found |
|
1616 |
||
1243
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1617 |
def ResetSelectedItem(self): |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1618 |
self.SelectedItem = None |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1619 |
|
814 | 1620 |
def OnProjectTreeBeginDrag(self, event): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1621 |
selected_item = (self.SelectedItem |
1243
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1622 |
if self.SelectedItem is not None |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1623 |
else event.GetItem()) |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1624 |
if selected_item.IsOk() and self.ProjectTree.GetPyData(selected_item)["type"] == ITEM_POU: |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1625 |
block_name = self.ProjectTree.GetItemText(selected_item) |
814 | 1626 |
block_type = self.Controler.GetPouType(block_name) |
1627 |
if block_type != "program": |
|
1628 |
data = wx.TextDataObject(str((block_name, block_type, ""))) |
|
1629 |
dragSource = wx.DropSource(self.ProjectTree) |
|
1630 |
dragSource.SetData(data) |
|
1631 |
dragSource.DoDragDrop() |
|
1632 |
self.ResetSelectedItem() |
|
1633 |
||
1634 |
def OnProjectTreeItemBeginEdit(self, event): |
|
1635 |
selected = event.GetItem() |
|
1636 |
if self.ProjectTree.GetPyData(selected)["type"] in ITEMS_UNEDITABLE: |
|
1637 |
event.Veto() |
|
1638 |
else: |
|
1639 |
event.Skip() |
|
1640 |
||
1641 |
def OnProjectTreeItemEndEdit(self, event): |
|
1642 |
message = None |
|
1643 |
abort = False |
|
1644 |
new_name = event.GetLabel() |
|
1645 |
if new_name != "": |
|
1646 |
if not TestIdentifier(new_name): |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1647 |
message = _("\"%s\" is not a valid identifier!") % new_name |
814 | 1648 |
elif new_name.upper() in IEC_KEYWORDS: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1649 |
message = _("\"%s\" is a keyword. It can't be used!") % new_name |
814 | 1650 |
else: |
1651 |
item = event.GetItem() |
|
1652 |
old_name = self.ProjectTree.GetItemText(item) |
|
1653 |
item_infos = self.ProjectTree.GetPyData(item) |
|
1654 |
if item_infos["type"] == ITEM_PROJECT: |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
1655 |
self.Controler.SetProjectProperties(name=new_name) |
814 | 1656 |
elif item_infos["type"] == ITEM_DATATYPE: |
1657 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1658 |
message = _("\"%s\" data type already exists!") % new_name |
814 | 1659 |
abort = True |
1660 |
if not abort: |
|
1661 |
self.Controler.ChangeDataTypeName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1662 |
self.RefreshEditorNames(ComputeDataTypeName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1663 |
ComputeDataTypeName(new_name)) |
814 | 1664 |
self.RefreshPageTitles() |
1665 |
elif item_infos["type"] == ITEM_POU: |
|
1666 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1667 |
message = _("\"%s\" pou already exists!") % new_name |
814 | 1668 |
abort = True |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1669 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1670 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1671 |
if messageDialog.ShowModal() == wx.ID_NO: |
1672 |
abort = True |
|
1673 |
messageDialog.Destroy() |
|
1674 |
if not abort: |
|
1675 |
self.Controler.ChangePouName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1676 |
self.RefreshEditorNames(ComputePouName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1677 |
ComputePouName(new_name)) |
814 | 1678 |
self.RefreshLibraryPanel() |
1679 |
self.RefreshPageTitles() |
|
1680 |
elif item_infos["type"] == ITEM_TRANSITION: |
|
1610
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1681 |
pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
1682 |
pou_name = self.ProjectTree.GetItemText(pou_item) |
814 | 1683 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1684 |
message = _("A POU named \"%s\" already exists!") % new_name |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1685 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1686 |
message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
814 | 1687 |
else: |
1688 |
words = item_infos["tagname"].split("::") |
|
1689 |
self.Controler.ChangePouTransitionName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1690 |
self.RefreshEditorNames(ComputePouTransitionName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1691 |
ComputePouTransitionName(words[1], new_name)) |
814 | 1692 |
self.RefreshPageTitles() |
1693 |
elif item_infos["type"] == ITEM_ACTION: |
|
1610
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1694 |
pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1695 |
pou_name = self.ProjectTree.GetItemText(pou_item) |
814 | 1696 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1697 |
message = _("A POU named \"%s\" already exists!") % new_name |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1698 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1699 |
message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
814 | 1700 |
else: |
1701 |
words = item_infos["tagname"].split("::") |
|
1702 |
self.Controler.ChangePouActionName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1703 |
self.RefreshEditorNames(ComputePouActionName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1704 |
ComputePouActionName(words[1], new_name)) |
814 | 1705 |
self.RefreshPageTitles() |
1706 |
elif item_infos["type"] == ITEM_CONFIGURATION: |
|
1707 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1708 |
message = _("\"%s\" config already exists!") % new_name |
814 | 1709 |
abort = True |
1710 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1711 |
messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1712 |
if messageDialog.ShowModal() == wx.ID_NO: |
1713 |
abort = True |
|
1714 |
messageDialog.Destroy() |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1715 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1716 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1717 |
if messageDialog.ShowModal() == wx.ID_NO: |
1718 |
abort = True |
|
1719 |
messageDialog.Destroy() |
|
1720 |
if not abort: |
|
1721 |
self.Controler.ChangeConfigurationName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1722 |
self.RefreshEditorNames(ComputeConfigurationName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1723 |
ComputeConfigurationName(new_name)) |
814 | 1724 |
self.RefreshPageTitles() |
1725 |
elif item_infos["type"] == ITEM_RESOURCE: |
|
1726 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1727 |
message = _("\"%s\" config already exists!") % new_name |
814 | 1728 |
abort = True |
1729 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1730 |
messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1731 |
if messageDialog.ShowModal() == wx.ID_NO: |
1732 |
abort = True |
|
1733 |
messageDialog.Destroy() |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1734 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1735 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1736 |
if messageDialog.ShowModal() == wx.ID_NO: |
1737 |
abort = True |
|
1738 |
messageDialog.Destroy() |
|
1739 |
if not abort: |
|
1740 |
words = item_infos["tagname"].split("::") |
|
1741 |
self.Controler.ChangeConfigurationResourceName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1742 |
self.RefreshEditorNames(ComputeConfigurationResourceName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1743 |
ComputeConfigurationResourceName(words[1], new_name)) |
814 | 1744 |
self.RefreshPageTitles() |
1745 |
if message or abort: |
|
1746 |
if message: |
|
1747 |
self.ShowErrorMessage(message) |
|
1748 |
event.Veto() |
|
1749 |
else: |
|
1750 |
wx.CallAfter(self.RefreshProjectTree) |
|
1751 |
self.RefreshEditor() |
|
1752 |
self._Refresh(TITLE, FILEMENU, EDITMENU) |
|
1753 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1754 |
|
814 | 1755 |
def OnProjectTreeItemActivated(self, event): |
1756 |
selected = event.GetItem() |
|
1757 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1758 |
if item_infos["type"] == ITEM_PROJECT: |
|
1759 |
self.EditProjectSettings() |
|
1760 |
else: |
|
1761 |
if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1762 |
ITEM_CONFIGURATION, ITEM_RESOURCE, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1763 |
ITEM_TRANSITION, ITEM_ACTION]: |
814 | 1764 |
self.EditProjectElement(item_infos["type"], item_infos["tagname"]) |
1765 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1766 |
|
814 | 1767 |
def ProjectTreeItemSelect(self, select_item): |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1768 |
if select_item is not None and select_item.IsOk(): |
1112
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1769 |
item_infos = self.ProjectTree.GetPyData(select_item) |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1770 |
if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU, |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1771 |
ITEM_CONFIGURATION, ITEM_RESOURCE, |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1772 |
ITEM_TRANSITION, ITEM_ACTION]: |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1773 |
self.EditProjectElement(item_infos["type"], item_infos["tagname"], True) |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1774 |
self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"]) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1775 |
|
814 | 1776 |
def OnProjectTreeLeftUp(self, event): |
1777 |
if self.SelectedItem is not None: |
|
1778 |
self.ProjectTree.SelectItem(self.SelectedItem) |
|
1779 |
self.ProjectTreeItemSelect(self.SelectedItem) |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
1780 |
self.ResetSelectedItem() |
814 | 1781 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1782 |
|
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1783 |
def OnProjectTreeMotion(self, event): |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1784 |
if not event.Dragging(): |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1785 |
pt = wx.Point(event.GetX(), event.GetY()) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1786 |
item, flags = self.ProjectTree.HitTest(pt) |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1787 |
if item is not None and item.IsOk() and flags & wx.TREE_HITTEST_ONITEMLABEL: |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1788 |
item_infos = self.ProjectTree.GetPyData(item) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1789 |
if item != self.LastToolTipItem and self.LastToolTipItem is not None: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1790 |
self.ProjectTree.SetToolTip(None) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1791 |
self.LastToolTipItem = None |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
1792 |
if self.LastToolTipItem != item and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
1793 |
item_infos["type"] in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1794 |
bodytype = self.Controler.GetEditedElementBodyType( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1795 |
item_infos["tagname"]) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1796 |
if item_infos["type"] == ITEM_POU: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1797 |
block_type = { |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1798 |
"program": _("Program"), |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1799 |
"functionBlock": _("Function Block"), |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1800 |
"function": _("Function") |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1801 |
}[self.Controler.GetPouType(item_infos["name"])] |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1802 |
elif item_infos["type"] == ITEM_TRANSITION: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1803 |
block_type = "Transition" |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1804 |
else: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1805 |
block_type = "Action" |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1806 |
self.LastToolTipItem = item |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1807 |
wx.CallAfter(self.ProjectTree.SetToolTipString, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1808 |
"%s : %s : %s" % ( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1809 |
block_type, bodytype, item_infos["name"])) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1810 |
elif self.LastToolTipItem is not None: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1811 |
self.ProjectTree.SetToolTip(None) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1812 |
self.LastToolTipItem = None |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1813 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1814 |
|
814 | 1815 |
def OnProjectTreeItemChanging(self, event): |
1816 |
if self.ProjectTree.GetPyData(event.GetItem())["type"] not in ITEMS_UNEDITABLE and self.SelectedItem is None: |
|
1817 |
self.SelectedItem = event.GetItem() |
|
1818 |
event.Veto() |
|
1819 |
else: |
|
1820 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1821 |
|
2524
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1822 |
def GetProjectElementWindow(self, element, tagname): |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1823 |
new_window = None |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1824 |
if self.Controler.GetEditedElement(tagname) is not None: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1825 |
new_window = None |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1826 |
if element == ITEM_CONFIGURATION: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1827 |
new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1828 |
new_window.SetIcon(GetBitmap("CONFIGURATION")) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1829 |
elif element == ITEM_RESOURCE: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1830 |
new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1831 |
new_window.SetIcon(GetBitmap("RESOURCE")) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1832 |
elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1833 |
bodytype = self.Controler.GetEditedElementBodyType(tagname) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1834 |
if bodytype == "FBD": |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1835 |
new_window = Viewer(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1836 |
new_window.RefreshScaling(False) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1837 |
elif bodytype == "LD": |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1838 |
new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1839 |
new_window.RefreshScaling(False) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1840 |
elif bodytype == "SFC": |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1841 |
new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1842 |
new_window.RefreshScaling(False) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1843 |
else: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1844 |
new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1845 |
new_window.SetTextSyntax(bodytype) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1846 |
if bodytype == "IL": |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1847 |
new_window.SetKeywords(IL_KEYWORDS) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1848 |
else: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1849 |
new_window.SetKeywords(ST_KEYWORDS) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1850 |
if element == ITEM_POU: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1851 |
pou_type = self.Controler.GetEditedElementType(tagname)[1].upper() |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1852 |
icon = GetBitmap(pou_type, bodytype) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1853 |
elif element == ITEM_TRANSITION: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1854 |
icon = GetBitmap("TRANSITION", bodytype) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1855 |
elif element == ITEM_ACTION: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1856 |
icon = GetBitmap("ACTION", bodytype) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1857 |
new_window.SetIcon(icon) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1858 |
elif element == ITEM_DATATYPE: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1859 |
new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1860 |
new_window.SetIcon(GetBitmap("DATATYPE")) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1861 |
return new_window |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1862 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
1863 |
def EditProjectElement(self, element, tagname, onlyopened=False): |
814 | 1864 |
openedidx = self.IsOpened(tagname) |
1865 |
if openedidx is not None: |
|
1866 |
old_selected = self.TabsOpened.GetSelection() |
|
1867 |
if old_selected != openedidx: |
|
1868 |
if old_selected >= 0: |
|
1869 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
1870 |
self.TabsOpened.SetSelection(openedidx) |
|
1871 |
self._Refresh(FILEMENU, EDITMENU, EDITORTOOLBAR, PAGETITLES) |
|
1872 |
elif not onlyopened: |
|
870
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1873 |
if isinstance(element, EditorPanel): |
814 | 1874 |
new_window = element |
2524
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1875 |
else: |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1876 |
new_window = self.GetProjectElementWindow(element, tagname) |
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1877 |
|
814 | 1878 |
if new_window is not None: |
2524
c80b0d864475
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2457
diff
changeset
|
1879 |
self.AddPage(new_window, "") |
814 | 1880 |
openedidx = self.IsOpened(tagname) |
1881 |
old_selected = self.TabsOpened.GetSelection() |
|
1882 |
if old_selected != openedidx: |
|
1883 |
if old_selected >= 0: |
|
1884 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
1885 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
1886 |
window = self.TabsOpened.GetPage(i) |
|
1887 |
if window == new_window: |
|
1888 |
self.TabsOpened.SetSelection(i) |
|
1889 |
window.SetFocus() |
|
1890 |
self.RefreshPageTitles() |
|
1891 |
return new_window |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1892 |
|
814 | 1893 |
def OnProjectTreeRightUp(self, event): |
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
1894 |
item = event.GetItem() |
814 | 1895 |
self.ProjectTree.SelectItem(item) |
1896 |
self.ProjectTreeItemSelect(item) |
|
1897 |
name = self.ProjectTree.GetItemText(item) |
|
1898 |
item_infos = self.ProjectTree.GetPyData(item) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1899 |
|
814 | 1900 |
menu = None |
1901 |
if item_infos["type"] in ITEMS_UNEDITABLE + [ITEM_PROJECT]: |
|
1902 |
if item_infos["type"] == ITEM_PROJECT: |
|
1903 |
name = "Project" |
|
1904 |
else: |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
1905 |
name = self.UNEDITABLE_NAMES_DICT[name] |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1906 |
|
814 | 1907 |
if name == "Data Types": |
1908 |
menu = wx.Menu(title='') |
|
1909 |
new_id = wx.NewId() |
|
1910 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add DataType")) |
|
1911 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1912 |
|
814 | 1913 |
elif name in ["Functions", "Function Blocks", "Programs", "Project"]: |
1914 |
menu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1915 |
|
814 | 1916 |
if name != "Project": |
1917 |
new_id = wx.NewId() |
|
1918 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add POU")) |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
1919 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions": "function", "Function Blocks": "functionBlock", "Programs": "program"}[name]), id=new_id) |
814 | 1920 |
|
1921 |
new_id = wx.NewId() |
|
1922 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Paste POU")) |
|
1923 |
self.Bind(wx.EVT_MENU, self.OnPastePou, id=new_id) |
|
1924 |
if self.GetCopyBuffer() is None: |
|
1925 |
menu.Enable(new_id, False) |
|
1926 |
||
1927 |
elif name == "Configurations": |
|
1928 |
menu = wx.Menu(title='') |
|
1929 |
new_id = wx.NewId() |
|
1930 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Configuration")) |
|
1931 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1932 |
|
814 | 1933 |
elif name == "Transitions": |
1934 |
menu = wx.Menu(title='') |
|
1935 |
new_id = wx.NewId() |
|
1936 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition")) |
|
1010
44c3cafef436
Fixed typo in IDEFrame OnProjectTreeRightUp method
Laurent Bessard
parents:
999
diff
changeset
|
1937 |
parent = self.ProjectTree.GetItemParent(item) |
44c3cafef436
Fixed typo in IDEFrame OnProjectTreeRightUp method
Laurent Bessard
parents:
999
diff
changeset
|
1938 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
814 | 1939 |
while parent_type != ITEM_POU: |
1940 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1941 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1942 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(self.ProjectTree.GetItemText(parent)), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1943 |
|
814 | 1944 |
elif name == "Actions": |
1945 |
menu = wx.Menu(title='') |
|
1946 |
new_id = wx.NewId() |
|
1947 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action")) |
|
1948 |
parent = self.ProjectTree.GetItemParent(item) |
|
1949 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1950 |
while parent_type != ITEM_POU: |
|
1951 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1952 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1953 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(self.ProjectTree.GetItemText(parent)), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1954 |
|
814 | 1955 |
elif name == "Resources": |
1956 |
menu = wx.Menu(title='') |
|
1957 |
new_id = wx.NewId() |
|
1958 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource")) |
|
1959 |
parent = self.ProjectTree.GetItemParent(item) |
|
1960 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1961 |
while parent_type not in [ITEM_CONFIGURATION, ITEM_PROJECT]: |
|
1962 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1963 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1964 |
parent_name = None |
814 | 1965 |
if parent_type == ITEM_PROJECT: |
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1966 |
config_names = self.Controler.GetProjectConfigNames() |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1967 |
if len(config_names) > 0: |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1968 |
parent_name = config_names[0] |
814 | 1969 |
else: |
1970 |
parent_name = self.ProjectTree.GetItemText(parent) |
|
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1971 |
if parent_name is not None: |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1972 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), id=new_id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1973 |
|
814 | 1974 |
else: |
1975 |
if item_infos["type"] == ITEM_POU: |
|
1976 |
menu = wx.Menu(title='') |
|
1977 |
if self.Controler.GetPouBodyType(name) == "SFC": |
|
1978 |
new_id = wx.NewId() |
|
1979 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition")) |
|
1980 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id) |
|
1981 |
new_id = wx.NewId() |
|
1982 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action")) |
|
1983 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id) |
|
1984 |
menu.AppendSeparator() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1985 |
|
814 | 1986 |
new_id = wx.NewId() |
1987 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy POU")) |
|
1988 |
self.Bind(wx.EVT_MENU, self.OnCopyPou, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1989 |
|
814 | 1990 |
pou_type = self.Controler.GetPouType(name) |
1991 |
if pou_type in ["function", "functionBlock"]: |
|
1992 |
change_menu = wx.Menu(title='') |
|
1993 |
if pou_type == "function": |
|
1994 |
new_id = wx.NewId() |
|
1995 |
AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Function Block")) |
|
1996 |
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), id=new_id) |
|
1997 |
new_id = wx.NewId() |
|
1998 |
AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Program")) |
|
1999 |
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id) |
|
2614
6b4061f6ced6
'Change POU Type To' becomes 'Duplicate as...', avoiding side effects of type change when POU is already instanciated. Also remove leftover returType tag in ex-function POUs, triggering exceptions at build time.
Edouard Tisserant
parents:
2529
diff
changeset
|
2000 |
menu.AppendMenu(wx.NewId(), _("Duplicate as..."), change_menu) |
814 | 2001 |
new_id = wx.NewId() |
2002 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Rename")) |
|
2003 |
self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2004 |
|
814 | 2005 |
elif item_infos["type"] == ITEM_CONFIGURATION: |
2006 |
menu = wx.Menu(title='') |
|
2007 |
new_id = wx.NewId() |
|
2008 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource")) |
|
2009 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2010 |
|
814 | 2011 |
elif item_infos["type"] in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]: |
2012 |
menu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2013 |
|
814 | 2014 |
if menu is not None: |
2015 |
new_id = wx.NewId() |
|
2016 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete")) |
|
2017 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2018 |
|
814 | 2019 |
if menu is not None: |
1480
79e54c5dead5
fix issue, then it wasn't possible to remove functional blocks from
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1408
diff
changeset
|
2020 |
self.FindFocus().PopupMenu(menu) |
814 | 2021 |
menu.Destroy() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2022 |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
2023 |
self.ResetSelectedItem() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2024 |
|
814 | 2025 |
event.Skip() |
2026 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2027 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2028 |
# Instances Tree Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2029 |
# ------------------------------------------------------------------------------- |
814 | 2030 |
|
2031 |
def GetTreeImage(self, var_class): |
|
2032 |
return self.TreeImageDict[var_class] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2033 |
|
814 | 2034 |
def RefreshPouInstanceVariablesPanel(self): |
2035 |
self.PouInstanceVariablesPanel.RefreshView() |
|
2036 |
||
2037 |
def OpenDebugViewer(self, instance_category, instance_path, instance_type): |
|
2038 |
openedidx = self.IsOpened(instance_path) |
|
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
916
diff
changeset
|
2039 |
new_window = None |
814 | 2040 |
if openedidx is not None: |
2041 |
old_selected = self.TabsOpened.GetSelection() |
|
2042 |
if old_selected != openedidx: |
|
2043 |
if old_selected >= 0: |
|
2044 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
2045 |
self.TabsOpened.SetSelection(openedidx) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2046 |
|
814 | 2047 |
elif instance_category in ITEMS_VARIABLE: |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2048 |
if self.Controler.IsNumType(instance_type, True): |
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2049 |
self.AddDebugVariable(instance_path, True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2050 |
|
814 | 2051 |
else: |
2052 |
bodytype = self.Controler.GetEditedElementBodyType(instance_type, True) |
|
2053 |
if bodytype == "FBD": |
|
2054 |
new_window = Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2055 |
new_window.RefreshScaling(False) |
|
2056 |
elif bodytype == "LD": |
|
2057 |
new_window = LD_Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2058 |
new_window.RefreshScaling(False) |
|
2059 |
elif bodytype == "SFC": |
|
2060 |
new_window = SFC_Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2061 |
new_window.RefreshScaling(False) |
|
2062 |
else: |
|
2063 |
new_window = TextViewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2064 |
new_window.SetTextSyntax(bodytype) |
|
2065 |
if bodytype == "IL": |
|
2066 |
new_window.SetKeywords(IL_KEYWORDS) |
|
2067 |
else: |
|
2068 |
new_window.SetKeywords(ST_KEYWORDS) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2069 |
|
814 | 2070 |
if new_window is not None: |
2071 |
if instance_category in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM]: |
|
2072 |
pou_type = self.Controler.GetEditedElementType(instance_type, True)[1].upper() |
|
2073 |
icon = GetBitmap(pou_type, bodytype) |
|
2074 |
elif instance_category == ITEM_TRANSITION: |
|
2075 |
icon = GetBitmap("TRANSITION", bodytype) |
|
2076 |
elif instance_category == ITEM_ACTION: |
|
2077 |
icon = GetBitmap("ACTION", bodytype) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2078 |
|
885
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2079 |
if new_window is not None: |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2080 |
new_window.SetIcon(icon) |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2081 |
self.AddPage(new_window, "") |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2082 |
new_window.RefreshView() |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2083 |
new_window.SetFocus() |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2084 |
self.RefreshPageTitles() |
814 | 2085 |
return new_window |
2086 |
||
2087 |
def ResetGraphicViewers(self): |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2088 |
if self.EnableDebug: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2089 |
self.DebugVariablePanel.ResetGraphicsValues() |
814 | 2090 |
|
2091 |
def CloseObsoleteDebugTabs(self): |
|
2092 |
if self.EnableDebug: |
|
2093 |
idxs = range(self.TabsOpened.GetPageCount()) |
|
2094 |
idxs.reverse() |
|
2095 |
for idx in idxs: |
|
2096 |
editor = self.TabsOpened.GetPage(idx) |
|
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2097 |
if isinstance(editor, Viewer) and editor.IsDebugging(): |
814 | 2098 |
instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug) |
2099 |
if instance_infos is None: |
|
2100 |
self.TabsOpened.DeletePage(idx) |
|
2101 |
else: |
|
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1171
diff
changeset
|
2102 |
editor.SubscribeAllDataConsumers() |
1710
953ceea2573e
fix bug with TextViewer instance in debug mode, appears after transferring new program on PLC
Surkov Sergey <surkovsv93@gmail.com>
parents:
1708
diff
changeset
|
2103 |
elif editor.IsDebugging() and hasattr(editor, 'SubscribeAllDataConsumers'): |
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1171
diff
changeset
|
2104 |
editor.SubscribeAllDataConsumers() |
1207 | 2105 |
self.DebugVariablePanel.SubscribeAllDataConsumers() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2106 |
|
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1207
diff
changeset
|
2107 |
def AddDebugVariable(self, iec_path, force=False, graph=False): |
814 | 2108 |
if self.EnableDebug: |
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1207
diff
changeset
|
2109 |
self.DebugVariablePanel.InsertValue(iec_path, force=force, graph=graph) |
814 | 2110 |
self.EnsureTabVisible(self.DebugVariablePanel) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2111 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2112 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2113 |
# Library Panel Management Function |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2114 |
# ------------------------------------------------------------------------------- |
814 | 2115 |
|
2116 |
def RefreshLibraryPanel(self): |
|
2117 |
self.LibraryPanel.RefreshTree() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2118 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2119 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2120 |
# ToolBars Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2121 |
# ------------------------------------------------------------------------------- |
814 | 2122 |
|
2123 |
def AddToMenuToolBar(self, items): |
|
2124 |
MenuToolBar = self.Panes["MenuToolBar"] |
|
2125 |
if MenuToolBar.GetToolsCount() > 0: |
|
2126 |
MenuToolBar.AddSeparator() |
|
2127 |
for toolbar_item in items: |
|
2128 |
if toolbar_item is None: |
|
2129 |
MenuToolBar.AddSeparator() |
|
2130 |
else: |
|
2131 |
id, bitmap, help, callback = toolbar_item |
|
2132 |
MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=GetBitmap(bitmap)) |
|
2133 |
if callback is not None: |
|
2134 |
self.Bind(wx.EVT_TOOL, callback, id=id) |
|
2135 |
MenuToolBar.Realize() |
|
2136 |
self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize()) |
|
2137 |
||
2138 |
def ResetEditorToolBar(self): |
|
2139 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2140 |
|
814 | 2141 |
for item in self.CurrentEditorToolBar: |
2177
10aa87518401
Drop support for wxPython 2.6 and below
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2169
diff
changeset
|
2142 |
self.Unbind(wx.EVT_MENU, id=item) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2143 |
|
814 | 2144 |
if EditorToolBar: |
2145 |
EditorToolBar.DeleteTool(item) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2146 |
|
814 | 2147 |
if EditorToolBar: |
2148 |
EditorToolBar.Realize() |
|
2149 |
self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |
|
2150 |
self.AUIManager.GetPane("EditorToolBar").Hide() |
|
2151 |
self.AUIManager.Update() |
|
2152 |
||
2153 |
def RefreshEditorToolBar(self): |
|
2154 |
selected = self.TabsOpened.GetSelection() |
|
2155 |
menu = None |
|
2156 |
if selected != -1: |
|
2157 |
window = self.TabsOpened.GetPage(selected) |
|
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2158 |
if isinstance(window, (Viewer, TextViewer)): |
814 | 2159 |
if not window.IsDebugging(): |
2160 |
menu = self.Controler.GetEditedElementBodyType(window.GetTagName()) |
|
2161 |
else: |
|
2162 |
menu = "debug" |
|
2163 |
if menu is not None and menu != self.CurrentMenu: |
|
2164 |
self.ResetEditorToolBar() |
|
2165 |
self.CurrentMenu = menu |
|
2166 |
self.CurrentEditorToolBar = [] |
|
2167 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
2168 |
if EditorToolBar: |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
2169 |
for radio, modes, id, method, picture, help in self.EditorToolBarItems[menu]: |
814 | 2170 |
if modes & self.DrawingMode: |
2171 |
if radio or self.DrawingMode == FREEDRAWING_MODE: |
|
2172 |
EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help) |
|
2173 |
else: |
|
2174 |
EditorToolBar.AddSimpleTool(id, GetBitmap(picture), help) |
|
2175 |
self.Bind(wx.EVT_MENU, getattr(self, method), id=id) |
|
2176 |
self.CurrentEditorToolBar.append(id) |
|
2177 |
EditorToolBar.Realize() |
|
2178 |
self.AUIManager.GetPane("EditorToolBar").Show() |
|
2179 |
self.AUIManager.Update() |
|
2256
5927710b5610
Fix non-usable toolbar on wxPython with GTK3+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2243
diff
changeset
|
2180 |
self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |
2302
69fefac5760e
Fix non-usable toolbar on wxPython with GTK3+ in PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2301
diff
changeset
|
2181 |
self.AUIManager.Update() |
814 | 2182 |
elif menu is None: |
2183 |
self.ResetEditorToolBar() |
|
2184 |
self.CurrentMenu = menu |
|
2185 |
self.ResetCurrentMode() |
|
2186 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2187 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2188 |
# EditorToolBar Items Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2189 |
# ------------------------------------------------------------------------------- |
814 | 2190 |
|
2191 |
def ResetCurrentMode(self): |
|
2192 |
selected = self.TabsOpened.GetSelection() |
|
2193 |
if selected != -1: |
|
2194 |
window = self.TabsOpened.GetPage(selected) |
|
2195 |
window.SetMode(MODE_SELECTION) |
|
2196 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
2197 |
if EditorToolBar: |
|
2198 |
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, False) |
|
2199 |
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, True) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2200 |
|
814 | 2201 |
def ResetToolToggle(self, id): |
2202 |
tool = self.Panes["EditorToolBar"].FindById(id) |
|
2203 |
tool.SetToggle(False) |
|
2204 |
||
2205 |
def OnSelectionTool(self, event): |
|
2206 |
selected = self.TabsOpened.GetSelection() |
|
2207 |
if selected != -1: |
|
2208 |
self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2209 |
|
814 | 2210 |
def OnMotionTool(self, event): |
2211 |
selected = self.TabsOpened.GetSelection() |
|
2212 |
if selected != -1: |
|
2213 |
self.TabsOpened.GetPage(selected).SetMode(MODE_MOTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2214 |
|
814 | 2215 |
def OnCommentTool(self, event): |
2216 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOMMENT) |
|
2217 |
selected = self.TabsOpened.GetSelection() |
|
2218 |
if selected != -1: |
|
2219 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2220 |
|
814 | 2221 |
def OnVariableTool(self, event): |
2222 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARVARIABLE) |
|
2223 |
selected = self.TabsOpened.GetSelection() |
|
2224 |
if selected != -1: |
|
2225 |
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2226 |
|
814 | 2227 |
def OnBlockTool(self, event): |
2228 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARBLOCK) |
|
2229 |
selected = self.TabsOpened.GetSelection() |
|
2230 |
if selected != -1: |
|
2231 |
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2232 |
|
814 | 2233 |
def OnConnectionTool(self, event): |
2234 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONNECTION) |
|
2235 |
selected = self.TabsOpened.GetSelection() |
|
2236 |
if selected != -1: |
|
2237 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2238 |
|
814 | 2239 |
def OnPowerRailTool(self, event): |
2240 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL) |
|
2241 |
selected = self.TabsOpened.GetSelection() |
|
2242 |
if selected != -1: |
|
2243 |
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2244 |
|
814 | 2245 |
def OnRungTool(self, event): |
2246 |
selected = self.TabsOpened.GetSelection() |
|
2247 |
if selected != -1: |
|
2248 |
self.TabsOpened.GetPage(selected).AddLadderRung() |
|
2249 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2250 |
|
814 | 2251 |
def OnCoilTool(self, event): |
2252 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOIL) |
|
2253 |
selected = self.TabsOpened.GetSelection() |
|
2254 |
if selected != -1: |
|
2255 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COIL) |
|
2256 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2257 |
|
814 | 2258 |
def OnContactTool(self, event): |
2259 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
2260 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONTACT) |
|
2261 |
selected = self.TabsOpened.GetSelection() |
|
2262 |
if selected != -1: |
|
2263 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
2264 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT) |
|
2265 |
else: |
|
2266 |
self.TabsOpened.GetPage(selected).AddLadderContact() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2267 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2268 |
def OnBranchTool(self, event): |
814 | 2269 |
selected = self.TabsOpened.GetSelection() |
2270 |
if selected != -1: |
|
2271 |
self.TabsOpened.GetPage(selected).AddLadderBranch() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2272 |
|
814 | 2273 |
def OnInitialStepTool(self, event): |
2274 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP) |
|
2275 |
selected = self.TabsOpened.GetSelection() |
|
2276 |
if selected != -1: |
|
2277 |
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2278 |
|
814 | 2279 |
def OnStepTool(self, event): |
2280 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2281 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARSTEP) |
|
2282 |
selected = self.TabsOpened.GetSelection() |
|
2283 |
if selected != -1: |
|
2284 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2285 |
self.TabsOpened.GetPage(selected).SetMode(MODE_STEP) |
|
2286 |
else: |
|
2287 |
self.TabsOpened.GetPage(selected).AddStep() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2288 |
|
814 | 2289 |
def OnActionBlockTool(self, event): |
2290 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2291 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK) |
|
2292 |
selected = self.TabsOpened.GetSelection() |
|
2293 |
if selected != -1: |
|
2294 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2295 |
self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION) |
|
2296 |
else: |
|
2297 |
self.TabsOpened.GetPage(selected).AddStepAction() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2298 |
|
814 | 2299 |
def OnTransitionTool(self, event): |
2300 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARTRANSITION) |
|
2301 |
selected = self.TabsOpened.GetSelection() |
|
2302 |
if selected != -1: |
|
2303 |
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2304 |
|
814 | 2305 |
def OnDivergenceTool(self, event): |
2306 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2307 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE) |
|
2308 |
selected = self.TabsOpened.GetSelection() |
|
2309 |
if selected != -1: |
|
2310 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2311 |
self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE) |
|
2312 |
else: |
|
2313 |
self.TabsOpened.GetPage(selected).AddDivergence() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2314 |
|
814 | 2315 |
def OnJumpTool(self, event): |
2316 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2317 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARJUMP) |
|
2318 |
selected = self.TabsOpened.GetSelection() |
|
2319 |
if selected != -1: |
|
2320 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2321 |
self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP) |
|
2322 |
else: |
|
2323 |
self.TabsOpened.GetPage(selected).AddJump() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2324 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2325 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2326 |
# Add Project Elements Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2327 |
# ------------------------------------------------------------------------------- |
814 | 2328 |
|
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2329 |
def OnAddNewProject(self, event): |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2330 |
# Asks user to create main program after creating new project |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2331 |
AddProgramDialog = self.GenerateAddPouFunction('program', True) |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2332 |
# Checks that user created main program |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2333 |
if AddProgramDialog(event): |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2334 |
self.Controler.SetProjectDefaultConfiguration() |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2335 |
|
814 | 2336 |
def OnAddDataTypeMenu(self, event): |
2337 |
tagname = self.Controler.ProjectAddDataType() |
|
2338 |
if tagname is not None: |
|
2339 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2340 |
self.EditProjectElement(ITEM_DATATYPE, tagname) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2341 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
2342 |
def GenerateAddPouFunction(self, pou_type, type_readonly=False): |
814 | 2343 |
def OnAddPouMenu(event): |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2344 |
dialog = PouDialog(self, pou_type, type_readonly) |
814 | 2345 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2346 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames()) |
814 | 2347 |
dialog.SetValues({"pouName": self.Controler.GenerateNewName(None, None, "%s%%d" % pou_type)}) |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2348 |
pou_created = False |
814 | 2349 |
if dialog.ShowModal() == wx.ID_OK: |
2350 |
values = dialog.GetValues() |
|
2351 |
tagname = self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"]) |
|
2352 |
if tagname is not None: |
|
2353 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2354 |
self.EditProjectElement(ITEM_POU, tagname) |
|
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2355 |
dialog.Destroy() |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2356 |
pou_created = True |
814 | 2357 |
dialog.Destroy() |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2358 |
return pou_created |
814 | 2359 |
return OnAddPouMenu |
2360 |
||
2361 |
def GenerateAddTransitionFunction(self, pou_name): |
|
2362 |
def OnAddTransitionMenu(event): |
|
2363 |
dialog = PouTransitionDialog(self) |
|
2364 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2365 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames(pou_name)) |
814 | 2366 |
dialog.SetValues({"transitionName": self.Controler.GenerateNewName(None, None, "transition%d")}) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2367 |
if dialog.ShowModal() == wx.ID_OK: |
814 | 2368 |
values = dialog.GetValues() |
2369 |
tagname = self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"]) |
|
2370 |
if tagname is not None: |
|
2371 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2372 |
self.EditProjectElement(ITEM_TRANSITION, tagname) |
|
2373 |
dialog.Destroy() |
|
2374 |
return OnAddTransitionMenu |
|
2375 |
||
2376 |
def GenerateAddActionFunction(self, pou_name): |
|
2377 |
def OnAddActionMenu(event): |
|
2378 |
dialog = PouActionDialog(self) |
|
2379 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2380 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames(pou_name)) |
814 | 2381 |
dialog.SetValues({"actionName": self.Controler.GenerateNewName(None, None, "action%d")}) |
2382 |
if dialog.ShowModal() == wx.ID_OK: |
|
2383 |
values = dialog.GetValues() |
|
2384 |
tagname = self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"]) |
|
2385 |
if tagname is not None: |
|
2386 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2387 |
self.EditProjectElement(ITEM_ACTION, tagname) |
|
2388 |
dialog.Destroy() |
|
2389 |
return OnAddActionMenu |
|
2390 |
||
2391 |
def OnAddConfigurationMenu(self, event): |
|
2392 |
tagname = self.Controler.ProjectAddConfiguration() |
|
2393 |
if tagname is not None: |
|
2394 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2395 |
self.EditProjectElement(ITEM_CONFIGURATION, tagname) |
|
2396 |
||
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2397 |
def AddResourceMenu(self, event): |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2398 |
config_names = self.Controler.GetProjectConfigNames() |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2399 |
if len(config_names) > 0: |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2400 |
tagname = self.Controler.ProjectAddConfigurationResource(config_names[0]) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2401 |
if tagname is not None: |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2402 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2403 |
self.EditProjectElement(ITEM_RESOURCE, tagname) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2404 |
|
814 | 2405 |
def GenerateAddResourceFunction(self, config_name): |
2406 |
def OnAddResourceMenu(event): |
|
2407 |
tagname = self.Controler.ProjectAddConfigurationResource(config_name) |
|
2408 |
if tagname is not None: |
|
2409 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2410 |
self.EditProjectElement(ITEM_RESOURCE, tagname) |
|
2411 |
return OnAddResourceMenu |
|
2412 |
||
2413 |
def GenerateChangePouTypeFunction(self, name, new_type): |
|
2414 |
def OnChangePouTypeMenu(event): |
|
2415 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2416 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
814 | 2417 |
self.Controler.ProjectChangePouType(name, new_type) |
2418 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2419 |
return OnChangePouTypeMenu |
|
2420 |
||
2421 |
def OnCopyPou(self, event): |
|
2422 |
selected = self.ProjectTree.GetSelection() |
|
2423 |
pou_name = self.ProjectTree.GetItemText(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2424 |
|
814 | 2425 |
pou_xml = self.Controler.GetPouXml(pou_name) |
2426 |
if pou_xml is not None: |
|
2427 |
self.SetCopyBuffer(pou_xml) |
|
2428 |
self._Refresh(EDITMENU) |
|
2429 |
||
2430 |
def OnPastePou(self, event): |
|
2431 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2432 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2433 |
if self.ProjectTree.GetPyData(selected)["type"] != ITEM_PROJECT: |
814 | 2434 |
pou_type = self.ProjectTree.GetItemText(selected) |
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2256
diff
changeset
|
2435 |
pou_type = self.UNEDITABLE_NAMES_DICT[pou_type] # one of 'Functions', 'Function Blocks' or 'Programs' |
814 | 2436 |
pou_type = {'Functions': 'function', 'Function Blocks': 'functionBlock', 'Programs': 'program'}[pou_type] |
2437 |
else: |
|
2438 |
pou_type = None |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2439 |
|
814 | 2440 |
pou_xml = self.GetCopyBuffer() |
2441 |
||
2442 |
result = self.Controler.PastePou(pou_type, pou_xml) |
|
2443 |
||
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
2444 |
if not isinstance(result, tuple): |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2445 |
self.ShowErrorMessage(result) |
814 | 2446 |
else: |
2447 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2448 |
self.EditProjectElement(ITEM_POU, result[0]) |
|
2449 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2450 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2451 |
# Remove Project Elements Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2452 |
# ------------------------------------------------------------------------------- |
814 | 2453 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2454 |
def CheckElementIsUsedBeforeDeletion(self, check_function, title, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2455 |
if not check_function(name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2456 |
return True |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2457 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
2458 |
dialog = wx.MessageDialog( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
2459 |
self, |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2460 |
_("\"%s\" is used by one or more POUs. Do you wish to continue?") % name, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
2461 |
title, wx.YES_NO | wx.ICON_QUESTION) |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2462 |
answer = dialog.ShowModal() |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2463 |
dialog.Destroy() |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2464 |
return answer == wx.ID_YES |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2465 |
|
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2466 |
def CheckDataTypeIsUsedBeforeDeletion(self, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2467 |
return self.CheckElementIsUsedBeforeDeletion( |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2468 |
self.Controler.DataTypeIsUsed, |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2469 |
_("Remove Datatype"), name) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2470 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2471 |
def CheckPouIsUsedBeforeDeletion(self, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2472 |
return self.CheckElementIsUsedBeforeDeletion( |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2473 |
self.Controler.PouIsUsed, |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2474 |
_("Remove Pou"), name) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2475 |
|
814 | 2476 |
def OnRemoveDataTypeMenu(self, event): |
2477 |
selected = self.ProjectTree.GetSelection() |
|
2478 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_DATATYPE: |
|
2479 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2480 |
if self.CheckDataTypeIsUsedBeforeDeletion(name): |
814 | 2481 |
self.Controler.ProjectRemoveDataType(name) |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2482 |
tagname = ComputeDataTypeName(name) |
814 | 2483 |
idx = self.IsOpened(tagname) |
2484 |
if idx is not None: |
|
2485 |
self.TabsOpened.DeletePage(idx) |
|
2486 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2487 |
|
814 | 2488 |
def OnRenamePouMenu(self, event): |
2489 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2490 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
814 | 2491 |
wx.CallAfter(self.ProjectTree.EditLabel, selected) |
2492 |
||
2493 |
def OnRemovePouMenu(self, event): |
|
2494 |
selected = self.ProjectTree.GetSelection() |
|
2495 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
|
2496 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2497 |
if self.CheckPouIsUsedBeforeDeletion(name): |
814 | 2498 |
self.Controler.ProjectRemovePou(name) |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2499 |
tagname = ComputePouName(name) |
814 | 2500 |
idx = self.IsOpened(tagname) |
2501 |
if idx is not None: |
|
2502 |
self.TabsOpened.DeletePage(idx) |
|
2503 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
|
2504 |
||
2505 |
def OnRemoveTransitionMenu(self, event): |
|
2506 |
selected = self.ProjectTree.GetSelection() |
|
2507 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2508 |
if item_infos["type"] == ITEM_TRANSITION: |
814 | 2509 |
transition = self.ProjectTree.GetItemText(selected) |
2510 |
pou_name = item_infos["tagname"].split("::")[1] |
|
2511 |
self.Controler.ProjectRemovePouTransition(pou_name, transition) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2512 |
tagname = ComputePouTransitionName(pou_name, transition) |
814 | 2513 |
idx = self.IsOpened(tagname) |
2514 |
if idx is not None: |
|
2515 |
self.TabsOpened.DeletePage(idx) |
|
2516 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2517 |
||
2518 |
def OnRemoveActionMenu(self, event): |
|
2519 |
selected = self.ProjectTree.GetSelection() |
|
2520 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2521 |
if item_infos["type"] == ITEM_ACTION: |
814 | 2522 |
action = self.ProjectTree.GetItemText(selected) |
2523 |
pou_name = item_infos["tagname"].split("::")[1] |
|
2524 |
self.Controler.ProjectRemovePouAction(pou_name, action) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2525 |
tagname = ComputePouActionName(pou_name, action) |
814 | 2526 |
idx = self.IsOpened(tagname) |
2527 |
if idx is not None: |
|
2528 |
self.TabsOpened.DeletePage(idx) |
|
2529 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2530 |
||
2531 |
def OnRemoveConfigurationMenu(self, event): |
|
2532 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2533 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFIGURATION: |
814 | 2534 |
name = self.ProjectTree.GetItemText(selected) |
2535 |
self.Controler.ProjectRemoveConfiguration(name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2536 |
tagname = ComputeConfigurationName(name) |
814 | 2537 |
idx = self.IsOpened(tagname) |
2538 |
if idx is not None: |
|
2539 |
self.TabsOpened.DeletePage(idx) |
|
2540 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2541 |
||
2542 |
def OnRemoveResourceMenu(self, event): |
|
2543 |
selected = self.ProjectTree.GetSelection() |
|
2544 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
2545 |
if item_infos["type"] == ITEM_RESOURCE: |
|
2546 |
resource = self.ProjectTree.GetItemText(selected) |
|
2547 |
config_name = item_infos["tagname"].split("::")[1] |
|
2548 |
self.Controler.ProjectRemoveConfigurationResource(config_name, resource) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2549 |
tagname = ComputeConfigurationResourceName(config_name, selected) |
814 | 2550 |
idx = self.IsOpened(tagname) |
2551 |
if idx is not None: |
|
2552 |
self.TabsOpened.DeletePage(idx) |
|
2553 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2554 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2555 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2556 |
# Highlights showing functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2557 |
# ------------------------------------------------------------------------------- |
814 | 2558 |
|
2559 |
def ShowHighlight(self, infos, start, end, highlight_type): |
|
2560 |
self.SelectProjectTreeItem(infos[0]) |
|
2561 |
if infos[1] == "name": |
|
2562 |
self.Highlights[infos[0]] = highlight_type |
|
2563 |
self.RefreshProjectTree() |
|
2564 |
self.ProjectTree.Unselect() |
|
2565 |
else: |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2566 |
self.EditProjectElement(GetElementType(infos[0]), infos[0]) |
814 | 2567 |
selected = self.TabsOpened.GetSelection() |
2568 |
if selected != -1: |
|
2569 |
viewer = self.TabsOpened.GetPage(selected) |
|
2570 |
viewer.AddHighlight(infos[1:], start, end, highlight_type) |
|
2571 |
||
2572 |
def ShowError(self, infos, start, end): |
|
2573 |
self.ShowHighlight(infos, start, end, ERROR_HIGHLIGHT) |
|
2574 |
||
2575 |
def ShowSearchResult(self, infos, start, end): |
|
2576 |
self.ShowHighlight(infos, start, end, SEARCH_RESULT_HIGHLIGHT) |
|
2577 |
||
2578 |
def ClearHighlights(self, highlight_type=None): |
|
2579 |
if highlight_type is None: |
|
2580 |
self.Highlights = {} |
|
2581 |
else: |
|
2582 |
self.Highlights = dict([(name, highlight) for name, highlight in self.Highlights.iteritems() if highlight != highlight_type]) |
|
2583 |
self.RefreshProjectTree() |
|
2584 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
2585 |
viewer = self.TabsOpened.GetPage(i) |
|
2586 |
viewer.ClearHighlights(highlight_type) |
|
2587 |
||
2588 |
def ClearErrors(self): |
|
2589 |
self.ClearHighlights(ERROR_HIGHLIGHT) |
|
2590 |
||
2591 |
def ClearSearchResults(self): |
|
2592 |
self.ClearHighlights(SEARCH_RESULT_HIGHLIGHT) |
|
838 | 2593 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2594 |
# ------------------------------------------------------------------------------- |
838 | 2595 |
# Viewer Printout |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2596 |
# ------------------------------------------------------------------------------- |
838 | 2597 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
2598 |
|
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
2599 |
def UPPER_DIV(x, y): |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2600 |
return (x // y) + {True: 0, False: 1}[(x % y) == 0] |
838 | 2601 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
2602 |
|
838 | 2603 |
class GraphicPrintout(wx.Printout): |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
2604 |
def __init__(self, viewer, page_size, margins, preview=False): |
838 | 2605 |
wx.Printout.__init__(self) |
2606 |
self.Viewer = viewer |
|
2607 |
self.PageSize = page_size |
|
2608 |
if self.PageSize[0] == 0 or self.PageSize[1] == 0: |
|
2609 |
self.PageSize = (1050, 1485) |
|
2610 |
self.Preview = preview |
|
2611 |
self.Margins = margins |
|
2612 |
self.FontSize = 5 |
|
2613 |
self.TextMargin = 3 |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2614 |
|
838 | 2615 |
maxx, maxy = viewer.GetMaxSize() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2616 |
self.PageGrid = (UPPER_DIV(maxx, self.PageSize[0]), |
838 | 2617 |
UPPER_DIV(maxy, self.PageSize[1])) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2618 |
|
838 | 2619 |
def GetPageNumber(self): |
2620 |
return self.PageGrid[0] * self.PageGrid[1] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2621 |
|
838 | 2622 |
def HasPage(self, page): |
2623 |
return page <= self.GetPageNumber() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2624 |
|
838 | 2625 |
def GetPageInfo(self): |
2626 |
page_number = self.GetPageNumber() |
|
2627 |
return (1, page_number, 1, page_number) |
|
2628 |
||
2629 |
def OnBeginDocument(self, startPage, endPage): |
|
2630 |
dc = self.GetDC() |
|
2631 |
if not self.Preview and isinstance(dc, wx.PostScriptDC): |
|
2632 |
dc.SetResolution(720) |
|
2633 |
super(GraphicPrintout, self).OnBeginDocument(startPage, endPage) |
|
2634 |
||
2635 |
def OnPrintPage(self, page): |
|
2636 |
dc = self.GetDC() |
|
2342
4ec6d6cd23ca
Fix black background in preview window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2302
diff
changeset
|
2637 |
dc.SetBackground(wx.WHITE_BRUSH) |
4ec6d6cd23ca
Fix black background in preview window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2302
diff
changeset
|
2638 |
dc.Clear() |
838 | 2639 |
dc.SetUserScale(1.0, 1.0) |
2640 |
dc.SetDeviceOrigin(0, 0) |
|
2641 |
dc.printing = not self.Preview |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2642 |
|
838 | 2643 |
# Get the size of the DC in pixels |
2644 |
ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() |
|
2645 |
pw, ph = self.GetPageSizePixels() |
|
2646 |
dw, dh = dc.GetSizeTuple() |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2647 |
Xscale = (dw * ppiPrinterX) / (pw * 25.4) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2648 |
Yscale = (dh * ppiPrinterY) / (ph * 25.4) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2649 |
|
838 | 2650 |
fontsize = self.FontSize * Yscale |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2651 |
|
838 | 2652 |
margin_left = self.Margins[0].x * Xscale |
2653 |
margin_top = self.Margins[0].y * Yscale |
|
2654 |
area_width = dw - self.Margins[1].x * Xscale - margin_left |
|
2655 |
area_height = dh - self.Margins[1].y * Yscale - margin_top |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2656 |
|
838 | 2657 |
dc.SetPen(MiterPen(wx.BLACK)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2658 |
dc.SetBrush(wx.TRANSPARENT_BRUSH) |
838 | 2659 |
dc.DrawRectangle(margin_left, margin_top, area_width, area_height) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2660 |
|
838 | 2661 |
dc.SetFont(wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) |
2662 |
dc.SetTextForeground(wx.BLACK) |
|
2663 |
block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:]) |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
2664 |
_text_width, text_height = dc.GetTextExtent(block_name) |
838 | 2665 |
dc.DrawText(block_name, margin_left, margin_top - text_height - self.TextMargin) |
2666 |
dc.DrawText(_("Page: %d") % page, margin_left, margin_top + area_height + self.TextMargin) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2667 |
|
838 | 2668 |
# Calculate the position on the DC for centering the graphic |
2669 |
posX = area_width * ((page - 1) % self.PageGrid[0]) |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2670 |
posY = area_height * ((page - 1) // self.PageGrid[0]) |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2671 |
|
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2672 |
scaleX = area_width / self.PageSize[0] |
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
2673 |
scaleY = area_height / self.PageSize[1] |
838 | 2674 |
scale = min(scaleX, scaleY) |
2675 |
||
2676 |
# Set the scale and origin |
|
2677 |
dc.SetDeviceOrigin(-posX + margin_left, -posY + margin_top) |
|
2678 |
dc.SetClippingRegion(posX, posY, self.PageSize[0] * scale, self.PageSize[1] * scale) |
|
2679 |
dc.SetUserScale(scale, scale) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2680 |
|
838 | 2681 |
self.Viewer.DoDrawing(dc, True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2682 |
|
838 | 2683 |
return True |