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