author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 09 Mar 2017 17:29:17 +0300 | |
changeset 1658 | ba6a6d6e989c |
parent 1646 | 2d1fb99065e8 |
child 1659 | aec0ed4b6f39 |
permissions | -rwxr-xr-x |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1 |
#!/usr/bin/env python |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
3 |
|
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
19 |
# GNU General Public License for more details. |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
588 | 24 |
|
25 |
updateinfo_url = None |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
26 |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1442
diff
changeset
|
27 |
import os, sys, getopt |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
28 |
import __builtin__ |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
29 |
import tempfile |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
30 |
import shutil |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
31 |
import random |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
32 |
import time |
1560
4ce8492159ab
add version with commit hash to 'About' dialogs for Beremiz IDE and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1549
diff
changeset
|
33 |
import version |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
34 |
from types import ListType |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
35 |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1442
diff
changeset
|
36 |
beremiz_dir = os.path.dirname(os.path.realpath(__file__)) |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1442
diff
changeset
|
37 |
|
1518
a656ccb868d4
- Fixed startup from ancestor code.
alexander@60.125.16.172.in-addr.arpa
parents:
1513
diff
changeset
|
38 |
if __name__ == '__main__': |
a656ccb868d4
- Fixed startup from ancestor code.
alexander@60.125.16.172.in-addr.arpa
parents:
1513
diff
changeset
|
39 |
import wxversion |
a656ccb868d4
- Fixed startup from ancestor code.
alexander@60.125.16.172.in-addr.arpa
parents:
1513
diff
changeset
|
40 |
wxversion.select(['2.8', '3.0']) |
a656ccb868d4
- Fixed startup from ancestor code.
alexander@60.125.16.172.in-addr.arpa
parents:
1513
diff
changeset
|
41 |
import wx |
a656ccb868d4
- Fixed startup from ancestor code.
alexander@60.125.16.172.in-addr.arpa
parents:
1513
diff
changeset
|
42 |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1442
diff
changeset
|
43 |
from wx.lib.agw.advancedsplash import AdvancedSplash |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
44 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
45 |
def Bpath(*args): |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1442
diff
changeset
|
46 |
return os.path.join(beremiz_dir,*args) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
47 |
|
1489
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
48 |
def ShowSplashScreen(): |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
49 |
bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap() |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
50 |
#splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000) |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
51 |
splash = AdvancedSplash(None, bitmap=bmp) |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
52 |
|
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
53 |
# process all events |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
54 |
# even the events generated by splash themself during showing |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
55 |
for i in range(0,30): |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
56 |
wx.Yield() |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
57 |
time.sleep(0.01); |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
58 |
return splash |
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
59 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
60 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
61 |
def usage(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
62 |
print "\nUsage of Beremiz.py :" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
63 |
print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
64 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
65 |
try: |
736 | 66 |
opts, args = getopt.getopt(sys.argv[1:], "hu:e:", ["help", "updatecheck=", "extend="]) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
67 |
except getopt.GetoptError: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
68 |
# print help information and exit: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
69 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
70 |
sys.exit(2) |
731 | 71 |
|
72 |
extensions=[] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
73 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
74 |
for o, a in opts: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
75 |
if o in ("-h", "--help"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
76 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
77 |
sys.exit() |
588 | 78 |
if o in ("-u", "--updatecheck"): |
79 |
updateinfo_url = a |
|
731 | 80 |
if o in ("-e", "--extend"): |
81 |
extensions.append(a) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
82 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
83 |
if len(args) > 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
84 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
85 |
sys.exit() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
86 |
elif len(args) == 1: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
87 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
88 |
buildpath = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
89 |
elif len(args) == 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
90 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
91 |
buildpath = args[1] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
92 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
93 |
projectOpen = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
94 |
buildpath = None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
95 |
|
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
96 |
if os.path.exists("BEREMIZ_DEBUG"): |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
97 |
__builtin__.__dict__["BMZ_DBG"] = True |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
98 |
else : |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
99 |
__builtin__.__dict__["BMZ_DBG"] = False |
571
427bf9130d12
Debug switch (file in CWD). LPC : better MD5 handling, Run button in boot mode, handling data feedback in boot protocol
edouard
parents:
569
diff
changeset
|
100 |
|
1483
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
101 |
if wx.VERSION >= (3, 0, 0): |
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
102 |
app = wx.App(redirect=BMZ_DBG) |
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
103 |
else: |
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
104 |
app = wx.PySimpleApp(redirect=BMZ_DBG) |
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
105 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
106 |
app.SetAppName('beremiz') |
1483
004f9c52f7d8
enable use of wxWidgets-3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
107 |
if wx.VERSION < (3, 0, 0): |
1572
078c760620d7
fix inconsistent whitespace
ctbenergy <ewald.weinahndl@gmail.com>
parents:
1571
diff
changeset
|
108 |
wx.InitAllImageHandlers() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
109 |
|
588 | 110 |
# popup splash |
1489
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
111 |
splash = ShowSplashScreen() |
1582
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
112 |
|
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
113 |
# load internatialization files |
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
114 |
from util.misc import InstallLocalRessources |
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
115 |
InstallLocalRessources(beremiz_dir) |
1489
9c22ff9c8c06
fix splash loading with wx3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1483
diff
changeset
|
116 |
|
588 | 117 |
if updateinfo_url is not None: |
1582
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
118 |
updateinfo = _("Fetching %s") % updateinfo_url |
588 | 119 |
# warn for possible updates |
120 |
def updateinfoproc(): |
|
121 |
global updateinfo |
|
122 |
try : |
|
123 |
import urllib2 |
|
124 |
updateinfo = urllib2.urlopen(updateinfo_url,None).read() |
|
125 |
except : |
|
1582
dee51e22a9aa
add internatialization support to startup messages during checking software updates
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
126 |
updateinfo = _("update info unavailable.") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
127 |
|
588 | 128 |
from threading import Thread |
129 |
splash.SetText(text=updateinfo) |
|
130 |
wx.Yield() |
|
131 |
updateinfoThread = Thread(target=updateinfoproc) |
|
132 |
updateinfoThread.start() |
|
133 |
updateinfoThread.join(2) |
|
134 |
splash.SetText(text=updateinfo) |
|
135 |
wx.Yield() |
|
136 |
||
735
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
137 |
# Load extensions |
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
138 |
for extfilename in extensions: |
1393
e6c3908c925d
Fixed import error when loading extensions
Edouard Tisserant
parents:
1388
diff
changeset
|
139 |
from util.TranslationCatalogs import AddCatalog |
e6c3908c925d
Fixed import error when loading extensions
Edouard Tisserant
parents:
1388
diff
changeset
|
140 |
from util.BitmapLibrary import AddBitmapFolder |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
141 |
extension_folder = os.path.split(os.path.realpath(extfilename))[0] |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
142 |
sys.path.append(extension_folder) |
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
143 |
AddCatalog(os.path.join(extension_folder, "locale")) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
144 |
AddBitmapFolder(os.path.join(extension_folder, "images")) |
737 | 145 |
execfile(extfilename, locals()) |
735
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
146 |
|
1388
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
147 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
148 |
import wx.lib.buttons, wx.lib.statbmp, wx.stc |
724 | 149 |
import cPickle |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
150 |
import types, time, re, platform, time, traceback, commands |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
151 |
|
727 | 152 |
from docutil import OpenHtmlFrame |
814 | 153 |
from editors.EditorPanel import EditorPanel |
154 |
from editors.Viewer import Viewer |
|
155 |
from editors.TextViewer import TextViewer |
|
156 |
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor |
|
157 |
from editors.DataTypeEditor import DataTypeEditor |
|
807
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
158 |
from util.MiniTextControler import MiniTextControler |
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
159 |
from util.ProcessLogger import ProcessLogger |
978 | 160 |
from controls.LogViewer import LogViewer |
1091
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
161 |
from controls.CustomStyledTextCtrl import CustomStyledTextCtrl |
1574
ce9c0e68389c
add progress bar to status bar
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
162 |
from controls import EnhancedStatusBar as esb |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1564
diff
changeset
|
163 |
from dialogs.AboutDialog import ShowAboutDialog |
814 | 164 |
|
165 |
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE |
|
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
166 |
from ProjectController import ProjectController, GetAddMenuItems, MATIEC_ERROR_MODEL, ITEM_CONFNODE |
807
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
167 |
|
814 | 168 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
169 |
MAX_RECENT_PROJECTS = 10 |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
170 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
171 |
if wx.Platform == '__WXMSW__': |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
172 |
faces = { |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
173 |
'mono' : 'Courier New', |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
174 |
'size' : 8, |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
175 |
} |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
176 |
else: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
177 |
faces = { |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
178 |
'mono' : 'Courier', |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
179 |
'size' : 10, |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
180 |
} |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
181 |
|
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
182 |
from threading import Lock,Timer,currentThread |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
183 |
MainThread = currentThread().ident |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
184 |
REFRESH_PERIOD = 0.1 |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
185 |
from time import time as gettime |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
186 |
class LogPseudoFile: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
187 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
451 | 188 |
def __init__(self, output, risecall): |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
189 |
self.red_white = 1 |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
190 |
self.red_yellow = 2 |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
191 |
self.black_white = wx.stc.STC_STYLE_DEFAULT |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
192 |
self.output = output |
451 | 193 |
self.risecall = risecall |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
194 |
# to prevent rapid fire on rising log panel |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
195 |
self.rising_timer = 0 |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
196 |
self.lock = Lock() |
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
197 |
self.YieldLock = Lock() |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
198 |
self.RefreshLock = Lock() |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
199 |
self.TimerAccessLock = Lock() |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
200 |
self.stack = [] |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
201 |
self.LastRefreshTime = gettime() |
688
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
202 |
self.LastRefreshTimer = None |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
203 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
204 |
def write(self, s, style = None): |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
205 |
if self.lock.acquire(): |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
206 |
self.stack.append((s,style)) |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
207 |
self.lock.release() |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
208 |
current_time = gettime() |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
209 |
self.TimerAccessLock.acquire() |
688
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
210 |
if self.LastRefreshTimer: |
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
211 |
self.LastRefreshTimer.cancel() |
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
212 |
self.LastRefreshTimer=None |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
213 |
self.TimerAccessLock.release() |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
214 |
if current_time - self.LastRefreshTime > REFRESH_PERIOD and self.RefreshLock.acquire(False): |
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
215 |
self._should_write() |
688
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
216 |
else: |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
217 |
self.TimerAccessLock.acquire() |
875
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
218 |
self.LastRefreshTimer = Timer(REFRESH_PERIOD, self._timer_expired) |
688
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
219 |
self.LastRefreshTimer.start() |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
220 |
self.TimerAccessLock.release() |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
221 |
|
875
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
222 |
def _timer_expired(self): |
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
223 |
if self.RefreshLock.acquire(False): |
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
224 |
self._should_write() |
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
225 |
else: |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
226 |
self.TimerAccessLock.acquire() |
875
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
227 |
self.LastRefreshTimer = Timer(REFRESH_PERIOD, self._timer_expired) |
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
228 |
self.LastRefreshTimer.start() |
881
68ac754a5a72
Fix bug with concurrent access to LastRefreshTimer in LogPseudoFile for Log Console
Laurent Bessard
parents:
875
diff
changeset
|
229 |
self.TimerAccessLock.release() |
875
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
230 |
|
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
231 |
def _should_write(self): |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
232 |
wx.CallAfter(self._write) |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
233 |
if MainThread == currentThread().ident: |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
234 |
app = wx.GetApp() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
235 |
if app is not None: |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
236 |
if self.YieldLock.acquire(0): |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
237 |
app.Yield() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
238 |
self.YieldLock.release() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
239 |
|
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
240 |
def _write(self): |
701
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
241 |
if self.output : |
875
a8952b79caec
Fix bug in Debug refresh lock that, with too much data to debug, flooded GUI and blocked it
Laurent Bessard
parents:
843
diff
changeset
|
242 |
self.output.Freeze() |
701
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
243 |
self.lock.acquire() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
244 |
for s, style in self.stack: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
245 |
if style is None : style=self.black_white |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
246 |
if style != self.black_white: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
247 |
self.output.StartStyling(self.output.GetLength(), 0xff) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
248 |
|
1091
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
249 |
# Temporary deactivate read only mode on StyledTextCtrl for |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
250 |
# adding text. It seems that text modifications, even |
1091
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
251 |
# programmatically, are disabled in StyledTextCtrl when read |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
252 |
# only is active |
1564
8ffd0b52c2c7
fix highlighting error and warning messages with non-lating characters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
253 |
start_pos = self.output.GetLength() |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
254 |
self.output.SetReadOnly(False) |
1091
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
255 |
self.output.AppendText(s) |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
256 |
self.output.SetReadOnly(True) |
1564
8ffd0b52c2c7
fix highlighting error and warning messages with non-lating characters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
257 |
text_len = self.output.GetLength() - start_pos |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
258 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
259 |
if style != self.black_white: |
1564
8ffd0b52c2c7
fix highlighting error and warning messages with non-lating characters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
260 |
self.output.SetStyling(text_len, style) |
701
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
261 |
self.stack = [] |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
262 |
self.lock.release() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
263 |
self.output.Thaw() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
264 |
self.LastRefreshTime = gettime() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
265 |
try: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
266 |
self.RefreshLock.release() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
267 |
except: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
268 |
pass |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
269 |
newtime = time.time() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
270 |
if newtime - self.rising_timer > 1: |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
271 |
self.risecall(self.output) |
701
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
272 |
self.rising_timer = newtime |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
273 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
274 |
def write_warning(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
275 |
self.write(s,self.red_white) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
276 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
277 |
def write_error(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
278 |
self.write(s,self.red_yellow) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
279 |
|
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
280 |
def writeyield(self, s): |
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
281 |
self.write(s) |
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
282 |
wx.GetApp().Yield() |
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
283 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
284 |
def flush(self): |
1091
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
285 |
# Temporary deactivate read only mode on StyledTextCtrl for clearing |
5f612651d227
Fixed bug with margin cursor in StyledTextCtrl on Windows
Laurent Bessard
parents:
1090
diff
changeset
|
286 |
# text. It seems that text modifications, even programmatically, are |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
287 |
# disabled in StyledTextCtrl when read only is active |
1025
36e38d3c28b2
Fixed LogConsole not cleared when building several times
Laurent Bessard
parents:
1024
diff
changeset
|
288 |
self.output.SetReadOnly(False) |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
289 |
self.output.SetText("") |
1025
36e38d3c28b2
Fixed LogConsole not cleared when building several times
Laurent Bessard
parents:
1024
diff
changeset
|
290 |
self.output.SetReadOnly(True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
291 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
292 |
def isatty(self): |
1269 | 293 |
return False |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
294 |
|
1281 | 295 |
ID_FILEMENURECENTPROJECTS = wx.NewId() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
296 |
|
1388
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
297 |
from IDEFrame import TITLE,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
298 |
EDITORTOOLBAR,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
299 |
FILEMENU,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
300 |
EDITMENU,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
301 |
DISPLAYMENU,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
302 |
PROJECTTREE,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
303 |
POUINSTANCEVARIABLESPANEL,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
304 |
LIBRARYTREE,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
305 |
SCALING,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
306 |
PAGETITLES,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
307 |
IDEFrame, AppendMenu,\ |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
308 |
EncodeFileSystemPath, DecodeFileSystemPath |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
309 |
from util.BitmapLibrary import GetBitmap |
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1364
diff
changeset
|
310 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
311 |
class Beremiz(IDEFrame): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
312 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
313 |
def _init_utils(self): |
717 | 314 |
self.ConfNodeMenu = wx.Menu(title='') |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
315 |
self.RecentProjectsMenu = wx.Menu(title='') |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
316 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
317 |
IDEFrame._init_utils(self) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
318 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
319 |
def _init_coll_FileMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
320 |
AppendMenu(parent, help='', id=wx.ID_NEW, |
814 | 321 |
kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
322 |
AppendMenu(parent, help='', id=wx.ID_OPEN, |
814 | 323 |
kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
702 | 324 |
parent.AppendMenu(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
325 |
parent.AppendSeparator() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
326 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
814 | 327 |
kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
328 |
AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
814 | 329 |
kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
330 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
814 | 331 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
332 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
814 | 333 |
kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
334 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
335 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
814 | 336 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
337 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
814 | 338 |
kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
339 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
814 | 340 |
kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
341 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
342 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
814 | 343 |
kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
344 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
345 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
346 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
347 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
348 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
349 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
350 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
351 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
352 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
353 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
354 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
355 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
356 |
self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
357 |
(wx.ID_OPEN, "open", _(u'Open'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
358 |
(wx.ID_SAVE, "save", _(u'Save'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
359 |
(wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
360 |
(wx.ID_PRINT, "print", _(u'Print'), None)]) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
361 |
|
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
362 |
def _RecursiveAddMenuItems(self, menu, items): |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
363 |
for name, text, help, children in items: |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
364 |
new_id = wx.NewId() |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
365 |
if len(children) > 0: |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
366 |
new_menu = wx.Menu(title='') |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
367 |
menu.AppendMenu(new_id, text, new_menu) |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
368 |
self._RecursiveAddMenuItems(new_menu, children) |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
369 |
else: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
370 |
AppendMenu(menu, help=help, id=new_id, |
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
371 |
kind=wx.ITEM_NORMAL, text=text) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
372 |
self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name), |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
373 |
id=new_id) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
374 |
|
738 | 375 |
def _init_coll_AddMenu_Items(self, parent): |
376 |
IDEFrame._init_coll_AddMenu_Items(self, parent, False) |
|
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
377 |
self._RecursiveAddMenuItems(parent, GetAddMenuItems()) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
378 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
379 |
def _init_coll_HelpMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
380 |
parent.Append(help='', id=wx.ID_ABOUT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
381 |
kind=wx.ITEM_NORMAL, text=_(u'About')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
382 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
383 |
|
1000 | 384 |
def _init_coll_ConnectionStatusBar_Fields(self, parent): |
385 |
parent.SetFieldsCount(3) |
|
386 |
||
387 |
parent.SetStatusText(number=0, text='') |
|
388 |
parent.SetStatusText(number=1, text='') |
|
389 |
parent.SetStatusText(number=2, text='') |
|
390 |
||
391 |
parent.SetStatusWidths([-1, 300, 200]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
392 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
393 |
def _init_ctrls(self, prnt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
394 |
IDEFrame._init_ctrls(self, prnt) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
395 |
|
771 | 396 |
self.EditMenuSize = self.EditMenu.GetMenuItemCount() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
397 |
|
1281 | 398 |
inspectorID = wx.NewId() |
399 |
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID) |
|
400 |
accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), inspectorID)] |
|
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1518
diff
changeset
|
401 |
|
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1518
diff
changeset
|
402 |
keyID = wx.NewId() |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1518
diff
changeset
|
403 |
self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=keyID) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1518
diff
changeset
|
404 |
accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, wx.WXK_F12, keyID)] |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1518
diff
changeset
|
405 |
|
623
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
406 |
for method,shortcut in [("Stop", wx.WXK_F4), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
407 |
("Run", wx.WXK_F5), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
408 |
("Transfer", wx.WXK_F6), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
409 |
("Connect", wx.WXK_F7), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
410 |
("Build", wx.WXK_F11)]: |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
411 |
def OnMethodGen(obj,meth): |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
412 |
def OnMethod(evt): |
717 | 413 |
if obj.CTR is not None: |
414 |
obj.CTR.CallMethod('_'+meth) |
|
738 | 415 |
wx.CallAfter(self.RefreshStatusToolBar) |
623
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
416 |
return OnMethod |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
417 |
newid = wx.NewId() |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
418 |
self.Bind(wx.EVT_MENU, OnMethodGen(self,method), id=newid) |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
419 |
accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)] |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
420 |
|
623
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
421 |
self.SetAcceleratorTable(wx.AcceleratorTable(accels)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
422 |
|
1281 | 423 |
self.LogConsole = CustomStyledTextCtrl( |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
424 |
name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
425 |
size=wx.Size(0, 0)) |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
426 |
self.LogConsole.Bind(wx.EVT_SET_FOCUS, self.OnLogConsoleFocusChanged) |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
427 |
self.LogConsole.Bind(wx.EVT_KILL_FOCUS, self.OnLogConsoleFocusChanged) |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
428 |
self.LogConsole.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnLogConsoleUpdateUI) |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
429 |
self.LogConsole.SetReadOnly(True) |
1007
025ac12cd0d2
Added automatic line wrapping to log console
Laurent Bessard
parents:
1000
diff
changeset
|
430 |
self.LogConsole.SetWrapMode(wx.stc.STC_WRAP_CHAR) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
431 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
432 |
# Define Log Console styles |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
433 |
self.LogConsole.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d" % faces) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
434 |
self.LogConsole.StyleClearAll() |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
435 |
self.LogConsole.StyleSetSpec(1, "face:%(mono)s,fore:#FF0000,size:%(size)d" % faces) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
436 |
self.LogConsole.StyleSetSpec(2, "face:%(mono)s,fore:#FF0000,back:#FFFF00,size:%(size)d" % faces) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
437 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
438 |
# Define Log Console markers |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
439 |
self.LogConsole.SetMarginSensitive(1, True) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
440 |
self.LogConsole.SetMarginType(1, wx.stc.STC_MARGIN_SYMBOL) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
441 |
self.LogConsole.MarkerDefine(0, wx.stc.STC_MARK_CIRCLE, "BLACK", "RED") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
442 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
443 |
self.LogConsole.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
444 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
445 |
self.LogConsole.Bind(wx.stc.EVT_STC_MARGINCLICK, self.OnLogConsoleMarginClick) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
446 |
self.LogConsole.Bind(wx.stc.EVT_STC_MODIFIED, self.OnLogConsoleModified) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
447 |
|
986 | 448 |
self.MainTabs["LogConsole"] = (self.LogConsole, _("Console")) |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
449 |
self.BottomNoteBook.AddPage(*self.MainTabs["LogConsole"]) |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
450 |
#self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogConsole), wx.RIGHT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
451 |
|
978 | 452 |
self.LogViewer = LogViewer(self.BottomNoteBook, self) |
986 | 453 |
self.MainTabs["LogViewer"] = (self.LogViewer, _("PLC Log")) |
978 | 454 |
self.BottomNoteBook.AddPage(*self.MainTabs["LogViewer"]) |
994
0401295d9804
Inverted Console and LogViewer tabs in bottom Notebook
Laurent Bessard
parents:
986
diff
changeset
|
455 |
#self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogViewer), wx.RIGHT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
456 |
|
738 | 457 |
StatusToolBar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, |
458 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
|
459 |
StatusToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
460 |
StatusToolBar.Realize() |
|
461 |
self.Panes["StatusToolBar"] = StatusToolBar |
|
462 |
self.AUIManager.AddPane(StatusToolBar, wx.aui.AuiPaneInfo(). |
|
463 |
Name("StatusToolBar").Caption(_("Status ToolBar")). |
|
765
ef221ba41dec
Add support for reorganizing toolbars when their size changed
laurent
parents:
762
diff
changeset
|
464 |
ToolbarPane().Top().Position(1). |
738 | 465 |
LeftDockable(False).RightDockable(False)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
466 |
|
738 | 467 |
self.AUIManager.Update() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
468 |
|
1574
ce9c0e68389c
add progress bar to status bar
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
469 |
self.ConnectionStatusBar = esb.EnhancedStatusBar(self, style=wx.ST_SIZEGRIP) |
1000 | 470 |
self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar) |
1574
ce9c0e68389c
add progress bar to status bar
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
471 |
self.ProgressStatusBar = wx.Gauge(self.ConnectionStatusBar, -1, range = 100) |
ce9c0e68389c
add progress bar to status bar
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
472 |
self.ConnectionStatusBar.AddWidget(self.ProgressStatusBar, esb.ESB_EXACT_FIT, esb.ESB_EXACT_FIT, 2) |
ce9c0e68389c
add progress bar to status bar
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1572
diff
changeset
|
473 |
self.ProgressStatusBar.Hide() |
1000 | 474 |
self.SetStatusBar(self.ConnectionStatusBar) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
475 |
|
1549
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
476 |
def __init_execute_path(self): |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
477 |
if os.name == 'nt': |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
478 |
# on windows, desktop shortcut launches Beremiz.py |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
479 |
# with working dir set to mingw/bin. |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
480 |
# then we prefix CWD to PATH in order to ensure that |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
481 |
# commands invoked by build process by default are |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
482 |
# found here. |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
483 |
os.environ["PATH"] = os.getcwd()+';'+os.environ["PATH"] |
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
484 |
|
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
485 |
|
717 | 486 |
def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True): |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1489
diff
changeset
|
487 |
# Add beremiz's icon in top left corner of the frame |
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1489
diff
changeset
|
488 |
self.icon = wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO) |
1549
f526fd97a7b0
add $(Beremiz installation)/mingw/bin in PATH on Windows platform
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1530
diff
changeset
|
489 |
self.__init_execute_path() |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1489
diff
changeset
|
490 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
491 |
IDEFrame.__init__(self, parent, debug) |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
492 |
self.Log = LogPseudoFile(self.LogConsole,self.SelectTab) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
493 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
494 |
self.local_runtime = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
495 |
self.runtime_port = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
496 |
self.local_runtime_tmpdir = None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
497 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
498 |
self.LastPanelSelected = None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
499 |
|
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
500 |
# Define Tree item icon list |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
501 |
self.LocationImageList = wx.ImageList(16, 16) |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
502 |
self.LocationImageDict = {} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
503 |
|
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
504 |
# Icons for location items |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
505 |
for imgname, itemtype in [ |
717 | 506 |
("CONFIGURATION", LOCATION_CONFNODE), |
650
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
507 |
("RESOURCE", LOCATION_MODULE), |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
508 |
("PROGRAM", LOCATION_GROUP), |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
509 |
("VAR_INPUT", LOCATION_VAR_INPUT), |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
510 |
("VAR_OUTPUT", LOCATION_VAR_OUTPUT), |
26236e691330
Replacing sizers structure for locations tree by a treectrl in Topology panel in order to make refreshing of this panel faster
laurent
parents:
636
diff
changeset
|
511 |
("VAR_LOCAL", LOCATION_VAR_MEMORY)]: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
512 |
self.LocationImageDict[itemtype] = self.LocationImageList.Add(GetBitmap(imgname)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
513 |
|
738 | 514 |
# Icons for other items |
515 |
for imgname, itemtype in [ |
|
516 |
("Extension", ITEM_CONFNODE)]: |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
517 |
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
518 |
|
788 | 519 |
if projectOpen is not None: |
520 |
projectOpen = DecodeFileSystemPath(projectOpen, False) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
521 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
522 |
if projectOpen is not None and os.path.isdir(projectOpen): |
725 | 523 |
self.CTR = ProjectController(self, self.Log) |
717 | 524 |
self.Controler = self.CTR |
1633
f629a91b456d
fix a side effect of 95ecb26fdc4e
Edouard Tisserant 7BB06627 <edouard.tisserant@gmail.com>
parents:
1623
diff
changeset
|
525 |
result, err = self.CTR.LoadProject(projectOpen, buildpath) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
526 |
if not result: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
527 |
self.LibraryPanel.SetController(self.Controler) |
738 | 528 |
self.ProjectTree.Enable(True) |
730 | 529 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
530 |
self.RefreshConfigRecentProjects(os.path.abspath(projectOpen)) |
730 | 531 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
532 |
else: |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
533 |
self.ResetView() |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
534 |
self.ShowErrorMessage(result) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
535 |
else: |
717 | 536 |
self.CTR = ctr |
537 |
self.Controler = ctr |
|
538 |
if ctr is not None: |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
539 |
self.LibraryPanel.SetController(self.Controler) |
738 | 540 |
self.ProjectTree.Enable(True) |
730 | 541 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
542 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
|
490 | 543 |
if self.EnableDebug: |
717 | 544 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
545 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
546 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
547 |
|
706 | 548 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
755 | 549 |
self.RefreshAll() |
590 | 550 |
self.LogConsole.SetFocus() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
551 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
552 |
def RefreshTitle(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
553 |
name = _("Beremiz") |
717 | 554 |
if self.CTR is not None: |
555 |
projectname = self.CTR.GetProjectName() |
|
556 |
if self.CTR.ProjectTestModified(): |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
557 |
projectname = "~%s~" % projectname |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
558 |
self.SetTitle("%s - %s" % (name, projectname)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
559 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
560 |
self.SetTitle(name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
561 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
562 |
def StartLocalRuntime(self, taskbaricon = True): |
713
37dc330e96a2
Reflected recent changes in ProcessLogger changes in StartLocalRuntime
Edouard Tisserant
parents:
710
diff
changeset
|
563 |
if (self.local_runtime is None) or (self.local_runtime.exitcode is not None): |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
564 |
# create temporary directory for runtime working directory |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
565 |
self.local_runtime_tmpdir = tempfile.mkdtemp() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
566 |
# choose an arbitrary random port for runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
567 |
self.runtime_port = int(random.random() * 1000) + 61131 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
568 |
# launch local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
569 |
self.local_runtime = ProcessLogger(self.Log, |
958
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
570 |
"\"%s\" \"%s\" -p %s -i localhost %s %s"%( |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
571 |
sys.executable, |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
572 |
Bpath("Beremiz_service.py"), |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
573 |
self.runtime_port, |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
574 |
{False : "-x 0", True :"-x 1"}[taskbaricon], |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
575 |
self.local_runtime_tmpdir), |
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
576 |
no_gui=False, |
1595
b3cc68dd037d
add internatialization support for Beremiz_service.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1582
diff
changeset
|
577 |
timeout=500, keyword = self.local_runtime_tmpdir, |
958
511bf048b8b7
Added CWD to ProcessLogger, and make sure local runtime have CWD setup correctly
Edouard Tisserant
parents:
918
diff
changeset
|
578 |
cwd = self.local_runtime_tmpdir) |
704 | 579 |
self.local_runtime.spin() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
580 |
return self.runtime_port |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
581 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
582 |
def KillLocalRuntime(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
583 |
if self.local_runtime is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
584 |
# shutdown local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
585 |
self.local_runtime.kill(gently=False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
586 |
# clear temp dir |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
587 |
shutil.rmtree(self.local_runtime_tmpdir) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
588 |
|
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
513
diff
changeset
|
589 |
self.local_runtime = None |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
590 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
591 |
def OnOpenWidgetInspector(self, evt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
592 |
# Activate the widget inspection tool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
593 |
from wx.lib.inspection import InspectionTool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
594 |
if not InspectionTool().initialized: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
595 |
InspectionTool().Init() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
596 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
597 |
# Find a widget to be selected in the tree. Use either the |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
598 |
# one under the cursor, if any, or this frame. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
599 |
wnd = wx.FindWindowAtPointer() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
600 |
if not wnd: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
601 |
wnd = self |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
602 |
InspectionTool().Show(wnd, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
603 |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
604 |
def OnLogConsoleFocusChanged(self, event): |
1087 | 605 |
self.RefreshEditMenu() |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
606 |
event.Skip() |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
607 |
|
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
608 |
def OnLogConsoleUpdateUI(self, event): |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
609 |
self.SetCopyBuffer(self.LogConsole.GetSelectedText(), True) |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
610 |
event.Skip() |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
611 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
612 |
def OnLogConsoleMarginClick(self, event): |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
613 |
line_idx = self.LogConsole.LineFromPosition(event.GetPosition()) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
614 |
wx.CallAfter(self.SearchLineForError, self.LogConsole.GetLine(line_idx)) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
615 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
616 |
|
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
617 |
def OnLogConsoleModified(self, event): |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
618 |
line_idx = self.LogConsole.LineFromPosition(event.GetPosition()) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
619 |
line = self.LogConsole.GetLine(line_idx) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
620 |
if line: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
621 |
result = MATIEC_ERROR_MODEL.match(line) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
622 |
if result is not None: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
623 |
self.LogConsole.MarkerAdd(line_idx, 0) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
624 |
event.Skip() |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
625 |
|
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
994
diff
changeset
|
626 |
def SearchLineForError(self, line): |
717 | 627 |
if self.CTR is not None: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
628 |
result = MATIEC_ERROR_MODEL.match(line) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
629 |
if result is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
630 |
first_line, first_column, last_line, last_column, error = result.groups() |
717 | 631 |
infos = self.CTR.ShowError(self.Log, |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
632 |
(int(first_line), int(first_column)), |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
633 |
(int(last_line), int(last_column))) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
634 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
635 |
## Function displaying an Error dialog in PLCOpenEditor. |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
636 |
# @return False if closing cancelled. |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
637 |
def CheckSaveBeforeClosing(self, title=_("Close Project")): |
717 | 638 |
if self.CTR.ProjectTestModified(): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
639 |
dialog = wx.MessageDialog(self, |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
640 |
_("There are changes, do you want to save?"), |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
641 |
title, |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
642 |
wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
643 |
answer = dialog.ShowModal() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
644 |
dialog.Destroy() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
645 |
if answer == wx.ID_YES: |
717 | 646 |
self.CTR.SaveProject() |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
647 |
elif answer == wx.ID_CANCEL: |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
648 |
return False |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
649 |
|
797
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
650 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
651 |
window = self.TabsOpened.GetPage(idx) |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
652 |
if not window.CheckSaveBeforeClosing(): |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
653 |
return False |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
654 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
655 |
return True |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
656 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
657 |
def GetTabInfos(self, tab): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
658 |
if (isinstance(tab, EditorPanel) and |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
659 |
not isinstance(tab, (Viewer, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
660 |
TextViewer, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
661 |
ResourceEditor, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
662 |
ConfigurationEditor, |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
663 |
DataTypeEditor))): |
782 | 664 |
return ("confnode", tab.Controler.CTNFullName(), tab.GetTagName()) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
665 |
elif (isinstance(tab, TextViewer) and |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
666 |
(tab.Controler is None or isinstance(tab.Controler, MiniTextControler))): |
717 | 667 |
return ("confnode", None, tab.GetInstancePath()) |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
668 |
else: |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
669 |
return IDEFrame.GetTabInfos(self, tab) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
670 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
671 |
def LoadTab(self, notebook, page_infos): |
717 | 672 |
if page_infos[0] == "confnode": |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
673 |
if page_infos[1] is None: |
717 | 674 |
confnode = self.CTR |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
675 |
else: |
717 | 676 |
confnode = self.CTR.GetChildByName(page_infos[1]) |
677 |
return notebook.GetPageIndex(confnode._OpenView(*page_infos[2:])) |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
678 |
else: |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
679 |
return IDEFrame.LoadTab(self, notebook, page_infos) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
680 |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
681 |
# Strange hack required by WAMP connector, using twisted. |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
682 |
# Twisted reactor needs to be stopped only before quit, |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
683 |
# since it cannot be restarted |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
684 |
ToDoBeforeQuit = [] |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
685 |
def AddToDoBeforeQuit(self, Thing): |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
686 |
self.ToDoBeforeQuit.append(Thing) |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
687 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
688 |
def OnCloseFrame(self, event): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
689 |
for evt_type in [wx.EVT_SET_FOCUS, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
690 |
wx.EVT_KILL_FOCUS, |
1090 | 691 |
wx.stc.EVT_STC_UPDATEUI]: |
692 |
self.LogConsole.Unbind(evt_type) |
|
717 | 693 |
if self.CTR is None or self.CheckSaveBeforeClosing(_("Close Application")): |
694 |
if self.CTR is not None: |
|
695 |
self.CTR.KillDebugThread() |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
696 |
self.KillLocalRuntime() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
697 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
698 |
self.SaveLastState() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
699 |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
700 |
for Thing in self.ToDoBeforeQuit : |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
701 |
Thing() |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
702 |
self.ToDoBeforeQuit = [] |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1408
diff
changeset
|
703 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
704 |
event.Skip() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
705 |
else: |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
706 |
event.Veto() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
707 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
708 |
def RefreshFileMenu(self): |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
709 |
self.RefreshRecentProjectsMenu() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
710 |
|
706 | 711 |
MenuToolBar = self.Panes["MenuToolBar"] |
717 | 712 |
if self.CTR is not None: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
713 |
selected = self.TabsOpened.GetSelection() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
714 |
if selected >= 0: |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
715 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
716 |
viewer_is_modified = window.IsModified() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
717 |
is_viewer = isinstance(window, Viewer) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
718 |
else: |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
719 |
viewer_is_modified = is_viewer = False |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
720 |
if self.TabsOpened.GetPageCount() > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
721 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
722 |
if is_viewer: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
723 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
724 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
706 | 725 |
MenuToolBar.EnableTool(wx.ID_PRINT, True) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
726 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
727 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
728 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 729 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
730 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
731 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
732 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
733 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 734 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
735 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
736 |
project_modified = self.CTR.ProjectTestModified() or viewer_is_modified |
706 | 737 |
self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
738 |
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
739 |
self.FileMenu.Enable(wx.ID_SAVEAS, True) |
706 | 740 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, True) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
741 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
742 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
743 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
744 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
745 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
746 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 747 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
748 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
706 | 749 |
MenuToolBar.EnableTool(wx.ID_SAVE, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
750 |
self.FileMenu.Enable(wx.ID_SAVEAS, False) |
706 | 751 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
752 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
753 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
754 |
def RefreshRecentProjectsMenu(self): |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
755 |
try: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
756 |
recent_projects = map(DecodeFileSystemPath, |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
757 |
self.GetConfigEntry("RecentProjects", [])) |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
758 |
except: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
759 |
recent_projects = [] |
1601
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
760 |
|
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
761 |
while self.RecentProjectsMenu.GetMenuItemCount() > len(recent_projects): |
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
762 |
item = self.RecentProjectsMenu.FindItemByPosition(0) |
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
763 |
self.RecentProjectsMenu.RemoveItem(item) |
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
764 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
765 |
self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
766 |
for idx, projectpath in enumerate(recent_projects): |
730 | 767 |
text = u'%d: %s' % (idx + 1, projectpath) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
768 |
|
730 | 769 |
if idx < self.RecentProjectsMenu.GetMenuItemCount(): |
770 |
item = self.RecentProjectsMenu.FindItemByPosition(idx) |
|
771 |
id = item.GetId() |
|
772 |
item.SetItemLabel(text) |
|
773 |
self.Disconnect(id, id, wx.EVT_BUTTON._getEvtType()) |
|
774 |
else: |
|
775 |
id = wx.NewId() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
776 |
AppendMenu(self.RecentProjectsMenu, help='', id=id, |
730 | 777 |
kind=wx.ITEM_NORMAL, text=text) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
778 |
self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), id=id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
779 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
780 |
def GenerateOpenRecentProjectFunction(self, projectpath): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
781 |
def OpenRecentProject(event): |
717 | 782 |
if self.CTR is not None and not self.CheckSaveBeforeClosing(): |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
783 |
return |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
784 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
785 |
self.OpenProject(projectpath) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
786 |
return OpenRecentProject |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
787 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
788 |
def GenerateMenuRecursive(self, items, menu): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
789 |
for kind, infos in items: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
790 |
if isinstance(kind, ListType): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
791 |
text, id = infos |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
792 |
submenu = wx.Menu('') |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
793 |
self.GenerateMenuRecursive(kind, submenu) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
794 |
menu.AppendMenu(id, text, submenu) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
795 |
elif kind == wx.ITEM_SEPARATOR: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
796 |
menu.AppendSeparator() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
797 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
798 |
text, id, help, callback = infos |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
799 |
AppendMenu(menu, help='', id=id, kind=kind, text=text) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
800 |
if callback is not None: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
801 |
self.Bind(wx.EVT_MENU, callback, id=id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
802 |
|
766
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
803 |
def RefreshEditorToolBar(self): |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
804 |
IDEFrame.RefreshEditorToolBar(self) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
805 |
self.AUIManager.GetPane("EditorToolBar").Position(2) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
806 |
self.AUIManager.GetPane("StatusToolBar").Position(1) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
807 |
self.AUIManager.Update() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
808 |
|
738 | 809 |
def RefreshStatusToolBar(self): |
810 |
StatusToolBar = self.Panes["StatusToolBar"] |
|
811 |
StatusToolBar.ClearTools() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
812 |
|
738 | 813 |
if self.CTR is not None: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
814 |
|
738 | 815 |
for confnode_method in self.CTR.StatusMethods: |
816 |
if "method" in confnode_method and confnode_method.get("shown",True): |
|
817 |
id = wx.NewId() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
818 |
StatusToolBar.AddSimpleTool(id, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
819 |
GetBitmap(confnode_method.get("bitmap", "Unknown")), |
738 | 820 |
confnode_method["tooltip"]) |
821 |
self.Bind(wx.EVT_MENU, self.GetMenuCallBackFunction(confnode_method["method"]), id=id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
822 |
|
738 | 823 |
StatusToolBar.Realize() |
824 |
self.AUIManager.GetPane("StatusToolBar").BestSize(StatusToolBar.GetBestSize()).Show() |
|
825 |
else: |
|
826 |
self.AUIManager.GetPane("StatusToolBar").Hide() |
|
766
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
827 |
self.AUIManager.GetPane("EditorToolBar").Position(2) |
765
ef221ba41dec
Add support for reorganizing toolbars when their size changed
laurent
parents:
762
diff
changeset
|
828 |
self.AUIManager.GetPane("StatusToolBar").Position(1) |
738 | 829 |
self.AUIManager.Update() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
830 |
|
771 | 831 |
def RefreshEditMenu(self): |
832 |
IDEFrame.RefreshEditMenu(self) |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
833 |
if self.FindFocus() == self.LogConsole: |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
834 |
self.EditMenu.Enable(wx.ID_COPY, True) |
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1007
diff
changeset
|
835 |
self.Panes["MenuToolBar"].EnableTool(wx.ID_COPY, True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
836 |
|
717 | 837 |
if self.CTR is not None: |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
838 |
selected = self.TabsOpened.GetSelection() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
839 |
if selected >= 0: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
840 |
panel = self.TabsOpened.GetPage(selected) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
841 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
842 |
panel = None |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
843 |
if panel != self.LastPanelSelected: |
771 | 844 |
for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
845 |
item = self.EditMenu.FindItemByPosition(self.EditMenuSize) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
846 |
if item is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
847 |
if item.IsSeparator(): |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
848 |
self.EditMenu.RemoveItem(item) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
849 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
850 |
self.EditMenu.Delete(item.GetId()) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
851 |
self.LastPanelSelected = panel |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
852 |
if panel is not None: |
717 | 853 |
items = panel.GetConfNodeMenuItems() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
854 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
855 |
items = [] |
771 | 856 |
if len(items) > 0: |
857 |
self.EditMenu.AppendSeparator() |
|
858 |
self.GenerateMenuRecursive(items, self.EditMenu) |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
859 |
if panel is not None: |
771 | 860 |
panel.RefreshConfNodeMenu(self.EditMenu) |
861 |
else: |
|
862 |
for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
|
863 |
item = self.EditMenu.FindItemByPosition(i) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
864 |
if item is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
865 |
if item.IsSeparator(): |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
866 |
self.EditMenu.RemoveItem(item) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
867 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
868 |
self.EditMenu.Delete(item.GetId()) |
771 | 869 |
self.LastPanelSelected = None |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
870 |
self.MenuBar.UpdateMenus() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
871 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
872 |
def RefreshAll(self): |
755 | 873 |
self.RefreshStatusToolBar() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
874 |
|
738 | 875 |
def GetMenuCallBackFunction(self, method): |
876 |
""" Generate the callbackfunc for a given CTR method""" |
|
877 |
def OnMenu(event): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
878 |
# Disable button to prevent re-entrant call |
738 | 879 |
event.GetEventObject().Disable() |
880 |
# Call |
|
881 |
getattr(self.CTR, method)() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
882 |
# Re-enable button |
738 | 883 |
event.GetEventObject().Enable() |
884 |
return OnMenu |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
885 |
|
738 | 886 |
def GetConfigEntry(self, entry_name, default): |
887 |
return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default)))) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
888 |
|
1000 | 889 |
def ResetConnectionStatusBar(self): |
890 |
for field in xrange(self.ConnectionStatusBar.GetFieldsCount()): |
|
891 |
self.ConnectionStatusBar.SetStatusText('', field) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
892 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
893 |
def ResetView(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
894 |
IDEFrame.ResetView(self) |
717 | 895 |
self.ConfNodeInfos = {} |
896 |
if self.CTR is not None: |
|
897 |
self.CTR.CloseProject() |
|
898 |
self.CTR = None |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
899 |
self.Log.flush() |
490 | 900 |
if self.EnableDebug: |
901 |
self.DebugVariablePanel.SetDataProducer(None) |
|
1000 | 902 |
self.ResetConnectionStatusBar() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
903 |
|
1601
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
904 |
def RefreshConfigRecentProjects(self, projectpath, err=False): |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
905 |
try: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
906 |
recent_projects = map(DecodeFileSystemPath, |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
907 |
self.GetConfigEntry("RecentProjects", [])) |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
908 |
except: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
909 |
recent_projects = [] |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
910 |
if projectpath in recent_projects: |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
911 |
recent_projects.remove(projectpath) |
1601
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
912 |
if not err: |
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
913 |
recent_projects.insert(0, projectpath) |
788 | 914 |
self.Config.Write("RecentProjects", cPickle.dumps( |
915 |
map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS]))) |
|
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
916 |
self.Config.Flush() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
917 |
|
743 | 918 |
def ResetPerspective(self): |
919 |
IDEFrame.ResetPerspective(self) |
|
920 |
self.RefreshStatusToolBar() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
921 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
922 |
def OnNewProjectMenu(self, event): |
717 | 923 |
if self.CTR is not None and not self.CheckSaveBeforeClosing(): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
924 |
return |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
925 |
|
790
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
926 |
try: |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
927 |
defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
928 |
except: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
929 |
defaultpath = os.path.expanduser("~") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
930 |
|
833
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
931 |
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
932 |
if dialog.ShowModal() == wx.ID_OK: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
933 |
projectpath = dialog.GetPath() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
934 |
self.Config.Write("lastopenedfolder", |
788 | 935 |
EncodeFileSystemPath(os.path.dirname(projectpath))) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
936 |
self.Config.Flush() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
937 |
self.ResetView() |
725 | 938 |
ctr = ProjectController(self, self.Log) |
717 | 939 |
result = ctr.NewProject(projectpath) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
940 |
if not result: |
717 | 941 |
self.CTR = ctr |
942 |
self.Controler = self.CTR |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
943 |
self.LibraryPanel.SetController(self.Controler) |
738 | 944 |
self.ProjectTree.Enable(True) |
730 | 945 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
946 |
self.RefreshConfigRecentProjects(projectpath) |
490 | 947 |
if self.EnableDebug: |
717 | 948 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
730 | 949 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
950 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
951 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
952 |
self.ShowErrorMessage(result) |
755 | 953 |
self.RefreshAll() |
706 | 954 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
955 |
dialog.Destroy() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
956 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
957 |
def OnOpenProjectMenu(self, event): |
717 | 958 |
if self.CTR is not None and not self.CheckSaveBeforeClosing(): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
959 |
return |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
960 |
|
790
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
961 |
try: |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
962 |
defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
963 |
except: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
964 |
defaultpath = os.path.expanduser("~") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
965 |
|
833
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
966 |
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, style=wx.DEFAULT_DIALOG_STYLE| |
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
967 |
wx.RESIZE_BORDER) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
968 |
if dialog.ShowModal() == wx.ID_OK: |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
969 |
self.OpenProject(dialog.GetPath()) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
970 |
dialog.Destroy() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
971 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
972 |
def OpenProject(self, projectpath): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
973 |
if os.path.isdir(projectpath): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
974 |
self.Config.Write("lastopenedfolder", |
788 | 975 |
EncodeFileSystemPath(os.path.dirname(projectpath))) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
976 |
self.Config.Flush() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
977 |
self.ResetView() |
725 | 978 |
self.CTR = ProjectController(self, self.Log) |
717 | 979 |
self.Controler = self.CTR |
1602
95ecb26fdc4e
fix bug with recent projects menu, remove path to the project from menu, if project directory doesn't exist
Sergey Surkov <surkovsv93@gmail.com>
parents:
1601
diff
changeset
|
980 |
result, err = self.CTR.LoadProject(projectpath) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
981 |
if not result: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
982 |
self.LibraryPanel.SetController(self.Controler) |
738 | 983 |
self.ProjectTree.Enable(True) |
730 | 984 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
985 |
if self.EnableDebug: |
717 | 986 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
730 | 987 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
988 |
else: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
989 |
self.ResetView() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
990 |
self.ShowErrorMessage(result) |
755 | 991 |
self.RefreshAll() |
1623
aa9ec1d5c54c
clean search result panel after open another project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1602
diff
changeset
|
992 |
self.SearchResultPanel.ResetSearchResults() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
993 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
994 |
self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
1601
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
995 |
err = True |
37271c24ce45
fix bug with empty directories in recent projects menu
Sergey Surkov <surkovsv93@gmail.com>
parents:
1600
diff
changeset
|
996 |
self.RefreshConfigRecentProjects(projectpath, err) |
706 | 997 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
998 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
999 |
def OnCloseProjectMenu(self, event): |
717 | 1000 |
if self.CTR is not None and not self.CheckSaveBeforeClosing(): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1001 |
return |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1002 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1003 |
self.ResetView() |
706 | 1004 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
755 | 1005 |
self.RefreshAll() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1006 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1007 |
def OnSaveProjectMenu(self, event): |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1008 |
selected = self.TabsOpened.GetSelection() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1009 |
if selected != -1: |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1010 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1011 |
window.Save() |
717 | 1012 |
if self.CTR is not None: |
1013 |
self.CTR.SaveProject() |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
1014 |
self.RefreshAll() |
636
35c59bfc54f2
Fixing refresh of notebook tab titles after project save
laurent
parents:
631
diff
changeset
|
1015 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1016 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1017 |
def OnSaveProjectAsMenu(self, event): |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1018 |
selected = self.TabsOpened.GetSelection() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1019 |
if selected != -1: |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1020 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
1021 |
window.SaveAs() |
717 | 1022 |
if self.CTR is not None: |
1023 |
self.CTR.SaveProjectAs() |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
1024 |
self.RefreshAll() |
1600
481a71c864d4
fix list of recent projects in File menu, add path to current project after Save As
Sergey Surkov <surkovsv93@gmail.com>
parents:
1595
diff
changeset
|
1025 |
self.RefreshConfigRecentProjects(self.CTR.ProjectPath) |
636
35c59bfc54f2
Fixing refresh of notebook tab titles after project save
laurent
parents:
631
diff
changeset
|
1026 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1027 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1028 |
def OnQuitMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1029 |
self.Close() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1030 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1031 |
def OnAboutMenu(self, event): |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1564
diff
changeset
|
1032 |
info = version.GetAboutDialogInfo() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1564
diff
changeset
|
1033 |
ShowAboutDialog(self, info) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1034 |
|
738 | 1035 |
def OnProjectTreeItemBeginEdit(self, event): |
1036 |
selected = event.GetItem() |
|
747 | 1037 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFNODE: |
738 | 1038 |
event.Veto() |
1039 |
else: |
|
1040 |
IDEFrame.OnProjectTreeItemBeginEdit(self, event) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1041 |
|
738 | 1042 |
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:
1211
diff
changeset
|
1043 |
item = event.GetItem() |
738 | 1044 |
item_infos = self.ProjectTree.GetPyData(item) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1045 |
|
738 | 1046 |
if item_infos["type"] == ITEM_CONFNODE: |
1047 |
confnode_menu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1048 |
|
738 | 1049 |
confnode = item_infos["confnode"] |
967
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1050 |
if confnode is not None: |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1051 |
menu_items = confnode.GetContextualMenuItems() |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1052 |
if menu_items is not None: |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1053 |
for text, help, callback in menu_items: |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1054 |
new_id = wx.NewId() |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1055 |
confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=text) |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1056 |
self.Bind(wx.EVT_MENU, callback, id=new_id) |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1057 |
else: |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1058 |
for name, XSDClass, help in confnode.CTNChildrenTypes: |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1059 |
new_id = wx.NewId() |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1060 |
confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Add") + " " + name) |
8a339cd61cb4
Added support for extension custom contextual add menu
Laurent Bessard
parents:
958
diff
changeset
|
1061 |
self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name, confnode), id=new_id) |
738 | 1062 |
|
1063 |
new_id = wx.NewId() |
|
1064 |
AppendMenu(confnode_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete")) |
|
755 | 1065 |
self.Bind(wx.EVT_MENU, self.GetDeleteMenuFunction(confnode), id=new_id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1066 |
|
738 | 1067 |
self.PopupMenu(confnode_menu) |
1068 |
confnode_menu.Destroy() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1069 |
|
738 | 1070 |
event.Skip() |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1393
diff
changeset
|
1071 |
elif item_infos["type"] == ITEM_RESOURCE: |
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1393
diff
changeset
|
1072 |
# prevent last resource to be delted |
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1073 |
parent = self.ProjectTree.GetItemParent(item) |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1074 |
parent_name = self.ProjectTree.GetItemText(parent) |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1393
diff
changeset
|
1075 |
if parent_name == _("Resources"): |
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1076 |
IDEFrame.OnProjectTreeRightUp(self, event) |
1038
1923a69482f8
Fixed bug when right click on ProjectTree project item
Laurent Bessard
parents:
1025
diff
changeset
|
1077 |
else: |
1923a69482f8
Fixed bug when right click on ProjectTree project item
Laurent Bessard
parents:
1025
diff
changeset
|
1078 |
IDEFrame.OnProjectTreeRightUp(self, event) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1079 |
|
738 | 1080 |
def OnProjectTreeItemActivated(self, event): |
1081 |
selected = event.GetItem() |
|
1082 |
name = self.ProjectTree.GetItemText(selected) |
|
1083 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1084 |
if item_infos["type"] == ITEM_CONFNODE: |
|
1085 |
item_infos["confnode"]._OpenView() |
|
1086 |
event.Skip() |
|
1087 |
elif item_infos["type"] == ITEM_PROJECT: |
|
1088 |
self.CTR._OpenView() |
|
1089 |
else: |
|
1090 |
IDEFrame.OnProjectTreeItemActivated(self, event) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1091 |
|
782 | 1092 |
def ProjectTreeItemSelect(self, select_item): |
1272
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1093 |
if select_item is not None and select_item.IsOk(): |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1094 |
name = self.ProjectTree.GetItemText(select_item) |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1095 |
item_infos = self.ProjectTree.GetPyData(select_item) |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1096 |
if item_infos["type"] == ITEM_CONFNODE: |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1097 |
item_infos["confnode"]._OpenView(onlyopened=True) |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1098 |
elif item_infos["type"] == ITEM_PROJECT: |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1099 |
self.CTR._OpenView(onlyopened=True) |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1100 |
else: |
0086cbee609b
Fixed bug when open editor while Build is working
Laurent Bessard
parents:
1269
diff
changeset
|
1101 |
IDEFrame.ProjectTreeItemSelect(self, select_item) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1102 |
|
738 | 1103 |
def SelectProjectTreeItem(self, tagname): |
1104 |
if self.ProjectTree is not None: |
|
1105 |
root = self.ProjectTree.GetRootItem() |
|
1106 |
if root.IsOk(): |
|
1107 |
words = tagname.split("::") |
|
1108 |
if len(words) == 1: |
|
1109 |
if tagname == "Project": |
|
1110 |
self.SelectedItem = root |
|
1111 |
self.ProjectTree.SelectItem(root) |
|
1269 | 1112 |
self.ResetSelectedItem() |
738 | 1113 |
else: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1114 |
return self.RecursiveProjectTreeItemSelection(root, |
738 | 1115 |
[(word, ITEM_CONFNODE) for word in tagname.split(".")]) |
1116 |
elif words[0] == "R": |
|
1117 |
return self.RecursiveProjectTreeItemSelection(root, [(words[2], ITEM_RESOURCE)]) |
|
1274 | 1118 |
elif not os.path.exists(words[0]): |
738 | 1119 |
IDEFrame.SelectProjectTreeItem(self, tagname) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1120 |
|
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1121 |
def GetAddConfNodeFunction(self, name, confnode=None): |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1122 |
def AddConfNodeMenuFunction(event): |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1123 |
wx.CallAfter(self.AddConfNode, name, confnode) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1124 |
return AddConfNodeMenuFunction |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1125 |
|
755 | 1126 |
def GetDeleteMenuFunction(self, confnode): |
1127 |
def DeleteMenuFunction(event): |
|
717 | 1128 |
wx.CallAfter(self.DeleteConfNode, confnode) |
755 | 1129 |
return DeleteMenuFunction |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1130 |
|
738 | 1131 |
def AddConfNode(self, ConfNodeType, confnode=None): |
717 | 1132 |
if self.CTR.CheckProjectPathPerm(): |
833
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
1133 |
ConfNodeName = "%s_0" % ConfNodeType |
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1134 |
if confnode is not None: |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1135 |
confnode.CTNAddChild(ConfNodeName, ConfNodeType) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1136 |
else: |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1137 |
self.CTR.CTNAddChild(ConfNodeName, ConfNodeType) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1138 |
self._Refresh(TITLE, FILEMENU, PROJECTTREE) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1139 |
|
717 | 1140 |
def DeleteConfNode(self, confnode): |
1141 |
if self.CTR.CheckProjectPathPerm(): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1142 |
dialog = wx.MessageDialog(self, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1143 |
_("Really delete node '%s'?") % confnode.CTNName(), |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1144 |
_("Remove %s node") % confnode.CTNType, |
801
435e49e80832
Update list of messages to be translated for internationalization and french translations
laurent
parents:
799
diff
changeset
|
1145 |
wx.YES_NO|wx.NO_DEFAULT) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1146 |
if dialog.ShowModal() == wx.ID_YES: |
718 | 1147 |
confnode.CTNRemove() |
717 | 1148 |
del confnode |
738 | 1149 |
self._Refresh(TITLE, FILEMENU, PROJECTTREE) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1150 |
dialog.Destroy() |
900
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1151 |
|
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1152 |
#------------------------------------------------------------------------------- |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1153 |
# Highlights showing functions |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1154 |
#------------------------------------------------------------------------------- |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1155 |
|
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1156 |
def ShowHighlight(self, infos, start, end, highlight_type): |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1157 |
config_name = self.Controler.GetProjectMainConfigurationName() |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1158 |
if config_name is not None and infos[0] == self.Controler.ComputeConfigurationName(config_name): |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1159 |
self.CTR._OpenView() |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1160 |
selected = self.TabsOpened.GetSelection() |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1161 |
if selected != -1: |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1162 |
viewer = self.TabsOpened.GetPage(selected) |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1163 |
viewer.AddHighlight(infos[1:], start, end, highlight_type) |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1164 |
else: |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1165 |
IDEFrame.ShowHighlight(self, infos, start, end, highlight_type) |
3e78925125e1
Fix bug main configuration variables not displayed in lower left panel when project root element is selected
Laurent Bessard
parents:
881
diff
changeset
|
1166 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1167 |
#------------------------------------------------------------------------------- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1168 |
# Exception Handler |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1169 |
#------------------------------------------------------------------------------- |
1067
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1170 |
import threading, traceback |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1171 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1172 |
Max_Traceback_List_Size = 20 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1173 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1174 |
def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1175 |
trcbck_lst = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1176 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
734 | 1177 |
trcbck = " " + str(i+1) + ". " |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1178 |
if line[0].find(os.getcwd()) == -1: |
734 | 1179 |
trcbck += "file : " + str(line[0]) + ", " |
1180 |
else: |
|
1181 |
trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
|
1182 |
trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1183 |
trcbck_lst.append(trcbck) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1184 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1185 |
# Allow clicking.... |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1186 |
cap = wx.Window_GetCapture() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1187 |
if cap: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1188 |
cap.ReleaseMouse() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1189 |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1190 |
dlg = wx.SingleChoiceDialog(None, |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1191 |
_(""" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1192 |
An unhandled exception (bug) occured. Bug report saved at : |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1193 |
(%s) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1194 |
|
434 | 1195 |
Please be kind enough to send this file to: |
734 | 1196 |
beremiz-devel@lists.sourceforge.net |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1197 |
|
1580
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1574
diff
changeset
|
1198 |
You should now restart program. |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1199 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1200 |
Traceback: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1201 |
""") % bug_report_path + |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1202 |
repr(e_type) + " : " + repr(e_value), |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1203 |
_("Error"), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1204 |
trcbck_lst) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1205 |
try: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1206 |
res = (dlg.ShowModal() == wx.ID_OK) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1207 |
finally: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1208 |
dlg.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1209 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1210 |
return res |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1211 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1212 |
def get_last_traceback(tb): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1213 |
while tb.tb_next: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1214 |
tb = tb.tb_next |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1215 |
return tb |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1216 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1217 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1218 |
def format_namespace(d, indent=' '): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1219 |
return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1220 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1221 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1222 |
ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1223 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1224 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1225 |
|
1646
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1226 |
def save_bug_report(e_type, e_value, e_traceback, bug_report_path,date): |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1227 |
info = { |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1228 |
'app-title': wx.GetApp().GetAppName(), # app_title |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1229 |
'app-version': app_version, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1230 |
'wx-version': wx.VERSION_STRING, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1231 |
'wx-platform': wx.Platform, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1232 |
'python-version': platform.python_version(), # sys.version.split()[0], |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1233 |
'platform': platform.platform(), |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1234 |
'e-type': e_type, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1235 |
'e-value': e_value, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1236 |
'date': date, |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1237 |
'cwd': os.getcwd(), |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1238 |
} |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1239 |
if e_traceback: |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1240 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1241 |
last_tb = get_last_traceback(e_traceback) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1242 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1243 |
info['locals'] = format_namespace(exception_locals) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1244 |
if 'self' in exception_locals: |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1245 |
try: |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1246 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1247 |
except: |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1248 |
pass |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1249 |
if not os.path.exists(path): |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1250 |
os.mkdir(path) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1251 |
output = open(bug_report_path, 'w') |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1252 |
lst = info.keys() |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1253 |
lst.sort() |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1254 |
for a in lst: |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1255 |
output.write(a + ":\n" + str(info[a]) + "\n\n") |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1256 |
output.close() |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1257 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1258 |
def handle_exception(e_type, e_value, e_traceback): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1259 |
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1260 |
last_tb = get_last_traceback(e_traceback) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1261 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
701
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
1262 |
if ex not in ignored_exceptions: |
1646
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1263 |
ignored_exceptions.append(ex) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1264 |
date = time.ctime() |
1646
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1265 |
bug_report_path = path + os.sep + "bug_report_" + date.replace(':', '-').replace(' ', '_') + ".txt" |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1266 |
save_bug_report(e_type, e_value, e_traceback, bug_report_path, date) |
2d1fb99065e8
fix exception handling
Surkov Sergey <surkovsv93@gmail.com>
parents:
1645
diff
changeset
|
1267 |
Display_Exception_Dialog(e_type, e_value, e_traceback, bug_report_path) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1268 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1269 |
sys.excepthook = handle_exception |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1270 |
|
1067
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1271 |
init_old = threading.Thread.__init__ |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1272 |
def init(self, *args, **kwargs): |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1273 |
init_old(self, *args, **kwargs) |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1274 |
run_old = self.run |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1275 |
def run_with_except_hook(*args, **kw): |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1276 |
try: |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1277 |
run_old(*args, **kw) |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1278 |
except (KeyboardInterrupt, SystemExit): |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1279 |
raise |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1280 |
except: |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1281 |
sys.excepthook(*sys.exc_info()) |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1282 |
self.run = run_with_except_hook |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1283 |
threading.Thread.__init__ = init |
4f460c1dffb5
Added exception hook to Beremiz_service, so that exception go in PLC log. Extended Beremiz.py exception hook to threads. Stripped images embedded in Beremiz_service.py, user real images instead.
Edouard Tisserant
parents:
1061
diff
changeset
|
1284 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1285 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1286 |
# Install a exception handle for bug reports |
1645
91b7cc4b0d44
change directory for saving Beremiz bug reports from current working directory to TEMP directory.
Surkov Sergey <surkovsv93@gmail.com>
parents:
1633
diff
changeset
|
1287 |
logpath = tempfile.gettempdir()+os.sep+'Beremiz' |
91b7cc4b0d44
change directory for saving Beremiz bug reports from current working directory to TEMP directory.
Surkov Sergey <surkovsv93@gmail.com>
parents:
1633
diff
changeset
|
1288 |
AddExceptHook(logpath ,version.app_version) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1404
diff
changeset
|
1289 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1290 |
frame = Beremiz(None, projectOpen, buildpath) |
1211
e3f805ba74ca
Fixed bug when launching Beremiz with a wrong project path
Laurent Bessard
parents:
1091
diff
changeset
|
1291 |
if splash: |
e3f805ba74ca
Fixed bug when launching Beremiz with a wrong project path
Laurent Bessard
parents:
1091
diff
changeset
|
1292 |
splash.Close() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1293 |
frame.Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1294 |
app.MainLoop() |