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