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