etherlab/ConfigEditor.py
changeset 2053 5998beb54a6c
parent 2048 5726f2bbdace
child 2055 d845f2c546a6
equal deleted inserted replaced
2052:bf9d93a06a18 2053:5998beb54a6c
     1 import wx
     1 import wx
     2 import wx.grid
     2 import wx.grid
     3 import wx.gizmos
     3 import wx.gizmos
     4 
     4 
     5 from controls import CustomGrid, CustomTable, EditorPanel
     5 from controls import CustomGrid, CustomTable
       
     6 from ConfTreeNodeEditor import ConfTreeNodeEditor
     6 
     7 
     7 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
     8 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
     8 
     9 
     9 def AppendMenu(parent, help, id, kind, text):
    10 def AppendMenu(parent, help, id, kind, text):
    10     if wx.VERSION >= (2, 6, 0):
    11     if wx.VERSION >= (2, 6, 0):
    35  ID_NODEEDITORPHYSICS, ID_NODEEDITORSYNCMANAGERSLABEL, 
    36  ID_NODEEDITORPHYSICS, ID_NODEEDITORSYNCMANAGERSLABEL, 
    36  ID_NODEEDITORSYNCMANAGERSGRID, ID_NODEEDITORVARIABLESLABEL, 
    37  ID_NODEEDITORSYNCMANAGERSGRID, ID_NODEEDITORVARIABLESLABEL, 
    37  ID_NODEEDITORVARIABLESGRID, 
    38  ID_NODEEDITORVARIABLESGRID, 
    38 ] = [wx.NewId() for _init_ctrls in range(13)]
    39 ] = [wx.NewId() for _init_ctrls in range(13)]
    39 
    40 
    40 class NodeEditor(EditorPanel):
    41 class NodeEditor(ConfTreeNodeEditor):
    41     
    42     
    42     ID = ID_NODEEDITOR
    43     ID = ID_NODEEDITOR
    43     
    44     
    44     def _init_coll_MainSizer_Items(self, parent):
    45     def _init_coll_MainSizer_Items(self, parent):
    45         parent.AddSizer(self.SlaveInfosDetailsSizer, 0, border=5, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
    46         parent.AddSizer(self.SlaveInfosDetailsSizer, 0, border=5, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
   136         self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick)
   137         self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick)
   137                 
   138                 
   138         self._init_sizers()
   139         self._init_sizers()
   139     
   140     
   140     def __init__(self, parent, controler, window):
   141     def __init__(self, parent, controler, window):
   141         EditorPanel.__init__(self, parent, "", window, controler)
   142         ConfTreeNodeEditor.__init__(self, parent, "", window, controler)
   142     
   143     
   143         self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
   144         self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
   144         self.SyncManagersGrid.SetTable(self.SyncManagersTable)
   145         self.SyncManagersGrid.SetTable(self.SyncManagersTable)
   145         self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   146         self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   146                                                wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT]
   147                                                wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT]
   158                                               [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   159                                               [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   159                                                wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   160                                                wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, 
   160                                                wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
   161                                                wx.ALIGN_LEFT, wx.ALIGN_LEFT]):
   161             self.VariablesGrid.AddColumn(colname, colsize, colalign)
   162             self.VariablesGrid.AddColumn(colname, colsize, colalign)
   162         self.VariablesGrid.SetMainColumn(1)
   163         self.VariablesGrid.SetMainColumn(1)
   163         
       
   164         img = wx.Bitmap(self.Controler.GetIconPath("Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
       
   165         self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))
       
   166     
       
   167     def __del__(self):
       
   168         self.Controler.OnCloseEditor(self)
       
   169     
       
   170     def GetTitle(self):
       
   171         return self.Controler.CTNFullName()
       
   172     
   164     
   173     def GetBufferState(self):
   165     def GetBufferState(self):
   174         return False, False
   166         return False, False
   175         
   167         
   176     def RefreshView(self):
   168     def RefreshView(self):
   257                 dragSource.SetData(data)
   249                 dragSource.SetData(data)
   258                 dragSource.DoDragDrop()
   250                 dragSource.DoDragDrop()
   259             
   251             
   260         event.Skip()
   252         event.Skip()
   261 
   253 
   262 class CIA402NodeEditor(NodeEditor):
   254 CIA402NodeEditor = NodeEditor
   263     
       
   264     def __init__(self, parent, controler, window):
       
   265         NodeEditor.__init__(self, parent, controler, window)
       
   266         
       
   267         img = wx.Bitmap(self.Controler.GetIconPath("CIA402Slave.png"), wx.BITMAP_TYPE_PNG).ConvertToImage()
       
   268         self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))