author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 17 Aug 2017 10:04:24 +0300 | |
changeset 1759 | 56e7f4a11046 |
parent 1758 | 845ca626db09 |
child 1768 | 691083b5682a |
permissions | -rw-r--r-- |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
1 |
#!/usr/bin/env python |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
3 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
6 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1562
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
9 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
11 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
12 |
# This program is free software; you can redistribute it and/or |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
13 |
# modify it under the terms of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
14 |
# as published by the Free Software Foundation; either version 2 |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
16 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
17 |
# This program is distributed in the hope that it will be useful, |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
20 |
# GNU General Public License for more details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
21 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
23 |
# along with this program; if not, write to the Free Software |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1451
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
738 | 25 |
|
26 |
import os |
|
27 |
import types |
|
28 |
||
29 |
import wx |
|
30 |
||
814 | 31 |
from EditorPanel import EditorPanel |
32 |
||
33 |
from IDEFrame import TITLE, FILEMENU, PROJECTTREE, PAGETITLES |
|
34 |
||
35 |
from controls import TextCtrlAutoComplete |
|
36 |
from dialogs import BrowseValuesLibraryDialog |
|
37 |
from util.BitmapLibrary import GetBitmap |
|
738 | 38 |
|
39 |
if wx.Platform == '__WXMSW__': |
|
1747
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
40 |
faces = { |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
41 |
'times': 'Times New Roman', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
42 |
'mono': 'Courier New', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
43 |
'helv': 'Arial', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
44 |
'other': 'Comic Sans MS', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
45 |
'size': 16, |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
46 |
} |
738 | 47 |
else: |
1747
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
48 |
faces = { |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
49 |
'times': 'Times', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
50 |
'mono': 'Courier', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
51 |
'helv': 'Helvetica', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
52 |
'other': 'new century schoolbook', |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
53 |
'size': 18, |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
54 |
} |
738 | 55 |
|
56 |
SCROLLBAR_UNIT = 10 |
|
57 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
58 |
|
738 | 59 |
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton): |
60 |
def _GetLabelSize(self): |
|
61 |
""" used internally """ |
|
62 |
w, h = self.GetTextExtent(self.GetLabel()) |
|
63 |
if not self.bmpLabel: |
|
64 |
return w, h, False # if there isn't a bitmap use the size of the text |
|
65 |
||
66 |
w_bmp = self.bmpLabel.GetWidth()+2 |
|
67 |
h_bmp = self.bmpLabel.GetHeight()+2 |
|
68 |
height = h + h_bmp |
|
69 |
if w_bmp > w: |
|
70 |
width = w_bmp |
|
71 |
else: |
|
72 |
width = w |
|
73 |
return width, height, False |
|
74 |
||
75 |
def DrawLabel(self, dc, width, height, dw=0, dy=0): |
|
76 |
bmp = self.bmpLabel |
|
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
77 |
if bmp is not None: # if the bitmap is used |
738 | 78 |
if self.bmpDisabled and not self.IsEnabled(): |
79 |
bmp = self.bmpDisabled |
|
80 |
if self.bmpFocus and self.hasFocus: |
|
81 |
bmp = self.bmpFocus |
|
82 |
if self.bmpSelected and not self.up: |
|
83 |
bmp = self.bmpSelected |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
84 |
bw, bh = bmp.GetWidth(), bmp.GetHeight() |
738 | 85 |
if not self.up: |
86 |
dw = dy = self.labelDelta |
|
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
87 |
hasMask = bmp.GetMask() is not None |
738 | 88 |
else: |
89 |
bw = bh = 0 # no bitmap -> size is zero |
|
90 |
||
91 |
dc.SetFont(self.GetFont()) |
|
92 |
if self.IsEnabled(): |
|
93 |
dc.SetTextForeground(self.GetForegroundColour()) |
|
94 |
else: |
|
95 |
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) |
|
96 |
||
97 |
label = self.GetLabel() |
|
98 |
tw, th = dc.GetTextExtent(label) # size of text |
|
99 |
if not self.up: |
|
100 |
dw = dy = self.labelDelta |
|
101 |
||
102 |
pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
|
103 |
pos_y = (height-bh-th)/2+dy |
|
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
104 |
if bmp is not None: |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
105 |
dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
738 | 106 |
pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre |
107 |
pos_y += bh + 2 |
|
108 |
||
109 |
dc.DrawText(label, pos_x, pos_y) # draw the text |
|
110 |
||
111 |
||
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
112 |
class GenStaticBitmap(wx.StaticBitmap): |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
113 |
""" Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
738 | 114 |
and accept image name as __init__ parameter, fail silently if file do not exist""" |
115 |
def __init__(self, parent, ID, bitmapname, |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
116 |
pos=wx.DefaultPosition, size=wx.DefaultSize, |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
117 |
style=0, |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
118 |
name="genstatbmp"): |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
119 |
|
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
120 |
bitmap = GetBitmap(bitmapname) |
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
121 |
if bitmap is None: |
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
122 |
bitmap = wx.EmptyBitmap(0, 0) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
123 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
124 |
wx.StaticBitmap.__init__(self, parent, ID, |
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
125 |
bitmap, |
738 | 126 |
pos, size, |
127 |
style, |
|
128 |
name) |
|
129 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
130 |
|
738 | 131 |
class ConfTreeNodeEditor(EditorPanel): |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
132 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
133 |
SHOW_BASE_PARAMS = True |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
134 |
SHOW_PARAMS = True |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
135 |
CONFNODEEDITOR_TABS = [] |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
136 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
137 |
def _init_Editor(self, parent): |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
138 |
tabs_num = len(self.CONFNODEEDITOR_TABS) |
1055 | 139 |
if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0: |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
140 |
tabs_num += 1 |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
141 |
|
1055 | 142 |
if tabs_num > 1 or self.SHOW_BASE_PARAMS: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
143 |
self.Editor = wx.Panel(parent, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
144 |
style=wx.SUNKEN_BORDER | wx.SP_3D) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
145 |
|
1055 | 146 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
147 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
148 |
if self.SHOW_BASE_PARAMS: |
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
149 |
baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
150 |
self.MainSizer.AddSizer(baseparamseditor_sizer, border=5, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
151 |
flag=wx.GROW | wx.ALL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
152 |
|
1055 | 153 |
self.FullIECChannel = wx.StaticText(self.Editor, -1) |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
154 |
self.FullIECChannel.SetFont( |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
155 |
wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
156 |
wx.BOLD, faceName=faces["helv"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
157 |
baseparamseditor_sizer.AddWindow(self.FullIECChannel, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
158 |
flag=wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
159 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
160 |
updownsizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
161 |
baseparamseditor_sizer.AddSizer(updownsizer, border=5, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
162 |
flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
163 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
164 |
self.IECCUpButton = wx.lib.buttons.GenBitmapTextButton(self.Editor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
165 |
bitmap=GetBitmap('IECCDown'), size=wx.Size(16, 16), style=wx.NO_BORDER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
166 |
self.IECCUpButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(1), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
167 |
self.IECCUpButton) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
168 |
updownsizer.AddWindow(self.IECCUpButton, flag=wx.ALIGN_LEFT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
169 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
170 |
self.IECCDownButton = wx.lib.buttons.GenBitmapButton(self.Editor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
171 |
bitmap=GetBitmap('IECCUp'), size=wx.Size(16, 16), style=wx.NO_BORDER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
172 |
self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
173 |
self.IECCDownButton) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
174 |
updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
175 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
176 |
self.ConfNodeName = wx.TextCtrl(self.Editor, |
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
177 |
size=wx.Size(150, 25)) |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
178 |
self.ConfNodeName.SetFont( |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
179 |
wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
180 |
wx.BOLD, faceName=faces["helv"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
181 |
self.ConfNodeName.Bind(wx.EVT_TEXT, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
182 |
self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
183 |
self.ConfNodeName) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
184 |
baseparamseditor_sizer.AddWindow(self.ConfNodeName, border=5, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
185 |
flag=wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
186 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
187 |
buttons_sizer = self.GenerateMethodButtonSizer() |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
188 |
baseparamseditor_sizer.AddSizer(buttons_sizer, flag=wx.ALIGN_CENTER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
189 |
|
1055 | 190 |
if tabs_num > 1: |
191 |
self.ConfNodeNoteBook = wx.Notebook(self.Editor) |
|
192 |
parent = self.ConfNodeNoteBook |
|
193 |
self.MainSizer.AddWindow(self.ConfNodeNoteBook, 1, flag=wx.GROW) |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
194 |
else: |
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
195 |
parent = self.Editor |
1055 | 196 |
self.ConfNodeNoteBook = None |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
197 |
|
1055 | 198 |
self.Editor.SetSizer(self.MainSizer) |
199 |
else: |
|
200 |
self.ConfNodeNoteBook = None |
|
201 |
self.Editor = None |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
202 |
|
1055 | 203 |
for title, create_func_name in self.CONFNODEEDITOR_TABS: |
204 |
editor = getattr(self, create_func_name)(parent) |
|
205 |
if self.ConfNodeNoteBook is not None: |
|
206 |
self.ConfNodeNoteBook.AddPage(editor, title) |
|
207 |
elif self.SHOW_BASE_PARAMS: |
|
208 |
self.MainSizer.AddWindow(editor, 1, flag=wx.GROW) |
|
209 |
else: |
|
210 |
self.Editor = editor |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
211 |
|
1055 | 212 |
if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
213 |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
214 |
panel_style = wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL |
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
215 |
if self.ConfNodeNoteBook is None and parent != self.Editor: |
1055 | 216 |
panel_style |= wx.SUNKEN_BORDER |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
217 |
self.ParamsEditor = wx.ScrolledWindow(parent, |
1055 | 218 |
style=panel_style) |
1180 | 219 |
self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnParamsEditorResize) |
220 |
self.ParamsEditor.Bind(wx.EVT_SCROLLWIN, self.OnParamsEditorScroll) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
221 |
|
1055 | 222 |
self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5) |
223 |
self.ParamsEditorSizer.AddGrowableCol(0) |
|
224 |
self.ParamsEditorSizer.AddGrowableRow(0) |
|
225 |
self.ParamsEditor.SetSizer(self.ParamsEditorSizer) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
226 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
227 |
self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
228 |
self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, border=5, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
229 |
flag=wx.LEFT | wx.RIGHT | wx.BOTTOM) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
230 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
231 |
self.RefreshConfNodeParamsSizer() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
232 |
|
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
233 |
if self.ConfNodeNoteBook is not None: |
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
234 |
self.ConfNodeNoteBook.AddPage(self.ParamsEditor, _("Config")) |
1055 | 235 |
elif self.SHOW_BASE_PARAMS: |
236 |
self.MainSizer.AddWindow(self.ParamsEditor, 1, flag=wx.GROW) |
|
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
237 |
else: |
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
238 |
self.Editor = self.ParamsEditor |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
239 |
else: |
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
240 |
self.ParamsEditor = None |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
241 |
|
743 | 242 |
def __init__(self, parent, controler, window, tagname=""): |
738 | 243 |
EditorPanel.__init__(self, parent, tagname, window, controler) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
244 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
245 |
icon_name = self.Controler.GetIconName() |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
246 |
if icon_name is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
247 |
self.SetIcon(GetBitmap(icon_name)) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
248 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
249 |
self.SetIcon(GetBitmap("Extension")) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
250 |
|
738 | 251 |
def __del__(self): |
252 |
self.Controler.OnCloseEditor(self) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
253 |
|
738 | 254 |
def GetTagName(self): |
255 |
return self.Controler.CTNFullName() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
256 |
|
738 | 257 |
def GetTitle(self): |
258 |
fullname = self.Controler.CTNFullName() |
|
259 |
if self.Controler.CTNTestModified(): |
|
260 |
return "~%s~" % fullname |
|
261 |
return fullname |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
262 |
|
738 | 263 |
def HasNoModel(self): |
264 |
return False |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
265 |
|
743 | 266 |
def GetBufferState(self): |
267 |
return False, False |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
268 |
|
743 | 269 |
def Undo(self): |
270 |
pass |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
271 |
|
743 | 272 |
def Redo(self): |
273 |
pass |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
274 |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
275 |
def RefreshView(self): |
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
276 |
EditorPanel.RefreshView(self) |
1055 | 277 |
if self.SHOW_BASE_PARAMS: |
278 |
self.ConfNodeName.ChangeValue(self.Controler.MandatoryParams[1].getName()) |
|
279 |
self.RefreshIECChannelControlsState() |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
280 |
if self.ParamsEditor is not None: |
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
281 |
self.RefreshConfNodeParamsSizer() |
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
282 |
self.RefreshScrollbars() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
283 |
|
738 | 284 |
def RefreshIECChannelControlsState(self): |
285 |
self.FullIECChannel.SetLabel(self.Controler.GetFullIEC_Channel()) |
|
286 |
self.IECCDownButton.Enable(self.Controler.BaseParams.getIEC_Channel() > 0) |
|
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
287 |
self.MainSizer.Layout() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
288 |
|
738 | 289 |
def RefreshConfNodeParamsSizer(self): |
290 |
self.Freeze() |
|
291 |
self.ConfNodeParamsSizer.Clear(True) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
292 |
|
738 | 293 |
confnode_infos = self.Controler.GetParamsAttributes() |
294 |
if len(confnode_infos) > 0: |
|
295 |
self.GenerateSizerElements(self.ConfNodeParamsSizer, confnode_infos, None, False) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
296 |
|
738 | 297 |
self.ParamsEditorSizer.Layout() |
298 |
self.Thaw() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
299 |
|
738 | 300 |
def GenerateMethodButtonSizer(self): |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
301 |
normal_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
302 |
mouseover_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
303 |
|
738 | 304 |
msizer = wx.BoxSizer(wx.HORIZONTAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
305 |
|
738 | 306 |
for confnode_method in self.Controler.ConfNodeMethods: |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
307 |
if "method" in confnode_method and confnode_method.get("shown", True): |
1055 | 308 |
button = GenBitmapTextButton(self.Editor, |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
309 |
bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
310 |
label=confnode_method["name"], style=wx.NO_BORDER) |
738 | 311 |
button.SetFont(normal_bt_font) |
312 |
button.SetToolTipString(confnode_method["tooltip"]) |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
313 |
if confnode_method.get("push", False): |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
314 |
button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True)) |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
315 |
else: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
316 |
button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button) |
738 | 317 |
# a fancy underline on mouseover |
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1748
diff
changeset
|
318 |
|
738 | 319 |
def setFontStyle(b, s): |
320 |
def fn(event): |
|
321 |
b.SetFont(s) |
|
322 |
b.Refresh() |
|
323 |
event.Skip() |
|
324 |
return fn |
|
325 |
button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) |
|
326 |
button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) |
|
1733
dea107dce0c4
clean-up: fix some PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1712
diff
changeset
|
327 |
# hack to force size to mini |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
328 |
if not confnode_method.get("enabled", True): |
738 | 329 |
button.Disable() |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
330 |
msizer.AddWindow(button, flag=wx.ALIGN_CENTER) |
738 | 331 |
return msizer |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
332 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
333 |
def GenerateSizerElements(self, sizer, elements, path, clean=True): |
738 | 334 |
if clean: |
335 |
sizer.Clear(True) |
|
336 |
first = True |
|
337 |
for element_infos in elements: |
|
338 |
if path: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
339 |
element_path = "%s.%s" % (path, element_infos["name"]) |
738 | 340 |
else: |
341 |
element_path = element_infos["name"] |
|
342 |
if element_infos["type"] == "element": |
|
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
343 |
name = element_infos["name"] |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
344 |
value = element_infos["value"] |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
345 |
label = _(name) |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
346 |
if value is not None: |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
347 |
label += " - %s" % _(value) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
348 |
staticbox = wx.StaticBox(self.ParamsEditor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
349 |
label=_(label), size=wx.Size(10, 0)) |
738 | 350 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
351 |
flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
738 | 352 |
if first: |
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
353 |
flags |= wx.TOP |
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
354 |
sizer.AddSizer(staticboxsizer, border=5, flag=flags) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
355 |
self.GenerateSizerElements(staticboxsizer, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
356 |
element_infos["children"], |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
357 |
element_path) |
738 | 358 |
else: |
359 |
boxsizer = wx.FlexGridSizer(cols=3, rows=1) |
|
360 |
boxsizer.AddGrowableCol(1) |
|
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
361 |
flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
738 | 362 |
if first: |
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
363 |
flags |= wx.TOP |
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
364 |
sizer.AddSizer(boxsizer, border=5, flag=flags) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
365 |
staticbitmap = GenStaticBitmap(ID=-1, bitmapname=element_infos["name"], |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
366 |
name="%s_bitmap" % element_infos["name"], parent=self.ParamsEditor, |
738 | 367 |
pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
368 |
boxsizer.AddWindow(staticbitmap, border=5, flag=wx.RIGHT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
369 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
370 |
statictext = wx.StaticText(self.ParamsEditor, |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
371 |
label="%s:" % _(element_infos["name"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
372 |
boxsizer.AddWindow(statictext, border=5, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
373 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
374 |
|
738 | 375 |
if isinstance(element_infos["type"], types.ListType): |
376 |
if isinstance(element_infos["value"], types.TupleType): |
|
377 |
browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
378 |
boxsizer.AddSizer(browse_boxsizer) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
379 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
380 |
textctrl = wx.TextCtrl(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
381 |
size=wx.Size(275, -1), style=wx.TE_READONLY) |
738 | 382 |
if element_infos["value"] is not None: |
383 |
textctrl.SetValue(element_infos["value"][0]) |
|
384 |
value_infos = element_infos["value"][1] |
|
385 |
else: |
|
386 |
value_infos = None |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
387 |
browse_boxsizer.AddWindow(textctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
388 |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1562
diff
changeset
|
389 |
button = wx.Button(self.ParamsEditor, label="...") |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
390 |
browse_boxsizer.AddWindow(button) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
391 |
button.Bind(wx.EVT_BUTTON, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
392 |
self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"], |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
393 |
value_infos, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
394 |
button) |
738 | 395 |
else: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
396 |
combobox = wx.ComboBox(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
397 |
size=wx.Size(300, -1), style=wx.CB_READONLY) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
398 |
boxsizer.AddWindow(combobox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
399 |
|
738 | 400 |
if element_infos["use"] == "optional": |
401 |
combobox.Append("") |
|
402 |
if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
|
403 |
for choice, xsdclass in element_infos["type"]: |
|
404 |
combobox.Append(choice) |
|
405 |
name = element_infos["name"] |
|
406 |
value = element_infos["value"] |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
407 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
408 |
staticbox = wx.StaticBox(self.ParamsEditor, |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
409 |
label="%s - %s" % (_(name), _(value)), size=wx.Size(10, 0)) |
738 | 410 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
411 |
sizer.AddSizer(staticboxsizer, border=5, flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
738 | 412 |
self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path) |
413 |
callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, element_path) |
|
414 |
else: |
|
415 |
for choice in element_infos["type"]: |
|
416 |
combobox.Append(choice) |
|
417 |
callback = self.GetChoiceCallBackFunction(combobox, element_path) |
|
418 |
if element_infos["value"] is None: |
|
419 |
combobox.SetStringSelection("") |
|
420 |
else: |
|
1712
c1987ef148e4
Backout changeset 92537edeb2052d53ba5cad8b6da8463dbc660bb1
Surkov Sergey <surkovsv93@gmail.com>
parents:
1707
diff
changeset
|
421 |
combobox.SetStringSelection(element_infos["value"]) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
422 |
combobox.Bind(wx.EVT_COMBOBOX, callback, combobox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
423 |
|
738 | 424 |
elif isinstance(element_infos["type"], types.DictType): |
425 |
scmin = -(2**31) |
|
426 |
scmax = 2**31-1 |
|
427 |
if "min" in element_infos["type"]: |
|
428 |
scmin = element_infos["type"]["min"] |
|
429 |
if "max" in element_infos["type"]: |
|
430 |
scmax = element_infos["type"]["max"] |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
431 |
spinctrl = wx.SpinCtrl(self.ParamsEditor, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
432 |
size=wx.Size(300, -1), style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
433 |
spinctrl.SetRange(scmin, scmax) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
434 |
boxsizer.AddWindow(spinctrl) |
738 | 435 |
if element_infos["value"] is not None: |
436 |
spinctrl.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
437 |
spinctrl.Bind(wx.EVT_SPINCTRL, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
438 |
self.GetTextCtrlCallBackFunction(spinctrl, element_path), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
439 |
spinctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
440 |
|
738 | 441 |
else: |
442 |
if element_infos["type"] == "boolean": |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
443 |
checkbox = wx.CheckBox(self.ParamsEditor, size=wx.Size(17, 25)) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
444 |
boxsizer.AddWindow(checkbox) |
738 | 445 |
if element_infos["value"] is not None: |
446 |
checkbox.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
447 |
checkbox.Bind(wx.EVT_CHECKBOX, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
448 |
self.GetCheckBoxCallBackFunction(checkbox, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
449 |
checkbox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
450 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
451 |
elif element_infos["type"] in ["unsignedLong", "long", "integer"]: |
738 | 452 |
if element_infos["type"].startswith("unsigned"): |
453 |
scmin = 0 |
|
454 |
else: |
|
455 |
scmin = -(2**31) |
|
456 |
scmax = 2**31-1 |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
457 |
spinctrl = wx.SpinCtrl(self.ParamsEditor, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
458 |
size=wx.Size(300, -1), style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT) |
738 | 459 |
spinctrl.SetRange(scmin, scmax) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
460 |
boxsizer.AddWindow(spinctrl) |
738 | 461 |
if element_infos["value"] is not None: |
462 |
spinctrl.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
463 |
spinctrl.Bind(wx.EVT_SPINCTRL, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
464 |
self.GetTextCtrlCallBackFunction(spinctrl, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
465 |
spinctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
466 |
|
738 | 467 |
else: |
468 |
choices = self.ParentWindow.GetConfigEntry(element_path, [""]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
469 |
textctrl = TextCtrlAutoComplete(name=element_infos["name"], |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
470 |
parent=self.ParamsEditor, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
471 |
choices=choices, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
472 |
element_path=element_path, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
473 |
size=wx.Size(300, -1)) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
474 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
475 |
boxsizer.AddWindow(textctrl) |
738 | 476 |
if element_infos["value"] is not None: |
477 |
textctrl.ChangeValue(str(element_infos["value"])) |
|
1180 | 478 |
callback = self.GetTextCtrlCallBackFunction(textctrl, element_path) |
479 |
textctrl.Bind(wx.EVT_TEXT_ENTER, callback) |
|
480 |
textctrl.Bind(wx.EVT_KILL_FOCUS, callback) |
|
738 | 481 |
first = False |
1562
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
482 |
sizer.Layout() |
6e38f13d4b7b
fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents:
1511
diff
changeset
|
483 |
self.RefreshScrollbars() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
484 |
|
738 | 485 |
def GetItemChannelChangedFunction(self, dir): |
486 |
def OnConfNodeTreeItemChannelChanged(event): |
|
487 |
confnode_IECChannel = self.Controler.BaseParams.getIEC_Channel() |
|
488 |
res = self.SetConfNodeParamsAttribute("BaseParams.IEC_Channel", confnode_IECChannel + dir) |
|
489 |
wx.CallAfter(self.RefreshIECChannelControlsState) |
|
490 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE) |
|
491 |
event.Skip() |
|
492 |
return OnConfNodeTreeItemChannelChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
493 |
|
738 | 494 |
def SetConfNodeParamsAttribute(self, *args, **kwargs): |
495 |
res, StructChanged = self.Controler.SetParamsAttribute(*args, **kwargs) |
|
1111
ee1a8c961f11
Fixed bug when changing IEC_Channel of node without params
Laurent Bessard
parents:
1105
diff
changeset
|
496 |
if StructChanged and self.ParamsEditor is not None: |
738 | 497 |
wx.CallAfter(self.RefreshConfNodeParamsSizer) |
498 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU) |
|
499 |
return res |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
500 |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
501 |
def GetButtonCallBackFunction(self, method, push=False): |
738 | 502 |
""" Generate the callbackfunc for a given confnode method""" |
503 |
def OnButtonClick(event): |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
504 |
# Disable button to prevent re-entrant call |
738 | 505 |
event.GetEventObject().Disable() |
506 |
# Call |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
507 |
getattr(self.Controler, method)() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
508 |
# Re-enable button |
738 | 509 |
event.GetEventObject().Enable() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
510 |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
511 |
if not push: |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
512 |
event.Skip() |
738 | 513 |
return OnButtonClick |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
514 |
|
738 | 515 |
def GetChoiceCallBackFunction(self, choicectrl, path): |
516 |
def OnChoiceChanged(event): |
|
517 |
res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1282
diff
changeset
|
518 |
if res is None: |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1282
diff
changeset
|
519 |
res = "" |
738 | 520 |
choicectrl.SetStringSelection(res) |
521 |
event.Skip() |
|
522 |
return OnChoiceChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
523 |
|
738 | 524 |
def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path): |
525 |
def OnChoiceContentChanged(event): |
|
526 |
res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
527 |
wx.CallAfter(self.RefreshConfNodeParamsSizer) |
738 | 528 |
event.Skip() |
529 |
return OnChoiceContentChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
530 |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
531 |
def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False): |
738 | 532 |
def OnTextCtrlChanged(event): |
533 |
res = self.SetConfNodeParamsAttribute(path, textctrl.GetValue()) |
|
534 |
if res != textctrl.GetValue(): |
|
844
ec9e6ef49878
Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents:
840
diff
changeset
|
535 |
if isinstance(textctrl, wx.SpinCtrl): |
ec9e6ef49878
Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents:
840
diff
changeset
|
536 |
textctrl.SetValue(res) |
1179
3e7bd88fcff7
Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents:
1162
diff
changeset
|
537 |
elif res is not None: |
3e7bd88fcff7
Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents:
1162
diff
changeset
|
538 |
textctrl.ChangeValue(str(res)) |
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
539 |
if refresh: |
738 | 540 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES) |
541 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName()) |
|
542 |
event.Skip() |
|
543 |
return OnTextCtrlChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
544 |
|
738 | 545 |
def GetCheckBoxCallBackFunction(self, chkbx, path): |
546 |
def OnCheckBoxChanged(event): |
|
547 |
res = self.SetConfNodeParamsAttribute(path, chkbx.IsChecked()) |
|
548 |
chkbx.SetValue(res) |
|
549 |
event.Skip() |
|
550 |
return OnCheckBoxChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
551 |
|
738 | 552 |
def GetBrowseCallBackFunction(self, name, textctrl, library, value_infos, path): |
553 |
infos = [value_infos] |
|
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1748
diff
changeset
|
554 |
|
738 | 555 |
def OnBrowseButton(event): |
556 |
dialog = BrowseValuesLibraryDialog(self, name, library, infos[0]) |
|
557 |
if dialog.ShowModal() == wx.ID_OK: |
|
558 |
value, value_infos = self.SetConfNodeParamsAttribute(path, dialog.GetValueInfos()) |
|
559 |
textctrl.ChangeValue(value) |
|
560 |
infos[0] = value_infos |
|
561 |
dialog.Destroy() |
|
562 |
event.Skip() |
|
563 |
return OnBrowseButton |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
564 |
|
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
565 |
def RefreshScrollbars(self): |
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
566 |
self.ParamsEditor.GetBestSize() |
738 | 567 |
xstart, ystart = self.ParamsEditor.GetViewStart() |
568 |
window_size = self.ParamsEditor.GetClientSize() |
|
569 |
maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
|
570 |
posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
|
571 |
posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
|
572 |
self.ParamsEditor.Scroll(posx, posy) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
573 |
self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
738 | 574 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
575 |
|
1180 | 576 |
def OnParamsEditorResize(self, event): |
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
577 |
self.RefreshScrollbars() |
738 | 578 |
event.Skip() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
579 |
|
1180 | 580 |
def OnParamsEditorScroll(self, event): |
581 |
control = self.ParamsEditor.FindFocus() |
|
582 |
if isinstance(control, TextCtrlAutoComplete): |
|
583 |
control.DismissListBox() |
|
584 |
self.Refresh() |
|
585 |
event.Skip() |