32 |
32 |
33 class LDElementDialog(wx.Dialog): |
33 class LDElementDialog(wx.Dialog): |
34 |
34 |
35 def __init__(self, parent, controller, type): |
35 def __init__(self, parent, controller, type): |
36 if type == "contact": |
36 if type == "contact": |
37 wx.Dialog.__init__(self, parent, size=wx.Size(350, 310), |
37 wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), |
38 title=_("Edit Contact Values")) |
38 title=_("Edit Contact Values")) |
39 else: |
39 else: |
40 wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), |
40 wx.Dialog.__init__(self, parent, size=wx.Size(350, 310), |
41 title=_("Edit Coil Values")) |
41 title=_("Edit Coil Values")) |
42 |
42 |
43 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
43 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
44 main_sizer.AddGrowableCol(0) |
44 main_sizer.AddGrowableCol(0) |
45 main_sizer.AddGrowableRow(0) |
45 main_sizer.AddGrowableRow(0) |
47 column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
47 column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
48 main_sizer.AddSizer(column_sizer, border=20, |
48 main_sizer.AddSizer(column_sizer, border=20, |
49 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
49 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
50 |
50 |
51 if type == "contact": |
51 if type == "contact": |
52 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5) |
52 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=0) |
53 else: |
53 else: |
54 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) |
54 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=0) |
55 left_gridsizer.AddGrowableCol(0) |
55 left_gridsizer.AddGrowableCol(0) |
56 column_sizer.AddSizer(left_gridsizer, 1, border=5, |
56 column_sizer.AddSizer(left_gridsizer, 1, border=5, |
57 flag=wx.GROW|wx.RIGHT) |
57 flag=wx.GROW|wx.RIGHT) |
58 |
58 |
59 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
59 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
60 left_gridsizer.AddWindow(modifier_label, flag=wx.GROW) |
60 left_gridsizer.AddWindow(modifier_label, border=5, flag=wx.GROW|wx.BOTTOM) |
61 |
61 |
62 self.Normal = wx.RadioButton(self, label=_("Normal"), style=wx.RB_GROUP) |
62 self.Normal = wx.RadioButton(self, label=_("Normal"), style=wx.RB_GROUP) |
63 self.Normal.SetValue(True) |
63 self.Normal.SetValue(True) |
64 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Normal) |
64 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Normal) |
65 left_gridsizer.AddWindow(self.Normal, flag=wx.GROW) |
65 left_gridsizer.AddWindow(self.Normal, flag=wx.GROW) |
66 |
66 |
67 self.Negated = wx.RadioButton(self, label=_("Negated")) |
67 self.Negated = wx.RadioButton(self, label=_("Negated")) |
68 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Negated) |
68 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Negated) |
69 left_gridsizer.AddWindow(self.Negated, flag=wx.GROW) |
69 left_gridsizer.AddWindow(self.Negated, flag=wx.GROW) |
70 |
70 |
71 if type == "contact": |
71 if type != "contact": |
72 self.Set = wx.RadioButton(self, label=_("Set")) |
72 self.Set = wx.RadioButton(self, label=_("Set")) |
73 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Set) |
73 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Set) |
74 left_gridsizer.AddWindow(self.Set, flag=wx.GROW) |
74 left_gridsizer.AddWindow(self.Set, flag=wx.GROW) |
75 |
75 |
76 self.Reset = wx.RadioButton(self, label=_("Reset")) |
76 self.Reset = wx.RadioButton(self, label=_("Reset")) |
84 self.FallingEdge = wx.RadioButton(self, label=_("Falling Edge")) |
84 self.FallingEdge = wx.RadioButton(self, label=_("Falling Edge")) |
85 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.FallingEdge) |
85 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.FallingEdge) |
86 left_gridsizer.AddWindow(self.FallingEdge, flag=wx.GROW) |
86 left_gridsizer.AddWindow(self.FallingEdge, flag=wx.GROW) |
87 |
87 |
88 element_name_label = wx.StaticText(self, label=_('Name:')) |
88 element_name_label = wx.StaticText(self, label=_('Name:')) |
89 left_gridsizer.AddWindow(element_name_label, flag=wx.GROW) |
89 left_gridsizer.AddWindow(element_name_label, border=5, flag=wx.GROW|wx.TOP) |
90 |
90 |
91 self.ElementName = wx.ComboBox(self, style=wx.CB_READONLY) |
91 self.ElementName = wx.ComboBox(self, style=wx.CB_READONLY) |
92 self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, self.ElementName) |
92 self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, self.ElementName) |
93 left_gridsizer.AddWindow(self.ElementName, flag=wx.GROW) |
93 left_gridsizer.AddWindow(self.ElementName, border=5, flag=wx.GROW|wx.TOP) |
94 |
94 |
95 right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
95 right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
96 right_gridsizer.AddGrowableCol(0) |
96 right_gridsizer.AddGrowableCol(0) |
97 right_gridsizer.AddGrowableRow(1) |
97 right_gridsizer.AddGrowableRow(1) |
98 column_sizer.AddSizer(right_gridsizer, 1, border=5, |
98 column_sizer.AddSizer(right_gridsizer, 1, border=5, |
99 flag=wx.GROW|wx.LEFT) |
99 flag=wx.GROW|wx.LEFT) |
100 |
100 |
101 preview_sizer = wx.StaticText(self, label=_('Preview:')) |
101 preview_label = wx.StaticText(self, label=_('Preview:')) |
102 right_gridsizer.AddWindow(preview_sizer, flag=wx.GROW) |
102 right_gridsizer.AddWindow(preview_label, flag=wx.GROW) |
103 |
103 |
104 self.Preview = wx.Panel(self, |
104 self.Preview = wx.Panel(self, |
105 style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
105 style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
106 self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
106 self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
107 setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
107 setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
108 setattr(self.Preview, "GetScaling", lambda:None) |
108 setattr(self.Preview, "GetScaling", lambda:None) |
109 setattr(self.Preview, "IsOfType", controller.IsOfType) |
109 setattr(self.Preview, "IsOfType", controller.IsOfType) |
110 self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
110 self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
111 right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
111 |
112 |
112 button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
113 button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
113 main_sizer.AddSizer(button_sizer, border=20, |
114 main_sizer.AddSizer(button_sizer, border=20, |
114 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
115 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
115 |
116 |