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