author | Laurent Bessard |
Wed, 01 Aug 2012 12:44:51 +0200 | |
changeset 737 | 85a4bc7dc31e |
parent 714 | 131ea7f237b9 |
child 757 | 628dd4762b57 |
permissions | -rw-r--r-- |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
2 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
3 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
4 |
#based on the plcopen standard. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
5 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
6 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
7 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
8 |
#See COPYING file for copyrights details. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
9 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
10 |
#This library is free software; you can redistribute it and/or |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
11 |
#modify it under the terms of the GNU General Public |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
12 |
#License as published by the Free Software Foundation; either |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
14 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
15 |
#This library is distributed in the hope that it will be useful, |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
18 |
#General Public License for more details. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
19 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
20 |
#You should have received a copy of the GNU General Public |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
21 |
#License along with this library; if not, write to the Free Software |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
23 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
24 |
import wx |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
25 |
import wx.grid |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
26 |
import wx.lib.buttons |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
27 |
|
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
577
diff
changeset
|
28 |
from controls import CustomGrid, CustomTable |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
29 |
from utils.BitmapLibrary import GetBitmap |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
30 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
31 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
32 |
# Helpers |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
33 |
#------------------------------------------------------------------------------- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
34 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
35 |
def GetActionTableColnames(): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
36 |
_ = lambda x: x |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
37 |
return [_("Qualifier"), _("Duration"), _("Type"), _("Value"), _("Indicator")] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
38 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
39 |
def GetTypeList(): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
40 |
_ = lambda x: x |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
41 |
return [_("Action"), _("Variable"), _("Inline")] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
42 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
43 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
44 |
# Action Table |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
45 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
46 |
|
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
577
diff
changeset
|
47 |
class ActionTable(CustomTable): |
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
577
diff
changeset
|
48 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
49 |
def GetValue(self, row, col): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
50 |
if row < self.GetNumberRows(): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
51 |
colname = self.GetColLabelValue(col, False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
52 |
name = str(self.data[row].get(colname, "")) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
53 |
if colname == "Type": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
54 |
return _(name) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
55 |
return name |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
56 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
57 |
def SetValue(self, row, col, value): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
58 |
if col < len(self.colnames): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
59 |
colname = self.GetColLabelValue(col, False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
60 |
if colname == "Type": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
61 |
value = self.Parent.TranslateType[value] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
62 |
self.data[row][colname] = value |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
63 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
64 |
def _updateColAttrs(self, grid): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
65 |
""" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
66 |
wx.Grid -> update the column attributes to add the |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
67 |
appropriate renderer given the column name. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
68 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
69 |
Otherwise default to the default renderer. |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
70 |
""" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
71 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
72 |
for row in range(self.GetNumberRows()): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
73 |
for col in range(self.GetNumberCols()): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
74 |
editor = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
75 |
renderer = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
76 |
readonly = False |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
77 |
colname = self.GetColLabelValue(col, False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
78 |
if colname == "Qualifier": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
79 |
editor = wx.grid.GridCellChoiceEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
80 |
editor.SetParameters(self.Parent.QualifierList) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
81 |
if colname == "Duration": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
82 |
editor = wx.grid.GridCellTextEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
83 |
renderer = wx.grid.GridCellStringRenderer() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
84 |
if self.Parent.DurationList[self.data[row]["Qualifier"]]: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
85 |
readonly = False |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
86 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
87 |
readonly = True |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
88 |
self.data[row]["Duration"] = "" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
89 |
elif colname == "Type": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
90 |
editor = wx.grid.GridCellChoiceEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
91 |
editor.SetParameters(self.Parent.TypeList) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
92 |
elif colname == "Value": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
93 |
type = self.data[row]["Type"] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
94 |
if type == "Action": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
95 |
editor = wx.grid.GridCellChoiceEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
96 |
editor.SetParameters(self.Parent.ActionList) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
97 |
elif type == "Variable": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
98 |
editor = wx.grid.GridCellChoiceEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
99 |
editor.SetParameters(self.Parent.VariableList) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
100 |
elif type == "Inline": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
101 |
editor = wx.grid.GridCellTextEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
102 |
renderer = wx.grid.GridCellStringRenderer() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
103 |
elif colname == "Indicator": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
104 |
editor = wx.grid.GridCellChoiceEditor() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
105 |
editor.SetParameters(self.Parent.VariableList) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
106 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
107 |
grid.SetCellEditor(row, col, editor) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
108 |
grid.SetCellRenderer(row, col, renderer) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
109 |
grid.SetReadOnly(row, col, readonly) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
110 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
111 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
604
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
577
diff
changeset
|
112 |
self.ResizeRow(grid, row) |
5b42b4401e6b
Adding support for unifying grid table control elements
laurent
parents:
577
diff
changeset
|
113 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
114 |
#------------------------------------------------------------------------------- |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
115 |
# Action Block Dialog |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
116 |
#------------------------------------------------------------------------------- |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
117 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
118 |
class ActionBlockDialog(wx.Dialog): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
119 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
120 |
def __init__(self, parent): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
121 |
wx.Dialog.__init__(self, parent, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
122 |
size=wx.Size(500, 300), title=_('Edit action block properties')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
123 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
124 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
125 |
main_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
126 |
main_sizer.AddGrowableRow(1) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
127 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
128 |
top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
129 |
top_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
130 |
top_sizer.AddGrowableRow(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
131 |
main_sizer.AddSizer(top_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
132 |
flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
133 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
134 |
actions_label = wx.StaticText(self, label=_('Actions:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
135 |
top_sizer.AddWindow(actions_label, flag=wx.ALIGN_BOTTOM) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
136 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
137 |
for name, bitmap, help in [ |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
138 |
("AddButton", "add_element", _("Add action")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
139 |
("DeleteButton", "remove_element", _("Remove action")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
140 |
("UpButton", "up", _("Move action up")), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
141 |
("DownButton", "down", _("Move action down"))]: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
142 |
button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
143 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
144 |
button.SetToolTipString(help) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
145 |
setattr(self, name, button) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
146 |
top_sizer.AddWindow(button) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
147 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
148 |
self.ActionsGrid = CustomGrid(self, style=wx.VSCROLL) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
149 |
self.ActionsGrid.DisableDragGridSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
150 |
self.ActionsGrid.EnableScrolling(False, True) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
151 |
self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
152 |
self.OnActionsGridCellChange) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
153 |
main_sizer.AddSizer(self.ActionsGrid, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
154 |
flag=wx.GROW|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
155 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
156 |
button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
157 |
self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
158 |
main_sizer.AddSizer(button_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
159 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
160 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
606
diff
changeset
|
161 |
self.SetSizer(main_sizer) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
162 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
163 |
self.Table = ActionTable(self, [], GetActionTableColnames()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
164 |
typelist = GetTypeList() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
165 |
self.TypeList = ",".join(map(_,typelist)) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
166 |
self.TranslateType = dict([(_(value), value) for value in typelist]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
167 |
self.ColSizes = [60, 90, 80, 110, 80] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
168 |
self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
169 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
170 |
self.ActionsGrid.SetTable(self.Table) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
171 |
self.ActionsGrid.SetDefaultValue({"Qualifier" : "N", |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
172 |
"Duration" : "", |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
173 |
"Type" : "Action", |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
174 |
"Value" : "", |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
175 |
"Indicator" : ""}) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
176 |
self.ActionsGrid.SetButtons({"Add": self.AddButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
177 |
"Delete": self.DeleteButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
178 |
"Up": self.UpButton, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
179 |
"Down": self.DownButton}) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
180 |
self.ActionsGrid.SetRowLabelSize(0) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
181 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
182 |
for col in range(self.Table.GetNumberCols()): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
183 |
attr = wx.grid.GridCellAttr() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
184 |
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
185 |
self.ActionsGrid.SetColAttr(col, attr) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
186 |
self.ActionsGrid.SetColMinimalWidth(col, self.ColSizes[col]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
187 |
self.ActionsGrid.AutoSizeColumn(col, False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
188 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
189 |
self.Table.ResetView(self.ActionsGrid) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
190 |
self.ActionsGrid.SetFocus() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
191 |
self.ActionsGrid.RefreshButtons() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
192 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
193 |
def OnOK(self, event): |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
194 |
self.ActionsGrid.CloseEditControl() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
195 |
self.EndModal(wx.ID_OK) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
196 |
|
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
197 |
def OnActionsGridCellChange(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
198 |
wx.CallAfter(self.Table.ResetView, self.ActionsGrid) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
199 |
event.Skip() |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
200 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
201 |
def SetQualifierList(self, list): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
202 |
self.QualifierList = "," + ",".join(list) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
203 |
self.DurationList = list |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
204 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
205 |
def SetVariableList(self, list): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
206 |
self.VariableList = "," + ",".join([variable["Name"] for variable in list]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
207 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
208 |
def SetActionList(self, list): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
209 |
self.ActionList = "," + ",".join(list) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
210 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
211 |
def SetValues(self, actions): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
212 |
for action in actions: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
213 |
row = {"Qualifier" : action["qualifier"], "Value" : action["value"]} |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
214 |
if action["type"] == "reference": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
215 |
if action["value"] in self.ActionList: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
216 |
row["Type"] = "Action" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
217 |
elif action["value"] in self.VariableList: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
218 |
row["Type"] = "Variable" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
219 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
220 |
row["Type"] = "Inline" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
221 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
222 |
row["Type"] = "Inline" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
223 |
if "duration" in action: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
224 |
row["Duration"] = action["duration"] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
225 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
226 |
row["Duration"] = "" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
227 |
if "indicator" in action: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
228 |
row["Indicator"] = action["indicator"] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
229 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
230 |
row["Indicator"] = "" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
231 |
self.Table.AppendRow(row) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
232 |
self.Table.ResetView(self.ActionsGrid) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
233 |
if len(actions) > 0: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
234 |
self.ActionsGrid.SetGridCursor(0, 0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
235 |
self.ActionsGrid.RefreshButtons() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
236 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
237 |
def GetValues(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
238 |
values = [] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
239 |
for data in self.Table.GetData(): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
240 |
action = {"qualifier" : data["Qualifier"], "value" : data["Value"]} |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
241 |
if data["Type"] in ["Action", "Variable"]: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
242 |
action["type"] = "reference" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
243 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
244 |
action["type"] = "inline" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
245 |
if data["Duration"] != "": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
246 |
action["duration"] = data["Duration"] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
247 |
if data["Indicator"] != "": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
248 |
action["indicator"] = data["Indicator"] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
249 |
values.append(action) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
250 |
return values |