PLCOpenEditor.py
changeset 52 35b54852c533
parent 51 47c72c77590a
child 53 4988262d03e3
equal deleted inserted replaced
51:47c72c77590a 52:35b54852c533
  1907         return row
  1907         return row
  1908 
  1908 
  1909     def GetValue(self, row, col):
  1909     def GetValue(self, row, col):
  1910         if row < self.GetNumberRows():
  1910         if row < self.GetNumberRows():
  1911             if col == 0:
  1911             if col == 0:
  1912                 return "d"
  1912                 return self.Parent.Values.index(self.data[row]) + 1
  1913             name = str(self.data[row].get(self.GetColLabelValue(col), ""))
  1913             name = str(self.data[row].get(self.GetColLabelValue(col), ""))
  1914             return name
  1914             return name
  1915     
  1915     
  1916     def GetValueByName(self, row, colname):
  1916     def GetValueByName(self, row, colname):
  1917         return self.data[row].get(colname)
  1917         return self.data[row].get(colname)
  1974             for col in range(self.GetNumberCols()):
  1974             for col in range(self.GetNumberCols()):
  1975                 editor = None
  1975                 editor = None
  1976                 renderer = None
  1976                 renderer = None
  1977                 colname = self.GetColLabelValue(col)
  1977                 colname = self.GetColLabelValue(col)
  1978                 grid.SetReadOnly(row, col, False)
  1978                 grid.SetReadOnly(row, col, False)
  1979                 if colname == "Drag":
  1979                 if col == 0:
  1980                     grid.SetReadOnly(row, col, True)
  1980                     grid.SetReadOnly(row, col, True)
  1981                 elif colname == "Name":
  1981                 elif colname == "Name":
  1982                     if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]:
  1982                     if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]:
  1983                         grid.SetReadOnly(row, col, True)
  1983                         grid.SetReadOnly(row, col, True)
  1984                     else:
  1984                     else:
  2084 
  2084 
  2085     def _init_coll_ChoicePanelSizer_Items(self, parent):
  2085     def _init_coll_ChoicePanelSizer_Items(self, parent):
  2086         # generated method, don't edit
  2086         # generated method, don't edit
  2087 
  2087 
  2088         parent.AddWindow(self.staticText1, 0, border=0, flag=wxALIGN_BOTTOM)
  2088         parent.AddWindow(self.staticText1, 0, border=0, flag=wxALIGN_BOTTOM)
       
  2089         parent.AddWindow(self.ReturnType, 0, border=0, flag=0)
  2089         parent.AddWindow(self.staticText2, 0, border=0, flag=wxALIGN_BOTTOM)
  2090         parent.AddWindow(self.staticText2, 0, border=0, flag=wxALIGN_BOTTOM)
  2090         parent.AddWindow(self.ReturnType, 0, border=0, flag=0)
       
  2091         parent.AddWindow(self.ClassFilter, 0, border=0, flag=0)
  2091         parent.AddWindow(self.ClassFilter, 0, border=0, flag=0)
  2092 
  2092 
  2093     def _init_coll_ButtonPanelSizer_Items(self, parent):
  2093     def _init_coll_ButtonPanelSizer_Items(self, parent):
  2094         # generated method, don't edit
  2094         # generated method, don't edit
  2095 
  2095 
       
  2096         parent.AddWindow(self.UpButton, 0, border=0, flag=0)
  2096         parent.AddWindow(self.AddButton, 0, border=0, flag=0)
  2097         parent.AddWindow(self.AddButton, 0, border=0, flag=0)
       
  2098         parent.AddWindow(self.DownButton, 0, border=0, flag=0)
  2097         parent.AddWindow(self.DeleteButton, 0, border=0, flag=0)
  2099         parent.AddWindow(self.DeleteButton, 0, border=0, flag=0)
  2098         parent.AddWindow(self.UpButton, 0, border=0, flag=0)
  2100         
  2099         parent.AddWindow(self.DownButton, 0, border=0, flag=0)
       
  2100 
       
  2101     def _init_coll_ButtonPanelSizer_Growables(self, parent):
  2101     def _init_coll_ButtonPanelSizer_Growables(self, parent):
  2102         # generated method, don't edit
  2102         # generated method, don't edit
  2103 
  2103 
  2104         parent.AddGrowableCol(0)
  2104         parent.AddGrowableCol(0)
  2105         parent.AddGrowableCol(1)
  2105         parent.AddGrowableCol(1)
  2111         # generated method, don't edit
  2111         # generated method, don't edit
  2112         self.MainPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  2112         self.MainPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  2113         
  2113         
  2114         self.VariablePanelSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0)
  2114         self.VariablePanelSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0)
  2115         
  2115         
  2116         self.ControlPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  2116         self.ControlPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  2117         
  2117         
  2118         self.ChoicePanelSizer = wx.GridSizer(cols=2, hgap=5, rows=2, vgap=5)
  2118         self.ChoicePanelSizer = wx.GridSizer(cols=1, hgap=5, rows=4, vgap=5)
  2119         
  2119         
  2120         self.ButtonPanelSizer = wx.FlexGridSizer(cols=4, hgap=5, rows=1, vgap=0)
  2120         self.ButtonPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0)
  2121         
  2121         
  2122         self._init_coll_MainPanelSizer_Items(self.MainPanelSizer)
  2122         self._init_coll_MainPanelSizer_Items(self.MainPanelSizer)
  2123         self._init_coll_MainPanelSizer_Growables(self.MainPanelSizer)
  2123         self._init_coll_MainPanelSizer_Growables(self.MainPanelSizer)
  2124         self._init_coll_VariablePanelSizer_Items(self.VariablePanelSizer)
  2124         self._init_coll_VariablePanelSizer_Items(self.VariablePanelSizer)
  2125         self._init_coll_VariablePanelSizer_Growables(self.VariablePanelSizer)
  2125         self._init_coll_VariablePanelSizer_Growables(self.VariablePanelSizer)
  2161               label='Return Type:', name='staticText1', parent=self,
  2161               label='Return Type:', name='staticText1', parent=self,
  2162               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
  2162               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
  2163 
  2163 
  2164         self.ReturnType = wx.Choice(id=wxID_POUEDITORPANELRETURNTYPE,
  2164         self.ReturnType = wx.Choice(id=wxID_POUEDITORPANELRETURNTYPE,
  2165               name='ReturnType', parent=self, pos=wx.Point(0, 0),
  2165               name='ReturnType', parent=self, pos=wx.Point(0, 0),
  2166               size=wx.Size(95, 24), style=0)
  2166               size=wx.Size(145, 24), style=0)
  2167 
  2167 
  2168         self.staticText2 = wx.StaticText(id=wxID_POUEDITORPANELSTATICTEXT2,
  2168         self.staticText2 = wx.StaticText(id=wxID_POUEDITORPANELSTATICTEXT2,
  2169               label='Class Filter:', name='staticText2', parent=self,
  2169               label='Class Filter:', name='staticText2', parent=self,
  2170               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
  2170               pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
  2171 
  2171 
  2172         self.ClassFilter = wx.Choice(id=wxID_POUEDITORPANELCLASSFILTER,
  2172         self.ClassFilter = wx.Choice(id=wxID_POUEDITORPANELCLASSFILTER,
  2173               name='ClassFilter', parent=self, pos=wx.Point(0, 0),
  2173               name='ClassFilter', parent=self, pos=wx.Point(0, 0),
  2174               size=wx.Size(95, 24), style=0)
  2174               size=wx.Size(145, 24), style=0)
  2175         EVT_CHOICE(self, wxID_POUEDITORPANELCLASSFILTER, self.OnClassFilter)
  2175         EVT_CHOICE(self, wxID_POUEDITORPANELCLASSFILTER, self.OnClassFilter)
  2176 
  2176 
  2177         self.VariablesGrid = wx.grid.Grid(id=wxID_POUEDITORPANELVARIABLESGRID,
  2177         self.VariablesGrid = wx.grid.Grid(id=wxID_POUEDITORPANELVARIABLESGRID,
  2178               name='VariablesGrid', parent=self, pos=wx.Point(0, 0), 
  2178               name='VariablesGrid', parent=self, pos=wx.Point(0, 0), 
  2179               size=wx.Size(-1, 150), style=wxVSCROLL|wxHSCROLL)
  2179               size=wx.Size(0, 150), style=wxVSCROLL)
  2180         self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
  2180         self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
  2181               'Sans'))
  2181               'Sans'))
  2182         self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
  2182         self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
  2183               False, 'Sans'))
  2183               False, 'Sans'))
  2184         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange)
  2184         self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange)
  2244             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
  2244             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
  2245         else:
  2245         else:
  2246             self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
  2246             self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"}
  2247             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
  2247             self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
  2248         if pou_type in ["config", "resource"] or pou_type == "program":
  2248         if pou_type in ["config", "resource"] or pou_type == "program":
  2249             self.Table = VariableTable(self, [], ["Drag", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"])
  2249             self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"])
  2250             if pou_type not in ["config", "resource"]:
  2250             if pou_type not in ["config", "resource"]:
  2251                 self.FilterChoices = ["All","Interface","   Input","   Output","   InOut","   External","Variables","   Local","   Temp","Global","Access"]
  2251                 self.FilterChoices = ["All","Interface","   Input","   Output","   InOut","   External","Variables","   Local","   Temp","Global","Access"]
  2252             else:
  2252             else:
  2253                 self.FilterChoices = ["All","Global","Access"]
  2253                 self.FilterChoices = ["All","Global","Access"]
  2254             self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70]
  2254             self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70]
  2255             self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER]
  2255             self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER]
  2256         else:
  2256         else:
  2257             self.Table = VariableTable(self, [], ["Drag", "Name", "Class", "Type", "Initial Value", "Retain", "Constant"])
  2257             self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Initial Value", "Retain", "Constant"])
  2258             self.FilterChoices = ["All","Interface","   Input","   Output","   InOut","   External","Variables","   Local","   Temp"]
  2258             self.FilterChoices = ["All","Interface","   Input","   Output","   InOut","   External","Variables","   Local","   Temp"]
  2259             self.ColSizes = [40, 120, 70, 80, 120, 60, 70]
  2259             self.ColSizes = [40, 120, 70, 80, 120, 60, 70]
  2260             self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER]
  2260             self.ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_CENTER]
  2261         for choice in self.FilterChoices:
  2261         for choice in self.FilterChoices:
  2262             self.ClassFilter.Append(choice)
  2262             self.ClassFilter.Append(choice)