diff -r 6431f26aa501 -r 3291024e00da dialogs/SFCDivergenceDialog.py --- a/dialogs/SFCDivergenceDialog.py Thu Feb 16 14:34:40 2017 +0500 +++ b/dialogs/SFCDivergenceDialog.py Thu Feb 16 14:35:12 2017 +0500 @@ -1,25 +1,26 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- -#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor -#based on the plcopen standard. +# This file is part of Beremiz, a Integrated Development Environment for +# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. # -#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD +# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD # -#See COPYING file for copyrights details. +# See COPYING file for copyrights details. # -#This library is free software; you can redistribute it and/or -#modify it under the terms of the GNU General Public -#License as published by the Free Software Foundation; either -#version 2.1 of the License, or (at your option) any later version. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # -#This library is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -#General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -#You should have received a copy of the GNU General Public -#License along with this library; if not, write to the Free Software -#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import wx @@ -39,12 +40,13 @@ class SFCDivergenceDialog(BlockPreviewDialog): - def __init__(self, parent, controller, tagname): + def __init__(self, parent, controller, tagname, poss_div_types = None): """ Constructor @param parent: Parent wx.Window of dialog for modal @param controller: Reference to project controller @param tagname: Tagname of project POU edited + @param poss_div_types: Types of divergence that will be available in the dialog window """ BlockPreviewDialog.__init__(self, parent, controller, tagname, size=wx.Size(500, 300), @@ -58,19 +60,28 @@ self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW) # Create radio buttons for selecting divergence type + divergence_buttons = [ + (SELECTION_DIVERGENCE, _('Selection Divergence')), + (SELECTION_CONVERGENCE, _('Selection Convergence')), + (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')), + (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))] + poss_div_btns = [] + if poss_div_types is not None: + for val in poss_div_types: + poss_div_btns.append(divergence_buttons[val]) + else: + poss_div_btns = divergence_buttons self.TypeRadioButtons = {} first = True - for type, label in [ - (SELECTION_DIVERGENCE, _('Selection Divergence')), - (SELECTION_CONVERGENCE, _('Selection Convergence')), - (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')), - (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))]: + focusbtn = None + for type, label in poss_div_btns: radio_button = wx.RadioButton(self, label=label, style=(wx.RB_GROUP if first else 0)) radio_button.SetValue(first) self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) self.TypeRadioButtons[type] = radio_button + if first: focusbtn = type first = False # Create label for number of divergence sequences @@ -79,7 +90,7 @@ self.LeftGridSizer.AddWindow(sequences_label, flag=wx.GROW) # Create spin control for defining number of divergence sequences - self.Sequences = wx.SpinCtrl(self, min=2, max=20) + self.Sequences = wx.SpinCtrl(self, min=2, max=20, initial=2) self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences) self.LeftGridSizer.AddWindow(self.Sequences, flag=wx.GROW) @@ -93,7 +104,7 @@ # Selection divergence radio button is default control having keyboard # focus - self.TypeRadioButtons[SELECTION_DIVERGENCE].SetFocus() + self.TypeRadioButtons[focusbtn].SetFocus() def GetMinElementSize(self): """ @@ -151,4 +162,4 @@ # Call BlockPreviewDialog function BlockPreviewDialog.RefreshPreview(self) - \ No newline at end of file +