author | Laurent Bessard |
Thu, 18 Oct 2012 12:05:45 +0200 | |
changeset 856 | b64e436f000e |
parent 843 | 7e6fb43804a8 |
child 875 | a8952b79caec |
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 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
4 |
#This file is part of Beremiz, a Integrated Development Environment for |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
5 |
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
6 |
# |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
8 |
# |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
10 |
# |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
15 |
# |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
19 |
#General Public License for more details. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
20 |
# |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
21 |
#You should have received a copy of the GNU General Public |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
24 |
|
588 | 25 |
|
26 |
updateinfo_url = None |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
27 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
28 |
import os, sys, getopt, wx |
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
|
29 |
import __builtin__ |
588 | 30 |
from wx.lib.agw.advancedsplash import AdvancedSplash |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
31 |
import tempfile |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
32 |
import shutil |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
33 |
import random |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
34 |
import time |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
35 |
from types import ListType |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
36 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
37 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
38 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
39 |
def Bpath(*args): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
40 |
return os.path.join(CWD,*args) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
41 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
42 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
43 |
def usage(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
44 |
print "\nUsage of Beremiz.py :" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
45 |
print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
46 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
47 |
try: |
736 | 48 |
opts, args = getopt.getopt(sys.argv[1:], "hu:e:", ["help", "updatecheck=", "extend="]) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
49 |
except getopt.GetoptError: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
50 |
# print help information and exit: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
51 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
52 |
sys.exit(2) |
731 | 53 |
|
54 |
extensions=[] |
|
55 |
||
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
56 |
for o, a in opts: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
57 |
if o in ("-h", "--help"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
58 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
59 |
sys.exit() |
588 | 60 |
if o in ("-u", "--updatecheck"): |
61 |
updateinfo_url = a |
|
731 | 62 |
if o in ("-e", "--extend"): |
63 |
extensions.append(a) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
64 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
65 |
if len(args) > 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
66 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
67 |
sys.exit() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
68 |
elif len(args) == 1: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
69 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
70 |
buildpath = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
71 |
elif len(args) == 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
72 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
73 |
buildpath = args[1] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
74 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
75 |
projectOpen = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
76 |
buildpath = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
77 |
|
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
|
78 |
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
|
79 |
__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
|
80 |
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
|
81 |
__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
|
82 |
|
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
|
83 |
app = wx.PySimpleApp(redirect=BMZ_DBG) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
84 |
app.SetAppName('beremiz') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
85 |
wx.InitAllImageHandlers() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
86 |
|
588 | 87 |
# popup splash |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
88 |
bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap() |
588 | 89 |
#splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000) |
90 |
splash=AdvancedSplash(None, bitmap=bmp) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
91 |
wx.Yield() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
92 |
|
588 | 93 |
if updateinfo_url is not None: |
94 |
updateinfo = "Fetching %s" % updateinfo_url |
|
95 |
# warn for possible updates |
|
96 |
def updateinfoproc(): |
|
97 |
global updateinfo |
|
98 |
try : |
|
99 |
import urllib2 |
|
100 |
updateinfo = urllib2.urlopen(updateinfo_url,None).read() |
|
101 |
except : |
|
102 |
updateinfo = "update info unavailable." |
|
103 |
||
104 |
from threading import Thread |
|
105 |
splash.SetText(text=updateinfo) |
|
106 |
wx.Yield() |
|
107 |
updateinfoThread = Thread(target=updateinfoproc) |
|
108 |
updateinfoThread.start() |
|
109 |
updateinfoThread.join(2) |
|
110 |
splash.SetText(text=updateinfo) |
|
111 |
wx.Yield() |
|
112 |
||
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
113 |
from util.TranslationCatalogs import AddCatalog, locale |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
114 |
from util.BitmapLibrary import AddBitmapFolder, GetBitmap |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
115 |
|
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
116 |
AddCatalog(os.path.join(CWD, "locale")) |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
117 |
AddBitmapFolder(os.path.join(CWD, "images")) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
118 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
119 |
if __name__ == '__main__': |
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
120 |
# Import module for internationalization |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
121 |
import gettext |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
122 |
|
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
123 |
__builtin__.__dict__['loc'] = locale |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
124 |
__builtin__.__dict__['_'] = wx.GetTranslation |
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
125 |
|
735
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
126 |
# Load extensions |
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
127 |
for extfilename in extensions: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
128 |
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
|
129 |
sys.path.append(extension_folder) |
815
e4f24593a758
Adding support for extending internationalization to extensions
laurent
parents:
814
diff
changeset
|
130 |
AddCatalog(os.path.join(extension_folder, "locale")) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
131 |
AddBitmapFolder(os.path.join(extension_folder, "images")) |
737 | 132 |
execfile(extfilename, locals()) |
735
d9f4ecee761d
Fixed extension loading too late causing features to be ignored
Edouard Tisserant
parents:
734
diff
changeset
|
133 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
134 |
import wx.lib.buttons, wx.lib.statbmp |
724 | 135 |
import cPickle |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
136 |
import types, time, re, platform, time, traceback, commands |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
137 |
|
727 | 138 |
from docutil import OpenHtmlFrame |
814 | 139 |
from IDEFrame import IDEFrame, AppendMenu |
140 |
from IDEFrame import TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
|
141 |
from IDEFrame import EncodeFileSystemPath, DecodeFileSystemPath |
|
142 |
from editors.EditorPanel import EditorPanel |
|
143 |
from editors.Viewer import Viewer |
|
144 |
from editors.TextViewer import TextViewer |
|
145 |
from editors.GraphicViewer import GraphicViewer |
|
146 |
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor |
|
147 |
from editors.DataTypeEditor import DataTypeEditor |
|
807
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
148 |
from util.MiniTextControler import MiniTextControler |
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
149 |
from util.ProcessLogger import ProcessLogger |
814 | 150 |
|
151 |
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE |
|
807
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
152 |
from ProjectController import ProjectController, MATIEC_ERROR_MODEL, ITEM_CONFNODE |
17c97fec1164
Fix import order in Beremiz.py to prevent wrong translations in internationalization
laurent
parents:
801
diff
changeset
|
153 |
|
814 | 154 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
155 |
MAX_RECENT_PROJECTS = 10 |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
156 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
157 |
class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
158 |
""" Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
159 |
and accept image name as __init__ parameter, fail silently if file do not exist""" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
160 |
def __init__(self, parent, ID, bitmapname, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
161 |
pos = wx.DefaultPosition, size = wx.DefaultSize, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
162 |
style = 0, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
163 |
name = "genstatbmp"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
164 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
165 |
wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
166 |
GetBitmap(bitmapname), |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
167 |
pos, size, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
168 |
style, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
169 |
name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
170 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
171 |
def OnPaint(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
172 |
dc = wx.PaintDC(self) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
173 |
colour = self.GetParent().GetBackgroundColour() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
174 |
dc.SetPen(wx.Pen(colour)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
175 |
dc.SetBrush(wx.Brush(colour )) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
176 |
dc.DrawRectangle(0, 0, *dc.GetSizeTuple()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
177 |
if self._bitmap: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
178 |
dc.DrawBitmap(self._bitmap, 0, 0, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
179 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
180 |
|
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
181 |
from threading import Lock,Timer,currentThread |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
182 |
MainThread = currentThread().ident |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
183 |
REFRESH_PERIOD = 0.1 |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
184 |
from time import time as gettime |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
185 |
class LogPseudoFile: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
186 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
451 | 187 |
def __init__(self, output, risecall): |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
188 |
self.red_white = wx.TextAttr("RED", "WHITE") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
189 |
self.red_yellow = wx.TextAttr("RED", "YELLOW") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
190 |
self.black_white = wx.TextAttr("BLACK", "WHITE") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
191 |
self.default_style = None |
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() |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
199 |
self.stack = [] |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
200 |
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
|
201 |
self.LastRefreshTimer = None |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
202 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
203 |
def write(self, s, style = None): |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
204 |
if self.lock.acquire(): |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
205 |
self.stack.append((s,style)) |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
206 |
self.lock.release() |
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
207 |
current_time = gettime() |
688
6324b40d82a5
Even more robust logger, up to the really last line that comes after the rush
Edouard Tisserant
parents:
687
diff
changeset
|
208 |
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
|
209 |
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
|
210 |
self.LastRefreshTimer=None |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
else: |
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
214 |
self.LastRefreshTimer = Timer(REFRESH_PERIOD, 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
|
215 |
self.LastRefreshTimer.start() |
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
216 |
|
705
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
217 |
def _should_write(self): |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
218 |
wx.CallAfter(self._write) |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
219 |
if MainThread == currentThread().ident: |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
220 |
app = wx.GetApp() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
221 |
if app is not None: |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
222 |
if self.YieldLock.acquire(0): |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
223 |
app.Yield() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
224 |
self.YieldLock.release() |
a5977f64d4d9
More gentle use of app.Yield in ProcessLogger
Edouard Tisserant
parents:
704
diff
changeset
|
225 |
|
686
e4e1da75d411
More robust Logger, now resist to flooding.
Edouard Tisserant
parents:
683
diff
changeset
|
226 |
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
|
227 |
if self.output : |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
228 |
self.output.Freeze(); |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
229 |
self.lock.acquire() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
230 |
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
|
231 |
if style is None : style=self.black_white |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
232 |
if self.default_style != style: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
233 |
self.output.SetDefaultStyle(style) |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
234 |
self.default_style = style |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
235 |
self.output.AppendText(s) |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
236 |
self.output.ScrollLines(s.count('\n')+1) |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
237 |
self.stack = [] |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
238 |
self.lock.release() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
239 |
self.output.ShowPosition(self.output.GetLastPosition()) |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
240 |
self.output.Thaw() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
241 |
self.LastRefreshTime = gettime() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
242 |
try: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
243 |
self.RefreshLock.release() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
244 |
except: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
245 |
pass |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
246 |
newtime = time.time() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
247 |
if newtime - self.rising_timer > 1: |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
248 |
self.risecall() |
166db2cb630b
Stripped dead code in bug report dialog.\nFixed error when log flooded while quitting
Edouard Tisserant
parents:
692
diff
changeset
|
249 |
self.rising_timer = newtime |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
250 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
251 |
def write_warning(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
252 |
self.write(s,self.red_white) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
253 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
254 |
def write_error(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
255 |
self.write(s,self.red_yellow) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
256 |
|
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
261 |
def flush(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
262 |
self.output.SetValue("") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
263 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
264 |
def isatty(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
265 |
return false |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
266 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
267 |
[ID_BEREMIZ, ID_BEREMIZMAINSPLITTER, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
268 |
ID_BEREMIZPLCCONFIG, ID_BEREMIZLOGCONSOLE, |
623
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
269 |
ID_BEREMIZINSPECTOR] = [wx.NewId() for _init_ctrls in range(5)] |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
270 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
271 |
[ID_FILEMENURECENTPROJECTS, |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
272 |
] = [wx.NewId() for _init_ctrls in range(1)] |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
273 |
|
717 | 274 |
CONFNODEMENU_POSITION = 3 |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
275 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
276 |
class Beremiz(IDEFrame): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
277 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
278 |
def _init_utils(self): |
717 | 279 |
self.ConfNodeMenu = wx.Menu(title='') |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
280 |
self.RecentProjectsMenu = wx.Menu(title='') |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
281 |
|
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
282 |
IDEFrame._init_utils(self) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
283 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
284 |
def _init_coll_FileMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
285 |
AppendMenu(parent, help='', id=wx.ID_NEW, |
814 | 286 |
kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
287 |
AppendMenu(parent, help='', id=wx.ID_OPEN, |
814 | 288 |
kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
702 | 289 |
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
|
290 |
parent.AppendSeparator() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
291 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
814 | 292 |
kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
293 |
AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
814 | 294 |
kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
295 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
814 | 296 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab') + '\tCTRL+W') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
297 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
814 | 298 |
kind=wx.ITEM_NORMAL, text=_(u'Close Project') + '\tCTRL+SHIFT+W') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
299 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
300 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
814 | 301 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup') + '\tCTRL+ALT+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
302 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
814 | 303 |
kind=wx.ITEM_NORMAL, text=_(u'Preview') + '\tCTRL+SHIFT+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
304 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
814 | 305 |
kind=wx.ITEM_NORMAL, text=_(u'Print') + '\tCTRL+P') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
306 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
307 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
814 | 308 |
kind=wx.ITEM_NORMAL, text=_(u'Quit') + '\tCTRL+Q') |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
309 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
310 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
311 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
312 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
313 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
314 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
315 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
316 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
317 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
318 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
319 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
799 | 320 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
321 |
self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
322 |
(wx.ID_OPEN, "open", _(u'Open'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
323 |
(wx.ID_SAVE, "save", _(u'Save'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
324 |
(wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
325 |
(wx.ID_PRINT, "print", _(u'Print'), None)]) |
706 | 326 |
|
738 | 327 |
def _init_coll_AddMenu_Items(self, parent): |
328 |
IDEFrame._init_coll_AddMenu_Items(self, parent, False) |
|
329 |
new_id = wx.NewId() |
|
330 |
AppendMenu(parent, help='', id=new_id, |
|
331 |
kind=wx.ITEM_NORMAL, text=_(u'&Resource')) |
|
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
332 |
self.Bind(wx.EVT_MENU, self.AddResourceMenu, id=new_id) |
738 | 333 |
for name, XSDClass, help in ProjectController.CTNChildrenTypes: |
334 |
new_id = wx.NewId() |
|
335 |
AppendMenu(parent, help='', id=new_id, |
|
336 |
kind=wx.ITEM_NORMAL, text=help) |
|
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
337 |
self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name), id=new_id) |
738 | 338 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
339 |
def _init_coll_HelpMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
340 |
parent.Append(help='', id=wx.ID_ABOUT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
341 |
kind=wx.ITEM_NORMAL, text=_(u'About')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
342 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
343 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
344 |
def _init_ctrls(self, prnt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
345 |
IDEFrame._init_ctrls(self, prnt) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
346 |
|
771 | 347 |
self.EditMenuSize = self.EditMenu.GetMenuItemCount() |
348 |
||
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
349 |
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR) |
623
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
350 |
accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)] |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
351 |
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
|
352 |
("Run", wx.WXK_F5), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
353 |
("Transfer", wx.WXK_F6), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
354 |
("Connect", wx.WXK_F7), |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
355 |
("Build", wx.WXK_F11)]: |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
356 |
def OnMethodGen(obj,meth): |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
357 |
def OnMethod(evt): |
717 | 358 |
if obj.CTR is not None: |
359 |
obj.CTR.CallMethod('_'+meth) |
|
738 | 360 |
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
|
361 |
return OnMethod |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
362 |
newid = wx.NewId() |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
363 |
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
|
364 |
accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)] |
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
365 |
|
8cdb533c3c7a
A few new keyboard shortcuts : F4=stop, F5=run, F5=transfer, F7=connect
Edouard Tisserant
parents:
619
diff
changeset
|
366 |
self.SetAcceleratorTable(wx.AcceleratorTable(accels)) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
367 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
368 |
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
369 |
name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
370 |
size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
371 |
self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
372 |
self.MainTabs["LogConsole"] = (self.LogConsole, _("Log Console")) |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
373 |
self.BottomNoteBook.AddPage(*self.MainTabs["LogConsole"]) |
799 | 374 |
#self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogConsole), wx.RIGHT) |
738 | 375 |
|
376 |
StatusToolBar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, |
|
377 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
|
378 |
StatusToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
379 |
StatusToolBar.Realize() |
|
380 |
self.Panes["StatusToolBar"] = StatusToolBar |
|
381 |
self.AUIManager.AddPane(StatusToolBar, wx.aui.AuiPaneInfo(). |
|
382 |
Name("StatusToolBar").Caption(_("Status ToolBar")). |
|
765
ef221ba41dec
Add support for reorganizing toolbars when their size changed
laurent
parents:
762
diff
changeset
|
383 |
ToolbarPane().Top().Position(1). |
738 | 384 |
LeftDockable(False).RightDockable(False)) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
385 |
|
738 | 386 |
self.AUIManager.Update() |
387 |
||
717 | 388 |
def __init__(self, parent, projectOpen=None, buildpath=None, ctr=None, debug=True): |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
389 |
IDEFrame.__init__(self, parent, debug) |
451 | 390 |
self.Log = LogPseudoFile(self.LogConsole,self.RiseLogConsole) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
391 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
392 |
self.local_runtime = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
393 |
self.runtime_port = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
394 |
self.local_runtime_tmpdir = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
395 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
396 |
self.LastPanelSelected = None |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
397 |
|
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
|
398 |
# 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
|
399 |
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
|
400 |
self.LocationImageDict = {} |
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
|
401 |
|
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
|
402 |
# 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
|
403 |
for imgname, itemtype in [ |
717 | 404 |
("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
|
405 |
("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
|
406 |
("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
|
407 |
("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
|
408 |
("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
|
409 |
("VAR_LOCAL", LOCATION_VAR_MEMORY)]: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
410 |
self.LocationImageDict[itemtype] = self.LocationImageList.Add(GetBitmap(imgname)) |
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
|
411 |
|
738 | 412 |
# Icons for other items |
413 |
for imgname, itemtype in [ |
|
414 |
("Extension", ITEM_CONFNODE)]: |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
415 |
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
738 | 416 |
|
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
|
417 |
# Add beremiz's icon in top left corner of the frame |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
418 |
self.SetIcon(wx.Icon(Bpath("images", "brz.ico"), wx.BITMAP_TYPE_ICO)) |
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
|
419 |
|
788 | 420 |
if projectOpen is not None: |
421 |
projectOpen = DecodeFileSystemPath(projectOpen, False) |
|
422 |
||
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
761
diff
changeset
|
423 |
if ctr is None and projectOpen is None and self.Config.HasEntry("currenteditedproject"): |
790
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
424 |
try: |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
425 |
projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject")) |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
426 |
if projectOpen == "": |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
427 |
projectOpen = None |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
428 |
except: |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
429 |
projectOpen = None |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
430 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
431 |
if projectOpen is not None and os.path.isdir(projectOpen): |
725 | 432 |
self.CTR = ProjectController(self, self.Log) |
717 | 433 |
self.Controler = self.CTR |
434 |
result = self.CTR.LoadProject(projectOpen, buildpath) |
|
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
435 |
if not result: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
436 |
self.LibraryPanel.SetController(self.Controler) |
738 | 437 |
self.ProjectTree.Enable(True) |
730 | 438 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
439 |
self.RefreshConfigRecentProjects(os.path.abspath(projectOpen)) |
730 | 440 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
441 |
else: |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
442 |
self.ResetView() |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
443 |
self.ShowErrorMessage(result) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
444 |
else: |
717 | 445 |
self.CTR = ctr |
446 |
self.Controler = ctr |
|
447 |
if ctr is not None: |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
448 |
self.LibraryPanel.SetController(self.Controler) |
738 | 449 |
self.ProjectTree.Enable(True) |
730 | 450 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
451 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
|
490 | 452 |
if self.EnableDebug: |
717 | 453 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
454 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
455 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
456 |
|
706 | 457 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
755 | 458 |
self.RefreshAll() |
590 | 459 |
self.LogConsole.SetFocus() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
460 |
|
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
461 |
def RiseLogConsole(self): |
513
feb2acb04070
Split BottomNoteBook to make LogConsole always visible
laurent
parents:
509
diff
changeset
|
462 |
self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
463 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
464 |
def RefreshTitle(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
465 |
name = _("Beremiz") |
717 | 466 |
if self.CTR is not None: |
467 |
projectname = self.CTR.GetProjectName() |
|
468 |
if self.CTR.ProjectTestModified(): |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
469 |
projectname = "~%s~" % projectname |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
470 |
self.SetTitle("%s - %s" % (name, projectname)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
471 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
472 |
self.SetTitle(name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
473 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
474 |
def StartLocalRuntime(self, taskbaricon = True): |
713
37dc330e96a2
Reflected recent changes in ProcessLogger changes in StartLocalRuntime
Edouard Tisserant
parents:
710
diff
changeset
|
475 |
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
|
476 |
# create temporary directory for runtime working directory |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
477 |
self.local_runtime_tmpdir = tempfile.mkdtemp() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
478 |
# choose an arbitrary random port for runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
479 |
self.runtime_port = int(random.random() * 1000) + 61131 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
480 |
# launch local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
481 |
self.local_runtime = ProcessLogger(self.Log, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
482 |
"\"%s\" \"%s\" -p %s -i localhost %s %s"%(sys.executable, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
483 |
Bpath("Beremiz_service.py"), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
484 |
self.runtime_port, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
485 |
{False : "-x 0", True :"-x 1"}[taskbaricon], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
486 |
self.local_runtime_tmpdir), |
704 | 487 |
no_gui=False, |
488 |
timeout=500, keyword = "working") |
|
489 |
self.local_runtime.spin() |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
490 |
return self.runtime_port |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
491 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
492 |
def KillLocalRuntime(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
493 |
if self.local_runtime is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
494 |
# shutdown local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
495 |
self.local_runtime.kill(gently=False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
496 |
# clear temp dir |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
497 |
shutil.rmtree(self.local_runtime_tmpdir) |
539
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
513
diff
changeset
|
498 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
513
diff
changeset
|
499 |
self.local_runtime = None |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
500 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
501 |
def OnOpenWidgetInspector(self, evt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
502 |
# Activate the widget inspection tool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
503 |
from wx.lib.inspection import InspectionTool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
504 |
if not InspectionTool().initialized: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
505 |
InspectionTool().Init() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
506 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
507 |
# Find a widget to be selected in the tree. Use either the |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
508 |
# one under the cursor, if any, or this frame. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
509 |
wnd = wx.FindWindowAtPointer() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
510 |
if not wnd: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
511 |
wnd = self |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
512 |
InspectionTool().Show(wnd, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
513 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
514 |
def OnLogConsoleDClick(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
515 |
wx.CallAfter(self.SearchLineForError) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
516 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
517 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
518 |
def SearchLineForError(self): |
717 | 519 |
if self.CTR is not None: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
520 |
text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
521 |
line = self.LogConsole.GetLineText(len(text.splitlines()) - 1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
522 |
result = MATIEC_ERROR_MODEL.match(line) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
523 |
if result is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
524 |
first_line, first_column, last_line, last_column, error = result.groups() |
717 | 525 |
infos = self.CTR.ShowError(self.Log, |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
526 |
(int(first_line), int(first_column)), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
527 |
(int(last_line), int(last_column))) |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
528 |
|
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
529 |
## 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
|
530 |
# @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
|
531 |
def CheckSaveBeforeClosing(self, title=_("Close Project")): |
717 | 532 |
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
|
533 |
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
|
534 |
_("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
|
535 |
title, |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
536 |
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
|
537 |
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
|
538 |
dialog.Destroy() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
539 |
if answer == wx.ID_YES: |
717 | 540 |
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
|
541 |
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
|
542 |
return False |
797
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
543 |
|
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
544 |
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
|
545 |
window = self.TabsOpened.GetPage(idx) |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
546 |
if not window.CheckSaveBeforeClosing(): |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
547 |
return False |
61280a7d9ff2
Adding support for checking that tab content is saved before closing it
laurent
parents:
793
diff
changeset
|
548 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
549 |
return True |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
550 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
551 |
def GetTabInfos(self, tab): |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
552 |
if (isinstance(tab, EditorPanel) and |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
553 |
not isinstance(tab, (Viewer, |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
554 |
TextViewer, |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
555 |
GraphicViewer, |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
556 |
ResourceEditor, |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
557 |
ConfigurationEditor, |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
558 |
DataTypeEditor))): |
782 | 559 |
return ("confnode", tab.Controler.CTNFullName(), tab.GetTagName()) |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
560 |
elif (isinstance(tab, TextViewer) and |
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
561 |
(tab.Controler is None or isinstance(tab.Controler, MiniTextControler))): |
717 | 562 |
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
|
563 |
else: |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
564 |
return IDEFrame.GetTabInfos(self, tab) |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
565 |
|
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
566 |
def LoadTab(self, notebook, page_infos): |
717 | 567 |
if page_infos[0] == "confnode": |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
568 |
if page_infos[1] is None: |
717 | 569 |
confnode = self.CTR |
716
180e4a7d945c
Adding search field for finding function or function block in library tree
laurent
parents:
715
diff
changeset
|
570 |
else: |
717 | 571 |
confnode = self.CTR.GetChildByName(page_infos[1]) |
572 |
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
|
573 |
else: |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
574 |
return IDEFrame.LoadTab(self, notebook, page_infos) |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
575 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
576 |
def OnCloseFrame(self, event): |
717 | 577 |
if self.CTR is None or self.CheckSaveBeforeClosing(_("Close Application")): |
578 |
if self.CTR is not None: |
|
579 |
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
|
580 |
self.KillLocalRuntime() |
598
6c919bc1551d
Adding support for saving frame size while closing and restore it at next launch
laurent
parents:
590
diff
changeset
|
581 |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
582 |
self.SaveLastState() |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
583 |
|
717 | 584 |
if self.CTR is not None: |
585 |
project_path = os.path.realpath(self.CTR.GetProjectPath()) |
|
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
586 |
else: |
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
587 |
project_path = "" |
788 | 588 |
self.Config.Write("currenteditedproject", EncodeFileSystemPath(project_path)) |
715
135566ab0807
Adding support for automatically saving and restoring state of frame or project perspective
laurent
parents:
714
diff
changeset
|
589 |
self.Config.Flush() |
598
6c919bc1551d
Adding support for saving frame size while closing and restore it at next launch
laurent
parents:
590
diff
changeset
|
590 |
|
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
591 |
event.Skip() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
592 |
else: |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
593 |
event.Veto() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
594 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
595 |
def RefreshFileMenu(self): |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
596 |
self.RefreshRecentProjectsMenu() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
597 |
|
706 | 598 |
MenuToolBar = self.Panes["MenuToolBar"] |
717 | 599 |
if self.CTR is not None: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
600 |
selected = self.TabsOpened.GetSelection() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
601 |
if selected >= 0: |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
602 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
603 |
viewer_is_modified = window.IsModified() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
604 |
is_viewer = isinstance(window, Viewer) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
605 |
else: |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
606 |
viewer_is_modified = is_viewer = False |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
607 |
if self.TabsOpened.GetPageCount() > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
608 |
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
|
609 |
if is_viewer: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
610 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
611 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
706 | 612 |
MenuToolBar.EnableTool(wx.ID_PRINT, True) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
613 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
614 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
615 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 616 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
617 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
618 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
619 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
620 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 621 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
622 |
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
|
623 |
project_modified = self.CTR.ProjectTestModified() or viewer_is_modified |
706 | 624 |
self.FileMenu.Enable(wx.ID_SAVE, project_modified) |
625 |
MenuToolBar.EnableTool(wx.ID_SAVE, project_modified) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
626 |
self.FileMenu.Enable(wx.ID_SAVEAS, True) |
706 | 627 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, True) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
628 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
629 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
630 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
631 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
632 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
633 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
706 | 634 |
MenuToolBar.EnableTool(wx.ID_PRINT, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
635 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
706 | 636 |
MenuToolBar.EnableTool(wx.ID_SAVE, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
637 |
self.FileMenu.Enable(wx.ID_SAVEAS, False) |
706 | 638 |
MenuToolBar.EnableTool(wx.ID_SAVEAS, False) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
639 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
640 |
|
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
641 |
def RefreshRecentProjectsMenu(self): |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
642 |
try: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
643 |
recent_projects = map(DecodeFileSystemPath, |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
644 |
self.GetConfigEntry("RecentProjects", [])) |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
645 |
except: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
646 |
recent_projects = [] |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
647 |
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
|
648 |
for idx, projectpath in enumerate(recent_projects): |
730 | 649 |
text = u'%d: %s' % (idx + 1, projectpath) |
650 |
||
651 |
if idx < self.RecentProjectsMenu.GetMenuItemCount(): |
|
652 |
item = self.RecentProjectsMenu.FindItemByPosition(idx) |
|
653 |
id = item.GetId() |
|
654 |
item.SetItemLabel(text) |
|
655 |
self.Disconnect(id, id, wx.EVT_BUTTON._getEvtType()) |
|
656 |
else: |
|
657 |
id = wx.NewId() |
|
658 |
AppendMenu(self.RecentProjectsMenu, help='', id=id, |
|
659 |
kind=wx.ITEM_NORMAL, text=text) |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
660 |
self.Bind(wx.EVT_MENU, self.GenerateOpenRecentProjectFunction(projectpath), id=id) |
730 | 661 |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
662 |
def GenerateOpenRecentProjectFunction(self, projectpath): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
663 |
def OpenRecentProject(event): |
717 | 664 |
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
|
665 |
return |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
666 |
|
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
667 |
self.OpenProject(projectpath) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
668 |
return OpenRecentProject |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
669 |
|
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
670 |
def GenerateMenuRecursive(self, items, menu): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
671 |
for kind, infos in items: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
672 |
if isinstance(kind, ListType): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
673 |
text, id = infos |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
674 |
submenu = wx.Menu('') |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
675 |
self.GenerateMenuRecursive(kind, submenu) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
676 |
menu.AppendMenu(id, text, submenu) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
677 |
elif kind == wx.ITEM_SEPARATOR: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
678 |
menu.AppendSeparator() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
679 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
680 |
text, id, help, callback = infos |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
681 |
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
|
682 |
if callback is not None: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
683 |
self.Bind(wx.EVT_MENU, callback, id=id) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
684 |
|
766
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
685 |
def RefreshEditorToolBar(self): |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
686 |
IDEFrame.RefreshEditorToolBar(self) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
687 |
self.AUIManager.GetPane("EditorToolBar").Position(2) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
688 |
self.AUIManager.GetPane("StatusToolBar").Position(1) |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
689 |
self.AUIManager.Update() |
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
690 |
|
738 | 691 |
def RefreshStatusToolBar(self): |
692 |
StatusToolBar = self.Panes["StatusToolBar"] |
|
693 |
StatusToolBar.ClearTools() |
|
694 |
||
695 |
if self.CTR is not None: |
|
696 |
||
697 |
for confnode_method in self.CTR.StatusMethods: |
|
698 |
if "method" in confnode_method and confnode_method.get("shown",True): |
|
699 |
id = wx.NewId() |
|
700 |
StatusToolBar.AddSimpleTool(id, |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
701 |
GetBitmap(confnode_method.get("bitmap", "Unknown")), |
738 | 702 |
confnode_method["tooltip"]) |
703 |
self.Bind(wx.EVT_MENU, self.GetMenuCallBackFunction(confnode_method["method"]), id=id) |
|
704 |
||
705 |
StatusToolBar.Realize() |
|
706 |
self.AUIManager.GetPane("StatusToolBar").BestSize(StatusToolBar.GetBestSize()).Show() |
|
707 |
else: |
|
708 |
self.AUIManager.GetPane("StatusToolBar").Hide() |
|
766
42c0062655a7
Fix bug in reorganization of toolbars after refreshing them
laurent
parents:
765
diff
changeset
|
709 |
self.AUIManager.GetPane("EditorToolBar").Position(2) |
765
ef221ba41dec
Add support for reorganizing toolbars when their size changed
laurent
parents:
762
diff
changeset
|
710 |
self.AUIManager.GetPane("StatusToolBar").Position(1) |
738 | 711 |
self.AUIManager.Update() |
712 |
||
771 | 713 |
def RefreshEditMenu(self): |
714 |
IDEFrame.RefreshEditMenu(self) |
|
715 |
||
717 | 716 |
if self.CTR is not None: |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
717 |
selected = self.TabsOpened.GetSelection() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
718 |
if selected >= 0: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
719 |
panel = self.TabsOpened.GetPage(selected) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
720 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
721 |
panel = None |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
722 |
if panel != self.LastPanelSelected: |
771 | 723 |
for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
724 |
item = self.EditMenu.FindItemByPosition(self.EditMenuSize) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
725 |
if item is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
726 |
if item.IsSeparator(): |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
727 |
self.EditMenu.RemoveItem(item) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
728 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
729 |
self.EditMenu.Delete(item.GetId()) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
730 |
self.LastPanelSelected = panel |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
731 |
if panel is not None: |
717 | 732 |
items = panel.GetConfNodeMenuItems() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
733 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
734 |
items = [] |
771 | 735 |
if len(items) > 0: |
736 |
self.EditMenu.AppendSeparator() |
|
737 |
self.GenerateMenuRecursive(items, self.EditMenu) |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
738 |
if panel is not None: |
771 | 739 |
panel.RefreshConfNodeMenu(self.EditMenu) |
740 |
else: |
|
741 |
for i in xrange(self.EditMenuSize, self.EditMenu.GetMenuItemCount()): |
|
742 |
item = self.EditMenu.FindItemByPosition(i) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
743 |
if item is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
744 |
if item.IsSeparator(): |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
745 |
self.EditMenu.RemoveItem(item) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
746 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
747 |
self.EditMenu.Delete(item.GetId()) |
771 | 748 |
self.LastPanelSelected = None |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
749 |
self.MenuBar.UpdateMenus() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
750 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
751 |
def RefreshAll(self): |
755 | 752 |
self.RefreshStatusToolBar() |
717 | 753 |
|
738 | 754 |
def GetMenuCallBackFunction(self, method): |
755 |
""" Generate the callbackfunc for a given CTR method""" |
|
756 |
def OnMenu(event): |
|
757 |
# Disable button to prevent re-entrant call |
|
758 |
event.GetEventObject().Disable() |
|
759 |
# Call |
|
760 |
getattr(self.CTR, method)() |
|
761 |
# Re-enable button |
|
762 |
event.GetEventObject().Enable() |
|
763 |
# Trigger refresh on Idle |
|
764 |
wx.CallAfter(self.RefreshStatusToolBar) |
|
765 |
return OnMenu |
|
766 |
||
767 |
def GetConfigEntry(self, entry_name, default): |
|
768 |
return cPickle.loads(str(self.Config.Read(entry_name, cPickle.dumps(default)))) |
|
769 |
||
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
770 |
def ResetView(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
771 |
IDEFrame.ResetView(self) |
717 | 772 |
self.ConfNodeInfos = {} |
773 |
if self.CTR is not None: |
|
774 |
self.CTR.CloseProject() |
|
775 |
self.CTR = None |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
776 |
self.Log.flush() |
490 | 777 |
if self.EnableDebug: |
778 |
self.DebugVariablePanel.SetDataProducer(None) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
779 |
|
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
780 |
def RefreshConfigRecentProjects(self, projectpath): |
793
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
781 |
try: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
782 |
recent_projects = map(DecodeFileSystemPath, |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
783 |
self.GetConfigEntry("RecentProjects", [])) |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
784 |
except: |
1b24b970a816
Fixing bug while loading recent projects open path with old configurations
laurent
parents:
790
diff
changeset
|
785 |
recent_projects = [] |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
786 |
if projectpath in recent_projects: |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
787 |
recent_projects.remove(projectpath) |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
788 |
recent_projects.insert(0, projectpath) |
788 | 789 |
self.Config.Write("RecentProjects", cPickle.dumps( |
790 |
map(EncodeFileSystemPath, recent_projects[:MAX_RECENT_PROJECTS]))) |
|
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
791 |
self.Config.Flush() |
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
792 |
|
743 | 793 |
def ResetPerspective(self): |
794 |
IDEFrame.ResetPerspective(self) |
|
795 |
self.RefreshStatusToolBar() |
|
796 |
||
797 |
def RestoreLastLayout(self): |
|
798 |
IDEFrame.RestoreLastLayout(self) |
|
799 |
self.RefreshStatusToolBar() |
|
800 |
||
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
801 |
def OnNewProjectMenu(self, event): |
717 | 802 |
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
|
803 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
804 |
|
790
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
805 |
try: |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
806 |
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
|
807 |
except: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
808 |
defaultpath = os.path.expanduser("~") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
809 |
|
833
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
810 |
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
811 |
if dialog.ShowModal() == wx.ID_OK: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
812 |
projectpath = dialog.GetPath() |
788 | 813 |
self.Config.Write("lastopenedfolder", |
814 |
EncodeFileSystemPath(os.path.dirname(projectpath))) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
815 |
self.Config.Flush() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
816 |
self.ResetView() |
725 | 817 |
ctr = ProjectController(self, self.Log) |
717 | 818 |
result = ctr.NewProject(projectpath) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
819 |
if not result: |
717 | 820 |
self.CTR = ctr |
821 |
self.Controler = self.CTR |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
822 |
self.LibraryPanel.SetController(self.Controler) |
738 | 823 |
self.ProjectTree.Enable(True) |
730 | 824 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
825 |
self.RefreshConfigRecentProjects(projectpath) |
490 | 826 |
if self.EnableDebug: |
717 | 827 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
730 | 828 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
829 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
830 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
831 |
self.ShowErrorMessage(result) |
755 | 832 |
self.RefreshAll() |
706 | 833 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
834 |
dialog.Destroy() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
835 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
836 |
def OnOpenProjectMenu(self, event): |
717 | 837 |
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
|
838 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
839 |
|
790
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
840 |
try: |
52d3a084d2b2
Adding secure extraction of last edited project path to avoid crash if path is not well formatted
laurent
parents:
788
diff
changeset
|
841 |
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
|
842 |
except: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
843 |
defaultpath = os.path.expanduser("~") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
844 |
|
833
3f997fb22928
Fix confnode new name format that generates an error with frame class name in wxGlade extension
laurent
parents:
815
diff
changeset
|
845 |
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
|
846 |
wx.RESIZE_BORDER) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
847 |
if dialog.ShowModal() == wx.ID_OK: |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
848 |
self.OpenProject(dialog.GetPath()) |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
849 |
dialog.Destroy() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
850 |
|
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
851 |
def OpenProject(self, projectpath): |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
852 |
if os.path.isdir(projectpath): |
788 | 853 |
self.Config.Write("lastopenedfolder", |
854 |
EncodeFileSystemPath(os.path.dirname(projectpath))) |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
855 |
self.Config.Flush() |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
856 |
self.ResetView() |
725 | 857 |
self.CTR = ProjectController(self, self.Log) |
717 | 858 |
self.Controler = self.CTR |
859 |
result = self.CTR.LoadProject(projectpath) |
|
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
860 |
if not result: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
861 |
self.LibraryPanel.SetController(self.Controler) |
738 | 862 |
self.ProjectTree.Enable(True) |
730 | 863 |
self.PouInstanceVariablesPanel.SetController(self.Controler) |
679
d72f3a42f440
Fix recent projects list not updated when creating new project
laurent
parents:
678
diff
changeset
|
864 |
self.RefreshConfigRecentProjects(projectpath) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
865 |
if self.EnableDebug: |
717 | 866 |
self.DebugVariablePanel.SetDataProducer(self.CTR) |
743 | 867 |
self.LoadProjectLayout() |
730 | 868 |
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
869 |
else: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
870 |
self.ResetView() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
871 |
self.ShowErrorMessage(result) |
755 | 872 |
self.RefreshAll() |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
873 |
else: |
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
666
diff
changeset
|
874 |
self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
706 | 875 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
876 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
877 |
def OnCloseProjectMenu(self, event): |
717 | 878 |
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
|
879 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
880 |
|
743 | 881 |
self.SaveProjectLayout() |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
882 |
self.ResetView() |
706 | 883 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU) |
755 | 884 |
self.RefreshAll() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
885 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
886 |
def OnSaveProjectMenu(self, event): |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
887 |
selected = self.TabsOpened.GetSelection() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
888 |
if selected != -1: |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
889 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
890 |
window.Save() |
717 | 891 |
if self.CTR is not None: |
892 |
self.CTR.SaveProject() |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
893 |
self.RefreshAll() |
636
35c59bfc54f2
Fixing refresh of notebook tab titles after project save
laurent
parents:
631
diff
changeset
|
894 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
895 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
896 |
def OnSaveProjectAsMenu(self, event): |
784
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
897 |
selected = self.TabsOpened.GetSelection() |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
898 |
if selected != -1: |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
899 |
window = self.TabsOpened.GetPage(selected) |
a1d970365e41
Adding support for beremiz extensions to define custom file editors for project files
laurent
parents:
782
diff
changeset
|
900 |
window.SaveAs() |
717 | 901 |
if self.CTR is not None: |
902 |
self.CTR.SaveProjectAs() |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
771
diff
changeset
|
903 |
self.RefreshAll() |
636
35c59bfc54f2
Fixing refresh of notebook tab titles after project save
laurent
parents:
631
diff
changeset
|
904 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
905 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
906 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
907 |
def OnQuitMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
908 |
self.Close() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
909 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
910 |
def OnAboutMenu(self, event): |
814 | 911 |
OpenHtmlFrame(self,_("About Beremiz"), Bpath("doc", "about.html"), wx.Size(550, 500)) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
912 |
|
738 | 913 |
def OnProjectTreeItemBeginEdit(self, event): |
914 |
selected = event.GetItem() |
|
747 | 915 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFNODE: |
738 | 916 |
event.Veto() |
917 |
else: |
|
918 |
IDEFrame.OnProjectTreeItemBeginEdit(self, event) |
|
919 |
||
920 |
def OnProjectTreeRightUp(self, event): |
|
921 |
if wx.Platform == '__WXMSW__': |
|
922 |
item = event.GetItem() |
|
923 |
else: |
|
924 |
item, flags = self.ProjectTree.HitTest(wx.Point(event.GetX(), event.GetY())) |
|
925 |
item_infos = self.ProjectTree.GetPyData(item) |
|
926 |
||
927 |
if item_infos["type"] == ITEM_CONFNODE: |
|
928 |
confnode_menu = wx.Menu(title='') |
|
929 |
||
930 |
confnode = item_infos["confnode"] |
|
931 |
if confnode is not None and len(confnode.CTNChildrenTypes) > 0: |
|
932 |
for name, XSDClass, help in confnode.CTNChildrenTypes: |
|
933 |
new_id = wx.NewId() |
|
843
7e6fb43804a8
Fix description of menu entry for adding sub ConfNode to ConfNode in Project Tree
laurent
parents:
833
diff
changeset
|
934 |
confnode_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Add") + " " + name) |
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
935 |
self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name, confnode), id=new_id) |
738 | 936 |
|
937 |
new_id = wx.NewId() |
|
938 |
AppendMenu(confnode_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete")) |
|
755 | 939 |
self.Bind(wx.EVT_MENU, self.GetDeleteMenuFunction(confnode), id=new_id) |
738 | 940 |
|
941 |
self.PopupMenu(confnode_menu) |
|
942 |
confnode_menu.Destroy() |
|
943 |
||
944 |
event.Skip() |
|
945 |
else: |
|
946 |
IDEFrame.OnProjectTreeRightUp(self, event) |
|
947 |
||
948 |
def OnProjectTreeItemActivated(self, event): |
|
949 |
selected = event.GetItem() |
|
950 |
name = self.ProjectTree.GetItemText(selected) |
|
951 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
952 |
if item_infos["type"] == ITEM_CONFNODE: |
|
953 |
item_infos["confnode"]._OpenView() |
|
954 |
event.Skip() |
|
955 |
elif item_infos["type"] == ITEM_PROJECT: |
|
956 |
self.CTR._OpenView() |
|
957 |
else: |
|
958 |
IDEFrame.OnProjectTreeItemActivated(self, event) |
|
959 |
||
782 | 960 |
def ProjectTreeItemSelect(self, select_item): |
961 |
name = self.ProjectTree.GetItemText(select_item) |
|
962 |
item_infos = self.ProjectTree.GetPyData(select_item) |
|
963 |
if item_infos["type"] == ITEM_CONFNODE: |
|
964 |
item_infos["confnode"]._OpenView(onlyopened=True) |
|
965 |
elif item_infos["type"] == ITEM_PROJECT: |
|
966 |
self.CTR._OpenView(onlyopened=True) |
|
967 |
else: |
|
968 |
IDEFrame.ProjectTreeItemSelect(self, select_item) |
|
969 |
||
970 |
||
738 | 971 |
def SelectProjectTreeItem(self, tagname): |
972 |
if self.ProjectTree is not None: |
|
973 |
root = self.ProjectTree.GetRootItem() |
|
974 |
if root.IsOk(): |
|
975 |
words = tagname.split("::") |
|
976 |
if len(words) == 1: |
|
977 |
if tagname == "Project": |
|
978 |
self.SelectedItem = root |
|
979 |
self.ProjectTree.SelectItem(root) |
|
980 |
wx.CallAfter(self.ResetSelectedItem) |
|
981 |
else: |
|
982 |
return self.RecursiveProjectTreeItemSelection(root, |
|
983 |
[(word, ITEM_CONFNODE) for word in tagname.split(".")]) |
|
984 |
elif words[0] == "R": |
|
985 |
return self.RecursiveProjectTreeItemSelection(root, [(words[2], ITEM_RESOURCE)]) |
|
986 |
else: |
|
987 |
IDEFrame.SelectProjectTreeItem(self, tagname) |
|
988 |
||
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
989 |
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
|
990 |
def AddConfNodeMenuFunction(event): |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
991 |
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
|
992 |
return AddConfNodeMenuFunction |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
993 |
|
755 | 994 |
def GetDeleteMenuFunction(self, confnode): |
995 |
def DeleteMenuFunction(event): |
|
717 | 996 |
wx.CallAfter(self.DeleteConfNode, confnode) |
755 | 997 |
return DeleteMenuFunction |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
998 |
|
760
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
999 |
def AddResourceMenu(self, event): |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1000 |
config_names = self.CTR.GetProjectConfigNames() |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1001 |
if len(config_names) > 0: |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1002 |
tagname = self.Controler.ProjectAddConfigurationResource(config_names[0]) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1003 |
if tagname is not None: |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1004 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1005 |
self.EditProjectElement(ITEM_RESOURCE, tagname) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1006 |
|
738 | 1007 |
def AddConfNode(self, ConfNodeType, confnode=None): |
717 | 1008 |
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
|
1009 |
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
|
1010 |
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
|
1011 |
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
|
1012 |
else: |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1013 |
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
|
1014 |
self._Refresh(TITLE, FILEMENU, PROJECTTREE) |
d38560559afb
Replacing dialog asking for a name when adding confnode to project by automatically generated name
laurent
parents:
755
diff
changeset
|
1015 |
|
717 | 1016 |
def DeleteConfNode(self, confnode): |
1017 |
if self.CTR.CheckProjectPathPerm(): |
|
801
435e49e80832
Update list of messages to be translated for internationalization and french translations
laurent
parents:
799
diff
changeset
|
1018 |
dialog = wx.MessageDialog(self, |
435e49e80832
Update list of messages to be translated for internationalization and french translations
laurent
parents:
799
diff
changeset
|
1019 |
_("Really delete node '%s'?") % confnode.CTNName(), |
435e49e80832
Update list of messages to be translated for internationalization and french translations
laurent
parents:
799
diff
changeset
|
1020 |
_("Remove %s node") % confnode.CTNType, |
435e49e80832
Update list of messages to be translated for internationalization and french translations
laurent
parents:
799
diff
changeset
|
1021 |
wx.YES_NO|wx.NO_DEFAULT) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1022 |
if dialog.ShowModal() == wx.ID_YES: |
718 | 1023 |
confnode.CTNRemove() |
717 | 1024 |
del confnode |
738 | 1025 |
self._Refresh(TITLE, FILEMENU, PROJECTTREE) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1026 |
dialog.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1027 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1028 |
#------------------------------------------------------------------------------- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1029 |
# Exception Handler |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1030 |
#------------------------------------------------------------------------------- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1031 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1032 |
Max_Traceback_List_Size = 20 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1033 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1034 |
def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1035 |
trcbck_lst = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1036 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
734 | 1037 |
trcbck = " " + str(i+1) + ". " |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1038 |
if line[0].find(os.getcwd()) == -1: |
734 | 1039 |
trcbck += "file : " + str(line[0]) + ", " |
1040 |
else: |
|
1041 |
trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
|
1042 |
trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1043 |
trcbck_lst.append(trcbck) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1044 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1045 |
# Allow clicking.... |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1046 |
cap = wx.Window_GetCapture() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1047 |
if cap: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1048 |
cap.ReleaseMouse() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1049 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1050 |
dlg = wx.SingleChoiceDialog(None, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1051 |
_(""" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1052 |
An unhandled exception (bug) occured. Bug report saved at : |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1053 |
(%s) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1054 |
|
434 | 1055 |
Please be kind enough to send this file to: |
734 | 1056 |
beremiz-devel@lists.sourceforge.net |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1057 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1058 |
You should now restart Beremiz. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1059 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1060 |
Traceback: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1061 |
""") % bug_report_path + |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1062 |
str(e_type) + " : " + str(e_value), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1063 |
_("Error"), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1064 |
trcbck_lst) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1065 |
try: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1066 |
res = (dlg.ShowModal() == wx.ID_OK) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1067 |
finally: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1068 |
dlg.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1069 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1070 |
return res |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1071 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1072 |
def get_last_traceback(tb): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1073 |
while tb.tb_next: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1074 |
tb = tb.tb_next |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1075 |
return tb |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1076 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1077 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1078 |
def format_namespace(d, indent=' '): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1079 |
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
|
1080 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1081 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1082 |
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
|
1083 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1084 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1085 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1086 |
def handle_exception(e_type, e_value, e_traceback): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1087 |
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
|
1088 |
last_tb = get_last_traceback(e_traceback) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1089 |
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
|
1090 |
if ex not in ignored_exceptions: |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1091 |
date = time.ctime() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1092 |
bug_report_path = path+os.sep+"bug_report_"+date.replace(':','-').replace(' ','_')+".txt" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1093 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback,bug_report_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1094 |
if result: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1095 |
ignored_exceptions.append(ex) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1096 |
info = { |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1097 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1098 |
'app-version' : app_version, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1099 |
'wx-version' : wx.VERSION_STRING, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1100 |
'wx-platform' : wx.Platform, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1101 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1102 |
'platform' : platform.platform(), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1103 |
'e-type' : e_type, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1104 |
'e-value' : e_value, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1105 |
'date' : date, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1106 |
'cwd' : os.getcwd(), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1107 |
} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1108 |
if e_traceback: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1109 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1110 |
last_tb = get_last_traceback(e_traceback) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1111 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1112 |
info['locals'] = format_namespace(exception_locals) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1113 |
if 'self' in exception_locals: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1114 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1115 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1116 |
output = open(bug_report_path,'w') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1117 |
lst = info.keys() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1118 |
lst.sort() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1119 |
for a in lst: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1120 |
output.write(a+":\n"+str(info[a])+"\n\n") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1121 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1122 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1123 |
sys.excepthook = handle_exception |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1124 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1125 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1126 |
# Install a exception handle for bug reports |
588 | 1127 |
AddExceptHook(os.getcwd(),updateinfo_url) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1128 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1129 |
frame = Beremiz(None, projectOpen, buildpath) |
590 | 1130 |
splash.Close() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1131 |
frame.Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1132 |
app.MainLoop() |