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