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