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