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