author | Laurent Bessard |
Mon, 25 Jun 2012 23:10:49 +0200 | |
changeset 715 | 6a3792a6bf7b |
parent 714 | 131ea7f237b9 |
child 718 | 0183a66eddf9 |
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 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
26 |
from graphics import * |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
27 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
28 |
#------------------------------------------------------------------------------- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
29 |
# Edit Step Content Dialog |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
30 |
#------------------------------------------------------------------------------- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
31 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
32 |
class SFCStepDialog(wx.Dialog): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
33 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
34 |
def __init__(self, parent, controller, initial = False): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
35 |
wx.Dialog.__init__(self, parent, title=_('Edit Step'), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
36 |
size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
37 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
38 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
39 |
main_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
40 |
main_sizer.AddGrowableRow(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
41 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
42 |
column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
43 |
main_sizer.AddSizer(column_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
44 |
flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
45 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
46 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
47 |
left_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
48 |
column_sizer.AddSizer(left_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
49 |
flag=wx.GROW|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
50 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
51 |
name_label = wx.StaticText(self, label=_('Name:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
52 |
left_gridsizer.AddWindow(name_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
53 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
54 |
self.StepName = wx.TextCtrl(self) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
55 |
self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.StepName) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
56 |
left_gridsizer.AddWindow(self.StepName, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
57 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
58 |
connectors_label = wx.StaticText(self, label=_('Connectors:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
59 |
left_gridsizer.AddWindow(connectors_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
60 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
61 |
self.Input = wx.CheckBox(self, label=_("Input")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
62 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Input) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
63 |
left_gridsizer.AddWindow(self.Input, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
64 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
65 |
self.Output = wx.CheckBox(self, label=_("Output")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
66 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Output) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
67 |
left_gridsizer.AddWindow(self.Output, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
68 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
69 |
self.Action = wx.CheckBox(self, label=_("Action")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
70 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Action) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
71 |
left_gridsizer.AddWindow(self.Action, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
72 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
73 |
right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
74 |
right_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
75 |
right_gridsizer.AddGrowableRow(1) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
76 |
column_sizer.AddSizer(right_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
77 |
flag=wx.GROW|wx.LEFT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
78 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
79 |
preview_label = wx.StaticText(self, label=_('Preview:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
80 |
right_gridsizer.AddWindow(preview_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
81 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
82 |
self.Preview = wx.Panel(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
83 |
style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
84 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
85 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
86 |
setattr(self.Preview, "RefreshStepModel", lambda x:None) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
87 |
setattr(self.Preview, "GetScaling", lambda:None) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
88 |
setattr(self.Preview, "IsOfType", controller.IsOfType) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
89 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
90 |
right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
91 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
92 |
button_sizer = self.CreateButtonSizer( |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
93 |
wx.OK|wx.CANCEL|wx.CENTRE) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
94 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
95 |
button_sizer.GetAffirmativeButton()) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
96 |
main_sizer.AddSizer(button_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
97 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
98 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
99 |
self.SetSizer(main_sizer) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
100 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
101 |
self.Step = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
102 |
self.Initial = initial |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
103 |
self.MinStepSize = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
104 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
105 |
self.PouNames = [] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
106 |
self.Variables = [] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
107 |
self.StepNames = [] |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
108 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
109 |
self.StepName.SetFocus() |
409
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 |
def SetPreviewFont(self, font): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
112 |
self.Preview.SetFont(font) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
113 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
114 |
def OnOK(self, event): |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
115 |
message = None |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
116 |
step_name = self.StepName.GetValue() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
117 |
if step_name == "": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
118 |
message = _("You must type a name!") |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
119 |
elif not TestIdentifier(step_name): |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
120 |
message = _("\"%s\" is not a valid identifier!") % step_name |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
121 |
elif step_name.upper() in IEC_KEYWORDS: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
122 |
message = _("\"%s\" is a keyword. It can't be used!") % step_name |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
123 |
elif step_name.upper() in self.PouNames: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
124 |
message = _("A POU named \"%s\" already exists!") % step_name |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
125 |
elif step_name.upper() in self.Variables: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
126 |
message = _("A variable with \"%s\" as name already exists in this pou!") % step_name |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
127 |
elif step_name.upper() in self.StepNames: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
128 |
message = _("\"%s\" step already exists!") % step_name |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
129 |
if message is not None: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
130 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
131 |
dialog.ShowModal() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
132 |
dialog.Destroy() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
133 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
134 |
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
|
135 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
136 |
def SetMinStepSize(self, size): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
137 |
self.MinStepSize = size |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
138 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
139 |
def SetPouNames(self, pou_names): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
140 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
141 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
142 |
def SetVariables(self, variables): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
143 |
self.Variables = [var["Name"].upper() for var in variables] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
144 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
145 |
def SetStepNames(self, step_names): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
146 |
self.StepNames = [step_name.upper() for step_name in step_names] |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
147 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
148 |
def SetValues(self, values): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
149 |
value_name = values.get("name", None) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
150 |
if value_name: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
151 |
self.StepName.SetValue(value_name) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
152 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
153 |
self.StepName.SetValue("") |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
154 |
self.Input.SetValue(values.get("input", False)) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
155 |
self.Output.SetValue(values.get("output", False)) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
156 |
self.Action.SetValue(values.get("action", False)) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
157 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
158 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
159 |
def GetValues(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
160 |
values = {} |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
161 |
values["name"] = self.StepName.GetValue() |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
162 |
values["input"] = self.Input.IsChecked() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
163 |
values["output"] = self.Output.IsChecked() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
164 |
values["action"] = self.Action.IsChecked() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
165 |
values["width"], values["height"] = self.Step.GetSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
166 |
return values |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
167 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
168 |
def OnConnectorsChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
169 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
170 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
171 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
172 |
def OnNameChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
173 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
174 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
175 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
176 |
def RefreshPreview(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
177 |
dc = wx.ClientDC(self.Preview) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
178 |
dc.SetFont(self.Preview.GetFont()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
179 |
dc.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
180 |
self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
181 |
if self.Input.IsChecked(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
182 |
self.Step.AddInput() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
183 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
184 |
self.Step.RemoveInput() |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
185 |
if self.Output.IsChecked(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
186 |
self.Step.AddOutput() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
187 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
188 |
self.Step.RemoveOutput() |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
189 |
if self.Action.IsChecked(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
190 |
self.Step.AddAction() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
191 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
192 |
self.Step.RemoveAction() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
193 |
width, height = self.MinStepSize |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
194 |
min_width, min_height = self.Step.GetMinSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
195 |
width, height = max(min_width, width), max(min_height, height) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
196 |
self.Step.SetSize(width, height) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
197 |
clientsize = self.Preview.GetClientSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
198 |
x = (clientsize.width - width) / 2 |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
199 |
y = (clientsize.height - height) / 2 |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
200 |
self.Step.SetPosition(x, y) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
201 |
self.Step.Draw(dc) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
202 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
203 |
def OnPaint(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
204 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
205 |
event.Skip() |