controls/VariablePanel.py
changeset 761 996515c4b394
parent 747 f36838792511
equal deleted inserted replaced
760:7cadc624cc74 761:996515c4b394
   230     def __init__(self, parent):
   230     def __init__(self, parent):
   231         wx.TextDropTarget.__init__(self)
   231         wx.TextDropTarget.__init__(self)
   232         self.ParentWindow = parent
   232         self.ParentWindow = parent
   233     
   233     
   234     def OnDropText(self, x, y, data):
   234     def OnDropText(self, x, y, data):
       
   235         self.ParentWindow.ParentWindow.Select()
   235         x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y)
   236         x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y)
   236         col = self.ParentWindow.VariablesGrid.XToCol(x)
   237         col = self.ParentWindow.VariablesGrid.XToCol(x)
   237         row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize())
   238         row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize())
   238         message = None
   239         message = None
   239         element_type = self.ParentWindow.ElementType
   240         element_type = self.ParentWindow.ElementType
   270                             elif location[0] not in LOCATIONDATATYPES:
   271                             elif location[0] not in LOCATIONDATATYPES:
   271                                 message = _("Unrecognized data size \"%s\"")%location[0]
   272                                 message = _("Unrecognized data size \"%s\"")%location[0]
   272                             elif base_type not in LOCATIONDATATYPES[location[0]]:
   273                             elif base_type not in LOCATIONDATATYPES[location[0]]:
   273                                 message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
   274                                 message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
   274                             else:
   275                             else:
   275                                 dialog = wx.SingleChoiceDialog(self.ParentWindow, 
   276                                 dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow, 
   276                                       _("Select a variable class:"), _("Variable class"), 
   277                                       _("Select a variable class:"), _("Variable class"), 
   277                                       ["Input", "Output", "Memory"], 
   278                                       ["Input", "Output", "Memory"], 
   278                                       wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
   279                                       wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
   279                                 if dialog.ShowModal() == wx.ID_OK:
   280                                 if dialog.ShowModal() == wx.ID_OK:
   280                                     selected = dialog.GetSelection()
   281                                     selected = dialog.GetSelection()
   281                                     if selected == 0:
   282                                 else:
   282                                         location = "%I" + location
   283                                     selected = None
   283                                     elif selected == 1:
       
   284                                         location = "%Q" + location
       
   285                                     else:
       
   286                                         location = "%M" + location
       
   287                                     self.ParentWindow.Table.SetValue(row, col, location)
       
   288                                     self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
       
   289                                     self.ParentWindow.SaveValues()
       
   290                                 dialog.Destroy()
   284                                 dialog.Destroy()
       
   285                                 if selected is None:
       
   286                                     return
       
   287                                 if selected == 0:
       
   288                                     location = "%I" + location
       
   289                                 elif selected == 1:
       
   290                                     location = "%Q" + location
       
   291                                 else:
       
   292                                     location = "%M" + location
       
   293                                 self.ParentWindow.Table.SetValue(row, col, location)
       
   294                                 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
       
   295                                 self.ParentWindow.SaveValues()
   291                 elif colname == "Initial Value" and values[1] == "Constant":
   296                 elif colname == "Initial Value" and values[1] == "Constant":
   292                     if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
   297                     if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
   293                         message = _("Can't set an initial value to a function block instance")
   298                         message = _("Can't set an initial value to a function block instance")
   294                     else:
   299                     else:
   295                         self.ParentWindow.Table.SetValue(row, col, values[0])
   300                         self.ParentWindow.Table.SetValue(row, col, values[0])