dialogs/FBDVariableDialog.py
branchpython3
changeset 3750 f62625418bff
parent 3303 0ffb41625592
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    21 #
    21 #
    22 # You should have received a copy of the GNU General Public License
    22 # You should have received a copy of the GNU General Public License
    23 # along with this program; if not, write to the Free Software
    23 # along with this program; if not, write to the Free Software
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    25 
    25 
    26 from __future__ import absolute_import
    26 
    27 import wx
    27 import wx
    28 
    28 
    29 from graphics.GraphicCommons import INPUT, INOUT, OUTPUT
    29 from graphics.GraphicCommons import INPUT, INOUT, OUTPUT
    30 from graphics.FBD_Objects import FBD_Variable
    30 from graphics.FBD_Objects import FBD_Variable
    31 from dialogs.BlockPreviewDialog import BlockPreviewDialog
    31 from dialogs.BlockPreviewDialog import BlockPreviewDialog
    64             INOUT:  _("InOut"),
    64             INOUT:  _("InOut"),
    65             OUTPUT: _("Output")
    65             OUTPUT: _("Output")
    66         }
    66         }
    67 
    67 
    68         self.VARIABLE_CLASSES_DICT_REVERSE = dict(
    68         self.VARIABLE_CLASSES_DICT_REVERSE = dict(
    69             [(value, key) for key, value in self.VARIABLE_CLASSES_DICT.iteritems()])
    69             [(value, key) for key, value in self.VARIABLE_CLASSES_DICT.items()])
    70 
    70 
    71         # Init common sizers
    71         # Init common sizers
    72         self._init_sizers(4, 2, 4, None, 3, 2)
    72         self._init_sizers(4, 2, 4, None, 3, 2)
    73 
    73 
    74         # Create label for variable class
    74         # Create label for variable class
   118         self.MainSizer.Add(
   118         self.MainSizer.Add(
   119             self.ButtonSizer, border=20,
   119             self.ButtonSizer, border=20,
   120             flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
   120             flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
   121 
   121 
   122         # Set options that can be selected in class combo box
   122         # Set options that can be selected in class combo box
   123         for var_class, choice in self.VARIABLE_CLASSES_DICT.iteritems():
   123         for var_class, choice in self.VARIABLE_CLASSES_DICT.items():
   124             if not exclude_input or var_class != INPUT:
   124             if not exclude_input or var_class != INPUT:
   125                 self.Class.Append(choice)
   125                 self.Class.Append(choice)
   126         self.Class.SetSelection(0)
   126         self.Class.SetSelection(0)
   127 
   127 
   128         # Extract list of variables defined in POU
   128         # Extract list of variables defined in POU
   146             self.Class.GetStringSelection()]
   146             self.Class.GetStringSelection()]
   147 
   147 
   148         # Refresh names in name list box by selecting variables in POU variables
   148         # Refresh names in name list box by selecting variables in POU variables
   149         # list that can be applied to variable class
   149         # list that can be applied to variable class
   150         self.VariableName.Clear()
   150         self.VariableName.Clear()
   151         for name, (var_type, _value_type) in self.VariableList.iteritems():
   151         for name, (var_type, _value_type) in self.VariableList.items():
   152             if var_type != "Input" or var_class == INPUT:
   152             if var_type != "Input" or var_class == INPUT:
   153                 self.VariableName.Append(name)
   153                 self.VariableName.Append(name)
   154 
   154 
   155         # Get variable expression and select corresponding value in name list
   155         # Get variable expression and select corresponding value in name list
   156         # box if it exists
   156         # box if it exists
   176             self.Class.SetStringSelection(self.VARIABLE_CLASSES_DICT[var_class])
   176             self.Class.SetStringSelection(self.VARIABLE_CLASSES_DICT[var_class])
   177             # Refresh names in name list box according to var class
   177             # Refresh names in name list box according to var class
   178             self.RefreshNameList()
   178             self.RefreshNameList()
   179 
   179 
   180         # For each parameters defined, set corresponding control value
   180         # For each parameters defined, set corresponding control value
   181         for name, value in values.items():
   181         for name, value in list(values.items()):
   182 
   182 
   183             # Parameter is variable expression
   183             # Parameter is variable expression
   184             if name == "expression":
   184             if name == "expression":
   185                 # Set expression text control value
   185                 # Set expression text control value
   186                 self.Expression.ChangeValue(value)
   186                 self.Expression.ChangeValue(value)