author | Minyoung Sung |
Mon, 27 Aug 2012 17:41:35 +0200 | |
changeset 749 | 7b17f3c5cf21 |
parent 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": |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
37 |
wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), |
714
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: |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
40 |
wx.Dialog.__init__(self, parent, size=wx.Size(350, 310), |
714
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": |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
52 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=0) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
53 |
else: |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
54 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=0) |
714
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:')) |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
60 |
left_gridsizer.AddWindow(modifier_label, border=5, flag=wx.GROW|wx.BOTTOM) |
714
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 |
|
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
71 |
if type != "contact": |
714
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:')) |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
89 |
left_gridsizer.AddWindow(element_name_label, border=5, flag=wx.GROW|wx.TOP) |
714
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) |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
93 |
left_gridsizer.AddWindow(self.ElementName, border=5, flag=wx.GROW|wx.TOP) |
714
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 |
|
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
101 |
preview_label = wx.StaticText(self, label=_('Preview:')) |
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
102 |
right_gridsizer.AddWindow(preview_label, flag=wx.GROW) |
714
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) |
740
b40ef1010140
Fix many bugs in control layout in LDElementDialog
Laurent Bessard
parents:
714
diff
changeset
|
111 |
right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
112 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
113 |
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
|
114 |
main_sizer.AddSizer(button_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
115 |
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
|
116 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
117 |
self.SetSizer(main_sizer) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
118 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
119 |
if type == "contact": |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
120 |
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
|
121 |
else: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
122 |
self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
123 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
124 |
self.Type = type |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
125 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
126 |
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
|
127 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
131 |
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
|
132 |
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
|
133 |
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
|
134 |
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
|
135 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
136 |
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
|
137 |
self.ElementName.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
142 |
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
|
143 |
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
|
144 |
if name == "name": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
145 |
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
|
146 |
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
|
147 |
elif name == "type": |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
148 |
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
|
149 |
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
|
150 |
if value == CONTACT_NORMAL: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
151 |
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
|
152 |
elif value == CONTACT_REVERSE: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
153 |
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
|
154 |
elif value == CONTACT_RISING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
155 |
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
|
156 |
elif value == CONTACT_FALLING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
if value == COIL_NORMAL: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
160 |
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
|
161 |
elif value == COIL_REVERSE: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
162 |
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
|
163 |
elif value == COIL_SET: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
164 |
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
|
165 |
elif value == COIL_RESET: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
166 |
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
|
167 |
elif value == COIL_RISING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
168 |
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
|
169 |
elif value == COIL_FALLING: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
170 |
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
|
171 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
172 |
def GetValues(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
173 |
values = {} |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
174 |
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
|
175 |
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
|
176 |
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
|
177 |
return values |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
178 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
179 |
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
|
180 |
if self.Type == "contact": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
181 |
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
|
182 |
self.Element.SetType(CONTACT_NORMAL) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
183 |
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
|
184 |
self.Element.SetType(CONTACT_REVERSE) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
185 |
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
|
186 |
self.Element.SetType(CONTACT_RISING) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
187 |
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
|
188 |
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
|
189 |
elif self.Type == "coil": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
190 |
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
|
191 |
self.Element.SetType(COIL_NORMAL) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
192 |
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
|
193 |
self.Element.SetType(COIL_REVERSE) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
194 |
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
|
195 |
self.Element.SetType(COIL_SET) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
196 |
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
|
197 |
self.Element.SetType(COIL_RESET) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
198 |
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
|
199 |
self.Element.SetType(COIL_RISING) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
200 |
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
|
201 |
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
|
202 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
203 |
event.Skip() |
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 OnNameChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
206 |
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
|
207 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
208 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
209 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
210 |
def RefreshPreview(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
dc.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
219 |
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
|
220 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
221 |
event.Skip() |