dialogs/ActionBlockDialog.py
changeset 1696 8043f32de7b8
parent 1571 486f94a8032c
child 1730 64d8f52bc8c8
equal deleted inserted replaced
1695:a63bb4025852 1696:8043f32de7b8
     2 
     2 
     3 # This file is part of Beremiz, a Integrated Development Environment for
     3 # This file is part of Beremiz, a Integrated Development Environment for
     4 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     4 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     5 #
     5 #
     6 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
     6 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
       
     7 # Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com>
     7 #
     8 #
     8 # See COPYING file for copyrights details.
     9 # See COPYING file for copyrights details.
     9 #
    10 #
    10 # This program is free software; you can redistribute it and/or
    11 # This program is free software; you can redistribute it and/or
    11 # modify it under the terms of the GNU General Public License
    12 # modify it under the terms of the GNU General Public License
   115 #-------------------------------------------------------------------------------
   116 #-------------------------------------------------------------------------------
   116 
   117 
   117 class ActionBlockDialog(wx.Dialog):
   118 class ActionBlockDialog(wx.Dialog):
   118     
   119     
   119     def __init__(self, parent):
   120     def __init__(self, parent):
   120         wx.Dialog.__init__(self, parent,
   121         wx.Dialog.__init__(self, parent, title=_('Edit action block properties'))
   121               size=wx.Size(500, 300), title=_('Edit action block properties'))
       
   122         
   122         
   123         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
   123         main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
   124         main_sizer.AddGrowableCol(0)
   124         main_sizer.AddGrowableCol(0)
   125         main_sizer.AddGrowableRow(1)
   125         main_sizer.AddGrowableRow(1)
   126         
   126         
   142                   size=wx.Size(28, 28), style=wx.NO_BORDER)
   142                   size=wx.Size(28, 28), style=wx.NO_BORDER)
   143             button.SetToolTipString(help)
   143             button.SetToolTipString(help)
   144             setattr(self, name, button)
   144             setattr(self, name, button)
   145             top_sizer.AddWindow(button)
   145             top_sizer.AddWindow(button)
   146         
   146         
   147         self.ActionsGrid = CustomGrid(self, size=wx.Size(0, 0), style=wx.VSCROLL)
   147         self.ActionsGrid = CustomGrid(self, size=wx.Size(-1, 250), style=wx.VSCROLL)
   148         self.ActionsGrid.DisableDragGridSize()
   148         self.ActionsGrid.DisableDragGridSize()
   149         self.ActionsGrid.EnableScrolling(False, True)
   149         self.ActionsGrid.EnableScrolling(False, True)
   150         self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, 
   150         self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, 
   151                               self.OnActionsGridCellChange)
   151                               self.OnActionsGridCellChange)
   152         main_sizer.AddSizer(self.ActionsGrid, border=20,
   152         main_sizer.AddSizer(self.ActionsGrid, border=20,
   161         
   161         
   162         self.Table = ActionTable(self, [], GetActionTableColnames())
   162         self.Table = ActionTable(self, [], GetActionTableColnames())
   163         typelist = GetTypeList()       
   163         typelist = GetTypeList()       
   164         self.TypeList = ",".join(map(_,typelist))
   164         self.TypeList = ",".join(map(_,typelist))
   165         self.TranslateType = dict([(_(value), value) for value in typelist])
   165         self.TranslateType = dict([(_(value), value) for value in typelist])
   166         self.ColSizes = [60, 90, 80, 110, 80]
   166         self.ColSizes = [60, 90, 130, 200, 50]
   167         self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]
   167         self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]
   168         
   168         
   169         self.ActionsGrid.SetTable(self.Table)
   169         self.ActionsGrid.SetTable(self.Table)
   170         self.ActionsGrid.SetDefaultValue(_ActionInfos("N", "Action", "", "", ""))
   170         self.ActionsGrid.SetDefaultValue(_ActionInfos("N", "Action", "", "", ""))
   171         self.ActionsGrid.SetButtons({"Add": self.AddButton,
   171         self.ActionsGrid.SetButtons({"Add": self.AddButton,
   182             self.ActionsGrid.AutoSizeColumn(col, False)
   182             self.ActionsGrid.AutoSizeColumn(col, False)
   183         
   183         
   184         self.Table.ResetView(self.ActionsGrid)
   184         self.Table.ResetView(self.ActionsGrid)
   185         self.ActionsGrid.SetFocus()
   185         self.ActionsGrid.SetFocus()
   186         self.ActionsGrid.RefreshButtons()
   186         self.ActionsGrid.RefreshButtons()
       
   187         self.Fit()
   187     
   188     
   188     def OnOK(self, event):
   189     def OnOK(self, event):
   189         self.ActionsGrid.CloseEditControl()
   190         self.ActionsGrid.CloseEditControl()
   190         self.EndModal(wx.ID_OK)
   191         self.EndModal(wx.ID_OK)
   191 
   192