author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 22 Jun 2017 16:07:56 +0300 | |
changeset 1704 | 794a47ef5323 |
parent 1692 | 9cb4d1392baf |
child 1718 | 703ddaf48b00 |
permissions | -rwxr-xr-x |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
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. |
814 | 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 |
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov |
814 | 9 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
814 | 11 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
12 |
# 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
|
13 |
# 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
|
14 |
# 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
|
15 |
# of the License, or (at your option) any later version. |
814 | 16 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
17 |
# 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
|
18 |
# 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
|
19 |
# 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
|
20 |
# GNU General Public License for more details. |
814 | 21 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1565
diff
changeset
|
22 |
# 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
|
23 |
# 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
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 25 |
|
26 |
import wx |
|
27 |
import os, sys, platform, time, traceback, getopt |
|
1560
4ce8492159ab
add version with commit hash to 'About' dialogs for Beremiz IDE and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1533
diff
changeset
|
28 |
import version |
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
29 |
import util.paths as paths |
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
30 |
|
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
31 |
beremiz_dir = paths.AbsDir(__file__) |
814 | 32 |
|
33 |
__version__ = "$Revision: 1.130 $" |
|
34 |
||
35 |
if __name__ == '__main__': |
|
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:
1388
diff
changeset
|
36 |
# Usage message displayed when help request or when error detected in |
814 | 37 |
# command line |
38 |
def usage(): |
|
39 |
print "\nUsage of PLCOpenEditor.py :" |
|
40 |
print "\n %s [Filepath]\n"%sys.argv[0] |
|
41 |
||
42 |
# Parse options given to PLCOpenEditor in command line |
|
43 |
try: |
|
44 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
45 |
except getopt.GetoptError: |
|
46 |
# print help information and exit: |
|
47 |
usage() |
|
48 |
sys.exit(2) |
|
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:
1388
diff
changeset
|
49 |
|
814 | 50 |
# Extract if help has been requested |
51 |
for o, a in opts: |
|
52 |
if o in ("-h", "--help"): |
|
53 |
usage() |
|
54 |
sys.exit() |
|
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:
1388
diff
changeset
|
55 |
|
814 | 56 |
# Extract the optional filename to open |
57 |
fileOpen = None |
|
58 |
if len(args) > 1: |
|
59 |
usage() |
|
60 |
sys.exit() |
|
61 |
elif len(args) == 1: |
|
62 |
fileOpen = args[0] |
|
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:
1388
diff
changeset
|
63 |
|
814 | 64 |
# Create wxApp (Need to create App before internationalization because of |
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:
1388
diff
changeset
|
65 |
# Windows) |
1533
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
66 |
if wx.VERSION >= (3, 0, 0): |
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
67 |
app = wx.App() |
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
68 |
else: |
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
69 |
app = wx.PySimpleApp() |
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
70 |
|
814 | 71 |
|
1388
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1330
diff
changeset
|
72 |
from util.misc import InstallLocalRessources |
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:
1388
diff
changeset
|
73 |
InstallLocalRessources(beremiz_dir) |
1388
67c9a9482d24
Factorized bitmap and i18n resources loading in between PLCopenEditor and Beremiz. Now in utils/misc.py
Edouard Tisserant
parents:
1330
diff
changeset
|
74 |
|
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
75 |
from docutil import * |
814 | 76 |
from IDEFrame import IDEFrame, AppendMenu |
77 |
from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, PAGETITLES |
|
78 |
from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath |
|
79 |
from editors.Viewer import Viewer |
|
80 |
from PLCControler import PLCControler |
|
1030
d9e75a5b5f08
Fix bug when creating New project in PLCOpenEditor
Laurent Bessard
parents:
980
diff
changeset
|
81 |
from dialogs import ProjectDialog |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
82 |
from dialogs.AboutDialog import ShowAboutDialog |
814 | 83 |
|
84 |
#------------------------------------------------------------------------------- |
|
85 |
# PLCOpenEditor Main Class |
|
86 |
#------------------------------------------------------------------------------- |
|
87 |
||
88 |
# Define PLCOpenEditor FileMenu extra items id |
|
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:
1388
diff
changeset
|
89 |
[ID_PLCOPENEDITORFILEMENUGENERATE, |
814 | 90 |
] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)] |
91 |
||
92 |
class PLCOpenEditor(IDEFrame): |
|
93 |
||
94 |
# Compatibility function for wx versions < 2.6 |
|
95 |
if wx.VERSION < (2, 6, 0): |
|
96 |
def Bind(self, event, function, id = None): |
|
97 |
if id is not None: |
|
98 |
event(self, id, function) |
|
99 |
else: |
|
100 |
event(self, function) |
|
101 |
||
102 |
def _init_coll_FileMenu_Items(self, parent): |
|
103 |
AppendMenu(parent, help='', id=wx.ID_NEW, |
|
104 |
kind=wx.ITEM_NORMAL, text=_(u'New') +'\tCTRL+N') |
|
105 |
AppendMenu(parent, help='', id=wx.ID_OPEN, |
|
106 |
kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
|
107 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
|
108 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') |
|
109 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
|
110 |
kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') |
|
111 |
parent.AppendSeparator() |
|
112 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
|
113 |
kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
|
114 |
AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
|
115 |
kind=wx.ITEM_NORMAL, text=_(u'Save As...') + '\tCTRL+SHIFT+S') |
|
116 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATE, |
|
117 |
kind=wx.ITEM_NORMAL, text=_(u'Generate Program') + '\tCTRL+G') |
|
118 |
parent.AppendSeparator() |
|
119 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
|
120 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') |
|
121 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
|
122 |
kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') |
|
123 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
|
124 |
kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') |
|
125 |
parent.AppendSeparator() |
|
126 |
AppendMenu(parent, help='', id=wx.ID_PROPERTIES, |
|
127 |
kind=wx.ITEM_NORMAL, text=_(u'&Properties')) |
|
128 |
parent.AppendSeparator() |
|
129 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
|
130 |
kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') |
|
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:
1388
diff
changeset
|
131 |
|
814 | 132 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
133 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
|
134 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
|
135 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
|
136 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
|
137 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
|
138 |
self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu, |
|
139 |
id=ID_PLCOPENEDITORFILEMENUGENERATE) |
|
140 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
|
141 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
|
142 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
|
143 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
|
144 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
|
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:
1388
diff
changeset
|
145 |
|
814 | 146 |
self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), |
147 |
(wx.ID_OPEN, "open", _(u'Open'), None), |
|
148 |
(wx.ID_SAVE, "save", _(u'Save'), None), |
|
149 |
(wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), |
|
150 |
(wx.ID_PRINT, "print", _(u'Print'), None)]) |
|
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:
1388
diff
changeset
|
151 |
|
814 | 152 |
def _init_coll_HelpMenu_Items(self, parent): |
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:
1388
diff
changeset
|
153 |
AppendMenu(parent, help='', id=wx.ID_HELP, |
814 | 154 |
kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor') + '\tF1') |
155 |
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS, |
|
156 |
# kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2') |
|
157 |
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT, |
|
158 |
# kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3') |
|
1692
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
159 |
|
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
160 |
handler=lambda event: { |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
161 |
wx.MessageBox(version.GetCommunityHelpMsg(), _(u'Community support'), wx.OK | wx.ICON_INFORMATION) |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
162 |
} |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
163 |
id = wx.NewId() |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
164 |
parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support')) |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
165 |
self.Bind(wx.EVT_MENU, handler, id=id) |
9cb4d1392baf
add information about community support channel to Beremiz and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
166 |
|
814 | 167 |
AppendMenu(parent, help='', id=wx.ID_ABOUT, |
168 |
kind=wx.ITEM_NORMAL, text=_(u'About')) |
|
169 |
self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP) |
|
170 |
#self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS) |
|
171 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
|
172 |
||
173 |
## Constructor of the PLCOpenEditor class. |
|
174 |
# @param parent The parent window. |
|
175 |
# @param controler The controler been used by PLCOpenEditor (default: None). |
|
176 |
# @param fileOpen The filepath to open if no controler defined (default: None). |
|
177 |
# @param debug The filepath to open if no controler defined (default: False). |
|
178 |
def __init__(self, parent, fileOpen = None): |
|
1533
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
179 |
self.icon = wx.Icon(os.path.join(beremiz_dir, "images", "poe.ico"), wx.BITMAP_TYPE_ICO) |
814 | 180 |
IDEFrame.__init__(self, parent) |
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:
1388
diff
changeset
|
181 |
|
814 | 182 |
result = None |
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:
1388
diff
changeset
|
183 |
|
814 | 184 |
# Open the filepath if defined |
185 |
if fileOpen is not None: |
|
186 |
fileOpen = DecodeFileSystemPath(fileOpen, False) |
|
187 |
if os.path.isfile(fileOpen): |
|
188 |
# Create a new controller |
|
189 |
controler = PLCControler() |
|
190 |
result = controler.OpenXMLFile(fileOpen) |
|
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
191 |
self.Controler = controler |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
192 |
self.LibraryPanel.SetController(controler) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
193 |
self.ProjectTree.Enable(True) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
194 |
self.PouInstanceVariablesPanel.SetController(controler) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
195 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
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:
1388
diff
changeset
|
196 |
|
814 | 197 |
# Define PLCOpenEditor icon |
1533
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
198 |
self.SetIcon(self.icon) |
814 | 199 |
|
200 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
|
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:
1388
diff
changeset
|
201 |
|
814 | 202 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
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:
1388
diff
changeset
|
203 |
|
814 | 204 |
if result is not None: |
1581
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
205 |
(num, line) = result |
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
206 |
self.ShowErrorMessage(_("PLC syntax error at line {a1}:\n{a2}").format(a1 = num, a2 = line)) |
814 | 207 |
|
208 |
def OnCloseFrame(self, event): |
|
209 |
if self.Controler is None or self.CheckSaveBeforeClosing(_("Close Application")): |
|
210 |
self.AUIManager.UnInit() |
|
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:
1388
diff
changeset
|
211 |
|
814 | 212 |
self.SaveLastState() |
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:
1388
diff
changeset
|
213 |
|
814 | 214 |
event.Skip() |
215 |
else: |
|
216 |
event.Veto() |
|
217 |
||
218 |
def RefreshTitle(self): |
|
219 |
name = _("PLCOpenEditor") |
|
220 |
if self.Controler is not None: |
|
221 |
self.SetTitle("%s - %s"%(name, self.Controler.GetFilename())) |
|
222 |
else: |
|
223 |
self.SetTitle(name) |
|
224 |
||
225 |
#------------------------------------------------------------------------------- |
|
226 |
# File Menu Functions |
|
227 |
#------------------------------------------------------------------------------- |
|
228 |
||
229 |
def RefreshFileMenu(self): |
|
230 |
MenuToolBar = self.Panes["MenuToolBar"] |
|
231 |
if self.Controler is not None: |
|
232 |
selected = self.TabsOpened.GetSelection() |
|
233 |
if selected >= 0: |
|
234 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
|
235 |
else: |
|
236 |
graphic_viewer = False |
|
237 |
if self.TabsOpened.GetPageCount() > 0: |
|
238 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
|
239 |
if graphic_viewer: |
|
240 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
|
241 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
|
242 |
MenuToolBar.EnableTool(wx.ID_PRINT, True) |
|
243 |
else: |
|
244 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
245 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
246 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
|
247 |
else: |
|
248 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
249 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
250 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
251 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
|
252 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
|
253 |
project_modified = not self.Controler.ProjectIsSaved() |
|
254 |
self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
|
255 |
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
|
256 |
self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
|
257 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
|
258 |
self.FileMenu.Enable(wx.ID_SAVEAS, True) |
|
259 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, True) |
|
260 |
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True) |
|
261 |
else: |
|
262 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
263 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
|
264 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
265 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
266 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
|
267 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
|
268 |
MenuToolBar.EnableTool(wx.ID_SAVE, False) |
|
269 |
self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
|
270 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
|
271 |
self.FileMenu.Enable(wx.ID_SAVEAS, False) |
|
272 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
|
273 |
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False) |
|
274 |
||
275 |
def OnNewProjectMenu(self, event): |
|
276 |
if self.Controler is not None and not self.CheckSaveBeforeClosing(): |
|
277 |
return |
|
278 |
dialog = ProjectDialog(self) |
|
279 |
if dialog.ShowModal() == wx.ID_OK: |
|
280 |
properties = dialog.GetValues() |
|
281 |
self.ResetView() |
|
282 |
self.Controler = PLCControler() |
|
283 |
self.Controler.CreateNewProject(properties) |
|
284 |
self.LibraryPanel.SetController(self.Controler) |
|
1295
2ad168756c5e
Fixed bug no contextual menu displayed in left panel tree when creating new project
Laurent Bessard
parents:
1030
diff
changeset
|
285 |
self.ProjectTree.Enable(True) |
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:
1388
diff
changeset
|
286 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, |
814 | 287 |
LIBRARYTREE) |
288 |
||
289 |
def OnOpenProjectMenu(self, event): |
|
290 |
if self.Controler is not None and not self.CheckSaveBeforeClosing(): |
|
291 |
return |
|
292 |
filepath = "" |
|
293 |
if self.Controler is not None: |
|
294 |
filepath = self.Controler.GetFilePath() |
|
295 |
if filepath != "": |
|
296 |
directory = os.path.dirname(filepath) |
|
297 |
else: |
|
298 |
directory = os.getcwd() |
|
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:
1388
diff
changeset
|
299 |
|
814 | 300 |
result = None |
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:
1388
diff
changeset
|
301 |
|
814 | 302 |
dialog = wx.FileDialog(self, _("Choose a file"), directory, "", _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.OPEN) |
303 |
if dialog.ShowModal() == wx.ID_OK: |
|
304 |
filepath = dialog.GetPath() |
|
305 |
if os.path.isfile(filepath): |
|
306 |
self.ResetView() |
|
307 |
controler = PLCControler() |
|
308 |
result = controler.OpenXMLFile(filepath) |
|
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
309 |
self.Controler = controler |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
310 |
self.LibraryPanel.SetController(controler) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
311 |
self.ProjectTree.Enable(True) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
312 |
self.PouInstanceVariablesPanel.SetController(controler) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1312
diff
changeset
|
313 |
self._Refresh(PROJECTTREE, LIBRARYTREE) |
814 | 314 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
315 |
dialog.Destroy() |
|
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:
1388
diff
changeset
|
316 |
|
814 | 317 |
if result is not None: |
1581
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
318 |
(num, line) = result |
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1580
diff
changeset
|
319 |
self.ShowErrorMessage(_("PLC syntax error at line {a1}:\n{a2}").format(a1 = num, a2 = line)) |
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:
1388
diff
changeset
|
320 |
|
814 | 321 |
def OnCloseProjectMenu(self, event): |
322 |
if not self.CheckSaveBeforeClosing(): |
|
323 |
return |
|
324 |
self.ResetView() |
|
325 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
|
326 |
||
327 |
def OnSaveProjectMenu(self, event): |
|
328 |
self.SaveProject() |
|
329 |
||
330 |
def OnSaveProjectAsMenu(self, event): |
|
331 |
self.SaveProjectAs() |
|
332 |
||
333 |
def OnGenerateProgramMenu(self, event): |
|
334 |
dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(), _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE|wx.CHANGE_DIR) |
|
335 |
if dialog.ShowModal() == wx.ID_OK: |
|
336 |
filepath = dialog.GetPath() |
|
337 |
message_text = "" |
|
338 |
header, icon = _("Done"), wx.ICON_INFORMATION |
|
339 |
if os.path.isdir(os.path.dirname(filepath)): |
|
340 |
program, errors, warnings = self.Controler.GenerateProgram(filepath) |
|
1312
250c3ae0787c
Fixed bug when printing program generating errors and warnings in PLCOpenEditor
Laurent Bessard
parents:
1295
diff
changeset
|
341 |
message_text += "".join([_("warning: %s\n") % warning for warning in warnings]) |
814 | 342 |
if len(errors) > 0: |
1312
250c3ae0787c
Fixed bug when printing program generating errors and warnings in PLCOpenEditor
Laurent Bessard
parents:
1295
diff
changeset
|
343 |
message_text += "".join([_("error: %s\n") % error for error in errors]) |
814 | 344 |
message_text += _("Can't generate program to file %s!")%filepath |
345 |
header, icon = _("Error"), wx.ICON_ERROR |
|
346 |
else: |
|
347 |
message_text += _("Program was successfully generated!") |
|
348 |
else: |
|
349 |
message_text += _("\"%s\" is not a valid folder!")%os.path.dirname(filepath) |
|
350 |
header, icon = _("Error"), wx.ICON_ERROR |
|
351 |
message = wx.MessageDialog(self, message_text, header, wx.OK|icon) |
|
352 |
message.ShowModal() |
|
353 |
message.Destroy() |
|
354 |
dialog.Destroy() |
|
355 |
||
356 |
def OnPLCOpenEditorMenu(self, event): |
|
357 |
wx.MessageBox(_("No documentation available.\nComing soon.")) |
|
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:
1388
diff
changeset
|
358 |
|
814 | 359 |
def OnPLCOpenMenu(self, event): |
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:
1388
diff
changeset
|
360 |
open_pdf(os.path.join(beremiz_dir, "plcopen", "TC6_XML_V101.pdf")) |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1388
diff
changeset
|
361 |
|
814 | 362 |
def OnAboutMenu(self, event): |
1565
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
363 |
info = version.GetAboutDialogInfo() |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
364 |
info.Name = "PLCOpenEditor" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
365 |
info.Description = _("PLCOpenEditor is part of Beremiz project.\n\n" |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
366 |
"Beremiz is an ") + info.Description |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
367 |
info.Icon = wx.Icon(os.path.join(beremiz_dir, "images", "aboutlogo.png"), wx.BITMAP_TYPE_PNG) |
894f31f8ca64
make about dialog boxes use standard wx about dialogs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1560
diff
changeset
|
368 |
ShowAboutDialog(self, info) |
814 | 369 |
|
370 |
def SaveProject(self): |
|
371 |
result = self.Controler.SaveXMLFile() |
|
372 |
if not result: |
|
373 |
self.SaveProjectAs() |
|
374 |
else: |
|
375 |
self._Refresh(TITLE, FILEMENU, PAGETITLES) |
|
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:
1388
diff
changeset
|
376 |
|
814 | 377 |
def SaveProjectAs(self): |
378 |
filepath = self.Controler.GetFilePath() |
|
379 |
if filepath != "": |
|
380 |
directory, filename = os.path.split(filepath) |
|
381 |
else: |
|
382 |
directory, filename = os.getcwd(), "%(projectName)s.xml"%self.Controler.GetProjectProperties() |
|
383 |
dialog = wx.FileDialog(self, _("Choose a file"), directory, filename, _("PLCOpen files (*.xml)|*.xml|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT) |
|
384 |
if dialog.ShowModal() == wx.ID_OK: |
|
385 |
filepath = dialog.GetPath() |
|
386 |
if os.path.isdir(os.path.dirname(filepath)): |
|
387 |
result = self.Controler.SaveXMLFile(filepath) |
|
388 |
if not result: |
|
389 |
self.ShowErrorMessage(_("Can't save project to file %s!")%filepath) |
|
390 |
else: |
|
391 |
self.ShowErrorMessage(_("\"%s\" is not a valid folder!")%os.path.dirname(filepath)) |
|
392 |
self._Refresh(TITLE, FILEMENU, PAGETITLES) |
|
393 |
dialog.Destroy() |
|
394 |
||
395 |
#------------------------------------------------------------------------------- |
|
396 |
# Exception Handler |
|
397 |
#------------------------------------------------------------------------------- |
|
398 |
||
399 |
Max_Traceback_List_Size = 20 |
|
400 |
||
401 |
def Display_Exception_Dialog(e_type,e_value,e_tb): |
|
402 |
trcbck_lst = [] |
|
403 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
|
404 |
trcbck = " " + str(i+1) + _(". ") |
|
405 |
if line[0].find(os.getcwd()) == -1: |
|
406 |
trcbck += _("file : ") + str(line[0]) + _(", ") |
|
407 |
else: |
|
408 |
trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(", ") |
|
409 |
trcbck += _("line : ") + str(line[1]) + _(", ") + _("function : ") + str(line[2]) |
|
410 |
trcbck_lst.append(trcbck) |
|
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:
1388
diff
changeset
|
411 |
|
814 | 412 |
# Allow clicking.... |
413 |
cap = wx.Window_GetCapture() |
|
414 |
if cap: |
|
415 |
cap.ReleaseMouse() |
|
416 |
||
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:
1388
diff
changeset
|
417 |
dlg = wx.SingleChoiceDialog(None, |
814 | 418 |
_(""" |
1580
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
419 |
An unhandled exception (bug) occured. Bug report saved at : |
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
420 |
(%s) |
814 | 421 |
|
422 |
Please be kind enough to send this file to: |
|
1580
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
423 |
beremiz-devel@lists.sourceforge.net |
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
424 |
|
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
425 |
You should now restart program. |
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
426 |
|
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
427 |
Traceback: |
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
428 |
""") % bug_report_path + |
f37b88d3edc6
change bug report address for PLCOpenEditor to beremiz-devel@lists.sourceforge.net
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
429 |
repr(e_type) + " : " + repr(e_value), |
814 | 430 |
_("Error"), |
431 |
trcbck_lst) |
|
432 |
try: |
|
433 |
res = (dlg.ShowModal() == wx.ID_OK) |
|
434 |
finally: |
|
435 |
dlg.Destroy() |
|
436 |
||
437 |
return res |
|
438 |
||
439 |
def Display_Error_Dialog(e_value): |
|
440 |
message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR) |
|
441 |
message.ShowModal() |
|
442 |
message.Destroy() |
|
443 |
||
444 |
def get_last_traceback(tb): |
|
445 |
while tb.tb_next: |
|
446 |
tb = tb.tb_next |
|
447 |
return tb |
|
448 |
||
449 |
||
450 |
def format_namespace(d, indent=' '): |
|
451 |
return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
|
452 |
||
453 |
||
454 |
ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
|
455 |
||
456 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
|
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:
1388
diff
changeset
|
457 |
|
814 | 458 |
def handle_exception(e_type, e_value, e_traceback): |
459 |
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
|
460 |
last_tb = get_last_traceback(e_traceback) |
|
461 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
|
462 |
if str(e_value).startswith("!!!"): |
|
463 |
Display_Error_Dialog(e_value) |
|
464 |
elif ex not in ignored_exceptions: |
|
465 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback) |
|
466 |
if result: |
|
467 |
ignored_exceptions.append(ex) |
|
468 |
info = { |
|
469 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
|
470 |
'app-version' : app_version, |
|
471 |
'wx-version' : wx.VERSION_STRING, |
|
472 |
'wx-platform' : wx.Platform, |
|
473 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
|
474 |
'platform' : platform.platform(), |
|
475 |
'e-type' : e_type, |
|
476 |
'e-value' : e_value, |
|
477 |
'date' : time.ctime(), |
|
478 |
'cwd' : os.getcwd(), |
|
479 |
} |
|
480 |
if e_traceback: |
|
481 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
|
482 |
last_tb = get_last_traceback(e_traceback) |
|
483 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
|
484 |
info['locals'] = format_namespace(exception_locals) |
|
485 |
if 'self' in exception_locals: |
|
486 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
|
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:
1388
diff
changeset
|
487 |
|
814 | 488 |
output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w') |
489 |
lst = info.keys() |
|
490 |
lst.sort() |
|
491 |
for a in lst: |
|
492 |
output.write(a+":\n"+str(info[a])+"\n\n") |
|
493 |
||
494 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
|
495 |
sys.excepthook = handle_exception |
|
496 |
||
497 |
if __name__ == '__main__': |
|
1533
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
498 |
if wx.VERSION < (3, 0, 0): |
aca8f43483e9
fix issues in PLCOpenEditor with moving from wxWidgets 2.8 to 3.0
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1492
diff
changeset
|
499 |
wx.InitAllImageHandlers() |
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:
1388
diff
changeset
|
500 |
|
814 | 501 |
# Install a exception handle for bug reports |
1560
4ce8492159ab
add version with commit hash to 'About' dialogs for Beremiz IDE and PLCOpenEditor
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1533
diff
changeset
|
502 |
AddExceptHook(os.getcwd(), version.app_version) |
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:
1388
diff
changeset
|
503 |
|
814 | 504 |
frame = PLCOpenEditor(None, fileOpen=fileOpen) |
505 |
||
506 |
frame.Show() |
|
507 |
app.MainLoop() |
|
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:
1388
diff
changeset
|
508 |