author | etisserant |
Tue, 04 Sep 2007 17:58:29 +0200 | |
changeset 20 | d3cb5020997b |
parent 19 | 73257cea38bd |
child 21 | bded6d31365c |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
3
6d8728efcdec
Adding validity verifications on project folders opened
lbessard
parents:
2
diff
changeset
|
4 |
#This file is part of Beremiz, a Integrated Development Environment for |
6d8728efcdec
Adding validity verifications on project folders opened
lbessard
parents:
2
diff
changeset
|
5 |
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
0 | 6 |
# |
3
6d8728efcdec
Adding validity verifications on project folders opened
lbessard
parents:
2
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
0 | 8 |
# |
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
3
6d8728efcdec
Adding validity verifications on project folders opened
lbessard
parents:
2
diff
changeset
|
19 |
#General Public License for more details. |
0 | 20 |
# |
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
25 |
__version__ = "$Revision$" |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
26 |
|
0 | 27 |
import wx |
5
9565bb5facf7
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
4
diff
changeset
|
28 |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
29 |
import types |
0 | 30 |
|
1 | 31 |
import os, re, platform, sys, time, traceback, getopt, commands |
20 | 32 |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
33 |
from plugger import PluginsRoot |
0 | 34 |
|
1 | 35 |
class LogPseudoFile: |
36 |
""" Base class for file like objects to facilitate StdOut for the Shell.""" |
|
37 |
def __init__(self, output = None): |
|
7
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
38 |
self.red_white = wx.TextAttr("RED", "WHITE") |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
39 |
self.red_yellow = wx.TextAttr("RED", "YELLOW") |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
40 |
self.black_white = wx.TextAttr("BLACK", "WHITE") |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
41 |
self.default_style = None |
1 | 42 |
self.output = output |
43 |
||
44 |
def writelines(self, l): |
|
45 |
map(self.write, l) |
|
46 |
||
47 |
def write(self, s): |
|
7
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
48 |
if self.default_style != self.black_white: |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
49 |
self.output.SetDefaultStyle(self.black_white) |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
50 |
self.default_style = self.black_white |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
51 |
self.output.AppendText(s) |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
52 |
|
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
53 |
def write_warning(self, s): |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
54 |
if self.default_style != self.red_white: |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
55 |
self.output.SetDefaultStyle(self.red_white) |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
56 |
self.default_style = self.red_white |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
57 |
self.output.AppendText(s) |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
58 |
|
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
59 |
def write_error(self, s): |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
60 |
if self.default_style != self.red_yellow: |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
61 |
self.output.SetDefaultStyle(self.red_yellow) |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
62 |
self.default_style = self.red_yellow |
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
63 |
self.output.AppendText(s) |
1 | 64 |
|
65 |
def flush(self): |
|
66 |
self.output.SetValue("") |
|
67 |
||
68 |
def isatty(self): |
|
69 |
return false |
|
70 |
||
20 | 71 |
def LogCommand(self, Command, sz_limit = 100): |
72 |
||
73 |
import os, popen2, fcntl, select, signal |
|
74 |
||
75 |
child = popen2.Popen3(Command, 1) # capture stdout and stderr from command |
|
76 |
child.tochild.close() # don't need to talk to child |
|
77 |
outfile = child.fromchild |
|
78 |
outfd = outfile.fileno() |
|
79 |
errfile = child.childerr |
|
80 |
errfd = errfile.fileno() |
|
81 |
outdata = errdata = '' |
|
82 |
outeof = erreof = 0 |
|
83 |
outlen = errlen = 0 |
|
84 |
while 1: |
|
85 |
ready = select.select([outfd,errfd],[],[]) # wait for input |
|
86 |
if outfd in ready[0]: |
|
87 |
outchunk = outfile.readline() |
|
88 |
if outchunk == '': outeof = 1 |
|
89 |
else : outlen += 1 |
|
90 |
outdata += outchunk |
|
91 |
self.write(outchunk) |
|
92 |
if errfd in ready[0]: |
|
93 |
errchunk = errfile.readline() |
|
94 |
if errchunk == '': erreof = 1 |
|
95 |
else : errlen += 1 |
|
96 |
errdata += errchunk |
|
97 |
self.write_warning(errchunk) |
|
98 |
if outeof and erreof : break |
|
99 |
if errlen > sz_limit or outlen > sz_limit : |
|
100 |
os.kill(child.pid, signal.SIGTERM) |
|
101 |
self.write_error("Output size reached limit -- killed\n") |
|
102 |
break |
|
103 |
err = child.wait() |
|
104 |
return (err, outdata, errdata) |
|
105 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
106 |
[ID_BEREMIZ, ID_BEREMIZMAINSPLITTER, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
107 |
ID_BEREMIZSECONDSPLITTER, ID_BEREMIZLEFTPANEL, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
108 |
ID_BEREMIZPARAMSPANEL, ID_BEREMIZLOGCONSOLE, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
109 |
ID_BEREMIZPLUGINTREE, ID_BEREMIZPLUGINCHILDS, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
110 |
ID_BEREMIZADDBUTTON, ID_BEREMIZDELETEBUTTON, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
111 |
ID_BEREMIZPARAMSSTATICBOX, ID_BEREMIZPARAMSENABLE, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
112 |
ID_BEREMIZPARAMSTARGETTYPE, ID_BEREMIZPARAMSIECCHANNEL, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
113 |
ID_BEREMIZPARAMSSTATICTEXT1, ID_BEREMIZPARAMSSTATICTEXT2, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
114 |
ID_BEREMIZPARAMSATTRIBUTESGRID, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
115 |
] = [wx.NewId() for _init_ctrls in range(17)] |
0 | 116 |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
117 |
[ID_BEREMIZFILEMENUITEMS0, ID_BEREMIZFILEMENUITEMS1, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
118 |
ID_BEREMIZFILEMENUITEMS2, ID_BEREMIZFILEMENUITEMS3, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
119 |
ID_BEREMIZFILEMENUITEMS5, ID_BEREMIZFILEMENUITEMS7, |
0 | 120 |
] = [wx.NewId() for _init_coll_FileMenu_Items in range(6)] |
121 |
||
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
122 |
[ID_BEREMIZEDITMENUITEMS0, ID_BEREMIZEDITMENUITEMS2, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
123 |
ID_BEREMIZEDITMENUITEMS3, |
0 | 124 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(3)] |
125 |
||
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
126 |
[ID_BEREMIZRUNMENUITEMS0, ID_BEREMIZRUNMENUITEMS2, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
127 |
ID_BEREMIZRUNMENUITEMS3, ID_BEREMIZRUNMENUITEMS5, |
0 | 128 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)] |
129 |
||
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
130 |
[ID_BEREMIZHELPMENUITEMS0, ID_BEREMIZHELPMENUITEMS1, |
0 | 131 |
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(2)] |
132 |
||
133 |
class Beremiz(wx.Frame): |
|
134 |
||
135 |
def _init_coll_FileMenu_Items(self, parent): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
136 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS0, |
0 | 137 |
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
|
138 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS1, |
0 | 139 |
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
|
140 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS2, |
0 | 141 |
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
|
142 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS3, |
0 | 143 |
kind=wx.ITEM_NORMAL, text=u'Close Project') |
144 |
parent.AppendSeparator() |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
145 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS5, |
0 | 146 |
kind=wx.ITEM_NORMAL, text=u'Properties') |
147 |
parent.AppendSeparator() |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
148 |
parent.Append(help='', id=ID_BEREMIZFILEMENUITEMS7, |
0 | 149 |
kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q') |
150 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
151 |
id=ID_BEREMIZFILEMENUITEMS0) |
0 | 152 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
153 |
id=ID_BEREMIZFILEMENUITEMS1) |
0 | 154 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
155 |
id=ID_BEREMIZFILEMENUITEMS2) |
0 | 156 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
157 |
id=ID_BEREMIZFILEMENUITEMS3) |
0 | 158 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
159 |
id=ID_BEREMIZFILEMENUITEMS5) |
0 | 160 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
161 |
id=ID_BEREMIZFILEMENUITEMS7) |
0 | 162 |
|
163 |
def _init_coll_EditMenu_Items(self, parent): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
164 |
parent.Append(help='', id=ID_BEREMIZEDITMENUITEMS0, |
0 | 165 |
kind=wx.ITEM_NORMAL, text=u'Edit PLC\tCTRL+R') |
166 |
parent.AppendSeparator() |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
167 |
parent.Append(help='', id=ID_BEREMIZEDITMENUITEMS2, |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
168 |
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
|
169 |
parent.Append(help='', id=ID_BEREMIZEDITMENUITEMS3, |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
170 |
kind=wx.ITEM_NORMAL, text=u'Delete Plugin') |
0 | 171 |
self.Bind(wx.EVT_MENU, self.OnEditPLCMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
172 |
id=ID_BEREMIZEDITMENUITEMS0) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
173 |
self.Bind(wx.EVT_MENU, self.OnAddMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
174 |
id=ID_BEREMIZEDITMENUITEMS2) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
175 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
176 |
id=ID_BEREMIZEDITMENUITEMS3) |
0 | 177 |
|
178 |
def _init_coll_RunMenu_Items(self, parent): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
179 |
parent.Append(help='', id=ID_BEREMIZRUNMENUITEMS0, |
0 | 180 |
kind=wx.ITEM_NORMAL, text=u'Build\tCTRL+R') |
181 |
parent.AppendSeparator() |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
182 |
parent.Append(help='', id=ID_BEREMIZRUNMENUITEMS2, |
0 | 183 |
kind=wx.ITEM_NORMAL, text=u'Simulate') |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
184 |
parent.Append(help='', id=ID_BEREMIZRUNMENUITEMS3, |
0 | 185 |
kind=wx.ITEM_NORMAL, text=u'Run') |
186 |
parent.AppendSeparator() |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
187 |
parent.Append(help='', id=ID_BEREMIZRUNMENUITEMS5, |
0 | 188 |
kind=wx.ITEM_NORMAL, text=u'Save Log') |
1 | 189 |
self.Bind(wx.EVT_MENU, self.OnBuildMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
190 |
id=ID_BEREMIZRUNMENUITEMS0) |
0 | 191 |
self.Bind(wx.EVT_MENU, self.OnSimulateMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
192 |
id=ID_BEREMIZRUNMENUITEMS2) |
0 | 193 |
self.Bind(wx.EVT_MENU, self.OnRunMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
194 |
id=ID_BEREMIZRUNMENUITEMS3) |
0 | 195 |
self.Bind(wx.EVT_MENU, self.OnSaveLogMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
196 |
id=ID_BEREMIZRUNMENUITEMS5) |
0 | 197 |
|
198 |
def _init_coll_HelpMenu_Items(self, parent): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
199 |
parent.Append(help='', id=ID_BEREMIZHELPMENUITEMS0, |
0 | 200 |
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
|
201 |
parent.Append(help='', id=ID_BEREMIZHELPMENUITEMS1, |
0 | 202 |
kind=wx.ITEM_NORMAL, text=u'About') |
203 |
self.Bind(wx.EVT_MENU, self.OnBeremizMenu, |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
204 |
id=ID_BEREMIZHELPMENUITEMS0) |
0 | 205 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
206 |
id=ID_BEREMIZHELPMENUITEMS1) |
0 | 207 |
|
208 |
def _init_coll_menuBar1_Menus(self, parent): |
|
209 |
parent.Append(menu=self.FileMenu, title=u'File') |
|
210 |
parent.Append(menu=self.EditMenu, title=u'Edit') |
|
211 |
parent.Append(menu=self.RunMenu, title=u'Run') |
|
212 |
parent.Append(menu=self.HelpMenu, title=u'Help') |
|
213 |
||
214 |
def _init_utils(self): |
|
215 |
self.menuBar1 = wx.MenuBar() |
|
216 |
self.FileMenu = wx.Menu(title=u'') |
|
217 |
self.EditMenu = wx.Menu(title=u'') |
|
218 |
self.RunMenu = wx.Menu(title=u'') |
|
219 |
self.HelpMenu = wx.Menu(title=u'') |
|
220 |
||
221 |
self._init_coll_menuBar1_Menus(self.menuBar1) |
|
222 |
self._init_coll_FileMenu_Items(self.FileMenu) |
|
223 |
self._init_coll_EditMenu_Items(self.EditMenu) |
|
224 |
self._init_coll_RunMenu_Items(self.RunMenu) |
|
225 |
self._init_coll_HelpMenu_Items(self.HelpMenu) |
|
226 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
227 |
def _init_coll_LeftGridSizer_Items(self, parent): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
228 |
parent.AddWindow(self.PluginTree, 0, border=0, flag=wx.GROW) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
229 |
parent.AddSizer(self.ButtonGridSizer, 0, border=0, flag=wx.GROW) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
230 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
231 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
0 | 232 |
parent.AddGrowableCol(0) |
233 |
parent.AddGrowableRow(0) |
|
234 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
235 |
def _init_coll_ButtonGridSizer_Items(self, parent): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
236 |
parent.AddWindow(self.PluginChilds, 0, border=0, flag=wx.GROW) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
237 |
parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
238 |
parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
239 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
240 |
def _init_coll_ButtonGridSizer_Growables(self, parent): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
241 |
parent.AddGrowableCol(0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
242 |
parent.AddGrowableRow(0) |
0 | 243 |
|
244 |
def _init_sizers(self): |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
245 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
246 |
self.ButtonGridSizer = wx.FlexGridSizer(cols=3, hgap=2, rows=1, vgap=2) |
19
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
247 |
self.ParamsPanelMainSizer = wx.BoxSizer(wx.VERTICAL) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
248 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
249 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
250 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
251 |
self._init_coll_ButtonGridSizer_Growables(self.ButtonGridSizer) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
252 |
self._init_coll_ButtonGridSizer_Items(self.ButtonGridSizer) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
253 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
254 |
self.LeftPanel.SetSizer(self.LeftGridSizer) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
255 |
self.ParamsPanel.SetSizer(self.ParamsPanelMainSizer) |
0 | 256 |
|
257 |
def _init_ctrls(self, prnt): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
258 |
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
|
259 |
parent=prnt, pos=wx.Point(0, 0), size=wx.Size(1000, 600), |
0 | 260 |
style=wx.DEFAULT_FRAME_STYLE, title=u'Beremiz') |
261 |
self._init_utils() |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
262 |
self.SetClientSize(wx.Size(1000, 600)) |
0 | 263 |
self.SetMenuBar(self.menuBar1) |
264 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
265 |
self.MainSplitter = wx.SplitterWindow(id=ID_BEREMIZMAINSPLITTER, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
266 |
name='MainSplitter', parent=self, point=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
267 |
size=wx.Size(0, 0), style=wx.SP_3D) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
268 |
self.MainSplitter.SetNeedUpdating(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
269 |
self.MainSplitter.SetMinimumPaneSize(1) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
270 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
271 |
self.LeftPanel = wx.Panel(id=ID_BEREMIZLEFTPANEL, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
272 |
name='LeftPanel', parent=self.MainSplitter, pos=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
273 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
274 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
275 |
self.PluginTree = wx.TreeCtrl(id=ID_BEREMIZPLUGINTREE, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
276 |
name='PluginTree', parent=self.LeftPanel, pos=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
277 |
size=wx.Size(-1, -1), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
278 |
self.PluginTree.Bind(wx.EVT_RIGHT_UP, self.OnPluginTreeRightUp) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
279 |
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnPluginTreeItemSelected, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
280 |
id=ID_BEREMIZPLUGINTREE) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
281 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
282 |
self.PluginChilds = wx.Choice(id=ID_BEREMIZPLUGINCHILDS, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
283 |
name='PluginChilds', parent=self.LeftPanel, pos=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
284 |
size=wx.Size(-1, -1), style=0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
285 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
286 |
self.AddButton = wx.Button(id=ID_BEREMIZADDBUTTON, label='Add', |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
287 |
name='AddBusButton', parent=self.LeftPanel, pos=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
288 |
size=wx.Size(48, 30), style=0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
289 |
self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButton, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
290 |
id=ID_BEREMIZADDBUTTON) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
291 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
292 |
self.DeleteButton = wx.Button(id=ID_BEREMIZDELETEBUTTON, label='Delete', |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
293 |
name='DeleteBusButton', parent=self.LeftPanel, pos=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
294 |
size=wx.Size(64, 30), style=0) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
295 |
self.DeleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteButton, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
296 |
id=ID_BEREMIZDELETEBUTTON) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
297 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
298 |
self.SecondSplitter = wx.SplitterWindow(id=ID_BEREMIZSECONDSPLITTER, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
299 |
name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0), |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
300 |
size=wx.Size(0, 0), style=wx.SP_3D) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
301 |
self.SecondSplitter.SetNeedUpdating(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
302 |
self.SecondSplitter.SetMinimumPaneSize(1) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
303 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
304 |
self.MainSplitter.SplitVertically(self.LeftPanel, self.SecondSplitter, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
305 |
300) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
306 |
|
19
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
307 |
self.ParamsPanel = wx.ScrolledWindow(id=ID_BEREMIZPARAMSPANEL, |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
308 |
name='ParamsPanel', parent=self.SecondSplitter, pos=wx.Point(0, 0), |
19
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
309 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.VSCROLL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
310 |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
311 |
self.LogConsole = wx.TextCtrl(id=ID_BEREMIZLOGCONSOLE, value='', |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
312 |
name='LogConsole', parent=self.SecondSplitter, pos=wx.Point(0, 0), |
7
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
313 |
size=wx.Size(0, 0), style=wx.TE_MULTILINE|wx.TE_RICH2) |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
314 |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
315 |
self.SecondSplitter.SplitHorizontally(self.ParamsPanel, self.LogConsole, |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
316 |
-250) |
0 | 317 |
|
318 |
self._init_sizers() |
|
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
319 |
|
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
320 |
def __init__(self, parent, projectOpen): |
0 | 321 |
self._init_ctrls(parent) |
322 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
323 |
self.Log = LogPseudoFile(self.LogConsole) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
324 |
|
20 | 325 |
self.PluginRoot = PluginsRoot(self) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
326 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
327 |
if projectOpen: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
328 |
self.PluginRoot.LoadProject(projectOpen) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
329 |
self.RefreshPluginTree() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
330 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
331 |
self.RefreshPluginParams() |
0 | 332 |
self.RefreshButtons() |
333 |
self.RefreshMainMenu() |
|
334 |
||
335 |
def RefreshButtons(self): |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
336 |
if self.PluginRoot.HasProjectOpened(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
337 |
self.PluginChilds.Enable(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
338 |
self.AddButton.Enable(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
339 |
self.DeleteButton.Enable(True) |
0 | 340 |
else: |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
341 |
self.PluginChilds.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
342 |
self.AddButton.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
343 |
self.DeleteButton.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
344 |
|
0 | 345 |
def RefreshMainMenu(self): |
346 |
if self.menuBar1: |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
347 |
if self.PluginRoot.HasProjectOpened(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
348 |
self.menuBar1.EnableTop(1, True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
349 |
self.menuBar1.EnableTop(2, True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
350 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS2, True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
351 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS3, True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
352 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS5, True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
353 |
else: |
0 | 354 |
self.menuBar1.EnableTop(1, False) |
355 |
self.menuBar1.EnableTop(2, False) |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
356 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS2, False) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
357 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS3, False) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
358 |
self.FileMenu.Enable(ID_BEREMIZFILEMENUITEMS5, False) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
359 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
360 |
def RefreshPluginTree(self): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
361 |
infos = self.PluginRoot.GetPlugInfos() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
362 |
root = self.PluginTree.GetRootItem() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
363 |
self.GenerateTreeBranch(root, infos) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
364 |
self.PluginTree.Expand(self.PluginTree.GetRootItem()) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
365 |
self.RefreshPluginParams() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
366 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
367 |
def GenerateTreeBranch(self, root, infos): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
368 |
to_delete = [] |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
369 |
if root.IsOk(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
370 |
self.PluginTree.SetItemText(root, infos["name"]) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
371 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
372 |
root = self.PluginTree.AddRoot(infos["name"]) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
373 |
self.PluginTree.SetPyData(root, infos["type"]) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
374 |
item, root_cookie = self.PluginTree.GetFirstChild(root) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
375 |
if len(infos["values"]) > 0: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
376 |
for values in infos["values"]: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
377 |
if not item.IsOk(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
378 |
item = self.PluginTree.AppendItem(root, "") |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
379 |
item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
380 |
self.GenerateTreeBranch(item, values) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
381 |
item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
382 |
while item.IsOk(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
383 |
to_delete.append(item) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
384 |
item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
385 |
for item in to_delete: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
386 |
self.PluginTree.Delete(item) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
387 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
388 |
def GetSelectedPlugin(self): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
389 |
selected = self.PluginTree.GetSelection() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
390 |
if not selected.IsOk(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
391 |
return None |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
392 |
if selected == self.PluginTree.GetRootItem(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
393 |
return self.PluginRoot |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
394 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
395 |
name = self.PluginTree.GetItemText(selected) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
396 |
item = self.PluginTree.GetItemParent(selected) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
397 |
while item.IsOk() and item != self.PluginTree.GetRootItem(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
398 |
name = "%s.%s"%(self.PluginTree.GetItemText(item), name) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
399 |
item = self.PluginTree.GetItemParent(item) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
400 |
return self.PluginRoot.GetChildByName(name) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
401 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
402 |
def OnPluginTreeItemSelected(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
403 |
wx.CallAfter(self.RefreshPluginParams) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
404 |
event.Skip() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
405 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
406 |
def _GetAddPluginFunction(self, name): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
407 |
def OnPluginMenu(event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
408 |
self.AddPlugin(name) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
409 |
event.Skip() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
410 |
return OnPluginMenu |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
411 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
412 |
def OnPluginTreeRightUp(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
413 |
plugin = self.GetSelectedPlugin() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
414 |
if plugin: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
415 |
main_menu = wx.Menu(title='') |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
416 |
if len(plugin.PlugChildsTypes) > 0: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
417 |
plugin_menu = wx.Menu(title='') |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
418 |
for name, XSDClass in self.GetSelectedPlugin().PlugChildsTypes: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
419 |
new_id = wx.NewId() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
420 |
plugin_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=name) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
421 |
self.Bind(wx.EVT_MENU, self._GetAddPluginFunction(name), id=new_id) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
422 |
main_menu.AppendMenu(-1, "Add", plugin_menu, '') |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
423 |
new_id = wx.NewId() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
424 |
main_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete") |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
425 |
self.Bind(wx.EVT_MENU, self.OnDeleteButton, id=new_id) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
426 |
rect = self.PluginTree.GetBoundingRect(self.PluginTree.GetSelection()) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
427 |
self.PluginTree.PopupMenuXY(main_menu, rect.x + rect.width, rect.y) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
428 |
event.Skip() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
429 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
430 |
def RefreshPluginParams(self): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
431 |
plugin = self.GetSelectedPlugin() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
432 |
if not plugin: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
433 |
# Refresh ParamsPanel |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
434 |
self.ParamsPanel.Hide() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
435 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
436 |
# Refresh PluginChilds |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
437 |
self.PluginChilds.Clear() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
438 |
self.PluginChilds.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
439 |
self.AddButton.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
440 |
self.DeleteButton.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
441 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
442 |
# Refresh ParamsPanel |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
443 |
self.ParamsPanel.Show() |
19
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
444 |
infos = plugin.GetParamsAttributes() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
445 |
self.RefreshSizerElement(self.ParamsPanelMainSizer, infos, None) |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
446 |
self.ParamsPanelMainSizer.Layout() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
447 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
448 |
# Refresh PluginChilds |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
449 |
self.PluginChilds.Clear() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
450 |
if len(plugin.PlugChildsTypes) > 0: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
451 |
self.PluginChilds.Append("") |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
452 |
for name, XSDClass in plugin.PlugChildsTypes: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
453 |
self.PluginChilds.Append(name) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
454 |
self.PluginChilds.Enable(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
455 |
self.AddButton.Enable(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
456 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
457 |
self.PluginChilds.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
458 |
self.AddButton.Enable(False) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
459 |
self.DeleteButton.Enable(True) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
460 |
|
19
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
461 |
def GetChoiceCallBackFunction(self, choicectrl, path): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
462 |
def OnChoiceChanged(event): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
463 |
plugin = self.GetSelectedPlugin() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
464 |
if plugin: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
465 |
plugin.SetParamsAttribute(path, choicectrl.GetStringSelection()) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
466 |
event.Skip() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
467 |
return OnChoiceChanged |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
468 |
|
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
469 |
def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
470 |
def OnChoiceContentChanged(event): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
471 |
plugin = self.GetSelectedPlugin() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
472 |
if plugin: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
473 |
plugin.SetParamsAttribute(path, choicectrl.GetStringSelection()) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
474 |
infos = self.PluginRoot.GetParamsAttributes(path) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
475 |
staticbox = staticboxsizer.GetStaticBox() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
476 |
staticbox.SetLabel("%(name)s - %(value)s"%infos) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
477 |
self.RefreshSizerElement(staticboxsizer, infos["children"], "%s.%s"%(path, infos["name"])) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
478 |
self.ParamsPanelMainSizer.Layout() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
479 |
event.Skip() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
480 |
return OnChoiceContentChanged |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
481 |
|
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
482 |
def GetTextCtrlCallBackFunction(self, textctrl, path): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
483 |
def OnTextCtrlChanged(event): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
484 |
plugin = self.GetSelectedPlugin() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
485 |
if plugin: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
486 |
plugin.SetParamsAttribute(path, textctrl.GetValue()) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
487 |
event.Skip() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
488 |
return OnTextCtrlChanged |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
489 |
|
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
490 |
def GetCheckBoxCallBackFunction(self, textctrl, path): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
491 |
def OnCheckBoxChanged(event): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
492 |
plugin = self.GetSelectedPlugin() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
493 |
if plugin: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
494 |
plugin.SetParamsAttribute(path, textctrl.IsChecked()) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
495 |
event.Skip() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
496 |
return OnCheckBoxChanged |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
497 |
|
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
498 |
def ClearSizer(self, sizer): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
499 |
staticboxes = [] |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
500 |
for item in sizer.GetChildren(): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
501 |
if item.IsSizer(): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
502 |
item_sizer = item.GetSizer() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
503 |
self.ClearSizer(item_sizer) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
504 |
if isinstance(item_sizer, wx.StaticBoxSizer): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
505 |
staticboxes.append(item_sizer.GetStaticBox()) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
506 |
sizer.Clear(True) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
507 |
for staticbox in staticboxes: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
508 |
staticbox.Destroy() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
509 |
|
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
510 |
def RefreshSizerElement(self, sizer, elements, path): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
511 |
self.ClearSizer(sizer) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
512 |
first = True |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
513 |
for element_infos in elements: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
514 |
if path: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
515 |
element_path = "%s.%s"%(path, element_infos["name"]) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
516 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
517 |
element_path = element_infos["name"] |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
518 |
if isinstance(element_infos["type"], types.ListType): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
519 |
boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
520 |
if first: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
521 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
522 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
523 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
524 |
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
525 |
name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
526 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
527 |
boxsizer.AddWindow(statictext, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
528 |
id = wx.NewId() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
529 |
choicectrl = wx.Choice(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
530 |
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
|
531 |
boxsizer.AddWindow(choicectrl, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
532 |
choicectrl.Append("") |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
533 |
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
|
534 |
for choice, xsdclass in element_infos["type"]: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
535 |
choicectrl.Append(choice) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
536 |
staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
537 |
name='%s_staticbox'%element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
538 |
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
|
539 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
540 |
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
541 |
self.RefreshSizerElement(staticboxsizer, element_infos["children"], element_path) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
542 |
callback = self.GetChoiceContentCallBackFunction(choicectrl, staticboxsizer, element_path) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
543 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
544 |
for choice in element_infos["type"]: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
545 |
choicectrl.Append(choice) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
546 |
callback = self.GetChoiceCallBackFunction(choicectrl, element_path) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
547 |
choicectrl.Bind(wx.EVT_CHOICE, callback, id=id) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
548 |
choicectrl.SetStringSelection(element_infos["value"]) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
549 |
elif isinstance(element_infos["type"], types.DictType): |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
550 |
boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
551 |
if first: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
552 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
553 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
554 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
555 |
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
556 |
name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
557 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
558 |
boxsizer.AddWindow(statictext, 0, border=0, flag=wx.TOP|wx.LEFT|wx.BOTTOM) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
559 |
id = wx.NewId() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
560 |
min = max = -1 |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
561 |
if "min" in element_infos["type"]: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
562 |
min = element_infos["type"]["min"] |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
563 |
if "max" in element_infos["type"]: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
564 |
max = element_infos["type"]["max"] |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
565 |
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
566 |
pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
567 |
min=min, max=max) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
568 |
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
569 |
spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, element_path), id=id) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
570 |
spinctrl.SetValue(element_infos["value"]) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
571 |
elif element_infos["type"] == "element": |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
572 |
staticbox = wx.StaticBox(id=-1, label=element_infos["name"], |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
573 |
name='%s_staticbox'%element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
574 |
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
|
575 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
576 |
if first: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
577 |
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW|wx.TOP) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
578 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
579 |
sizer.AddSizer(staticboxsizer, 0, border=0, flag=wx.GROW) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
580 |
self.RefreshSizerElement(staticboxsizer, element_infos["children"], element_path) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
581 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
582 |
boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
583 |
if first: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
584 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
585 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
586 |
sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
587 |
statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
588 |
name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
589 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
590 |
boxsizer.AddWindow(statictext, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
591 |
id = wx.NewId() |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
592 |
if element_infos["type"] == "boolean": |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
593 |
checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
594 |
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
|
595 |
boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
596 |
checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, element_path), id=id) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
597 |
checkbox.SetValue(element_infos["value"]) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
598 |
elif element_infos["type"] in ["unsignedLong", "long","integer"]: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
599 |
spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
600 |
pos=wx.Point(0, 0), size=wx.Size(150, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
601 |
boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
602 |
spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, element_path), id=id) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
603 |
spinctrl.SetValue(element_infos["value"]) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
604 |
else: |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
605 |
textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
606 |
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
|
607 |
boxsizer.AddWindow(textctrl, 0, border=0, flag=0) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
608 |
textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, element_path), id=id) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
609 |
textctrl.SetValue(str(element_infos["value"])) |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
610 |
first = False |
73257cea38bd
Adding Plugin params visualization with basic controls
lbessard
parents:
18
diff
changeset
|
611 |
|
0 | 612 |
def OnNewProjectMenu(self, event): |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
613 |
defaultpath = self.PluginRoot.GetProjectPath() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
614 |
if defaultpath == "": |
0 | 615 |
defaultpath = os.getcwd() |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
616 |
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
|
617 |
if dialog.ShowModal() == wx.ID_OK: |
0 | 618 |
projectpath = dialog.GetPath() |
619 |
dialog.Destroy() |
|
20 | 620 |
res = self.PluginRoot.NewProject(projectpath) |
621 |
if not res : |
|
622 |
self.RefreshPluginTree() |
|
623 |
self.RefreshButtons() |
|
624 |
self.RefreshMainMenu() |
|
0 | 625 |
else: |
20 | 626 |
message = wx.MessageDialog(self, res, "ERROR", wx.OK|wx.ICON_ERROR) |
0 | 627 |
message.ShowModal() |
628 |
message.Destroy() |
|
629 |
event.Skip() |
|
630 |
||
631 |
def OnOpenProjectMenu(self, event): |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
632 |
defaultpath = self.PluginRoot.GetProjectPath() |
20 | 633 |
if not defaultpath: |
0 | 634 |
defaultpath = os.getcwd() |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
635 |
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
|
636 |
if dialog.ShowModal() == wx.ID_OK: |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
637 |
projectpath = dialog.GetPath() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
638 |
if os.path.isdir(projectpath): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
639 |
result = self.PluginRoot.LoadProject(projectpath) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
640 |
if not result: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
641 |
self.RefreshPluginTree() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
642 |
self.RefreshButtons() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
643 |
self.RefreshMainMenu() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
644 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
645 |
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
|
646 |
message.ShowModal() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
647 |
message.Destroy() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
648 |
else: |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
649 |
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
|
650 |
message.ShowModal() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
651 |
message.Destroy() |
0 | 652 |
dialog.Destroy() |
653 |
event.Skip() |
|
654 |
||
655 |
def OnCloseProjectMenu(self, event): |
|
656 |
self.PLCManager = None |
|
657 |
self.CurrentProjectPath = projectpath |
|
658 |
self.RefreshButtons() |
|
659 |
self.RefreshMainMenu() |
|
660 |
event.Skip() |
|
661 |
||
662 |
def OnSaveProjectMenu(self, event): |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
663 |
if self.PluginRoot.HasProjectOpened(): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
664 |
self.PluginRoot.SaveProject() |
0 | 665 |
event.Skip() |
666 |
||
667 |
def OnPropertiesMenu(self, event): |
|
668 |
event.Skip() |
|
669 |
||
670 |
def OnQuitMenu(self, event): |
|
671 |
self.Close() |
|
672 |
event.Skip() |
|
673 |
||
674 |
def OnEditPLCMenu(self, event): |
|
675 |
self.EditPLC() |
|
676 |
event.Skip() |
|
677 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
678 |
def OnAddMenu(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
679 |
self.AddPlugin() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
680 |
event.Skip() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
681 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
682 |
def OnDeleteMenu(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
683 |
self.DeletePlugin() |
0 | 684 |
event.Skip() |
685 |
||
1 | 686 |
def OnBuildMenu(self, event): |
20 | 687 |
#self.BuildAutom() |
1 | 688 |
event.Skip() |
689 |
||
0 | 690 |
def OnSimulateMenu(self, event): |
691 |
event.Skip() |
|
692 |
||
693 |
def OnRunMenu(self, event): |
|
694 |
event.Skip() |
|
695 |
||
696 |
def OnSaveLogMenu(self, event): |
|
697 |
event.Skip() |
|
698 |
||
699 |
def OnBeremizMenu(self, event): |
|
700 |
event.Skip() |
|
701 |
||
702 |
def OnAboutMenu(self, event): |
|
703 |
event.Skip() |
|
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
704 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
705 |
def OnAddButton(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
706 |
PluginType = self.PluginChilds.GetStringSelection() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
707 |
if PluginType != "": |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
708 |
self.AddPlugin(PluginType) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
709 |
event.Skip() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
710 |
|
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
711 |
def OnDeleteButton(self, event): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
712 |
self.DeletePlugin() |
0 | 713 |
event.Skip() |
714 |
||
715 |
def CloseEditor(self, bus_id): |
|
716 |
if self.BusManagers.get(bus_id, None) != None: |
|
717 |
self.BusManagers[bus_id]["Editor"] = None |
|
718 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
719 |
def AddPlugin(self, PluginType): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
720 |
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
|
721 |
if dialog.ShowModal() == wx.ID_OK: |
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
722 |
PluginName = dialog.GetValue() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
723 |
plugin = self.GetSelectedPlugin() |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
724 |
plugin.PlugAddChild(PluginName, PluginType) |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
725 |
self.RefreshPluginTree() |
0 | 726 |
dialog.Destroy() |
727 |
||
17
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
728 |
def DeletePlugin(self): |
ee8cb104dbe0
First commit of Beremiz new version with plugin support
lbessard
parents:
13
diff
changeset
|
729 |
pass |
7
e20fa7257d41
Added stdout/stderr separation limitation and coloration
etisserant
parents:
6
diff
changeset
|
730 |
|
0 | 731 |
#------------------------------------------------------------------------------- |
732 |
# Add Bus Dialog |
|
733 |
#------------------------------------------------------------------------------- |
|
734 |
||
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
735 |
[ID_ADDBUSDIALOG, ID_ADDBUSDIALOGBUSID, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
736 |
ID_ADDBUSDIALOGBUSNAME, ID_ADDBUSDIALOGBUSTYPE, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
737 |
ID_ADDBUSDIALOGSTATICTEXT1, ID_ADDBUSDIALOGSTATICTEXT2, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
738 |
ID_ADDBUSDIALOGSTATICTEXT3, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
739 |
] = [wx.NewId() for _init_ctrls in range(7)] |
0 | 740 |
|
741 |
class AddBusDialog(wx.Dialog): |
|
742 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
743 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
744 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
745 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
746 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
747 |
parent.AddGrowableCol(0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
748 |
parent.AddGrowableRow(0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
749 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
750 |
def _init_coll_MainSizer_Items(self, parent): |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
751 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
752 |
parent.AddWindow(self.BusId, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
753 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
754 |
parent.AddWindow(self.BusType, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
755 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
756 |
parent.AddWindow(self.BusName, 0, border=0, flag=wx.GROW) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
757 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
758 |
def _init_coll_MainSizer_Growables(self, parent): |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
759 |
parent.AddGrowableCol(1) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
760 |
|
0 | 761 |
def _init_sizers(self): |
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
762 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
763 |
self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=3, vgap=15) |
0 | 764 |
|
765 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
766 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
767 |
self._init_coll_MainSizer_Items(self.MainSizer) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
768 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
0 | 769 |
|
770 |
self.SetSizer(self.flexGridSizer1) |
|
771 |
||
772 |
def _init_ctrls(self, prnt): |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
773 |
wx.Dialog.__init__(self, id=ID_ADDBUSDIALOG, |
0 | 774 |
name='PouDialog', parent=prnt, pos=wx.Point(376, 183), |
775 |
size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE, |
|
776 |
title='Create a new POU') |
|
777 |
self.SetClientSize(wx.Size(300, 200)) |
|
778 |
||
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
779 |
self.staticText1 = wx.StaticText(id=ID_ADDBUSDIALOGSTATICTEXT1, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
780 |
label='Bus ID:', name='staticText1', parent=self, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
781 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
782 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
783 |
self.BusId = wx.TextCtrl(id=ID_ADDBUSDIALOGBUSID, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
784 |
name='BusId', parent=self, pos=wx.Point(0, 0), |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
785 |
size=wx.Size(0, 24), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
786 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
787 |
self.staticText2 = wx.StaticText(id=ID_ADDBUSDIALOGSTATICTEXT2, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
788 |
label='Bus Type:', name='staticText2', parent=self, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
789 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
790 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
791 |
self.BusType = wx.Choice(id=ID_ADDBUSDIALOGBUSTYPE, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
792 |
name='BusType', parent=self, pos=wx.Point(0, 0), |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
793 |
size=wx.Size(0, 24), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
794 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
795 |
self.staticText3 = wx.StaticText(id=ID_ADDBUSDIALOGSTATICTEXT3, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
796 |
label='Bus Name:', name='staticText3', parent=self, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
797 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
798 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
799 |
self.BusName = wx.TextCtrl(id=ID_ADDBUSDIALOGBUSNAME, |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
800 |
name='BusName', parent=self, pos=wx.Point(0, 0), |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
801 |
size=wx.Size(0, 24), style=0) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
802 |
|
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
803 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
804 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
0 | 805 |
|
806 |
self._init_sizers() |
|
807 |
||
808 |
def __init__(self, parent): |
|
809 |
self._init_ctrls(parent) |
|
810 |
||
11 | 811 |
for option in [""] + plugins.__all__: |
0 | 812 |
self.BusType.Append(option) |
813 |
||
814 |
def OnOK(self, event): |
|
815 |
error = [] |
|
816 |
bus_id = self.BusId.GetValue() |
|
817 |
if bus_id == "": |
|
818 |
error.append("Bus ID") |
|
819 |
if self.BusType.GetStringSelection() == "": |
|
820 |
error.append("Bus Type") |
|
821 |
if self.BusName.GetValue() == "": |
|
822 |
error.append("Bus Name") |
|
823 |
if len(error) > 0: |
|
824 |
text = "" |
|
825 |
for i, item in enumerate(error): |
|
826 |
if i == 0: |
|
827 |
text += item |
|
828 |
elif i == len(error) - 1: |
|
829 |
text += " and %s"%item |
|
830 |
else: |
|
831 |
text += ", %s"%item |
|
832 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
833 |
message.ShowModal() |
|
834 |
message.Destroy() |
|
835 |
elif bus_id.startswith("0x"): |
|
836 |
try: |
|
837 |
bus_id = int(bus_id, 16) |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
838 |
self.EndModal(wx.ID_OK) |
0 | 839 |
except: |
840 |
message = wxMessageDialog(self, "Bus ID must be a decimal or hexadecimal number!", "Error", wxOK|wxICON_ERROR) |
|
841 |
message.ShowModal() |
|
842 |
message.Destroy() |
|
843 |
elif not bus_id.startswith("-"): |
|
844 |
try: |
|
845 |
bus_id = int(bus_id) |
|
4
e9d061c23e83
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
3
diff
changeset
|
846 |
self.EndModal(wx.ID_OK) |
0 | 847 |
except: |
848 |
message = wxMessageDialog(self, "Bus ID must be a decimal or hexadecimal number!", "Error", wxOK|wxICON_ERROR) |
|
849 |
message.ShowModal() |
|
850 |
message.Destroy() |
|
851 |
else: |
|
852 |
message = wxMessageDialog(self, "Bus Id must be greater than 0!", "Error", wxOK|wxICON_ERROR) |
|
853 |
message.ShowModal() |
|
854 |
message.Destroy() |
|
855 |
||
856 |
def SetValues(self, values): |
|
857 |
for item, value in values.items(): |
|
858 |
if item == "busID": |
|
859 |
self.BusID.SetValue(value) |
|
860 |
elif item == "busType": |
|
861 |
self.BusType.SetStringSelection(value) |
|
862 |
elif item == "busName": |
|
863 |
self.BusName.SetValue(value) |
|
864 |
||
865 |
def GetValues(self): |
|
866 |
values = {} |
|
867 |
values["busID"] = self.BusId.GetValue() |
|
868 |
values["busType"] = self.BusType.GetStringSelection() |
|
869 |
values["busName"] = self.BusName.GetValue() |
|
870 |
return values |
|
871 |
||
872 |
#------------------------------------------------------------------------------- |
|
873 |
# Exception Handler |
|
874 |
#------------------------------------------------------------------------------- |
|
875 |
||
876 |
Max_Traceback_List_Size = 20 |
|
877 |
||
878 |
def Display_Exception_Dialog(e_type,e_value,e_tb): |
|
879 |
trcbck_lst = [] |
|
880 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
|
881 |
trcbck = " " + str(i+1) + ". " |
|
882 |
if line[0].find(os.getcwd()) == -1: |
|
883 |
trcbck += "file : " + str(line[0]) + ", " |
|
884 |
else: |
|
885 |
trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
|
886 |
trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
|
887 |
trcbck_lst.append(trcbck) |
|
888 |
||
889 |
# Allow clicking.... |
|
890 |
cap = wx.Window_GetCapture() |
|
891 |
if cap: |
|
892 |
cap.ReleaseMouse() |
|
893 |
||
894 |
dlg = wx.SingleChoiceDialog(None, |
|
895 |
""" |
|
896 |
An error happens. |
|
897 |
||
898 |
Click on OK for saving an error report. |
|
899 |
||
900 |
Please contact LOLITech at: |
|
901 |
+33 (0)3 29 52 95 67 |
|
902 |
bugs_Beremiz@lolitech.fr |
|
903 |
||
904 |
||
905 |
Error: |
|
906 |
""" + |
|
907 |
str(e_type) + " : " + str(e_value), |
|
908 |
"Error", |
|
909 |
trcbck_lst) |
|
910 |
try: |
|
911 |
res = (dlg.ShowModal() == wx.ID_OK) |
|
912 |
finally: |
|
913 |
dlg.Destroy() |
|
914 |
||
915 |
return res |
|
916 |
||
917 |
def Display_Error_Dialog(e_value): |
|
918 |
message = wxMessageDialog(None, str(e_value), "Error", wxOK|wxICON_ERROR) |
|
919 |
message.ShowModal() |
|
920 |
message.Destroy() |
|
921 |
||
922 |
def get_last_traceback(tb): |
|
923 |
while tb.tb_next: |
|
924 |
tb = tb.tb_next |
|
925 |
return tb |
|
926 |
||
927 |
||
928 |
def format_namespace(d, indent=' '): |
|
929 |
return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
|
930 |
||
931 |
||
932 |
ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
|
933 |
||
5
9565bb5facf7
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
4
diff
changeset
|
934 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
0 | 935 |
|
936 |
def handle_exception(e_type, e_value, e_traceback): |
|
937 |
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
|
938 |
last_tb = get_last_traceback(e_traceback) |
|
939 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
|
940 |
if str(e_value).startswith("!!!"): |
|
941 |
Display_Error_Dialog(e_value) |
|
942 |
elif ex not in ignored_exceptions: |
|
943 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback) |
|
944 |
if result: |
|
945 |
ignored_exceptions.append(ex) |
|
946 |
info = { |
|
947 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
|
948 |
'app-version' : app_version, |
|
949 |
'wx-version' : wx.VERSION_STRING, |
|
950 |
'wx-platform' : wx.Platform, |
|
951 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
|
952 |
'platform' : platform.platform(), |
|
953 |
'e-type' : e_type, |
|
954 |
'e-value' : e_value, |
|
955 |
'date' : time.ctime(), |
|
956 |
'cwd' : os.getcwd(), |
|
957 |
} |
|
958 |
if e_traceback: |
|
959 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
|
960 |
last_tb = get_last_traceback(e_traceback) |
|
961 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
|
962 |
info['locals'] = format_namespace(exception_locals) |
|
963 |
if 'self' in exception_locals: |
|
964 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
|
965 |
||
966 |
output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w') |
|
967 |
lst = info.keys() |
|
968 |
lst.sort() |
|
969 |
for a in lst: |
|
970 |
output.write(a+":\n"+str(info[a])+"\n\n") |
|
971 |
||
972 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
|
973 |
sys.excepthook = handle_exception |
|
974 |
||
975 |
if __name__ == '__main__': |
|
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
976 |
def usage(): |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
977 |
print "\nUsage of Beremiz.py :" |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
978 |
print "\n %s [Projectpath]\n"%sys.argv[0] |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
979 |
|
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
980 |
try: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
981 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
982 |
except getopt.GetoptError: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
983 |
# print help information and exit: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
984 |
usage() |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
985 |
sys.exit(2) |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
986 |
|
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
987 |
for o, a in opts: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
988 |
if o in ("-h", "--help"): |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
989 |
usage() |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
990 |
sys.exit() |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
991 |
|
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
992 |
if len(args) > 1: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
993 |
usage() |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
994 |
sys.exit() |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
995 |
elif len(args) == 1: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
996 |
projectOpen = args[0] |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
997 |
else: |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
998 |
projectOpen = None |
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
999 |
|
5
9565bb5facf7
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
4
diff
changeset
|
1000 |
app = wx.PySimpleApp() |
9565bb5facf7
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
4
diff
changeset
|
1001 |
wx.InitAllImageHandlers() |
0 | 1002 |
|
1003 |
# Install a exception handle for bug reports |
|
5
9565bb5facf7
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
4
diff
changeset
|
1004 |
AddExceptHook(os.getcwd(),__version__) |
0 | 1005 |
|
13
f1f0edbeb313
More precise design for plugins.... to be continued...
etisserant
parents:
12
diff
changeset
|
1006 |
frame = Beremiz(None, projectOpen) |
0 | 1007 |
|
1008 |
frame.Show() |
|
1009 |
app.MainLoop() |