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