author | Laurent Bessard |
Mon, 25 Jun 2012 23:10:49 +0200 | |
changeset 715 | 6a3792a6bf7b |
parent 714 | 131ea7f237b9 |
child 740 | b40ef1010140 |
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 |
#!/usr/bin/env python |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
3 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
4 |
#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
|
5 |
#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
|
6 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
7 |
#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
|
8 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
9 |
#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
|
10 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
11 |
#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
|
12 |
#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
|
13 |
#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
|
14 |
#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
|
15 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
16 |
#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
|
17 |
#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
|
18 |
#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
|
19 |
#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
|
20 |
# |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
21 |
#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
|
22 |
#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
|
23 |
#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
|
24 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
25 |
import wx |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
26 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
27 |
from graphics import * |
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 |
#------------------------------------------------------------------------------- |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
30 |
# Edit Ladder Element Properties Dialog |
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 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
33 |
class LDElementDialog(wx.Dialog): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
34 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
35 |
def __init__(self, parent, controller, type): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
36 |
if type == "contact": |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
37 |
wx.Dialog.__init__(self, parent, size=wx.Size(350, 310), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
38 |
title=_("Edit Contact Values")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
39 |
else: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
40 |
wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
41 |
title=_("Edit Coil Values")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
42 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
43 |
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
|
44 |
main_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
45 |
main_sizer.AddGrowableRow(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
46 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
47 |
column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
48 |
main_sizer.AddSizer(column_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
49 |
flag=wx.GROW|wx.TOP|wx.LEFT|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 |
if type == "contact": |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
52 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
53 |
else: |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
54 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
55 |
left_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
56 |
column_sizer.AddSizer(left_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
57 |
flag=wx.GROW|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
58 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
59 |
modifier_label = wx.StaticText(self, label=_('Modifier:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
60 |
left_gridsizer.AddWindow(modifier_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
61 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
62 |
self.Normal = wx.RadioButton(self, label=_("Normal"), style=wx.RB_GROUP) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
63 |
self.Normal.SetValue(True) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
64 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Normal) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
65 |
left_gridsizer.AddWindow(self.Normal, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
66 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
67 |
self.Negated = wx.RadioButton(self, label=_("Negated")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
68 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Negated) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
69 |
left_gridsizer.AddWindow(self.Negated, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
70 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
71 |
if type == "contact": |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
72 |
self.Set = wx.RadioButton(self, label=_("Set")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
73 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Set) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
74 |
left_gridsizer.AddWindow(self.Set, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
75 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
76 |
self.Reset = wx.RadioButton(self, label=_("Reset")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
77 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Reset) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
78 |
left_gridsizer.AddWindow(self.Reset, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
79 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
80 |
self.RisingEdge = wx.RadioButton(self, label=_("Rising Edge")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
81 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.RisingEdge) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
82 |
left_gridsizer.AddWindow(self.RisingEdge, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
83 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
84 |
self.FallingEdge = wx.RadioButton(self, label=_("Falling Edge")) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
85 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.FallingEdge) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
86 |
left_gridsizer.AddWindow(self.FallingEdge, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
87 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
88 |
element_name_label = wx.StaticText(self, label=_('Name:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
89 |
left_gridsizer.AddWindow(element_name_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
90 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
91 |
self.ElementName = wx.ComboBox(self, style=wx.CB_READONLY) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
92 |
self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, self.ElementName) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
93 |
left_gridsizer.AddWindow(self.ElementName, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
94 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
95 |
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
|
96 |
right_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
97 |
right_gridsizer.AddGrowableRow(1) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
98 |
column_sizer.AddSizer(right_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
99 |
flag=wx.GROW|wx.LEFT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
100 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
101 |
preview_sizer = wx.StaticText(self, label=_('Preview:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
102 |
right_gridsizer.AddWindow(preview_sizer, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
103 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
104 |
self.Preview = wx.Panel(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
setattr(self.Preview, "GetScaling", lambda:None) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
109 |
setattr(self.Preview, "IsOfType", controller.IsOfType) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
110 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
111 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
112 |
button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
113 |
main_sizer.AddSizer(button_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
114 |
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
|
115 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
116 |
self.SetSizer(main_sizer) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
117 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
118 |
if type == "contact": |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
119 |
self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
120 |
else: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
121 |
self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
122 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
123 |
self.Type = type |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
124 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
125 |
self.Normal.SetFocus() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
126 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
130 |
def SetElementSize(self, size): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
131 |
min_width, min_height = self.Element.GetMinSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
132 |
width, height = max(min_width, size[0]), max(min_height, size[1]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
133 |
self.Element.SetSize(width, height) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
134 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
135 |
def SetVariables(self, vars): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
136 |
self.ElementName.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
137 |
for name in vars: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
138 |
self.ElementName.Append(name) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
139 |
self.ElementName.Enable(self.ElementName.GetCount() > 0) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
140 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
141 |
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
|
142 |
for name, value in values.items(): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
143 |
if name == "name": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
144 |
self.Element.SetName(value) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
145 |
self.ElementName.SetStringSelection(value) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
146 |
elif name == "type": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
147 |
self.Element.SetType(value) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
148 |
if self.Type == "contact": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
149 |
if value == CONTACT_NORMAL: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
150 |
self.Normal.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
151 |
elif value == CONTACT_REVERSE: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
152 |
self.Negated.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
153 |
elif value == CONTACT_RISING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
154 |
self.RisingEdge.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
155 |
elif value == CONTACT_FALLING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
156 |
self.FallingEdge.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
157 |
elif self.Type == "coil": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
158 |
if value == COIL_NORMAL: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
159 |
self.Normal.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
160 |
elif value == COIL_REVERSE: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
161 |
self.Negated.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
162 |
elif value == COIL_SET: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
163 |
self.Set.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
164 |
elif value == COIL_RESET: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
165 |
self.Reset.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
166 |
elif value == COIL_RISING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
167 |
self.RisingEdge.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
168 |
elif value == COIL_FALLING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
169 |
self.FallingEdge.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
170 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
171 |
def GetValues(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
172 |
values = {} |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
173 |
values["name"] = self.Element.GetName() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
174 |
values["type"] = self.Element.GetType() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
175 |
values["width"], values["height"] = self.Element.GetSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
176 |
return values |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
177 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
178 |
def OnTypeChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
179 |
if self.Type == "contact": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
180 |
if self.Normal.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
181 |
self.Element.SetType(CONTACT_NORMAL) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
182 |
elif self.Negated.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
183 |
self.Element.SetType(CONTACT_REVERSE) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
184 |
elif self.RisingEdge.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
185 |
self.Element.SetType(CONTACT_RISING) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
186 |
elif self.FallingEdge.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
187 |
self.Element.SetType(CONTACT_FALLING) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
188 |
elif self.Type == "coil": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
189 |
if self.Normal.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
190 |
self.Element.SetType(COIL_NORMAL) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
191 |
elif self.Negated.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
192 |
self.Element.SetType(COIL_REVERSE) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
193 |
elif self.Set.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
194 |
self.Element.SetType(COIL_SET) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
195 |
elif self.Reset.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
196 |
self.Element.SetType(COIL_RESET) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
197 |
elif self.RisingEdge.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
198 |
self.Element.SetType(COIL_RISING) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
199 |
elif self.FallingEdge.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
200 |
self.Element.SetType(COIL_FALLING) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
201 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
202 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
203 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
204 |
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
|
205 |
self.Element.SetName(self.ElementName.GetStringSelection()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
206 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
207 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
208 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
209 |
def RefreshPreview(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
dc.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
213 |
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
|
214 |
width, height = self.Element.GetSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
215 |
self.Element.SetPosition((clientsize.width - width) / 2, (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
|
216 |
self.Element.Draw(dc) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
217 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
218 |
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
|
219 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
220 |
event.Skip() |