author | edouard |
Wed, 23 Feb 2011 16:54:29 +0100 | |
changeset 578 | 6f5795bdee49 |
parent 571 | 427bf9130d12 |
child 588 | aa5a08d20ba1 |
permissions | -rw-r--r-- |
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 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
25 |
__version__ = "$Revision$" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
26 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
27 |
import os, sys, getopt, wx |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
28 |
import tempfile |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
29 |
import shutil |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
30 |
import random |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
31 |
import time |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
32 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
33 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
34 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
35 |
def Bpath(*args): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
36 |
return os.path.join(CWD,*args) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
37 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
38 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
39 |
def usage(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
40 |
print "\nUsage of Beremiz.py :" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
41 |
print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
42 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
43 |
try: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
44 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
45 |
except getopt.GetoptError: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
46 |
# print help information and exit: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
47 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
48 |
sys.exit(2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
49 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
50 |
for o, a in opts: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
51 |
if o in ("-h", "--help"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
52 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
53 |
sys.exit() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
54 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
55 |
if len(args) > 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
56 |
usage() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
57 |
sys.exit() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
58 |
elif len(args) == 1: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
59 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
60 |
buildpath = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
61 |
elif len(args) == 2: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
62 |
projectOpen = args[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
63 |
buildpath = args[1] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
64 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
65 |
projectOpen = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
66 |
buildpath = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
67 |
|
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
|
68 |
if os.path.exists("BEREMIZ_DEBUG"): |
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
|
69 |
__builtins__.BMZ_DBG = True |
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
|
70 |
else : |
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
|
71 |
__builtins__.BMZ_DBG = False |
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
|
72 |
|
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
|
73 |
app = wx.PySimpleApp(redirect=BMZ_DBG) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
74 |
app.SetAppName('beremiz') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
75 |
wx.InitAllImageHandlers() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
76 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
77 |
bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
78 |
splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
79 |
wx.Yield() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
80 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
81 |
# Import module for internationalization |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
82 |
import gettext |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
83 |
import __builtin__ |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
84 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
85 |
# Get folder containing translation files |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
86 |
localedir = os.path.join(CWD,"locale") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
87 |
# Get the default language |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
88 |
langid = wx.LANGUAGE_DEFAULT |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
89 |
# Define translation domain (name of translation files) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
90 |
domain = "Beremiz" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
91 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
92 |
# Define locale for wx |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
93 |
loc = __builtin__.__dict__.get('loc', None) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
94 |
if loc is None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
95 |
loc = wx.Locale(langid) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
96 |
__builtin__.__dict__['loc'] = loc |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
97 |
# Define location for searching translation files |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
98 |
loc.AddCatalogLookupPathPrefix(localedir) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
99 |
# Define locale domain |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
100 |
loc.AddCatalog(domain) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
101 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
102 |
def unicode_translation(message): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
103 |
return wx.GetTranslation(message).encode("utf-8") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
104 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
105 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
106 |
__builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
107 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
108 |
#Quick hack to be able to find Beremiz IEC tools. Should be config params. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
109 |
base_folder = os.path.split(sys.path[0])[0] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
110 |
sys.path.append(base_folder) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
111 |
sys.path.append(os.path.join(base_folder, "plcopeneditor")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
112 |
sys.path.append(os.path.join(base_folder, "docutils")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
113 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
114 |
import wx.lib.buttons, wx.lib.statbmp |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
115 |
import TextCtrlAutoComplete, cPickle |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
116 |
import types, time, re, platform, time, traceback, commands |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
117 |
from plugger import PluginsRoot, MATIEC_ERROR_MODEL |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
118 |
from wxPopen import ProcessLogger |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
119 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
120 |
from docutils import * |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
121 |
from PLCOpenEditor import IDEFrame, Viewer, AppendMenu, TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, INSTANCESTREE, LIBRARYTREE, SCALING |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
122 |
from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
123 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
124 |
SCROLLBAR_UNIT = 10 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
125 |
WINDOW_COLOUR = wx.Colour(240,240,240) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
126 |
TITLE_COLOUR = wx.Colour(200,200,220) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
127 |
CHANGED_TITLE_COLOUR = wx.Colour(220,200,220) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
128 |
CHANGED_WINDOW_COLOUR = wx.Colour(255,240,240) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
129 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
130 |
if wx.Platform == '__WXMSW__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
131 |
faces = { 'times': 'Times New Roman', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
132 |
'mono' : 'Courier New', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
133 |
'helv' : 'Arial', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
134 |
'other': 'Comic Sans MS', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
135 |
'size' : 16, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
136 |
} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
137 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
138 |
faces = { 'times': 'Times', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
139 |
'mono' : 'Courier', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
140 |
'helv' : 'Helvetica', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
141 |
'other': 'new century schoolbook', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
142 |
'size' : 18, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
143 |
} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
144 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
145 |
# Some helpers to tweak GenBitmapTextButtons |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
146 |
# TODO: declare customized classes instead. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
147 |
gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
148 |
gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
149 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
150 |
def make_genbitmaptogglebutton_flat(button): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
151 |
button.GetBackgroundBrush = gen_mini_GetBackgroundBrush(button) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
152 |
button.labelDelta = 0 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
153 |
button.SetBezelWidth(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
154 |
button.SetUseFocusIndicator(False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
155 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
156 |
# Patch wx.lib.imageutils so that gray is supported on alpha images |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
157 |
import wx.lib.imageutils |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
158 |
from wx.lib.imageutils import grayOut as old_grayOut |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
159 |
def grayOut(anImage): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
160 |
if anImage.HasAlpha(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
161 |
AlphaData = anImage.GetAlphaData() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
162 |
else : |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
163 |
AlphaData = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
164 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
165 |
old_grayOut(anImage) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
166 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
167 |
if AlphaData is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
168 |
anImage.SetAlphaData(AlphaData) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
169 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
170 |
wx.lib.imageutils.grayOut = grayOut |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
171 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
172 |
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
173 |
def _GetLabelSize(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
174 |
""" used internally """ |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
175 |
w, h = self.GetTextExtent(self.GetLabel()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
176 |
if not self.bmpLabel: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
177 |
return w, h, False # if there isn't a bitmap use the size of the text |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
178 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
179 |
w_bmp = self.bmpLabel.GetWidth()+2 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
180 |
h_bmp = self.bmpLabel.GetHeight()+2 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
181 |
height = h + h_bmp |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
182 |
if w_bmp > w: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
183 |
width = w_bmp |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
184 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
185 |
width = w |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
186 |
return width, height, False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
187 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
188 |
def DrawLabel(self, dc, width, height, dw=0, dy=0): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
189 |
bmp = self.bmpLabel |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
190 |
if bmp != None: # if the bitmap is used |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
191 |
if self.bmpDisabled and not self.IsEnabled(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
192 |
bmp = self.bmpDisabled |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
193 |
if self.bmpFocus and self.hasFocus: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
194 |
bmp = self.bmpFocus |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
195 |
if self.bmpSelected and not self.up: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
196 |
bmp = self.bmpSelected |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
197 |
bw,bh = bmp.GetWidth(), bmp.GetHeight() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
198 |
if not self.up: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
199 |
dw = dy = self.labelDelta |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
200 |
hasMask = bmp.GetMask() != None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
201 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
202 |
bw = bh = 0 # no bitmap -> size is zero |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
203 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
204 |
dc.SetFont(self.GetFont()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
205 |
if self.IsEnabled(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
206 |
dc.SetTextForeground(self.GetForegroundColour()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
207 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
208 |
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
209 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
210 |
label = self.GetLabel() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
211 |
tw, th = dc.GetTextExtent(label) # size of text |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
212 |
if not self.up: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
213 |
dw = dy = self.labelDelta |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
214 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
215 |
pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
216 |
pos_y = (height-bh-th)/2+dy |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
217 |
if bmp !=None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
218 |
dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
219 |
pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
220 |
pos_y += bh + 2 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
221 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
222 |
dc.DrawText(label, pos_x, pos_y) # draw the text |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
223 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
224 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
225 |
class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
226 |
""" Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
227 |
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
|
228 |
def __init__(self, parent, ID, bitmapname, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
229 |
pos = wx.DefaultPosition, size = wx.DefaultSize, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
230 |
style = 0, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
231 |
name = "genstatbmp"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
232 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
233 |
bitmappath = Bpath( "images", bitmapname) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
234 |
if os.path.isfile(bitmappath): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
235 |
bitmap = wx.Bitmap(bitmappath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
236 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
237 |
bitmap = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
238 |
wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, bitmap, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
239 |
pos, size, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
240 |
style, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
241 |
name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
242 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
243 |
def OnPaint(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
244 |
dc = wx.PaintDC(self) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
245 |
colour = self.GetParent().GetBackgroundColour() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
246 |
dc.SetPen(wx.Pen(colour)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
247 |
dc.SetBrush(wx.Brush(colour )) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
248 |
dc.DrawRectangle(0, 0, *dc.GetSizeTuple()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
249 |
if self._bitmap: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
250 |
dc.DrawBitmap(self._bitmap, 0, 0, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
251 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
252 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
253 |
class LogPseudoFile: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
254 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
451 | 255 |
def __init__(self, output, risecall): |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
256 |
self.red_white = wx.TextAttr("RED", "WHITE") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
257 |
self.red_yellow = wx.TextAttr("RED", "YELLOW") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
258 |
self.black_white = wx.TextAttr("BLACK", "WHITE") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
259 |
self.default_style = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
260 |
self.output = output |
451 | 261 |
self.risecall = risecall |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
262 |
# to prevent rapid fire on rising log panel |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
263 |
self.rising_timer = 0 |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
264 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
265 |
def write(self, s, style = None): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
266 |
if style is None : style=self.black_white |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
267 |
self.output.Freeze(); |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
268 |
if self.default_style != style: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
269 |
self.output.SetDefaultStyle(style) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
270 |
self.default_style = style |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
271 |
self.output.AppendText(s) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
272 |
self.output.ScrollLines(s.count('\n')+1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
273 |
self.output.ShowPosition(self.output.GetLastPosition()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
274 |
self.output.Thaw() |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
275 |
newtime = time.time() |
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
276 |
if newtime - self.rising_timer > 1: |
451 | 277 |
self.risecall() |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
278 |
self.rising_timer = newtime |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
279 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
280 |
def write_warning(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
281 |
self.write(s,self.red_white) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
282 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
283 |
def write_error(self, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
284 |
self.write(s,self.red_yellow) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
285 |
|
569
37af7286dd65
LPC program transfer more verbose, test code added in __main__ of LPCBootProto
Edouqrd Tisserant <edouard.tisserant@gmail.com>
parents:
550
diff
changeset
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
290 |
def flush(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
291 |
self.output.SetValue("") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
292 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
293 |
def isatty(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
294 |
return false |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
295 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
296 |
[ID_BEREMIZ, ID_BEREMIZMAINSPLITTER, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
297 |
ID_BEREMIZPLCCONFIG, ID_BEREMIZLOGCONSOLE, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
298 |
ID_BEREMIZINSPECTOR] = [wx.NewId() for _init_ctrls in range(5)] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
299 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
300 |
[ID_BEREMIZRUNMENUBUILD, ID_BEREMIZRUNMENUSIMULATE, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
301 |
ID_BEREMIZRUNMENURUN, ID_BEREMIZRUNMENUSAVELOG, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
302 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
303 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
304 |
class Beremiz(IDEFrame): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
305 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
306 |
def _init_coll_FileMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
307 |
AppendMenu(parent, help='', id=wx.ID_NEW, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
308 |
kind=wx.ITEM_NORMAL, text=_(u'New\tCTRL+N')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
309 |
AppendMenu(parent, help='', id=wx.ID_OPEN, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
310 |
kind=wx.ITEM_NORMAL, text=_(u'Open\tCTRL+O')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
311 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
312 |
kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
313 |
AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
314 |
kind=wx.ITEM_NORMAL, text=_(u'Save as\tCTRL+SHIFT+S')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
315 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
316 |
kind=wx.ITEM_NORMAL, text=_(u'Close Tab\tCTRL+W')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
317 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
318 |
kind=wx.ITEM_NORMAL, text=_(u'Close Project')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
319 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
320 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
321 |
kind=wx.ITEM_NORMAL, text=_(u'Page Setup')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
322 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
323 |
kind=wx.ITEM_NORMAL, text=_(u'Preview')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
324 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
325 |
kind=wx.ITEM_NORMAL, text=_(u'Print')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
326 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
327 |
AppendMenu(parent, help='', id=wx.ID_PROPERTIES, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
328 |
kind=wx.ITEM_NORMAL, text=_(u'Properties')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
329 |
parent.AppendSeparator() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
330 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
331 |
kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
332 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
333 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
334 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
335 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
336 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
337 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
338 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
339 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
340 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
341 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
342 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
343 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
344 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
345 |
def _init_coll_HelpMenu_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
346 |
parent.Append(help='', id=wx.ID_HELP, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
347 |
kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
348 |
parent.Append(help='', id=wx.ID_ABOUT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
349 |
kind=wx.ITEM_NORMAL, text=_(u'About')) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
350 |
self.Bind(wx.EVT_MENU, self.OnBeremizMenu, id=wx.ID_HELP) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
351 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
352 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
353 |
def _init_coll_PLCConfigMainSizer_Items(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
354 |
parent.AddSizer(self.PLCParamsSizer, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
355 |
parent.AddSizer(self.PluginTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
356 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
357 |
def _init_coll_PLCConfigMainSizer_Growables(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
358 |
parent.AddGrowableCol(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
359 |
parent.AddGrowableRow(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
360 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
361 |
def _init_coll_PluginTreeSizer_Growables(self, parent): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
362 |
parent.AddGrowableCol(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
363 |
parent.AddGrowableCol(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
364 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
365 |
def _init_beremiz_sizers(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
366 |
self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
367 |
self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
368 |
#self.PluginTreeSizer = wx.FlexGridSizer(cols=3, hgap=0, rows=0, vgap=2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
369 |
self.PluginTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
370 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
371 |
self._init_coll_PLCConfigMainSizer_Items(self.PLCConfigMainSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
372 |
self._init_coll_PLCConfigMainSizer_Growables(self.PLCConfigMainSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
373 |
self._init_coll_PluginTreeSizer_Growables(self.PluginTreeSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
374 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
375 |
self.PLCConfig.SetSizer(self.PLCConfigMainSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
376 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
377 |
def _init_ctrls(self, prnt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
378 |
IDEFrame._init_ctrls(self, prnt) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
379 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
380 |
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
381 |
accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
382 |
self.SetAcceleratorTable(accel) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
383 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
384 |
self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
385 |
name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
386 |
size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
387 |
self.PLCConfig.SetBackgroundColour(wx.WHITE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
388 |
self.PLCConfig.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
389 |
self.PLCConfig.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
390 |
self.PLCConfig.Bind(wx.EVT_MOUSEWHEEL, self.OnPLCConfigScroll) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
391 |
self.BottomNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
392 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
393 |
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
394 |
name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
395 |
size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
396 |
self.LogConsole.Bind(wx.EVT_LEFT_DCLICK, self.OnLogConsoleDClick) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
397 |
self.BottomNoteBook.AddPage(self.LogConsole, _("Log Console")) |
513
feb2acb04070
Split BottomNoteBook to make LogConsole always visible
laurent
parents:
509
diff
changeset
|
398 |
self.BottomNoteBook.Split(self.BottomNoteBook.GetPageIndex(self.LogConsole), wx.RIGHT) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
399 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
400 |
self._init_beremiz_sizers() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
401 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
402 |
def __init__(self, parent, projectOpen=None, buildpath=None, plugin_root=None, debug=True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
403 |
IDEFrame.__init__(self, parent, debug) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
404 |
self.Config = wx.ConfigBase.Get() |
451 | 405 |
self.Log = LogPseudoFile(self.LogConsole,self.RiseLogConsole) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
406 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
407 |
self.local_runtime = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
408 |
self.runtime_port = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
409 |
self.local_runtime_tmpdir = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
410 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
411 |
self.DisableEvents = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
412 |
# Variable allowing disabling of PLCConfig scroll when Popup shown |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
413 |
self.ScrollingEnabled = True |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
414 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
415 |
self.PluginInfos = {} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
416 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
417 |
if projectOpen is not None and os.path.isdir(projectOpen): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
418 |
self.PluginRoot = PluginsRoot(self, self.Log) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
419 |
self.Controler = self.PluginRoot |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
420 |
result = self.PluginRoot.LoadProject(projectOpen, buildpath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
421 |
if not result: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
422 |
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
423 |
self.RefreshAll() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
424 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
425 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
426 |
self.ShowErrorMessage(result) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
427 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
428 |
self.PluginRoot = plugin_root |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
429 |
self.Controler = plugin_root |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
430 |
if plugin_root is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
431 |
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
432 |
self.RefreshAll() |
490 | 433 |
if self.EnableDebug: |
434 |
self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
|
435 |
||
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
436 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
437 |
# Add beremiz's icon in top left corner of the frame |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
438 |
self.SetIcon(wx.Icon(Bpath( "images", "brz.ico"), wx.BITMAP_TYPE_ICO)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
439 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
440 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
441 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
442 |
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
443 |
|
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
444 |
def RiseLogConsole(self): |
513
feb2acb04070
Split BottomNoteBook to make LogConsole always visible
laurent
parents:
509
diff
changeset
|
445 |
self.BottomNoteBook.SetSelection(self.BottomNoteBook.GetPageIndex(self.LogConsole)) |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
439
diff
changeset
|
446 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
447 |
def RefreshTitle(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
448 |
name = _("Beremiz") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
449 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
450 |
projectname = self.PluginRoot.GetProjectName() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
451 |
if self.PluginRoot.PlugTestModified(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
452 |
projectname = "~%s~" % projectname |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
453 |
self.SetTitle("%s - %s" % (name, projectname)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
454 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
455 |
self.SetTitle(name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
456 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
457 |
def StartLocalRuntime(self, taskbaricon = True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
458 |
if self.local_runtime is None or self.local_runtime.finished: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
459 |
# create temporary directory for runtime working directory |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
460 |
self.local_runtime_tmpdir = tempfile.mkdtemp() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
461 |
# choose an arbitrary random port for runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
462 |
self.runtime_port = int(random.random() * 1000) + 61131 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
463 |
# launch local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
464 |
self.local_runtime = ProcessLogger(self.Log, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
465 |
"\"%s\" \"%s\" -p %s -i localhost %s %s"%(sys.executable, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
466 |
Bpath("Beremiz_service.py"), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
467 |
self.runtime_port, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
468 |
{False : "-x 0", True :"-x 1"}[taskbaricon], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
469 |
self.local_runtime_tmpdir), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
470 |
no_gui=False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
471 |
self.local_runtime.spin(timeout=500, keyword = "working", kill_it = False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
472 |
return self.runtime_port |
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 KillLocalRuntime(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
475 |
if self.local_runtime is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
476 |
# shutdown local runtime |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
477 |
self.local_runtime.kill(gently=False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
478 |
# clear temp dir |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
479 |
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
|
480 |
|
6ff2c1d34640
Modifying LPCBeremiz to launch silently a frame and show or hide it on demand.
laurent
parents:
513
diff
changeset
|
481 |
self.local_runtime = None |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
482 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
483 |
def OnOpenWidgetInspector(self, evt): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
484 |
# Activate the widget inspection tool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
485 |
from wx.lib.inspection import InspectionTool |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
486 |
if not InspectionTool().initialized: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
487 |
InspectionTool().Init() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
488 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
489 |
# Find a widget to be selected in the tree. Use either the |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
490 |
# one under the cursor, if any, or this frame. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
491 |
wnd = wx.FindWindowAtPointer() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
492 |
if not wnd: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
493 |
wnd = self |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
494 |
InspectionTool().Show(wnd, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
495 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
496 |
def OnLogConsoleDClick(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
497 |
wx.CallAfter(self.SearchLineForError) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
498 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
499 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
500 |
def SearchLineForError(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
501 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
502 |
text = self.LogConsole.GetRange(0, self.LogConsole.GetInsertionPoint()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
503 |
line = self.LogConsole.GetLineText(len(text.splitlines()) - 1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
504 |
result = MATIEC_ERROR_MODEL.match(line) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
505 |
if result is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
506 |
first_line, first_column, last_line, last_column, error = result.groups() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
507 |
infos = self.PluginRoot.ShowError(self.Log, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
508 |
(int(first_line), int(first_column)), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
509 |
(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
|
510 |
|
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
511 |
## 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
|
512 |
# @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
|
513 |
def CheckSaveBeforeClosing(self, title=_("Close Project")): |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
514 |
if self.PluginRoot.ProjectTestModified(): |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
515 |
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
|
516 |
_("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
|
517 |
title, |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
518 |
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
|
519 |
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
|
520 |
dialog.Destroy() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
521 |
if answer == wx.ID_YES: |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
522 |
self.PluginRoot.SaveProject() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
523 |
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
|
524 |
return False |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
525 |
return True |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
526 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
527 |
def OnCloseFrame(self, event): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
528 |
if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")): |
495
03e17cd5bde7
Bug when closing Beremiz without a project opened fixed
laurent
parents:
490
diff
changeset
|
529 |
if self.PluginRoot is not None: |
03e17cd5bde7
Bug when closing Beremiz without a project opened fixed
laurent
parents:
490
diff
changeset
|
530 |
self.PluginRoot.KillDebugThread() |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
531 |
self.KillLocalRuntime() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
532 |
event.Skip() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
533 |
else: |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
534 |
event.Veto() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
535 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
536 |
def OnMoveWindow(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
537 |
self.GetBestSize() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
538 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
539 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
540 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
541 |
def EnableScrolling(self, enable): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
542 |
self.ScrollingEnabled = enable |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
543 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
544 |
def OnPLCConfigScroll(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
545 |
if self.ScrollingEnabled: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
546 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
547 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
548 |
def OnPanelLeftDown(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
549 |
focused = self.FindFocus() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
550 |
if isinstance(focused, TextCtrlAutoComplete.TextCtrlAutoComplete): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
551 |
focused.DismissListBox() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
552 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
553 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
554 |
def RefreshFileMenu(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
555 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
556 |
selected = self.TabsOpened.GetSelection() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
557 |
if selected >= 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
558 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
559 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
560 |
graphic_viewer = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
561 |
if self.TabsOpened.GetPageCount() > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
562 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
563 |
if graphic_viewer: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
564 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
565 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
566 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
567 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
568 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
569 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
570 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
571 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
572 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
573 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
499
15a63eba885f
Enable Save Menu item according to project modification state
laurent
parents:
495
diff
changeset
|
574 |
self.FileMenu.Enable(wx.ID_SAVE, self.PluginRoot.PlugTestModified()) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
575 |
self.FileMenu.Enable(wx.ID_SAVEAS, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
576 |
self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
577 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
578 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
579 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
580 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
581 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
582 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
583 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
584 |
self.FileMenu.Enable(wx.ID_SAVEAS, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
585 |
self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
586 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
587 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
588 |
def RefreshScrollBars(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
589 |
xstart, ystart = self.PLCConfig.GetViewStart() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
590 |
window_size = self.PLCConfig.GetClientSize() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
591 |
sizer = self.PLCConfig.GetSizer() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
592 |
if sizer: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
593 |
maxx, maxy = sizer.GetMinSize() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
594 |
self.PLCConfig.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
595 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
596 |
max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
597 |
max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
598 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
599 |
def RefreshPLCParams(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
600 |
self.Freeze() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
601 |
self.ClearSizer(self.PLCParamsSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
602 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
603 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
604 |
plcwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
605 |
if self.PluginRoot.PlugTestModified(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
606 |
bkgdclr = CHANGED_TITLE_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
607 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
608 |
bkgdclr = TITLE_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
609 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
610 |
if self.PluginRoot not in self.PluginInfos: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
611 |
self.PluginInfos[self.PluginRoot] = {"right_visible" : False} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
612 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
613 |
plcwindow.SetBackgroundColour(TITLE_COLOUR) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
614 |
plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
615 |
self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
616 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
617 |
plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
618 |
plcwindow.SetSizer(plcwindowsizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
619 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
620 |
st = wx.StaticText(plcwindow, -1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
621 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
622 |
st.SetLabel(self.PluginRoot.GetProjectName()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
623 |
plcwindowsizer.AddWindow(st, 0, border=5, flag=wx.ALL|wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
624 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
625 |
addbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
626 |
addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
627 |
name='AddPluginButton', parent=plcwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
628 |
size=wx.Size(16, 16), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
629 |
addbutton.SetToolTipString(_("Add a sub plugin")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
630 |
addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(self.PluginRoot), id=addbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
631 |
plcwindowsizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
632 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
633 |
plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
634 |
plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
635 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
636 |
plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
637 |
plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
638 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
639 |
msizer = self.GenerateMethodButtonSizer(self.PluginRoot, plcwindow, not self.PluginInfos[self.PluginRoot]["right_visible"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
640 |
plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
641 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
642 |
paramswindow = wx.Panel(plcwindow, -1, size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
643 |
paramswindow.SetBackgroundColour(TITLE_COLOUR) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
644 |
paramswindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
645 |
plcwindowbuttonsizer.AddWindow(paramswindow, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
646 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
647 |
psizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
648 |
paramswindow.SetSizer(psizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
649 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
650 |
plugin_infos = self.PluginRoot.GetParamsAttributes() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
651 |
self.RefreshSizerElement(paramswindow, psizer, self.PluginRoot, plugin_infos, None, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
652 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
653 |
if not self.PluginInfos[self.PluginRoot]["right_visible"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
654 |
paramswindow.Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
655 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
656 |
minimizebutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
657 |
minimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=minimizebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Maximize.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
658 |
name='MinimizeButton', parent=plcwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
659 |
size=wx.Size(24, 24), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
660 |
make_genbitmaptogglebutton_flat(minimizebutton) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
661 |
minimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png'))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
662 |
minimizebutton.SetToggle(self.PluginInfos[self.PluginRoot]["right_visible"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
663 |
plcwindowbuttonsizer.AddWindow(minimizebutton, 0, border=5, flag=wx.ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
664 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
665 |
def togglewindow(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
666 |
if minimizebutton.GetToggle(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
667 |
paramswindow.Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
668 |
msizer.SetCols(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
669 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
670 |
paramswindow.Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
671 |
msizer.SetCols(len(self.PluginRoot.PluginMethods)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
672 |
self.PluginInfos[self.PluginRoot]["right_visible"] = minimizebutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
673 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
674 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
675 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
676 |
minimizebutton.Bind(wx.EVT_BUTTON, togglewindow, id=minimizebutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
677 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
678 |
self.PluginInfos[self.PluginRoot]["main"] = plcwindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
679 |
self.PluginInfos[self.PluginRoot]["params"] = paramswindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
680 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
681 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
682 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
683 |
self.Thaw() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
684 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
685 |
def GenerateMethodButtonSizer(self, plugin, parent, horizontal = True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
686 |
normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
687 |
mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
688 |
if horizontal: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
689 |
msizer = wx.FlexGridSizer(cols=len(plugin.PluginMethods)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
690 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
691 |
msizer = wx.FlexGridSizer(cols=1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
692 |
for plugin_method in plugin.PluginMethods: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
693 |
if "method" in plugin_method and plugin_method.get("shown",True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
694 |
id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
695 |
label = plugin_method["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
696 |
button = GenBitmapTextButton(id=id, parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
697 |
bitmap=wx.Bitmap(Bpath( "%s.png"%plugin_method.get("bitmap", os.path.join("images", "Unknown")))), label=label, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
698 |
name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
699 |
button.SetFont(normal_bt_font) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
700 |
button.SetToolTipString(plugin_method["tooltip"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
701 |
button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
702 |
# a fancy underline on mouseover |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
703 |
def setFontStyle(b, s): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
704 |
def fn(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
705 |
b.SetFont(s) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
706 |
b.Refresh() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
707 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
708 |
return fn |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
709 |
button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
710 |
button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
711 |
#hack to force size to mini |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
712 |
if not plugin_method.get("enabled",True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
713 |
button.Disable() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
714 |
msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
715 |
return msizer |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
716 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
717 |
def RefreshPluginTree(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
718 |
self.Freeze() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
719 |
self.ClearSizer(self.PluginTreeSizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
720 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
721 |
for child in self.PluginRoot.IECSortedChilds(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
722 |
self.GenerateTreeBranch(child) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
723 |
if not self.PluginInfos[child]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
724 |
self.CollapsePlugin(child) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
725 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
726 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
727 |
self.Thaw() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
728 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
729 |
def SetPluginParamsAttribute(self, plugin, *args, **kwargs): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
730 |
res, StructChanged = plugin.SetParamsAttribute(*args, **kwargs) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
731 |
if StructChanged: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
732 |
wx.CallAfter(self.RefreshPluginTree) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
733 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
734 |
if plugin == self.PluginRoot: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
735 |
bkgdclr = CHANGED_TITLE_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
736 |
items = ["main", "params"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
737 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
738 |
bkgdclr = CHANGED_WINDOW_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
739 |
items = ["left", "right", "params"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
740 |
for i in items: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
741 |
self.PluginInfos[plugin][i].SetBackgroundColour(bkgdclr) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
742 |
self.PluginInfos[plugin][i].Refresh() |
505
7f38c773427b
Adding support for refreshing FileMenu after plugin tree modification
laurent
parents:
499
diff
changeset
|
743 |
self.RefreshFileMenu() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
744 |
return res |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
745 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
746 |
def ExpandPlugin(self, plugin, force = False): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
747 |
for child in self.PluginInfos[plugin]["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
748 |
self.PluginInfos[child]["left"].Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
749 |
self.PluginInfos[child]["right"].Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
750 |
if force or not self.PluginInfos[child]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
751 |
self.ExpandPlugin(child, force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
752 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
753 |
self.PluginInfos[child]["expanded"] = True |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
754 |
locations_infos = self.PluginInfos[plugin].get("locations_infos", None) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
755 |
if locations_infos is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
756 |
if force or locations_infos["root"]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
757 |
self.ExpandLocation(locations_infos, "root", force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
758 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
759 |
locations_infos["root"]["expanded"] = True |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
760 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
761 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
762 |
def CollapsePlugin(self, plugin, force = False): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
763 |
for child in self.PluginInfos[plugin]["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
764 |
self.PluginInfos[child]["left"].Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
765 |
self.PluginInfos[child]["right"].Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
766 |
self.CollapsePlugin(child, force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
767 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
768 |
self.PluginInfos[child]["expanded"] = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
769 |
locations_infos = self.PluginInfos[plugin].get("locations_infos", None) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
770 |
if locations_infos is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
771 |
self.CollapseLocation(locations_infos, "root", force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
772 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
773 |
locations_infos["root"]["expanded"] = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
774 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
775 |
def ExpandLocation(self, locations_infos, group, force = False): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
776 |
for child in locations_infos[group]["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
777 |
locations_infos[child]["left"].Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
778 |
locations_infos[child]["right"].Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
779 |
if force or locations_infos[child]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
780 |
self.ExpandLocation(locations_infos, child, force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
781 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
782 |
locations_infos[child]["expanded"] = True |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
783 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
784 |
def CollapseLocation(self, locations_infos, group, force = False): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
785 |
for child in locations_infos[group]["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
786 |
locations_infos[child]["left"].Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
787 |
locations_infos[child]["right"].Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
788 |
self.CollapseLocation(locations_infos, child, force) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
789 |
if force: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
790 |
locations_infos[child]["expanded"] = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
791 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
792 |
def GenerateTreeBranch(self, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
793 |
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
794 |
if plugin.PlugTestModified(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
795 |
bkgdclr=CHANGED_WINDOW_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
796 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
797 |
bkgdclr=WINDOW_COLOUR |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
798 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
799 |
leftwindow.SetBackgroundColour(bkgdclr) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
800 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
801 |
if not self.PluginInfos.has_key(plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
802 |
self.PluginInfos[plugin] = {"expanded" : False, "right_visible" : False} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
803 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
804 |
self.PluginInfos[plugin]["children"] = plugin.IECSortedChilds() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
805 |
plugin_locations = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
806 |
if len(self.PluginInfos[plugin]["children"]) == 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
807 |
plugin_locations = plugin.GetVariableLocationTree()["children"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
808 |
if not self.PluginInfos[plugin].has_key("locations_infos"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
809 |
self.PluginInfos[plugin]["locations_infos"] = {"root": {"expanded" : False}} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
810 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
811 |
self.PluginInfos[plugin]["locations_infos"]["root"]["children"] = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
812 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
813 |
self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
814 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
815 |
leftwindowsizer = wx.FlexGridSizer(cols=1, rows=2) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
816 |
leftwindowsizer.AddGrowableCol(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
817 |
leftwindow.SetSizer(leftwindowsizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
818 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
819 |
leftbuttonmainsizer = wx.FlexGridSizer(cols=3, rows=1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
820 |
leftbuttonmainsizer.AddGrowableCol(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
821 |
leftwindowsizer.AddSizer(leftbuttonmainsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT) #|wx.TOP |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
822 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
823 |
leftbuttonsizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
824 |
leftbuttonmainsizer.AddSizer(leftbuttonsizer, 0, border=5, flag=wx.GROW|wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
825 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
826 |
leftsizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
827 |
leftbuttonsizer.AddSizer(leftsizer, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
828 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
829 |
rolesizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
830 |
leftsizer.AddSizer(rolesizer, 0, border=0, flag=wx.GROW|wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
831 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
832 |
enablebutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
833 |
enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
834 |
name='EnableButton', parent=leftwindow, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
835 |
enablebutton.SetToolTipString(_("Enable/Disable this plugin")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
836 |
make_genbitmaptogglebutton_flat(enablebutton) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
837 |
enablebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Enabled.png'))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
838 |
enablebutton.SetToggle(plugin.MandatoryParams[1].getEnabled()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
839 |
def toggleenablebutton(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
840 |
res = self.SetPluginParamsAttribute(plugin, "BaseParams.Enabled", enablebutton.GetToggle()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
841 |
enablebutton.SetToggle(res) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
842 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
843 |
enablebutton.Bind(wx.EVT_BUTTON, toggleenablebutton, id=enablebutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
844 |
rolesizer.AddWindow(enablebutton, 0, border=0, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
845 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
846 |
roletext = wx.StaticText(leftwindow, -1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
847 |
roletext.SetLabel(plugin.PlugHelp) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
848 |
rolesizer.AddWindow(roletext, 0, border=5, flag=wx.RIGHT|wx.ALIGN_LEFT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
849 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
850 |
plugin_IECChannel = plugin.BaseParams.getIEC_Channel() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
851 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
852 |
iecsizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
853 |
leftsizer.AddSizer(iecsizer, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
854 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
855 |
st = wx.StaticText(leftwindow, -1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
856 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
857 |
st.SetLabel(plugin.GetFullIEC_Channel()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
858 |
iecsizer.AddWindow(st, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
859 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
860 |
updownsizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
861 |
iecsizer.AddSizer(updownsizer, 0, border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
862 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
863 |
if plugin_IECChannel > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
864 |
ieccdownbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
865 |
ieccdownbutton = wx.lib.buttons.GenBitmapButton(id=ieccdownbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'IECCDown.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
866 |
name='IECCDownButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
867 |
size=wx.Size(16, 16), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
868 |
ieccdownbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel - 1), id=ieccdownbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
869 |
updownsizer.AddWindow(ieccdownbutton, 0, border=0, flag=wx.ALIGN_LEFT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
870 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
871 |
ieccupbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
872 |
ieccupbutton = wx.lib.buttons.GenBitmapTextButton(id=ieccupbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'IECCUp.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
873 |
name='IECCUpButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
874 |
size=wx.Size(16, 16), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
875 |
ieccupbutton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(plugin, plugin_IECChannel + 1), id=ieccupbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
876 |
updownsizer.AddWindow(ieccupbutton, 0, border=0, flag=wx.ALIGN_LEFT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
877 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
878 |
adddeletesizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
879 |
iecsizer.AddSizer(adddeletesizer, 0, border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
880 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
881 |
deletebutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
882 |
deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Delete.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
883 |
name='DeletePluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
884 |
size=wx.Size(16, 16), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
885 |
deletebutton.SetToolTipString(_("Delete this plugin")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
886 |
deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
887 |
adddeletesizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
888 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
889 |
if len(plugin.PlugChildsTypes) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
890 |
addbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
891 |
addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
892 |
name='AddPluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
893 |
size=wx.Size(16, 16), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
894 |
addbutton.SetToolTipString(_("Add a sub plugin")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
895 |
addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(plugin), id=addbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
896 |
adddeletesizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
897 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
898 |
expandbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
899 |
expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
900 |
name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
901 |
size=wx.Size(13, 13), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
902 |
expandbutton.labelDelta = 0 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
903 |
expandbutton.SetBezelWidth(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
904 |
expandbutton.SetUseFocusIndicator(False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
905 |
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
906 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
907 |
if len(self.PluginInfos[plugin]["children"]) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
908 |
expandbutton.SetToggle(self.PluginInfos[plugin]["expanded"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
909 |
def togglebutton(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
910 |
if expandbutton.GetToggle(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
911 |
self.ExpandPlugin(plugin) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
912 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
913 |
self.CollapsePlugin(plugin) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
914 |
self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
915 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
916 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
917 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
918 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
919 |
elif len(plugin_locations) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
920 |
locations_infos = self.PluginInfos[plugin]["locations_infos"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
921 |
expandbutton.SetToggle(locations_infos["root"]["expanded"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
922 |
def togglebutton(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
923 |
if expandbutton.GetToggle(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
924 |
self.ExpandLocation(locations_infos, "root") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
925 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
926 |
self.CollapseLocation(locations_infos, "root") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
927 |
self.PluginInfos[plugin]["expanded"] = expandbutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
928 |
locations_infos["root"]["expanded"] = expandbutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
929 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
930 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
931 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
932 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
933 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
934 |
expandbutton.Enable(False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
935 |
iecsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
936 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
937 |
tc_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
938 |
tc = wx.TextCtrl(leftwindow, tc_id, size=wx.Size(150, 25), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
939 |
tc.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
940 |
tc.ChangeValue(plugin.MandatoryParams[1].getName()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
941 |
tc.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(tc, plugin, "BaseParams.Name"), id=tc_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
942 |
iecsizer.AddWindow(tc, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
943 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
944 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
945 |
rightwindow.SetBackgroundColour(bkgdclr) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
946 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
947 |
self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
948 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
949 |
rightwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
950 |
rightwindow.SetSizer(rightwindowmainsizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
951 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
952 |
rightwindowsizer = wx.FlexGridSizer(cols=2, rows=1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
953 |
rightwindowsizer.AddGrowableCol(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
954 |
rightwindowsizer.AddGrowableRow(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
955 |
rightwindowmainsizer.AddSizer(rightwindowsizer, 0, border=8, flag=wx.TOP|wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
956 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
957 |
msizer = self.GenerateMethodButtonSizer(plugin, rightwindow, not self.PluginInfos[plugin]["right_visible"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
958 |
rightwindowsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
959 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
960 |
rightparamssizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
961 |
rightwindowsizer.AddSizer(rightparamssizer, 0, border=0, flag=wx.ALIGN_RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
962 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
963 |
paramswindow = wx.Panel(rightwindow, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
964 |
paramswindow.SetBackgroundColour(bkgdclr) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
965 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
966 |
psizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
967 |
paramswindow.SetSizer(psizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
968 |
self.PluginInfos[plugin]["params"] = paramswindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
969 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
970 |
rightparamssizer.AddWindow(paramswindow, 0, border=5, flag=wx.ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
971 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
972 |
plugin_infos = plugin.GetParamsAttributes() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
973 |
self.RefreshSizerElement(paramswindow, psizer, plugin, plugin_infos, None, False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
974 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
975 |
if not self.PluginInfos[plugin]["right_visible"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
976 |
paramswindow.Hide() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
977 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
978 |
rightminimizebutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
979 |
rightminimizebutton = wx.lib.buttons.GenBitmapToggleButton(id=rightminimizebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Maximize.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
980 |
name='MinimizeButton', parent=rightwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
981 |
size=wx.Size(24, 24), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
982 |
make_genbitmaptogglebutton_flat(rightminimizebutton) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
983 |
rightminimizebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Minimize.png'))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
984 |
rightminimizebutton.SetToggle(self.PluginInfos[plugin]["right_visible"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
985 |
rightparamssizer.AddWindow(rightminimizebutton, 0, border=5, flag=wx.ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
986 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
987 |
def togglerightwindow(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
988 |
if rightminimizebutton.GetToggle(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
989 |
rightparamssizer.Show(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
990 |
msizer.SetCols(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
991 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
992 |
rightparamssizer.Hide(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
993 |
msizer.SetCols(len(plugin.PluginMethods)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
994 |
self.PluginInfos[plugin]["right_visible"] = rightminimizebutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
995 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
996 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
997 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
998 |
rightminimizebutton.Bind(wx.EVT_BUTTON, togglerightwindow, id=rightminimizebutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
999 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1000 |
self.PluginInfos[plugin]["left"] = leftwindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1001 |
self.PluginInfos[plugin]["right"] = rightwindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1002 |
for child in self.PluginInfos[plugin]["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1003 |
self.GenerateTreeBranch(child) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1004 |
if not self.PluginInfos[child]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1005 |
self.CollapsePlugin(child) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1006 |
if len(plugin_locations) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1007 |
locations_infos = self.PluginInfos[plugin]["locations_infos"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1008 |
for location in plugin_locations: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1009 |
locations_infos["root"]["children"].append("root.%s" % location["name"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1010 |
self.GenerateLocationTreeBranch(locations_infos, "root", location) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1011 |
if not locations_infos["root"]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1012 |
self.CollapseLocation(locations_infos, "root") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1013 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1014 |
LOCATION_BITMAP = {LOCATION_PLUGIN: "CONFIGURATION", |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1015 |
LOCATION_MODULE: "RESOURCE", |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1016 |
LOCATION_GROUP: "PROGRAM", |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1017 |
LOCATION_VAR_INPUT: "VAR_INPUT", |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1018 |
LOCATION_VAR_OUTPUT: "VAR_OUTPUT", |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1019 |
LOCATION_VAR_MEMORY: "VAR_LOCAL"} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1020 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1021 |
def GenerateLocationTreeBranch(self, locations_infos, parent, location): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1022 |
leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1023 |
self.PluginTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1024 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1025 |
leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1026 |
leftwindow.SetSizer(leftwindowsizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1027 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1028 |
rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1029 |
self.PluginTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1030 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1031 |
location_name = "%s.%s" % (parent, location["name"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1032 |
if not locations_infos.has_key(location_name): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1033 |
locations_infos[location_name] = {"expanded" : False} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1034 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1035 |
if location["type"] in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP]: |
439
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1036 |
if location["type"] == LOCATION_GROUP: |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1037 |
leftwindow.SetBackgroundColour(wx.WHITE) |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1038 |
rightwindow.SetBackgroundColour(wx.WHITE) |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1039 |
else: |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1040 |
leftwindow.SetBackgroundColour(WINDOW_COLOUR) |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1041 |
rightwindow.SetBackgroundColour(WINDOW_COLOUR) |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1042 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1043 |
st = wx.StaticText(leftwindow, -1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1044 |
st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1045 |
st.SetLabel(location["location"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1046 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1047 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1048 |
expandbutton_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1049 |
expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1050 |
name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1051 |
size=wx.Size(13, 13), style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1052 |
expandbutton.labelDelta = 0 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1053 |
expandbutton.SetBezelWidth(0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1054 |
expandbutton.SetUseFocusIndicator(False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1055 |
expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png'))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1056 |
expandbutton.SetToggle(locations_infos[location_name]["expanded"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1057 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1058 |
if len(location["children"]) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1059 |
def togglebutton(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1060 |
if expandbutton.GetToggle(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1061 |
self.ExpandLocation(locations_infos, location_name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1062 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1063 |
self.CollapseLocation(locations_infos, location_name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1064 |
locations_infos[location_name]["expanded"] = expandbutton.GetToggle() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1065 |
self.PLCConfigMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1066 |
self.RefreshScrollBars() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1067 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1068 |
expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1069 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1070 |
expandbutton.Enable(False) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1071 |
leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1072 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1073 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1074 |
leftwindow.SetBackgroundColour(wx.WHITE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1075 |
rightwindow.SetBackgroundColour(wx.WHITE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1076 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1077 |
leftwindowsizer.Add(wx.Size(20, 16), 0) |
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
539
diff
changeset
|
1078 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1079 |
sb = wx.StaticBitmap(leftwindow, -1) |
439
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1080 |
icon = location.get("icon") |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1081 |
if icon is None: |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1082 |
icon = os.path.join(base_folder, "plcopeneditor", 'Images', '%s.png' % self.LOCATION_BITMAP[location["type"]]) |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1083 |
sb.SetBitmap(wx.Bitmap(icon)) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1084 |
leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1085 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1086 |
st_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1087 |
st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1088 |
label = location["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1089 |
if location["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1090 |
label += " (%s)" % location["location"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1091 |
infos = location.copy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1092 |
infos.pop("children") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1093 |
st.SetFont(wx.Font(faces["size"] * 0.5, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])) |
550
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
539
diff
changeset
|
1094 |
leftcallback = self.GenerateLocationLeftDownFunction(infos) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
539
diff
changeset
|
1095 |
st.Bind(wx.EVT_LEFT_DOWN, leftcallback) |
b03f586547c9
Adding support for initialize all LPC module variables even if not used
laurent
parents:
539
diff
changeset
|
1096 |
sb.Bind(wx.EVT_LEFT_DOWN, leftcallback) |
439
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1097 |
elif location["type"] == LOCATION_GROUP: |
aa7266534461
Adding support for defining user icons on VariableLocationTree
laurent
parents:
434
diff
changeset
|
1098 |
st.SetFont(wx.Font(faces["size"] * 0.6, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1099 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1100 |
st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1101 |
st.SetLabel(label) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1102 |
leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1103 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1104 |
locations_infos[location_name]["left"] = leftwindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1105 |
locations_infos[location_name]["right"] = rightwindow |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1106 |
locations_infos[location_name]["children"] = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1107 |
for child in location["children"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1108 |
child_name = "%s.%s" % (location_name, child["name"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1109 |
locations_infos[location_name]["children"].append(child_name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1110 |
self.GenerateLocationTreeBranch(locations_infos, location_name, child) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1111 |
if not locations_infos[location_name]["expanded"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1112 |
self.CollapseLocation(locations_infos, location_name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1113 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1114 |
def GenerateLocationLeftDownFunction(self, infos): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1115 |
def OnLocationLeftDownFunction(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1116 |
data = wx.TextDataObject(str((infos["location"], "location", infos["IEC_type"], infos["name"], infos["description"]))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1117 |
dragSource = wx.DropSource(self) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1118 |
dragSource.SetData(data) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1119 |
dragSource.DoDragDrop() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1120 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1121 |
return OnLocationLeftDownFunction |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1122 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1123 |
def RefreshAll(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1124 |
self.RefreshPLCParams() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1125 |
self.RefreshPluginTree() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1126 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1127 |
def GetItemChannelChangedFunction(self, plugin, value): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1128 |
def OnPluginTreeItemChannelChanged(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1129 |
res = self.SetPluginParamsAttribute(plugin, "BaseParams.IEC_Channel", value) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1130 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1131 |
return OnPluginTreeItemChannelChanged |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1132 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1133 |
def _GetAddPluginFunction(self, name, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1134 |
def OnPluginMenu(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1135 |
wx.CallAfter(self.AddPlugin, name, plugin) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1136 |
return OnPluginMenu |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1137 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1138 |
def Gen_AddPluginMenu(self, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1139 |
def AddPluginMenu(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1140 |
main_menu = wx.Menu(title='') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1141 |
if len(plugin.PlugChildsTypes) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1142 |
for name, XSDClass, help in plugin.PlugChildsTypes: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1143 |
new_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1144 |
main_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=_("Append ")+help) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1145 |
self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1146 |
self.PopupMenuXY(main_menu) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1147 |
return AddPluginMenu |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1148 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1149 |
def GetButtonCallBackFunction(self, plugin, method): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1150 |
""" Generate the callbackfunc for a given plugin method""" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1151 |
def OnButtonClick(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1152 |
# Disable button to prevent re-entrant call |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1153 |
event.GetEventObject().Disable() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1154 |
# Call |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1155 |
getattr(plugin,method)() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1156 |
# Re-enable button |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1157 |
event.GetEventObject().Enable() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1158 |
# Trigger refresh on Idle |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1159 |
wx.CallAfter(self.RefreshAll) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1160 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1161 |
return OnButtonClick |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1162 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1163 |
def GetChoiceCallBackFunction(self, choicectrl, plugin, path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1164 |
def OnChoiceChanged(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1165 |
res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1166 |
choicectrl.SetStringSelection(res) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1167 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1168 |
return OnChoiceChanged |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1169 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1170 |
def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, plugin, path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1171 |
def OnChoiceContentChanged(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1172 |
res = self.SetPluginParamsAttribute(plugin, path, choicectrl.GetStringSelection()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1173 |
if wx.VERSION < (2, 8, 0): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1174 |
self.ParamsPanel.Freeze() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1175 |
choicectrl.SetStringSelection(res) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1176 |
infos = self.PluginRoot.GetParamsAttributes(path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1177 |
staticbox = staticboxsizer.GetStaticBox() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1178 |
staticbox.SetLabel("%(name)s - %(value)s"%infos) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1179 |
self.RefreshSizerElement(self.ParamsPanel, staticboxsizer, infos["children"], "%s.%s"%(path, infos["name"]), selected=selected) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1180 |
self.ParamsPanelMainSizer.Layout() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1181 |
self.ParamsPanel.Thaw() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1182 |
self.ParamsPanel.Refresh() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1183 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1184 |
wx.CallAfter(self.RefreshAll) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1185 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1186 |
return OnChoiceContentChanged |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1187 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1188 |
def GetTextCtrlCallBackFunction(self, textctrl, plugin, path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1189 |
def OnTextCtrlChanged(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1190 |
res = self.SetPluginParamsAttribute(plugin, path, textctrl.GetValue()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1191 |
if res != textctrl.GetValue(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1192 |
textctrl.ChangeValue(res) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1193 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1194 |
return OnTextCtrlChanged |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1195 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1196 |
def GetCheckBoxCallBackFunction(self, chkbx, plugin, path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1197 |
def OnCheckBoxChanged(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1198 |
res = self.SetPluginParamsAttribute(plugin, path, chkbx.IsChecked()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1199 |
chkbx.SetValue(res) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1200 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1201 |
return OnCheckBoxChanged |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1202 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1203 |
def ClearSizer(self, sizer): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1204 |
staticboxes = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1205 |
for item in sizer.GetChildren(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1206 |
if item.IsSizer(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1207 |
item_sizer = item.GetSizer() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1208 |
self.ClearSizer(item_sizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1209 |
if isinstance(item_sizer, wx.StaticBoxSizer): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1210 |
staticboxes.append(item_sizer.GetStaticBox()) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1211 |
sizer.Clear(True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1212 |
for staticbox in staticboxes: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1213 |
staticbox.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1214 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1215 |
def RefreshSizerElement(self, parent, sizer, plugin, elements, path, clean = True): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1216 |
if clean: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1217 |
if wx.VERSION < (2, 8, 0): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1218 |
self.ClearSizer(sizer) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1219 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1220 |
sizer.Clear(True) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1221 |
first = True |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1222 |
for element_infos in elements: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1223 |
if path: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1224 |
element_path = "%s.%s"%(path, element_infos["name"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1225 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1226 |
element_path = element_infos["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1227 |
if element_infos["type"] == "element": |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1228 |
label = element_infos["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1229 |
staticbox = wx.StaticBox(id=-1, label=_(label), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1230 |
name='%s_staticbox'%element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1231 |
pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1232 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1233 |
if first: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1234 |
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1235 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1236 |
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1237 |
self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1238 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1239 |
boxsizer = wx.FlexGridSizer(cols=3, rows=1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1240 |
boxsizer.AddGrowableCol(1) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1241 |
if first: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1242 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1243 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1244 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1245 |
staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1246 |
name="%s_bitmap"%element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1247 |
pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1248 |
boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1249 |
label = element_infos["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1250 |
statictext = wx.StaticText(id=-1, label="%s:"%_(label), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1251 |
name="%s_label"%element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1252 |
pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1253 |
boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1254 |
id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1255 |
if isinstance(element_infos["type"], types.ListType): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1256 |
combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1257 |
pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1258 |
boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1259 |
if element_infos["use"] == "optional": |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1260 |
combobox.Append("") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1261 |
if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1262 |
for choice, xsdclass in element_infos["type"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1263 |
combobox.Append(choice) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1264 |
name = element_infos["name"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1265 |
value = element_infos["value"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1266 |
staticbox = wx.StaticBox(id=-1, label="%s - %s"%(_(name), _(value)), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1267 |
name='%s_staticbox'%element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1268 |
pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1269 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1270 |
sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1271 |
self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1272 |
callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, plugin, element_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1273 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1274 |
for choice in element_infos["type"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1275 |
combobox.Append(choice) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1276 |
callback = self.GetChoiceCallBackFunction(combobox, plugin, element_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1277 |
if element_infos["value"] is None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1278 |
combobox.SetStringSelection("") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1279 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1280 |
combobox.SetStringSelection(element_infos["value"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1281 |
combobox.Bind(wx.EVT_COMBOBOX, callback, id=id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1282 |
elif isinstance(element_infos["type"], types.DictType): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1283 |
scmin = -(2**31) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1284 |
scmax = 2**31-1 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1285 |
if "min" in element_infos["type"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1286 |
scmin = element_infos["type"]["min"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1287 |
if "max" in element_infos["type"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1288 |
scmax = element_infos["type"]["max"] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1289 |
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1290 |
pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1291 |
spinctrl.SetRange(scmin,scmax) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1292 |
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1293 |
spinctrl.SetValue(element_infos["value"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1294 |
spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1295 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1296 |
if element_infos["type"] == "boolean": |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1297 |
checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1298 |
pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1299 |
boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1300 |
checkbox.SetValue(element_infos["value"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1301 |
checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1302 |
elif element_infos["type"] in ["unsignedLong", "long","integer"]: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1303 |
if element_infos["type"].startswith("unsigned"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1304 |
scmin = 0 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1305 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1306 |
scmin = -(2**31) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1307 |
scmax = 2**31-1 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1308 |
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1309 |
pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1310 |
spinctrl.SetRange(scmin, scmax) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1311 |
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1312 |
spinctrl.SetValue(element_infos["value"]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1313 |
spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1314 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1315 |
choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""])))) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1316 |
textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1317 |
name=element_infos["name"], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1318 |
parent=parent, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1319 |
appframe=self, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1320 |
choices=choices, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1321 |
element_path=element_path, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1322 |
pos=wx.Point(0, 0), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1323 |
size=wx.Size(300, 25), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1324 |
style=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1325 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1326 |
boxsizer.AddWindow(textctrl, 0, border=0, flag=0) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1327 |
textctrl.ChangeValue(str(element_infos["value"])) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1328 |
textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1329 |
first = False |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1330 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1331 |
def ResetView(self): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1332 |
IDEFrame.ResetView(self) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1333 |
self.PluginInfos = {} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1334 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1335 |
self.PluginRoot.CloseProject() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1336 |
self.PluginRoot = None |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1337 |
self.Log.flush() |
490 | 1338 |
if self.EnableDebug: |
1339 |
self.DebugVariablePanel.SetDataProducer(None) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1340 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1341 |
def OnNewProjectMenu(self, event): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1342 |
if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1343 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1344 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1345 |
if not self.Config.HasEntry("lastopenedfolder"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1346 |
defaultpath = os.path.expanduser("~") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1347 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1348 |
defaultpath = self.Config.Read("lastopenedfolder") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1349 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1350 |
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1351 |
if dialog.ShowModal() == wx.ID_OK: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1352 |
projectpath = dialog.GetPath() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1353 |
dialog.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1354 |
self.Config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1355 |
self.Config.Flush() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1356 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1357 |
self.PluginRoot = PluginsRoot(self, self.Log) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1358 |
self.Controler = self.PluginRoot |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1359 |
result = self.PluginRoot.NewProject(projectpath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1360 |
if not result: |
490 | 1361 |
if self.EnableDebug: |
1362 |
self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1363 |
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1364 |
self.RefreshAll() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1365 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1366 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1367 |
self.ShowErrorMessage(result) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1368 |
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1369 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1370 |
def OnOpenProjectMenu(self, event): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1371 |
if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1372 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1373 |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1374 |
if not self.Config.HasEntry("lastopenedfolder"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1375 |
defaultpath = os.path.expanduser("~") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1376 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1377 |
defaultpath = self.Config.Read("lastopenedfolder") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1378 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1379 |
dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1380 |
if dialog.ShowModal() == wx.ID_OK: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1381 |
projectpath = dialog.GetPath() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1382 |
if os.path.isdir(projectpath): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1383 |
self.Config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1384 |
self.Config.Flush() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1385 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1386 |
self.PluginRoot = PluginsRoot(self, self.Log) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1387 |
self.Controler = self.PluginRoot |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1388 |
result = self.PluginRoot.LoadProject(projectpath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1389 |
if not result: |
490 | 1390 |
if self.EnableDebug: |
1391 |
self.DebugVariablePanel.SetDataProducer(self.PluginRoot) |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1392 |
self._Refresh(TYPESTREE, INSTANCESTREE, LIBRARYTREE) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1393 |
self.RefreshAll() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1394 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1395 |
self.ResetView() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1396 |
self.ShowErrorMessage(result) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1397 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1398 |
self.ShowErrorMessage(_("\"%s\" folder is not a valid Beremiz project\n") % projectpath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1399 |
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1400 |
dialog.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1401 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1402 |
def OnCloseProjectMenu(self, event): |
429
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1403 |
if self.PluginRoot is not None and not self.CheckSaveBeforeClosing(): |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1404 |
return |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1405 |
|
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1406 |
self.ResetView() |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1407 |
self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU) |
1a5471e81a93
Adding support for asking for saving while trying to close a modified project in any case
laurent
parents:
428
diff
changeset
|
1408 |
self.RefreshAll() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1409 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1410 |
def OnSaveProjectMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1411 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1412 |
self.PluginRoot.SaveProject() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1413 |
self.RefreshAll() |
509 | 1414 |
self._Refresh(TITLE, FILEMENU) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1415 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1416 |
def OnSaveProjectAsMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1417 |
if self.PluginRoot is not None: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1418 |
self.PluginRoot.SaveProjectAs() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1419 |
self.RefreshAll() |
509 | 1420 |
self._Refresh(TITLE, FILEMENU) |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1421 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1422 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1423 |
def OnPropertiesMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1424 |
self.ShowProperties() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1425 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1426 |
def OnQuitMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1427 |
self.Close() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1428 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1429 |
def OnBeremizMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1430 |
open_pdf(Bpath( "doc", "manual_beremiz.pdf")) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1431 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1432 |
def OnAboutMenu(self, event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1433 |
OpenHtmlFrame(self,_("About Beremiz"), Bpath("doc","about.html"), wx.Size(550, 500)) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1434 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1435 |
def GetAddButtonFunction(self, plugin, window): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1436 |
def AddButtonFunction(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1437 |
if plugin and len(plugin.PlugChildsTypes) > 0: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1438 |
plugin_menu = wx.Menu(title='') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1439 |
for name, XSDClass, help in plugin.PlugChildsTypes: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1440 |
new_id = wx.NewId() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1441 |
plugin_menu.Append(help=help, id=new_id, kind=wx.ITEM_NORMAL, text=name) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1442 |
self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name, plugin), id=new_id) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1443 |
window_pos = window.GetPosition() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1444 |
wx.CallAfter(self.PLCConfig.PopupMenu, plugin_menu) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1445 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1446 |
return AddButtonFunction |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1447 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1448 |
def GetDeleteButtonFunction(self, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1449 |
def DeleteButtonFunction(event): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1450 |
wx.CallAfter(self.DeletePlugin, plugin) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1451 |
event.Skip() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1452 |
return DeleteButtonFunction |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1453 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1454 |
def AddPlugin(self, PluginType, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1455 |
if self.PluginRoot.CheckProjectPathPerm(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1456 |
dialog = wx.TextEntryDialog(self, _("Please enter a name for plugin:"), _("Add Plugin"), "", wx.OK|wx.CANCEL) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1457 |
if dialog.ShowModal() == wx.ID_OK: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1458 |
PluginName = dialog.GetValue() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1459 |
plugin.PlugAddChild(PluginName, PluginType) |
505
7f38c773427b
Adding support for refreshing FileMenu after plugin tree modification
laurent
parents:
499
diff
changeset
|
1460 |
self.PluginRoot.RefreshPluginsBlockLists() |
7f38c773427b
Adding support for refreshing FileMenu after plugin tree modification
laurent
parents:
499
diff
changeset
|
1461 |
self.RefreshFileMenu() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1462 |
self.RefreshPluginTree() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1463 |
dialog.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1464 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1465 |
def DeletePlugin(self, plugin): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1466 |
if self.PluginRoot.CheckProjectPathPerm(): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1467 |
dialog = wx.MessageDialog(self, _("Really delete plugin ?"), _("Remove plugin"), wx.YES_NO|wx.NO_DEFAULT) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1468 |
if dialog.ShowModal() == wx.ID_YES: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1469 |
self.PluginInfos.pop(plugin) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1470 |
plugin.PlugRemove() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1471 |
del plugin |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1472 |
self.PluginRoot.RefreshPluginsBlockLists() |
505
7f38c773427b
Adding support for refreshing FileMenu after plugin tree modification
laurent
parents:
499
diff
changeset
|
1473 |
self.RefreshFileMenu() |
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1474 |
self.RefreshPluginTree() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1475 |
dialog.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1476 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1477 |
#------------------------------------------------------------------------------- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1478 |
# Exception Handler |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1479 |
#------------------------------------------------------------------------------- |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1480 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1481 |
Max_Traceback_List_Size = 20 |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1482 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1483 |
def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1484 |
trcbck_lst = [] |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1485 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1486 |
trcbck = " " + str(i+1) + _(". ") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1487 |
if line[0].find(os.getcwd()) == -1: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1488 |
trcbck += _("file : ") + str(line[0]) + _(", ") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1489 |
else: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1490 |
trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(", ") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1491 |
trcbck += _("line : ") + str(line[1]) + _(", ") + _("function : ") + str(line[2]) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1492 |
trcbck_lst.append(trcbck) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1493 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1494 |
# Allow clicking.... |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1495 |
cap = wx.Window_GetCapture() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1496 |
if cap: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1497 |
cap.ReleaseMouse() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1498 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1499 |
dlg = wx.SingleChoiceDialog(None, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1500 |
_(""" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1501 |
An unhandled exception (bug) occured. Bug report saved at : |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1502 |
(%s) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1503 |
|
434 | 1504 |
Please be kind enough to send this file to: |
1505 |
edouard.tisserant@gmail.com |
|
428
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1506 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1507 |
You should now restart Beremiz. |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1508 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1509 |
Traceback: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1510 |
""") % bug_report_path + |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1511 |
str(e_type) + " : " + str(e_value), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1512 |
_("Error"), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1513 |
trcbck_lst) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1514 |
try: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1515 |
res = (dlg.ShowModal() == wx.ID_OK) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1516 |
finally: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1517 |
dlg.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1518 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1519 |
return res |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1520 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1521 |
def Display_Error_Dialog(e_value): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1522 |
message = wxMessageDialog(None, str(e_value), _("Error"), wxOK|wxICON_ERROR) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1523 |
message.ShowModal() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1524 |
message.Destroy() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1525 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1526 |
def get_last_traceback(tb): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1527 |
while tb.tb_next: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1528 |
tb = tb.tb_next |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1529 |
return tb |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1530 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1531 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1532 |
def format_namespace(d, indent=' '): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1533 |
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
|
1534 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1535 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1536 |
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
|
1537 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1538 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1539 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1540 |
def handle_exception(e_type, e_value, e_traceback): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1541 |
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
|
1542 |
last_tb = get_last_traceback(e_traceback) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1543 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1544 |
if str(e_value).startswith("!!!"): |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1545 |
Display_Error_Dialog(e_value) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1546 |
elif ex not in ignored_exceptions: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1547 |
date = time.ctime() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1548 |
bug_report_path = path+os.sep+"bug_report_"+date.replace(':','-').replace(' ','_')+".txt" |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1549 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback,bug_report_path) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1550 |
if result: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1551 |
ignored_exceptions.append(ex) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1552 |
info = { |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1553 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1554 |
'app-version' : app_version, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1555 |
'wx-version' : wx.VERSION_STRING, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1556 |
'wx-platform' : wx.Platform, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1557 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1558 |
'platform' : platform.platform(), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1559 |
'e-type' : e_type, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1560 |
'e-value' : e_value, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1561 |
'date' : date, |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1562 |
'cwd' : os.getcwd(), |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1563 |
} |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1564 |
if e_traceback: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1565 |
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
|
1566 |
last_tb = get_last_traceback(e_traceback) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1567 |
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
|
1568 |
info['locals'] = format_namespace(exception_locals) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1569 |
if 'self' in exception_locals: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1570 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1571 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1572 |
output = open(bug_report_path,'w') |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1573 |
lst = info.keys() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1574 |
lst.sort() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1575 |
for a in lst: |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1576 |
output.write(a+":\n"+str(info[a])+"\n\n") |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1577 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1578 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1579 |
sys.excepthook = handle_exception |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1580 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1581 |
if __name__ == '__main__': |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1582 |
# Install a exception handle for bug reports |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1583 |
AddExceptHook(os.getcwd(),__version__) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1584 |
|
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1585 |
frame = Beremiz(None, projectOpen, buildpath) |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1586 |
frame.Show() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1587 |
splash.Close() |
ea09f33ce717
Update internationalization for new functionalities.
laurent
parents:
427
diff
changeset
|
1588 |
app.MainLoop() |