38 divergence graphic element |
38 divergence graphic element |
39 """ |
39 """ |
40 |
40 |
41 class SFCDivergenceDialog(BlockPreviewDialog): |
41 class SFCDivergenceDialog(BlockPreviewDialog): |
42 |
42 |
43 def __init__(self, parent, controller, tagname): |
43 def __init__(self, parent, controller, tagname, poss_div_types = None): |
44 """ |
44 """ |
45 Constructor |
45 Constructor |
46 @param parent: Parent wx.Window of dialog for modal |
46 @param parent: Parent wx.Window of dialog for modal |
47 @param controller: Reference to project controller |
47 @param controller: Reference to project controller |
48 @param tagname: Tagname of project POU edited |
48 @param tagname: Tagname of project POU edited |
|
49 @param poss_div_types: Types of divergence that will be available in the dialog window |
49 """ |
50 """ |
50 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
51 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
51 size=wx.Size(500, 300), |
52 size=wx.Size(500, 300), |
52 title=_('Create a new divergence or convergence')) |
53 title=_('Create a new divergence or convergence')) |
53 |
54 |
57 # Create label for divergence type |
58 # Create label for divergence type |
58 type_label = wx.StaticText(self, label=_('Type:')) |
59 type_label = wx.StaticText(self, label=_('Type:')) |
59 self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW) |
60 self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW) |
60 |
61 |
61 # Create radio buttons for selecting divergence type |
62 # Create radio buttons for selecting divergence type |
|
63 divergence_buttons = [ |
|
64 (SELECTION_DIVERGENCE, _('Selection Divergence')), |
|
65 (SELECTION_CONVERGENCE, _('Selection Convergence')), |
|
66 (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')), |
|
67 (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))] |
|
68 poss_div_btns = [] |
|
69 if poss_div_types is not None: |
|
70 for val in poss_div_types: |
|
71 poss_div_btns.append(divergence_buttons[val]) |
|
72 else: |
|
73 poss_div_btns = divergence_buttons |
62 self.TypeRadioButtons = {} |
74 self.TypeRadioButtons = {} |
63 first = True |
75 first = True |
64 for type, label in [ |
76 focusbtn = None |
65 (SELECTION_DIVERGENCE, _('Selection Divergence')), |
77 for type, label in poss_div_btns: |
66 (SELECTION_CONVERGENCE, _('Selection Convergence')), |
|
67 (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')), |
|
68 (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))]: |
|
69 radio_button = wx.RadioButton(self, label=label, |
78 radio_button = wx.RadioButton(self, label=label, |
70 style=(wx.RB_GROUP if first else 0)) |
79 style=(wx.RB_GROUP if first else 0)) |
71 radio_button.SetValue(first) |
80 radio_button.SetValue(first) |
72 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
81 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
73 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
82 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
74 self.TypeRadioButtons[type] = radio_button |
83 self.TypeRadioButtons[type] = radio_button |
|
84 if first: focusbtn = type |
75 first = False |
85 first = False |
76 |
86 |
77 # Create label for number of divergence sequences |
87 # Create label for number of divergence sequences |
78 sequences_label = wx.StaticText(self, |
88 sequences_label = wx.StaticText(self, |
79 label=_('Number of sequences:')) |
89 label=_('Number of sequences:')) |
92 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
102 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
93 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
103 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
94 |
104 |
95 # Selection divergence radio button is default control having keyboard |
105 # Selection divergence radio button is default control having keyboard |
96 # focus |
106 # focus |
97 self.TypeRadioButtons[SELECTION_DIVERGENCE].SetFocus() |
107 self.TypeRadioButtons[focusbtn].SetFocus() |
98 |
108 |
99 def GetMinElementSize(self): |
109 def GetMinElementSize(self): |
100 """ |
110 """ |
101 Get minimal graphic element size |
111 Get minimal graphic element size |
102 @return: Tuple containing minimal size (width, height) or None if no |
112 @return: Tuple containing minimal size (width, height) or None if no |