controls/LocationCellEditor.py
changeset 1004 bf3b6998f7b6
parent 855 b30421d07e8c
child 1536 3518d10487db
equal deleted inserted replaced
1003:de812e258213 1004:bf3b6998f7b6
    83     def OnBrowseButtonClick(self, event):
    83     def OnBrowseButtonClick(self, event):
    84         # pop up the location browser dialog
    84         # pop up the location browser dialog
    85         dialog = BrowseLocationsDialog(self, self.VarType, self.Controller)
    85         dialog = BrowseLocationsDialog(self, self.VarType, self.Controller)
    86         if dialog.ShowModal() == wx.ID_OK:
    86         if dialog.ShowModal() == wx.ID_OK:
    87             infos = dialog.GetValues()
    87             infos = dialog.GetValues()
    88 
    88         else:
       
    89             infos = None
       
    90         dialog.Destroy()
       
    91         
       
    92         if infos is not None:
       
    93             location = infos["location"]
    89             # set the location
    94             # set the location
    90             self.Location.SetValue(infos["location"])
    95             if not infos["location"].startswith("%"):
       
    96                 dialog = wx.SingleChoiceDialog(self, 
       
    97                       _("Select a variable class:"), _("Variable class"), 
       
    98                       ["Input", "Output", "Memory"], 
       
    99                       wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
       
   100                 if dialog.ShowModal() == wx.ID_OK:
       
   101                     selected = dialog.GetSelection()
       
   102                 else:
       
   103                     selected = None
       
   104                 dialog.Destroy()
       
   105                 if selected is None:
       
   106                     self.Location.SetFocus()
       
   107                     return
       
   108                 if selected == 0:
       
   109                     location = "%I" + location
       
   110                 elif selected == 1:
       
   111                     location = "%Q" + location
       
   112                 else:
       
   113                     location = "%M" + location
       
   114             
       
   115             self.Location.SetValue(location)
    91             self.VarType = infos["IEC_type"]
   116             self.VarType = infos["IEC_type"]
    92 
       
    93         dialog.Destroy()
       
    94 
   117 
    95         self.Location.SetFocus()
   118         self.Location.SetFocus()
    96 
   119 
    97     def OnLocationChar(self, event):
   120     def OnLocationChar(self, event):
    98         keycode = event.GetKeyCode()
   121         keycode = event.GetKeyCode()