dialogs/ForceVariableDialog.py
changeset 479 2fab0eefa66e
parent 476 2e09d2e86a35
child 516 40290ddff19c
equal deleted inserted replaced
478:dc403c47af54 479:2fab0eefa66e
    43 
    43 
    44 getinteger = gen_get_function(int)
    44 getinteger = gen_get_function(int)
    45 getfloat = gen_get_function(float)
    45 getfloat = gen_get_function(float)
    46 getstring = gen_get_function(str)
    46 getstring = gen_get_function(str)
    47 
    47 
    48 GetTypeValue = {"BOOL": lambda x: {"TRUE": True, "FALSE": False}.get(x, None),
    48 GetTypeValue = {"BOOL": lambda x: {"TRUE": True, "FALSE": False}.get(x.upper(), None),
    49                 "SINT": getinteger,
    49                 "SINT": getinteger,
    50                 "INT": getinteger,
    50                 "INT": getinteger,
    51                 "DINT": getinteger,
    51                 "DINT": getinteger,
    52                 "LINT": getinteger,
    52                 "LINT": getinteger,
    53                 "USINT": getinteger,
    53                 "USINT": getinteger,
    71             if id is not None:
    71             if id is not None:
    72                 event(self, id, function)
    72                 event(self, id, function)
    73             else:
    73             else:
    74                 event(self, function)
    74                 event(self, function)
    75 
    75 
    76     def __init__(self, parent, iec_type):
    76     def __init__(self, parent, iec_type, defaultValue=""):
    77         wx.TextEntryDialog.__init__(self, parent, message = _("Forcing Variable Value"), 
    77         wx.TextEntryDialog.__init__(self, parent, message = _("Forcing Variable Value"), 
    78                 caption = _("Please enter value for a \"%s\" variable:"%iec_type), defaultValue = "", 
    78                 caption = _("Please enter value for a \"%s\" variable:"%iec_type), defaultValue = defaultValue, 
    79                 style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition)
    79                 style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition)
    80         
    80         
    81         self.IEC_Type = iec_type 
    81         self.IEC_Type = iec_type 
    82         if wx.VERSION >= (2, 8, 0):
    82         if wx.VERSION >= (2, 8, 0):
    83             self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
    83             self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())