Dialogs.py
changeset 64 dd6f693e46a1
parent 62 1908c45f21ef
child 70 0e48629c1e6d
equal deleted inserted replaced
63:04a02b4b2a57 64:dd6f693e46a1
    20 #
    20 #
    21 #You should have received a copy of the GNU General Public
    21 #You should have received a copy of the GNU General Public
    22 #License along with this library; if not, write to the Free Software
    22 #License along with this library; if not, write to the Free Software
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24 
    24 
    25 from wxPython.wx import *
       
    26 from wxPython.grid import *
       
    27 import wx
    25 import wx
       
    26 import wx.grid
    28 
    27 
    29 from graphics import *
    28 from graphics import *
    30 
    29 
    31 #-------------------------------------------------------------------------------
    30 #-------------------------------------------------------------------------------
    32 #                          Create New Block Dialog
    31 #                          Create New Block Dialog
    33 #-------------------------------------------------------------------------------
    32 #-------------------------------------------------------------------------------
    34 
    33 
    35 [wxID_BLOCKPROPERTIESDIALOG, wxID_BLOCKPROPERTIESDIALOGNAME, 
    34 [ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME, 
    36  wxID_BLOCKPROPERTIESDIALOGTYPETREE, wxID_BLOCKPROPERTIESDIALOGTYPEDESC, 
    35  ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC, 
    37  wxID_BLOCKPROPERTIESDIALOGINPUTS, wxID_BLOCKPROPERTIESDIALOGPREVIEW, 
    36  ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW, 
    38  wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, 
    37  ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, 
    39  wxID_BLOCKPROPERTIESDIALOGSTATICTEXT3, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4, 
    38  ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, 
    40 ] = [wx.NewId() for _init_ctrls in range(10)]
    39 ] = [wx.NewId() for _init_ctrls in range(10)]
    41 
    40 
    42 [CATEGORY, BLOCK] = range(2)
    41 [CATEGORY, BLOCK] = range(2)
    43 
    42 
    44 class BlockPropertiesDialog(wx.Dialog):
    43 class BlockPropertiesDialog(wx.Dialog):
    45     def _init_coll_flexGridSizer1_Items(self, parent):
    44     def _init_coll_flexGridSizer1_Items(self, parent):
    46         # generated method, don't edit
    45         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
    47 
    46         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
    48         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
    49         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
    50 
    47 
    51     def _init_coll_flexGridSizer1_Growables(self, parent):
    48     def _init_coll_flexGridSizer1_Growables(self, parent):
    52         # generated method, don't edit
       
    53 
       
    54         parent.AddGrowableCol(0)
    49         parent.AddGrowableCol(0)
    55         parent.AddGrowableRow(0)
    50         parent.AddGrowableRow(0)
    56 
    51 
    57     def _init_coll_MainSizer_Items(self, parent):
    52     def _init_coll_MainSizer_Items(self, parent):
    58         # generated method, don't edit
    53         parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
    59 
    54         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
    60         parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
    61         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
    62 
    55 
    63     def _init_coll_LeftBoxSizer_Items(self, parent):
    56     def _init_coll_LeftBoxSizer_Items(self, parent):
    64         # generated method, don't edit
    57         parent.AddWindow(self.TypeTree, 3, border=5, flag=wx.GROW|wx.BOTTOM)
    65 
    58         parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW)
    66         parent.AddWindow(self.TypeTree, 3, border=5, flag=wxGROW|wxBOTTOM)
       
    67         parent.AddWindow(self.TypeDesc, 1, border=0, flag=wxGROW)
       
    68 
    59 
    69     def _init_coll_RightGridSizer_Items(self, parent):
    60     def _init_coll_RightGridSizer_Items(self, parent):
    70         # generated method, don't edit
    61         parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW)
    71 
    62         parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
    72         parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wxGROW)
    63         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
    73         parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW)
       
    74         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
    75 
    64 
    76     def _init_coll_RightGridSizer_Growables(self, parent):
    65     def _init_coll_RightGridSizer_Growables(self, parent):
    77         # generated method, don't edit
       
    78 
       
    79         parent.AddGrowableCol(0)
    66         parent.AddGrowableCol(0)
    80         parent.AddGrowableRow(2)
    67         parent.AddGrowableRow(2)
    81 
    68 
    82     def _init_coll_RightUpGridSizer_Items(self, parent):
    69     def _init_coll_RightUpGridSizer_Items(self, parent):
    83         # generated method, don't edit
    70         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM)
    84 
    71         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM)
    85         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM)
    72         parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
    86         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM)
    73         parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW)
    87         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
    88         parent.AddWindow(self.Inputs, 0, border=0, flag=wxGROW)
       
    89 
    74 
    90     def _init_sizers(self):
    75     def _init_sizers(self):
    91         # generated method, don't edit
       
    92         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
    76         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
    93         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
    77         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
    94         self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wxVERTICAL)
    78         self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL)
    95         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
    79         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
    96         self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=2, vgap=5)
    80         self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=2, vgap=5)
    97         
    81         
    98         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
    82         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
    99         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
    83         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   104         self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer)
    88         self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer)
   105         
    89         
   106         self.SetSizer(self.flexGridSizer1)
    90         self.SetSizer(self.flexGridSizer1)
   107 
    91 
   108     def _init_ctrls(self, prnt):
    92     def _init_ctrls(self, prnt):
   109         # generated method, don't edit
    93         wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG,
   110         wx.Dialog.__init__(self, id=wxID_BLOCKPROPERTIESDIALOG,
       
   111               name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
    94               name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   112               size=wx.Size(600, 360), style=wx.DEFAULT_DIALOG_STYLE|wxRESIZE_BORDER,
    95               size=wx.Size(600, 360), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
   113               title='Block Properties')
    96               title='Block Properties')
   114         self.SetClientSize(wx.Size(600, 360))
    97         self.SetClientSize(wx.Size(600, 360))
   115 
    98 
   116         self.staticbox1 = wx.StaticBox(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1,
    99         self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1,
   117               label='Type:', name='staticBox1', parent=self,
   100               label='Type:', name='staticBox1', parent=self,
   118               pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
   101               pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
   119 
   102 
   120         self.staticText2 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
   103         self.staticText2 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
   121               label='Name:', name='staticText2', parent=self,
   104               label='Name:', name='staticText2', parent=self,
   122               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   105               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   123 
   106 
   124         self.staticText3 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
   107         self.staticText3 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2,
   125               label='Inputs:', name='staticText4', parent=self,
   108               label='Inputs:', name='staticText4', parent=self,
   126               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   109               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   127 
   110 
   128         self.staticText4 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4,
   111         self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4,
   129               label='Preview:', name='staticText4', parent=self,
   112               label='Preview:', name='staticText4', parent=self,
   130               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   113               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   131 
   114 
   132         self.TypeTree = wx.TreeCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPETREE,
   115         self.TypeTree = wx.TreeCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPETREE,
   133               name='TypeTree', parent=self, pos=wx.Point(0, 0),
   116               name='TypeTree', parent=self, pos=wx.Point(0, 0),
   134               size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER)
   117               size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER)
   135         EVT_TREE_SEL_CHANGED(self, wxID_BLOCKPROPERTIESDIALOGTYPETREE, self.OnTypeTreeItemSelected)
   118         self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypeTreeItemSelected,
   136 
   119               id=ID_BLOCKPROPERTIESDIALOGTYPETREE)
   137         self.TypeDesc = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPEDESC,
   120 
       
   121         self.TypeDesc = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPEDESC,
   138               name='TypeDesc', parent=self, pos=wx.Point(0, 0),
   122               name='TypeDesc', parent=self, pos=wx.Point(0, 0),
   139               size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE)
   123               size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE)
   140 
   124 
   141         self.Name = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGNAME, value='',
   125         self.Name = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGNAME, value='',
   142               name='Name', parent=self, pos=wx.Point(0, 0),
   126               name='Name', parent=self, pos=wx.Point(0, 0),
   143               size=wx.Size(0, 24), style=0)
   127               size=wx.Size(0, 24), style=0)
   144         EVT_TEXT(self, wxID_BLOCKPROPERTIESDIALOGNAME, self.OnNameChanged)
   128         self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_BLOCKPROPERTIESDIALOGNAME)
   145 
   129 
   146         self.Inputs = wx.SpinCtrl(id=wxID_BLOCKPROPERTIESDIALOGINPUTS,
   130         self.Inputs = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGINPUTS,
   147               name='Inputs', parent=self, pos=wx.Point(0, 0),
   131               name='Inputs', parent=self, pos=wx.Point(0, 0),
   148               size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=2, max=20)
   132               size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=2, max=20)
   149         EVT_SPINCTRL(self, wxID_BLOCKPROPERTIESDIALOGINPUTS, self.OnInputsChanged)
   133         self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, id=ID_BLOCKPROPERTIESDIALOGINPUTS)
   150 
   134 
   151         self.Preview = wx.Panel(id=wxID_BLOCKPROPERTIESDIALOGPREVIEW,
   135         self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW,
   152               name='Preview', parent=self, pos=wx.Point(0, 0),
   136               name='Preview', parent=self, pos=wx.Point(0, 0),
   153               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   137               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   154         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   138         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
   155         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   139         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   156 
   140 
   157         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   141         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
       
   142         self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
       
   143         
       
   144         self.Bind(wx.EVT_PAINT, self.OnPaint)
   158         
   145         
   159         self._init_sizers()
   146         self._init_sizers()
   160 
   147 
   161     def __init__(self, parent):
   148     def __init__(self, parent):
   162         self._init_ctrls(parent)
   149         self._init_ctrls(parent)
   163         self.Name.SetValue("")
   150         self.Name.SetValue("")
   164         self.Name.Enable(False)
   151         self.Name.Enable(False)
   165         self.Inputs.Enable(False)
   152         self.Inputs.Enable(False)
   166         self.Block = None
   153         self.Block = None
   167         self.MinBlockSize = None
   154         self.MinBlockSize = None
   168         
       
   169         EVT_PAINT(self, self.OnPaint)
       
   170         EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
       
   171     
   155     
   172     def FindTreeItem(self, root, name, inputs = None):
   156     def FindTreeItem(self, root, name, inputs = None):
   173         if root.IsOk():
   157         if root.IsOk():
   174             pydata = self.TypeTree.GetPyData(root)
   158             pydata = self.TypeTree.GetPyData(root)
   175             if inputs and "inputs" in pydata:
   159             if inputs and "inputs" in pydata:
   189     
   173     
   190     def OnOK(self, event):
   174     def OnOK(self, event):
   191         error = []
   175         error = []
   192         selected = self.TypeTree.GetSelection()
   176         selected = self.TypeTree.GetSelection()
   193         if not selected.IsOk() or self.TypeTree.GetItemParent(selected) == self.TypeTree.GetRootItem() or selected == self.TypeTree.GetRootItem():
   177         if not selected.IsOk() or self.TypeTree.GetItemParent(selected) == self.TypeTree.GetRootItem() or selected == self.TypeTree.GetRootItem():
   194             message = wxMessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wxOK|wxICON_ERROR)
   178             message = wx.MessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wx.OK|wx.ICON_ERROR)
   195             message.ShowModal()
   179             message.ShowModal()
   196             message.Destroy()
   180             message.Destroy()
   197         elif self.Name.IsEnabled() and self.Name.GetValue() == "":
   181         elif self.Name.IsEnabled() and self.Name.GetValue() == "":
   198             message = wxMessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wxOK|wxICON_ERROR)
   182             message = wx.MessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wx.OK|wx.ICON_ERROR)
   199             message.ShowModal()
   183             message.ShowModal()
   200             message.Destroy()
   184             message.Destroy()
   201         else:
   185         else:
   202             self.EndModal(wxID_OK)
   186             self.EndModal(wx.ID_OK)
   203 
   187 
   204     def SetBlockList(self, blocktypes):
   188     def SetBlockList(self, blocktypes):
   205         root = self.TypeTree.AddRoot("")
   189         root = self.TypeTree.AddRoot("")
   206         self.TypeTree.SetPyData(root, {"type" : CATEGORY})
   190         self.TypeTree.SetPyData(root, {"type" : CATEGORY})
   207         for category in blocktypes:
   191         for category in blocktypes:
   249             if blocktype:
   233             if blocktype:
   250                 self.Inputs.SetValue(len(blocktype["inputs"]))
   234                 self.Inputs.SetValue(len(blocktype["inputs"]))
   251                 self.Inputs.Enable(blocktype["extensible"])
   235                 self.Inputs.Enable(blocktype["extensible"])
   252                 self.Name.Enable(blocktype["type"] != "function")
   236                 self.Name.Enable(blocktype["type"] != "function")
   253                 self.TypeDesc.SetValue(blocktype["comment"])
   237                 self.TypeDesc.SetValue(blocktype["comment"])
   254                 wxCallAfter(self.RefreshPreview)
   238                 wx.CallAfter(self.RefreshPreview)
   255             else:
   239             else:
   256                 self.Name.Enable(False)
   240                 self.Name.Enable(False)
   257                 self.Inputs.Enable(False)
   241                 self.Inputs.Enable(False)
   258                 self.Inputs.SetValue(2)
   242                 self.Inputs.SetValue(2)
   259                 self.TypeDesc.SetValue("")
   243                 self.TypeDesc.SetValue("")
   260                 wxCallAfter(self.ErasePreview)
   244                 wx.CallAfter(self.ErasePreview)
   261         else:
   245         else:
   262             self.Name.Enable(False)
   246             self.Name.Enable(False)
   263             self.Inputs.Enable(False)
   247             self.Inputs.Enable(False)
   264             self.Inputs.SetValue(2)
   248             self.Inputs.SetValue(2)
   265             self.TypeDesc.SetValue("")
   249             self.TypeDesc.SetValue("")
   266             wxCallAfter(self.ErasePreview)
   250             wx.CallAfter(self.ErasePreview)
   267         event.Skip()
   251         event.Skip()
   268 
   252 
   269     def OnNameChanged(self, event):
   253     def OnNameChanged(self, event):
   270         if self.Name.IsEnabled():
   254         if self.Name.IsEnabled():
   271             self.RefreshPreview()
   255             self.RefreshPreview()
   275         if self.Inputs.IsEnabled():
   259         if self.Inputs.IsEnabled():
   276             self.RefreshPreview()
   260             self.RefreshPreview()
   277         event.Skip()
   261         event.Skip()
   278     
   262     
   279     def ErasePreview(self):
   263     def ErasePreview(self):
   280         dc = wxClientDC(self.Preview)
   264         dc = wx.ClientDC(self.Preview)
   281         dc.Clear()
   265         dc.Clear()
   282         self.Block = None
   266         self.Block = None
   283         
   267         
   284     def RefreshPreview(self):
   268     def RefreshPreview(self):
   285         dc = wxClientDC(self.Preview)
   269         dc = wx.ClientDC(self.Preview)
   286         dc.Clear()
   270         dc.Clear()
   287         item = self.TypeTree.GetSelection()
   271         item = self.TypeTree.GetSelection()
   288         pydata = self.TypeTree.GetPyData(item)
   272         pydata = self.TypeTree.GetPyData(item)
   289         if pydata["type"] == CATEGORY:
   273         if pydata["type"] == CATEGORY:
   290             self.Block = None
   274             self.Block = None
   311 
   295 
   312 #-------------------------------------------------------------------------------
   296 #-------------------------------------------------------------------------------
   313 #                          Create New Variable Dialog
   297 #                          Create New Variable Dialog
   314 #-------------------------------------------------------------------------------
   298 #-------------------------------------------------------------------------------
   315 
   299 
   316 [wxID_VARIABLEPROPERTIESDIALOG, wxID_VARIABLEPROPERTIESDIALOGSPACER, 
   300 [ID_VARIABLEPROPERTIESDIALOG, ID_VARIABLEPROPERTIESDIALOGSPACER, 
   317  wxID_VARIABLEPROPERTIESDIALOGNAME, wxID_VARIABLEPROPERTIESDIALOGCLASS, 
   301  ID_VARIABLEPROPERTIESDIALOGNAME, ID_VARIABLEPROPERTIESDIALOGCLASS, 
   318  wxID_VARIABLEPROPERTIESDIALOGPREVIEW, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION,
   302  ID_VARIABLEPROPERTIESDIALOGPREVIEW, ID_VARIABLEPROPERTIESDIALOGEXPRESSION,
   319  wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2,
   303  ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2,
   320  wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4,
   304  ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4,
   321 ] = [wx.NewId() for _init_ctrls in range(10)]
   305 ] = [wx.NewId() for _init_ctrls in range(10)]
   322 
   306 
   323 class VariablePropertiesDialog(wx.Dialog):
   307 class VariablePropertiesDialog(wx.Dialog):
   324     def _init_coll_flexGridSizer1_Items(self, parent):
   308     def _init_coll_flexGridSizer1_Items(self, parent):
   325         # generated method, don't edit
   309         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
   326 
   310         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
   327         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
   328         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
   329         
   311         
   330     def _init_coll_flexGridSizer1_Growables(self, parent):
   312     def _init_coll_flexGridSizer1_Growables(self, parent):
   331         # generated method, don't edit
       
   332 
       
   333         parent.AddGrowableCol(0)
   313         parent.AddGrowableCol(0)
   334         parent.AddGrowableRow(0)
   314         parent.AddGrowableRow(0)
   335     
   315     
   336     def _init_coll_MainSizer_Items(self, parent):
   316     def _init_coll_MainSizer_Items(self, parent):
   337         # generated method, don't edit
   317         parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW)
   338 
   318         parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
   339         parent.AddSizer(self.TopSizer, 0, border=0, flag=wxGROW)
   319         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
   340         parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW)
       
   341         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
   342         
   320         
   343     def _init_coll_MainSizer_Growables(self, parent):
   321     def _init_coll_MainSizer_Growables(self, parent):
   344         # generated method, don't edit
       
   345 
       
   346         parent.AddGrowableCol(0)
   322         parent.AddGrowableCol(0)
   347         parent.AddGrowableRow(2)
   323         parent.AddGrowableRow(2)
   348     
   324     
   349     def _init_coll_TopSizer_Items(self, parent):
   325     def _init_coll_TopSizer_Items(self, parent):
   350         # generated method, don't edit
   326         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
   351 
   327         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
   352         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
   353         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
   354     
   328     
   355     def _init_coll_LeftGridSizer_Items(self, parent):
   329     def _init_coll_LeftGridSizer_Items(self, parent):
   356         # generated method, don't edit
   330         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
   357 
   331         parent.AddWindow(self.Class, 0, border=0, flag=wx.GROW)
   358         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
   332         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
   359         parent.AddWindow(self.Class, 0, border=0, flag=wxGROW)
   333         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
   360         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
   334         parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW)
   361         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
   362         parent.AddWindow(self.Expression, 0, border=0, flag=wxGROW)
       
   363     
   335     
   364     def _init_coll_LeftGridSizer_Growables(self, parent):
   336     def _init_coll_LeftGridSizer_Growables(self, parent):
   365         # generated method, don't edit
       
   366 
       
   367         parent.AddGrowableCol(0)
   337         parent.AddGrowableCol(0)
   368         parent.AddGrowableRow(2)
   338         parent.AddGrowableRow(2)
   369             
   339             
   370     def _init_coll_RightGridSizer_Items(self, parent):
   340     def _init_coll_RightGridSizer_Items(self, parent):
   371         # generated method, don't edit
   341         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
   372 
   342         parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
   373         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
   374         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
   375         
   343         
   376     def _init_coll_RightGridSizer_Growables(self, parent):
   344     def _init_coll_RightGridSizer_Growables(self, parent):
   377         # generated method, don't edit
       
   378 
       
   379         parent.AddGrowableCol(0)
   345         parent.AddGrowableCol(0)
   380         parent.AddGrowableRow(1)
   346         parent.AddGrowableRow(1)
   381         
   347         
   382     def _init_sizers(self):
   348     def _init_sizers(self):
   383         # generated method, don't edit
       
   384         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   349         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   385         self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
   350         self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
   386         self.TopSizer = wx.BoxSizer(wxHORIZONTAL)
   351         self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
   387         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
   352         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
   388         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   353         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   389 
   354 
   390         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   355         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   391         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   356         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   398         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   363         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   399         
   364         
   400         self.SetSizer(self.flexGridSizer1)
   365         self.SetSizer(self.flexGridSizer1)
   401 
   366 
   402     def _init_ctrls(self, prnt):
   367     def _init_ctrls(self, prnt):
   403         # generated method, don't edit
   368         wx.Dialog.__init__(self, id=ID_VARIABLEPROPERTIESDIALOG,
   404         wx.Dialog.__init__(self, id=wxID_VARIABLEPROPERTIESDIALOG,
       
   405               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   369               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   406               size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
   370               size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
   407               title='Variable Properties')
   371               title='Variable Properties')
   408         self.SetClientSize(wx.Size(400, 380))
   372         self.SetClientSize(wx.Size(400, 380))
   409 
   373 
   410         self.staticText1 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1,
   374         self.staticText1 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1,
   411               label='Class:', name='staticText1', parent=self,
   375               label='Class:', name='staticText1', parent=self,
   412               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   376               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   413 
   377 
   414         self.staticText2 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2,
   378         self.staticText2 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2,
   415               label='Expression:', name='staticText2', parent=self,
   379               label='Expression:', name='staticText2', parent=self,
   416               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   380               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   417 
   381 
   418         self.staticText3 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3,
   382         self.staticText3 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3,
   419               label='Name:', name='staticText3', parent=self,
   383               label='Name:', name='staticText3', parent=self,
   420               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   384               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   421 
   385 
   422         self.staticText4 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4,
   386         self.staticText4 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4,
   423               label='Preview:', name='staticText4', parent=self,
   387               label='Preview:', name='staticText4', parent=self,
   424               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   388               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   425 
   389 
   426         self.Class = wx.Choice(id=wxID_VARIABLEPROPERTIESDIALOGCLASS,
   390         self.Class = wx.Choice(id=ID_VARIABLEPROPERTIESDIALOGCLASS,
   427               name='Class', parent=self, pos=wx.Point(0, 0),
   391               name='Class', parent=self, pos=wx.Point(0, 0),
   428               size=wx.Size(0, 24), style=0)
   392               size=wx.Size(0, 24), style=0)
   429         EVT_CHOICE(self, wxID_VARIABLEPROPERTIESDIALOGCLASS, self.OnClassChanged)
   393         self.Bind(wx.EVT_CHOICE, self.OnClassChanged, id=ID_VARIABLEPROPERTIESDIALOGCLASS)
   430         
   394         
   431         self.Name = wx.ListBox(id=wxID_VARIABLEPROPERTIESDIALOGNAME,
   395         self.Name = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME,
   432               name='Name', parent=self, pos=wx.Point(0, 0),
   396               name='Name', parent=self, pos=wx.Point(0, 0),
   433               size=wx.Size(0, 90), style=wx.LB_SINGLE)
   397               size=wx.Size(0, 90), style=wx.LB_SINGLE)
   434         EVT_LISTBOX(self, wxID_VARIABLEPROPERTIESDIALOGNAME, self.OnNameChanged)
   398         self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_VARIABLEPROPERTIESDIALOGNAME)
   435 
   399 
   436         self.Expression = wx.TextCtrl(id=wxID_VARIABLEPROPERTIESDIALOGEXPRESSION,
   400         self.Expression = wx.TextCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION,
   437               name='Expression', parent=self, pos=wx.Point(0, 0),
   401               name='Expression', parent=self, pos=wx.Point(0, 0),
   438               size=wx.Size(0, 24), style=0)
   402               size=wx.Size(0, 24), style=0)
   439         EVT_TEXT(self, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, self.OnExpressionChanged)
   403         self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION)
   440 
   404 
   441         self.Spacer = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGSPACER,
   405         self.Spacer = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGSPACER,
   442               name='Spacer', parent=self, pos=wx.Point(0, 0),
   406               name='Spacer', parent=self, pos=wx.Point(0, 0),
   443               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   407               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   444 
   408 
   445         self.Preview = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGPREVIEW,
   409         self.Preview = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGPREVIEW,
   446               name='Preview', parent=self, pos=wx.Point(0, 0),
   410               name='Preview', parent=self, pos=wx.Point(0, 0),
   447               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   411               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   448         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   412         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
   449         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   413         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   450 
   414 
   451         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   415         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
       
   416 
       
   417         self.Bind(wx.EVT_PAINT, self.OnPaint)
   452 
   418 
   453         self._init_sizers()
   419         self._init_sizers()
   454 
   420 
   455     def __init__(self, parent):
   421     def __init__(self, parent):
   456         self._init_ctrls(parent)
   422         self._init_ctrls(parent)
   460         self.RefreshNameList()
   426         self.RefreshNameList()
   461         
   427         
   462         for choice in ["Input", "Output", "InOut"]:
   428         for choice in ["Input", "Output", "InOut"]:
   463             self.Class.Append(choice)
   429             self.Class.Append(choice)
   464         self.Class.SetStringSelection("Input")
   430         self.Class.SetStringSelection("Input")
   465         
       
   466         EVT_PAINT(self, self.OnPaint)
       
   467 
   431 
   468     def RefreshNameList(self):
   432     def RefreshNameList(self):
   469         selected = self.Name.GetStringSelection()
   433         selected = self.Name.GetStringSelection()
   470         self.Name.Clear()
   434         self.Name.Clear()
   471         self.Name.Append("")
   435         self.Name.Append("")
   476                 self.Name.Append(name)
   440                 self.Name.Append(name)
   477             elif var_type == "Output" and self.Class.GetStringSelection() == "Output":
   441             elif var_type == "Output" and self.Class.GetStringSelection() == "Output":
   478                 self.Name.Append(name)
   442                 self.Name.Append(name)
   479             elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut":
   443             elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut":
   480                 self.Name.Append(name)
   444                 self.Name.Append(name)
   481         if self.Name.FindString(selected) != wxNOT_FOUND:
   445         if self.Name.FindString(selected) != wx.NOT_FOUND:
   482             self.Name.SetStringSelection(selected)
   446             self.Name.SetStringSelection(selected)
   483         else:
   447         else:
   484             self.Name.SetStringSelection("")
   448             self.Name.SetStringSelection("")
   485         self.Name.Enable(self.Name.GetCount() > 0)
   449         self.Name.Enable(self.Name.GetCount() > 0)
   486             
   450             
   501                 self.Class.SetStringSelection("Output")
   465                 self.Class.SetStringSelection("Output")
   502             if value_type == INOUT:
   466             if value_type == INOUT:
   503                 self.Class.SetStringSelection("InOut")
   467                 self.Class.SetStringSelection("InOut")
   504             self.RefreshNameList()
   468             self.RefreshNameList()
   505         if value_name:
   469         if value_name:
   506             if self.Name.FindString(value_name) != wxNOT_FOUND:
   470             if self.Name.FindString(value_name) != wx.NOT_FOUND:
   507                 self.Name.SetStringSelection(value_name)
   471                 self.Name.SetStringSelection(value_name)
   508                 self.Expression.Enable(False)
   472                 self.Expression.Enable(False)
   509             else:
   473             else:
   510                 self.Expression.SetValue(value_name)
   474                 self.Expression.SetValue(value_name)
   511                 self.Name.Enable(False)
   475                 self.Name.Enable(False)
   556             self.Name.Enable(True)
   520             self.Name.Enable(True)
   557         self.RefreshPreview()
   521         self.RefreshPreview()
   558         event.Skip()
   522         event.Skip()
   559     
   523     
   560     def RefreshPreview(self):
   524     def RefreshPreview(self):
   561         dc = wxClientDC(self.Preview)
   525         dc = wx.ClientDC(self.Preview)
   562         dc.Clear()
   526         dc.Clear()
   563         expression = self.Expression.GetValue()
   527         expression = self.Expression.GetValue()
   564         if self.Expression.IsEnabled() and expression != "":
   528         if self.Expression.IsEnabled() and expression != "":
   565             name = expression
   529             name = expression
   566         else:
   530         else:
   591 
   555 
   592 #-------------------------------------------------------------------------------
   556 #-------------------------------------------------------------------------------
   593 #                          Create New Connection Dialog
   557 #                          Create New Connection Dialog
   594 #-------------------------------------------------------------------------------
   558 #-------------------------------------------------------------------------------
   595 
   559 
   596 [wxID_CONNECTIONPROPERTIESDIALOG, wxID_CONNECTIONPROPERTIESDIALOGSPACER, 
   560 [ID_CONNECTIONPROPERTIESDIALOG, ID_CONNECTIONPROPERTIESDIALOGSPACER, 
   597  wxID_CONNECTIONPROPERTIESDIALOGNAME, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, 
   561  ID_CONNECTIONPROPERTIESDIALOGNAME, ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, 
   598  wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   562  ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, ID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   599  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, 
   563  ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, 
   600  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, 
   564  ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, 
   601 ] = [wx.NewId() for _init_ctrls in range(9)]
   565 ] = [wx.NewId() for _init_ctrls in range(9)]
   602 
   566 
   603 class ConnectionPropertiesDialog(wx.Dialog):
   567 class ConnectionPropertiesDialog(wx.Dialog):
   604     def _init_coll_flexGridSizer1_Items(self, parent):
   568     def _init_coll_flexGridSizer1_Items(self, parent):
   605         # generated method, don't edit
   569         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
   606 
   570         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
   607         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
   608         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
   609         
   571         
   610     def _init_coll_flexGridSizer1_Growables(self, parent):
   572     def _init_coll_flexGridSizer1_Growables(self, parent):
   611         # generated method, don't edit
       
   612 
       
   613         parent.AddGrowableCol(0)
   573         parent.AddGrowableCol(0)
   614         parent.AddGrowableRow(0)
   574         parent.AddGrowableRow(0)
   615     
   575     
   616     def _init_coll_MainSizer_Items(self, parent):
   576     def _init_coll_MainSizer_Items(self, parent):
   617         # generated method, don't edit
   577         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
   618 
   578         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
   619         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
   620         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
   621     
   579     
   622     def _init_coll_LeftGridSizer_Items(self, parent):
   580     def _init_coll_LeftGridSizer_Items(self, parent):
   623         # generated method, don't edit
   581         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
   624 
   582         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
   625         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
   583         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
   626         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
   584         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
   627         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
   585         parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
   628         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
   586         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
   629         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
   630         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
   631     
   587     
   632     def _init_coll_LeftGridSizer_Growables(self, parent):
   588     def _init_coll_LeftGridSizer_Growables(self, parent):
   633         # generated method, don't edit
   589         parent.AddGrowableCol(0)
   634 
   590         parent.AddGrowableRow(5)
   635         parent.AddGrowableCol(0)
       
   636         parent.AddGrowableRow(3)
       
   637             
   591             
   638     def _init_coll_RightGridSizer_Items(self, parent):
   592     def _init_coll_RightGridSizer_Items(self, parent):
   639         # generated method, don't edit
   593         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
   640 
   594         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
   641         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
   642         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
   643         
   595         
   644     def _init_coll_RightGridSizer_Growables(self, parent):
   596     def _init_coll_RightGridSizer_Growables(self, parent):
   645         # generated method, don't edit
       
   646 
       
   647         parent.AddGrowableCol(0)
   597         parent.AddGrowableCol(0)
   648         parent.AddGrowableRow(1)
   598         parent.AddGrowableRow(1)
   649 
   599 
   650     def _init_sizers(self):
   600     def _init_sizers(self):
   651         # generated method, don't edit
       
   652         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   601         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   653         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
   602         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
   654         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
   603         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
   655         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   604         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   656 
   605 
   657         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   606         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   658         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   607         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   663         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   612         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   664 
   613 
   665         self.SetSizer(self.flexGridSizer1)
   614         self.SetSizer(self.flexGridSizer1)
   666 
   615 
   667     def _init_ctrls(self, prnt):
   616     def _init_ctrls(self, prnt):
   668         # generated method, don't edit
   617         wx.Dialog.__init__(self, id=ID_CONNECTIONPROPERTIESDIALOG,
   669         wx.Dialog.__init__(self, id=wxID_CONNECTIONPROPERTIESDIALOG,
       
   670               name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   618               name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   671               size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
   619               size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
   672               title='Connection Properties')
   620               title='Connection Properties')
   673         self.SetClientSize(wx.Size(350, 220))
   621         self.SetClientSize(wx.Size(350, 220))
   674 
   622 
   675         self.staticText1 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1,
   623         self.staticText1 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1,
   676               label='Type:', name='staticText1', parent=self,
   624               label='Type:', name='staticText1', parent=self,
   677               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   625               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   678 
   626 
   679         self.staticText2 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2,
   627         self.staticText2 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2,
   680               label='Name:', name='staticText2', parent=self,
   628               label='Name:', name='staticText2', parent=self,
   681               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   629               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   682 
   630 
   683         self.staticText3 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3,
   631         self.staticText3 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3,
   684               label='Preview:', name='staticText3', parent=self,
   632               label='Preview:', name='staticText3', parent=self,
   685               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   633               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   686 
   634 
   687         self.radioButton1 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1,
   635         self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1,
   688               label='Connector', name='radioButton1', parent=self,
   636               label='Connector', name='radioButton1', parent=self,
   689               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   637               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   690         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, self.OnTypeChanged)
   638         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1)
   691         self.radioButton1.SetValue(True)
   639         self.radioButton1.SetValue(True)
   692 
   640 
   693         self.radioButton2 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2,
   641         self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2,
   694               label='Continuation', name='radioButton2', parent=self, 
   642               label='Continuation', name='radioButton2', parent=self, 
   695               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   643               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   696         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, self.OnTypeChanged)
   644         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2)
   697         self.radioButton2.SetValue(False)
   645         self.radioButton2.SetValue(False)
   698         
   646         
   699         self.Name = wx.TextCtrl(id=wxID_CONNECTIONPROPERTIESDIALOGNAME,
   647         self.Name = wx.TextCtrl(id=ID_CONNECTIONPROPERTIESDIALOGNAME,
   700               name='Name', parent=self, pos=wx.Point(0, 0),
   648               name='Name', parent=self, pos=wx.Point(0, 0),
   701               size=wx.Size(0, 24), style=0)
   649               size=wx.Size(0, 24), style=0)
   702         EVT_TEXT(self, wxID_CONNECTIONPROPERTIESDIALOGNAME, self.OnNameChanged)
   650         self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_CONNECTIONPROPERTIESDIALOGNAME)
   703 
   651 
   704         self.Preview = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   652         self.Preview = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   705               name='Preview', parent=self, pos=wx.Point(0, 0),
   653               name='Preview', parent=self, pos=wx.Point(0, 0),
   706               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   654               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   707         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   655         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
   708         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   656         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   709 
   657 
   710         self.Spacer = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGSPACER,
   658         self.Spacer = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGSPACER,
   711               name='Spacer', parent=self, pos=wx.Point(0, 0),
   659               name='Spacer', parent=self, pos=wx.Point(0, 0),
   712               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   660               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   713 
   661 
   714         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   662         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
       
   663         
       
   664         self.Bind(wx.EVT_PAINT, self.OnPaint)
   715         
   665         
   716         self._init_sizers()
   666         self._init_sizers()
   717 
   667 
   718     def __init__(self, parent):
   668     def __init__(self, parent):
   719         self._init_ctrls(parent)
   669         self._init_ctrls(parent)
   720         self.Connection = None
   670         self.Connection = None
   721         self.MinConnectionSize = None
   671         self.MinConnectionSize = None
   722         
       
   723         EVT_PAINT(self, self.OnPaint)
       
   724             
   672             
   725     def SetMinConnectionSize(self, size):
   673     def SetMinConnectionSize(self, size):
   726         self.MinConnectionSize = size
   674         self.MinConnectionSize = size
   727     
   675     
   728     def SetValues(self, values):
   676     def SetValues(self, values):
   753     def OnNameChanged(self, event):
   701     def OnNameChanged(self, event):
   754         self.RefreshPreview()
   702         self.RefreshPreview()
   755         event.Skip()
   703         event.Skip()
   756         
   704         
   757     def RefreshPreview(self):
   705     def RefreshPreview(self):
   758         dc = wxClientDC(self.Preview)
   706         dc = wx.ClientDC(self.Preview)
   759         dc.Clear()
   707         dc.Clear()
   760         if self.radioButton1.GetValue():
   708         if self.radioButton1.GetValue():
   761             self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.Name.GetValue())
   709             self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.Name.GetValue())
   762         else:
   710         else:
   763             self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.Name.GetValue())
   711             self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.Name.GetValue())
   778 #-------------------------------------------------------------------------------
   726 #-------------------------------------------------------------------------------
   779 #                        Edit Ladder Element Properties Dialog
   727 #                        Edit Ladder Element Properties Dialog
   780 #-------------------------------------------------------------------------------
   728 #-------------------------------------------------------------------------------
   781 
   729 
   782 
   730 
   783 [wxID_LDELEMENTDIALOG, wxID_LDELEMENTDIALOGSPACER, 
   731 [ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, 
   784  wxID_LDELEMENTDIALOGNAME, wxID_LDELEMENTDIALOGRADIOBUTTON1, 
   732  ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, 
   785  wxID_LDELEMENTDIALOGRADIOBUTTON2, wxID_LDELEMENTDIALOGRADIOBUTTON3,
   733  ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3,
   786  wxID_LDELEMENTDIALOGRADIOBUTTON4, wxID_LDELEMENTDIALOGPREVIEW,
   734  ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGPREVIEW,
   787  wxID_LDELEMENTDIALOGSTATICTEXT1, wxID_LDELEMENTDIALOGSTATICTEXT2, 
   735  ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, 
   788  wxID_LDELEMENTDIALOGSTATICTEXT3, 
   736  ID_LDELEMENTDIALOGSTATICTEXT3, 
   789 ] = [wx.NewId() for _init_ctrls in range(11)]
   737 ] = [wx.NewId() for _init_ctrls in range(11)]
   790 
   738 
   791 class LDElementDialog(wx.Dialog):
   739 class LDElementDialog(wx.Dialog):
   792     def _init_coll_flexGridSizer1_Items(self, parent):
   740     def _init_coll_flexGridSizer1_Items(self, parent):
   793         # generated method, don't edit
   741         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
   794 
   742         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
   795         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
   796         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
   797         
   743         
   798     def _init_coll_flexGridSizer1_Growables(self, parent):
   744     def _init_coll_flexGridSizer1_Growables(self, parent):
   799         # generated method, don't edit
       
   800 
       
   801         parent.AddGrowableCol(0)
   745         parent.AddGrowableCol(0)
   802         parent.AddGrowableRow(0)
   746         parent.AddGrowableRow(0)
   803     
   747     
   804     def _init_coll_MainSizer_Items(self, parent):
   748     def _init_coll_MainSizer_Items(self, parent):
   805         # generated method, don't edit
   749         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
   806 
   750         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
   807         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
   808         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
   809     
   751     
   810     def _init_coll_LeftGridSizer_Items(self, parent):
   752     def _init_coll_LeftGridSizer_Items(self, parent):
   811         # generated method, don't edit
   753         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
   812 
   754         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
   813         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
   755         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
   814         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
   756         parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
   815         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
   757         parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW)
   816         parent.AddWindow(self.radioButton3, 0, border=0, flag=wxGROW)
   758         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
   817         parent.AddWindow(self.radioButton4, 0, border=0, flag=wxGROW)
   759         parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW)
   818         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
   760         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
   819         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
   761         
   820         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
   821     
       
   822     def _init_coll_LeftGridSizer_Growables(self, parent):
   762     def _init_coll_LeftGridSizer_Growables(self, parent):
   823         # generated method, don't edit
   763         parent.AddGrowableCol(0)
   824 
   764         parent.AddGrowableRow(7)
   825         parent.AddGrowableCol(0)
       
   826         parent.AddGrowableRow(5)
       
   827             
   765             
   828     def _init_coll_RightGridSizer_Items(self, parent):
   766     def _init_coll_RightGridSizer_Items(self, parent):
   829         # generated method, don't edit
   767         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
   830 
   768         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
   831         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
   832         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
   833         
   769         
   834     def _init_coll_RightGridSizer_Growables(self, parent):
   770     def _init_coll_RightGridSizer_Growables(self, parent):
   835         # generated method, don't edit
       
   836 
       
   837         parent.AddGrowableCol(0)
   771         parent.AddGrowableCol(0)
   838         parent.AddGrowableRow(1)
   772         parent.AddGrowableRow(1)
   839 
   773 
   840     def _init_sizers(self):
   774     def _init_sizers(self):
   841         # generated method, don't edit
       
   842         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   775         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   843         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
   776         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
   844         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
   777         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
   845         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   778         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   846 
   779 
   847         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   780         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   848         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   781         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   853         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   786         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   854 
   787 
   855         self.SetSizer(self.flexGridSizer1)
   788         self.SetSizer(self.flexGridSizer1)
   856 
   789 
   857     def _init_ctrls(self, prnt, title, labels):
   790     def _init_ctrls(self, prnt, title, labels):
   858         # generated method, don't edit
   791         wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG,
   859         wx.Dialog.__init__(self, id=wxID_LDELEMENTDIALOG,
       
   860               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   792               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   861               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
   793               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
   862               title=title)
   794               title=title)
   863         self.SetClientSize(wx.Size(350, 260))
   795         self.SetClientSize(wx.Size(350, 260))
   864 
   796 
   865         self.staticText1 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT1,
   797         self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1,
   866               label='Modifier:', name='staticText1', parent=self,
   798               label='Modifier:', name='staticText1', parent=self,
   867               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   799               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   868 
   800 
   869         self.staticText2 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT2,
   801         self.staticText2 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT2,
   870               label='Name:', name='staticText2', parent=self,
   802               label='Name:', name='staticText2', parent=self,
   871               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   803               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   872 
   804 
   873         self.staticText3 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT3,
   805         self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3,
   874               label='Preview:', name='staticText3', parent=self,
   806               label='Preview:', name='staticText3', parent=self,
   875               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   807               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   876 
   808 
   877         self.radioButton1 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON1,
   809         self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1,
   878               label=labels[0], name='radioButton1', parent=self,
   810               label=labels[0], name='radioButton1', parent=self,
   879               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   811               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   880         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON1, self.OnTypeChanged)
   812         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1)
   881         self.radioButton1.SetValue(True)
   813         self.radioButton1.SetValue(True)
   882 
   814 
   883         self.radioButton2 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON2,
   815         self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2,
   884               label=labels[1], name='radioButton2', parent=self, 
   816               label=labels[1], name='radioButton2', parent=self, 
   885               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   817               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   886         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON2, self.OnTypeChanged)
   818         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2)
   887 
   819 
   888         self.radioButton3 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON3,
   820         self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3,
   889               label=labels[2], name='radioButton3', parent=self,
   821               label=labels[2], name='radioButton3', parent=self,
   890               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   822               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   891         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON3, self.OnTypeChanged)
   823         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3)
   892 
   824 
   893         self.radioButton4 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON4,
   825         self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4,
   894               label=labels[3], name='radioButton4', parent=self, 
   826               label=labels[3], name='radioButton4', parent=self, 
   895               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   827               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   896         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON4, self.OnTypeChanged)
   828         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4)
   897 
   829 
   898         self.Name = wx.Choice(id=wxID_LDELEMENTDIALOGNAME,
   830         self.Name = wx.Choice(id=ID_LDELEMENTDIALOGNAME,
   899               name='Name', parent=self, pos=wx.Point(0, 0),
   831               name='Name', parent=self, pos=wx.Point(0, 0),
   900               size=wx.Size(0, 24), style=0)
   832               size=wx.Size(0, 24), style=0)
   901         EVT_CHOICE(self, wxID_LDELEMENTDIALOGNAME, self.OnNameChanged)
   833         self.Bind(wx.EVT_CHOICE, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME)
   902 
   834 
   903         self.Preview = wx.Panel(id=wxID_LDELEMENTDIALOGPREVIEW,
   835         self.Preview = wx.Panel(id=ID_LDELEMENTDIALOGPREVIEW,
   904               name='Preview', parent=self, pos=wx.Point(0, 0),
   836               name='Preview', parent=self, pos=wx.Point(0, 0),
   905               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   837               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   906         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   838         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
   907         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   839         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   908 
   840 
   909         self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER,
   841         self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
   910               name='Spacer', parent=self, pos=wx.Point(0, 0),
   842               name='Spacer', parent=self, pos=wx.Point(0, 0),
   911               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   843               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
   912 
   844 
   913         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   845         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
   914 
   846         
       
   847         self.Bind(wx.EVT_PAINT, self.OnPaint)
       
   848         
   915         self._init_sizers()
   849         self._init_sizers()
   916 
   850 
   917     def __init__(self, parent, type):
   851     def __init__(self, parent, type):
   918         self.Type = type
   852         self.Type = type
   919         if type == "contact":
   853         if type == "contact":
   920             self._init_ctrls(parent, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge'])
   854             self._init_ctrls(parent, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge'])
   921             self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
   855             self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
   922         elif type == "coil":
   856         elif type == "coil":
   923             self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
   857             self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
   924             self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
   858             self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
   925         self.Element.SetPosition((150 - LD_ELEMENT_SIZE[0]) / 2, (150 - LD_ELEMENT_SIZE[1]) / 2)
   859         
   926 
       
   927         EVT_PAINT(self, self.OnPaint)
       
   928 
       
   929     def SetElementSize(self, size):
   860     def SetElementSize(self, size):
   930         min_width, min_height = self.Element.GetMinSize()
   861         min_width, min_height = self.Element.GetMinSize()
   931         width, height = max(min_width, size[0]), max(min_height, size[1])
   862         width, height = max(min_width, size[0]), max(min_height, size[1])
   932         self.Element.SetSize(width, height)
   863         self.Element.SetSize(width, height)
   933         self.Element.SetPosition((150 - width) / 2, (150 - height) / 2)
   864         
   934 
       
   935     def SetVariables(self, vars):
   865     def SetVariables(self, vars):
   936         self.Name.Clear()
   866         self.Name.Clear()
   937         for name in vars:
   867         for name in vars:
   938             self.Name.Append(name)
   868             self.Name.Append(name)
   939         self.Name.Enable(self.Name.GetCount() > 0)
   869         self.Name.Enable(self.Name.GetCount() > 0)
   997         self.Element.SetName(self.Name.GetStringSelection())
   927         self.Element.SetName(self.Name.GetStringSelection())
   998         self.RefreshPreview()
   928         self.RefreshPreview()
   999         event.Skip()
   929         event.Skip()
  1000 
   930 
  1001     def RefreshPreview(self):
   931     def RefreshPreview(self):
  1002         dc = wxClientDC(self.Preview)
   932         dc = wx.ClientDC(self.Preview)
  1003         dc.Clear()
   933         dc.Clear()
  1004         clientsize = self.Preview.GetClientSize()
   934         clientsize = self.Preview.GetClientSize()
  1005         width, height = self.Element.GetSize()
   935         width, height = self.Element.GetSize()
  1006         self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
   936         self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
  1007         self.Element.Draw(dc)
   937         self.Element.Draw(dc)
  1014 #-------------------------------------------------------------------------------
   944 #-------------------------------------------------------------------------------
  1015 #                      Edit Ladder Power Rail Properties Dialog
   945 #                      Edit Ladder Power Rail Properties Dialog
  1016 #-------------------------------------------------------------------------------
   946 #-------------------------------------------------------------------------------
  1017 
   947 
  1018 
   948 
  1019 [wxID_LDPOWERRAILDIALOG, wxID_LDPOWERRAILDIALOGSPACER, 
   949 [ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, 
  1020  wxID_LDPOWERRAILDIALOGTYPE, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, 
   950  ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, 
  1021  wxID_LDPOWERRAILDIALOGRADIOBUTTON2, wxID_LDPOWERRAILDIALOGPREVIEW,
   951  ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW,
  1022  wxID_LDPOWERRAILDIALOGSTATICTEXT1, wxID_LDPOWERRAILDIALOGSTATICTEXT2, 
   952  ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, 
  1023  wxID_LDPOWERRAILDIALOGSTATICTEXT3, wxID_LDPOWERRAILDIALOGPINNUMBER,
   953  ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER,
  1024 ] = [wx.NewId() for _init_ctrls in range(10)]
   954 ] = [wx.NewId() for _init_ctrls in range(10)]
  1025 
   955 
  1026 class LDPowerRailDialog(wx.Dialog):
   956 class LDPowerRailDialog(wx.Dialog):
  1027     def _init_coll_flexGridSizer1_Items(self, parent):
   957     def _init_coll_flexGridSizer1_Items(self, parent):
  1028         # generated method, don't edit
   958         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1029 
   959         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1030         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
  1031         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
  1032         
   960         
  1033     def _init_coll_flexGridSizer1_Growables(self, parent):
   961     def _init_coll_flexGridSizer1_Growables(self, parent):
  1034         # generated method, don't edit
       
  1035 
       
  1036         parent.AddGrowableCol(0)
   962         parent.AddGrowableCol(0)
  1037         parent.AddGrowableRow(0)
   963         parent.AddGrowableRow(0)
  1038     
   964     
  1039     def _init_coll_MainSizer_Items(self, parent):
   965     def _init_coll_MainSizer_Items(self, parent):
  1040         # generated method, don't edit
   966         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
  1041 
   967         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
  1042         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
  1043         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
  1044     
   968     
  1045     def _init_coll_LeftGridSizer_Items(self, parent):
   969     def _init_coll_LeftGridSizer_Items(self, parent):
  1046         # generated method, don't edit
   970         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
  1047 
   971         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
  1048         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
   972         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
  1049         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
   973         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
  1050         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
   974         parent.AddWindow(self.PinNumber, 0, border=0, flag=wx.GROW)
  1051         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
   975         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
  1052         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
  1053         parent.AddWindow(self.PinNumber, 0, border=0, flag=wxGROW)
       
  1054     
   976     
  1055     def _init_coll_LeftGridSizer_Growables(self, parent):
   977     def _init_coll_LeftGridSizer_Growables(self, parent):
  1056         # generated method, don't edit
   978         parent.AddGrowableCol(0)
  1057 
   979         parent.AddGrowableRow(5)
  1058         parent.AddGrowableCol(0)
       
  1059         parent.AddGrowableRow(3)
       
  1060             
   980             
  1061     def _init_coll_RightGridSizer_Items(self, parent):
   981     def _init_coll_RightGridSizer_Items(self, parent):
  1062         # generated method, don't edit
   982         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
  1063 
   983         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
  1064         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
  1065         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
  1066         
   984         
  1067     def _init_coll_RightGridSizer_Growables(self, parent):
   985     def _init_coll_RightGridSizer_Growables(self, parent):
  1068         # generated method, don't edit
       
  1069 
       
  1070         parent.AddGrowableCol(0)
   986         parent.AddGrowableCol(0)
  1071         parent.AddGrowableRow(1)
   987         parent.AddGrowableRow(1)
  1072 
   988 
  1073     def _init_sizers(self):
   989     def _init_sizers(self):
  1074         # generated method, don't edit
       
  1075         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
   990         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  1076         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
   991         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
  1077         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
   992         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
  1078         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   993         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1079 
   994 
  1080         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   995         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1081         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
   996         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
  1086         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
  1001         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
  1087 
  1002 
  1088         self.SetSizer(self.flexGridSizer1)
  1003         self.SetSizer(self.flexGridSizer1)
  1089 
  1004 
  1090     def _init_ctrls(self, prnt):
  1005     def _init_ctrls(self, prnt):
  1091         # generated method, don't edit
  1006         wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG,
  1092         wx.Dialog.__init__(self, id=wxID_LDPOWERRAILDIALOG,
       
  1093               name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
  1007               name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
  1094               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
  1008               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
  1095               title='Power Rail Properties')
  1009               title='Power Rail Properties')
  1096         self.SetClientSize(wx.Size(350, 260))
  1010         self.SetClientSize(wx.Size(350, 260))
  1097 
  1011 
  1098         self.staticText1 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT1,
  1012         self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1,
  1099               label='Type:', name='staticText1', parent=self,
  1013               label='Type:', name='staticText1', parent=self,
  1100               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1014               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1101 
  1015 
  1102         self.staticText2 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT2,
  1016         self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2,
  1103               label='Pin number:', name='staticText2', parent=self,
  1017               label='Pin number:', name='staticText2', parent=self,
  1104               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1018               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1105 
  1019 
  1106         self.staticText3 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT3,
  1020         self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3,
  1107               label='Preview:', name='staticText3', parent=self,
  1021               label='Preview:', name='staticText3', parent=self,
  1108               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1022               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1109 
  1023 
  1110         self.radioButton1 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON1,
  1024         self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1,
  1111               label='Left PowerRail', name='radioButton1', parent=self,
  1025               label='Left PowerRail', name='radioButton1', parent=self,
  1112               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1026               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1113         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, self.OnTypeChanged)
  1027         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1)
  1114         self.radioButton1.SetValue(True)
  1028         self.radioButton1.SetValue(True)
  1115 
  1029 
  1116         self.radioButton2 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON2,
  1030         self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2,
  1117               label='Right PowerRail', name='radioButton2', parent=self, 
  1031               label='Right PowerRail', name='radioButton2', parent=self, 
  1118               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1032               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1119         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON2, self.OnTypeChanged)
  1033         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON2)
  1120 
  1034 
  1121         self.PinNumber = wx.SpinCtrl(id=wxID_LDPOWERRAILDIALOGPINNUMBER,
  1035         self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER,
  1122               name='PinNumber', parent=self, pos=wx.Point(0, 0),
  1036               name='PinNumber', parent=self, pos=wx.Point(0, 0),
  1123               size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=1, max=20)
  1037               size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=1, max=20)
  1124         EVT_SPINCTRL(self, wxID_LDPOWERRAILDIALOGPINNUMBER, self.OnPinNumberChanged)
  1038         self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, id=ID_LDPOWERRAILDIALOGPINNUMBER)
  1125 
  1039 
  1126         self.Preview = wx.Panel(id=wxID_LDPOWERRAILDIALOGPREVIEW,
  1040         self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW,
  1127               name='Preview', parent=self, pos=wx.Point(0, 0),
  1041               name='Preview', parent=self, pos=wx.Point(0, 0),
  1128               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1042               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1129         self.Preview.SetBackgroundColour(wxColour(255,255,255))
  1043         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
  1130         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
  1044         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
  1131 
  1045 
  1132         self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER,
  1046         self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
  1133               name='Spacer', parent=self, pos=wx.Point(0, 0),
  1047               name='Spacer', parent=self, pos=wx.Point(0, 0),
  1134               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
  1048               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
  1135 
  1049 
  1136         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
  1050         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
  1137 
  1051         
       
  1052         self.Bind(wx.EVT_PAINT, self.OnPaint)
       
  1053         
  1138         self._init_sizers()
  1054         self._init_sizers()
  1139 
  1055 
  1140     def __init__(self, parent, type = LEFTRAIL, number = 1):
  1056     def __init__(self, parent, type = LEFTRAIL, number = 1):
  1141         self._init_ctrls(parent)
  1057         self._init_ctrls(parent)
  1142         self.Type = type
  1058         self.Type = type
  1147         self.PinNumber.SetValue(number)
  1063         self.PinNumber.SetValue(number)
  1148         
  1064         
  1149         self.PowerRailMinSize = (0, 0)
  1065         self.PowerRailMinSize = (0, 0)
  1150         self.PowerRail = None
  1066         self.PowerRail = None
  1151 
  1067 
  1152         EVT_PAINT(self, self.OnPaint)
       
  1153 
       
  1154     def SetMinSize(self, size):
  1068     def SetMinSize(self, size):
  1155         self.PowerRailMinSize = size
  1069         self.PowerRailMinSize = size
  1156         self.RefreshPreview()    
  1070         self.RefreshPreview()    
  1157 
  1071 
  1158     def GetValues(self):
  1072     def GetValues(self):
  1173     def OnPinNumberChanged(self, event):
  1087     def OnPinNumberChanged(self, event):
  1174         self.RefreshPreview()
  1088         self.RefreshPreview()
  1175         event.Skip()
  1089         event.Skip()
  1176 
  1090 
  1177     def RefreshPreview(self):
  1091     def RefreshPreview(self):
  1178         dc = wxClientDC(self.Preview)
  1092         dc = wx.ClientDC(self.Preview)
  1179         dc.Clear()
  1093         dc.Clear()
  1180         self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
  1094         self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
  1181         min_width, min_height = self.PowerRail.GetMinSize()
  1095         min_width, min_height = self.PowerRail.GetMinSize()
  1182         width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
  1096         width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
  1183         self.PowerRail.SetSize(width, height)
  1097         self.PowerRail.SetSize(width, height)
  1192 
  1106 
  1193 #-------------------------------------------------------------------------------
  1107 #-------------------------------------------------------------------------------
  1194 #                          Edit Transition Content Dialog
  1108 #                          Edit Transition Content Dialog
  1195 #-------------------------------------------------------------------------------
  1109 #-------------------------------------------------------------------------------
  1196 
  1110 
  1197 [wxID_TRANSITIONCONTENTDIALOG, wxID_TRANSITIONCONTENTDIALOGMAINPANEL, 
  1111 [ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, 
  1198  wxID_TRANSITIONCONTENTDIALOGREFERENCE, wxID_TRANSITIONCONTENTDIALOGINLINE, 
  1112  ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, 
  1199  wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, 
  1113  ID_TRANSITIONCONTENTDIALOGPREVIEW, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, 
  1200 ] = [wx.NewId() for _init_ctrls in range(6)]
  1114  ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, 
       
  1115  ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, 
       
  1116 ] = [wx.NewId() for _init_ctrls in range(10)]
  1201 
  1117 
  1202 class TransitionContentDialog(wx.Dialog):
  1118 class TransitionContentDialog(wx.Dialog):
  1203     def _init_coll_flexGridSizer1_Items(self, parent):
  1119     def _init_coll_flexGridSizer1_Items(self, parent):
  1204         # generated method, don't edit
  1120         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1205 
  1121         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1206         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
  1122         
       
  1123     def _init_coll_flexGridSizer1_Growables(self, parent):
       
  1124         parent.AddGrowableCol(0)
       
  1125         parent.AddGrowableRow(0)
       
  1126     
       
  1127     def _init_coll_MainSizer_Items(self, parent):
       
  1128         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
       
  1129         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
       
  1130     
       
  1131     def _init_coll_LeftGridSizer_Items(self, parent):
       
  1132         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
       
  1133         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
       
  1134         parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW)
       
  1135         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
       
  1136         parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW)
       
  1137         parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
       
  1138         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
       
  1139     
       
  1140     def _init_coll_LeftGridSizer_Growables(self, parent):
       
  1141         parent.AddGrowableCol(0)
       
  1142         parent.AddGrowableRow(6)
       
  1143             
       
  1144     def _init_coll_RightGridSizer_Items(self, parent):
       
  1145         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
       
  1146         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
       
  1147         
       
  1148     def _init_coll_RightGridSizer_Growables(self, parent):
       
  1149         parent.AddGrowableCol(0)
       
  1150         parent.AddGrowableRow(1)
  1207 
  1151 
  1208     def _init_sizers(self):
  1152     def _init_sizers(self):
  1209         # generated method, don't edit
  1153         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  1210         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  1154         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
       
  1155         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
       
  1156         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1211 
  1157 
  1212         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1158         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
       
  1159         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
  1160         self._init_coll_MainSizer_Items(self.MainSizer)
       
  1161         self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
       
  1162         self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
       
  1163         self._init_coll_RightGridSizer_Items(self.RightGridSizer)
       
  1164         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
  1213 
  1165 
  1214         self.SetSizer(self.flexGridSizer1)
  1166         self.SetSizer(self.flexGridSizer1)
  1215 
  1167 
  1216     def _init_ctrls(self, prnt):
  1168     def _init_ctrls(self, prnt):
  1217         # generated method, don't edit
  1169         wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG,
  1218         wx.Dialog.__init__(self, id=wxID_TRANSITIONCONTENTDIALOG,
       
  1219               name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
  1170               name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
  1220               size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE,
  1171               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
  1221               title='Edit transition')
  1172               title='Edit transition')
  1222         self.SetClientSize(wx.Size(300, 200))
  1173         self.SetClientSize(wx.Size(350, 260))
  1223 
  1174 
  1224         self.MainPanel = wx.Panel(id=wxID_TRANSITIONCONTENTDIALOGMAINPANEL,
  1175         self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1,
  1225               name='MainPanel', parent=self, pos=wx.Point(0, 0),
  1176               label='Type:', name='staticText1', parent=self,
  1226               size=wx.Size(300, 200), style=wx.TAB_TRAVERSAL)
  1177               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1227         self.MainPanel.SetAutoLayout(True)
  1178 
  1228 
  1179         self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2,
  1229         self.radioButton1 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
  1180               label='Preview:', name='staticText2', parent=self,
  1230               label='Reference', name='radioButton1', parent=self.MainPanel,
  1181               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1231               pos=wx.Point(24, 24), size=wx.Size(114, 24), style=0)
  1182 
  1232         EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, self.OnTypeChanged)
  1183         self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
       
  1184               label='Reference', name='radioButton1', parent=self,
       
  1185               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
       
  1186         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1)
  1233         self.radioButton1.SetValue(True)
  1187         self.radioButton1.SetValue(True)
  1234 
  1188 
  1235         self.Reference = wx.Choice(id=wxID_TRANSITIONCONTENTDIALOGREFERENCE,
  1189         self.Reference = wx.Choice(id=ID_TRANSITIONCONTENTDIALOGREFERENCE,
  1236               name='Reference', parent=self.MainPanel, pos=wx.Point(48, 48), 
  1190               name='Reference', parent=self, pos=wx.Point(0, 0), 
  1237               size=wx.Size(200, 24), style=0)
  1191               size=wx.Size(0, 24), style=0)
  1238 
  1192         self.Bind(wx.EVT_CHOICE, self.OnReferenceChanged, id=ID_TRANSITIONCONTENTDIALOGREFERENCE)
  1239         self.radioButton2 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2,
  1193 
  1240               label='Inline', name='radioButton2', parent=self.MainPanel,
  1194         self.radioButton2 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2,
  1241               pos=wx.Point(24, 72), size=wx.Size(114, 24), style=0)
  1195               label='Inline', name='radioButton2', parent=self,
  1242         EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, self.OnTypeChanged)
  1196               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
       
  1197         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2)
  1243         self.radioButton2.SetValue(False)
  1198         self.radioButton2.SetValue(False)
  1244 
  1199 
  1245         self.Inline = wx.TextCtrl(id=wxID_TRANSITIONCONTENTDIALOGINLINE,
  1200         self.Inline = wx.TextCtrl(id=ID_TRANSITIONCONTENTDIALOGINLINE,
  1246               name='Inline', parent=self.MainPanel, pos=wx.Point(48, 96),
  1201               name='Inline', parent=self, pos=wx.Point(0, 0),
  1247               size=wx.Size(200, 24), style=0)
  1202               size=wx.Size(0, 24), style=0)
  1248 
  1203         self.Bind(wx.EVT_TEXT, self.OnInlineChanged, id=ID_TRANSITIONCONTENTDIALOGINLINE)
       
  1204 
       
  1205         self.radioButton3 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3,
       
  1206               label='Connection', name='radioButton3', parent=self,
       
  1207               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
       
  1208         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3)
       
  1209         self.radioButton3.SetValue(False)
       
  1210         if not self.Connection:
       
  1211             self.radioButton3.Hide()
       
  1212 
       
  1213         self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW,
       
  1214               name='Preview', parent=self, pos=wx.Point(0, 0),
       
  1215               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
       
  1216         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
       
  1217         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
       
  1218         setattr(self.Preview, "RefreshTransitionModel", lambda x:None)
       
  1219 
       
  1220         self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
       
  1221               name='Spacer', parent=self, pos=wx.Point(0, 0),
       
  1222               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
       
  1223 
       
  1224         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
       
  1225         self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
       
  1226         
       
  1227         self.Bind(wx.EVT_PAINT, self.OnPaint)
       
  1228         
  1249         self._init_sizers()
  1229         self._init_sizers()
  1250 
  1230 
  1251     def __init__(self, parent):
  1231     def __init__(self, parent, connection):
       
  1232         self.Connection = connection
  1252         self._init_ctrls(parent)
  1233         self._init_ctrls(parent)
  1253         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
  1234         self.Transition = None
  1254         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
  1235         self.MinTransitionSize = None
  1255         
  1236         
  1256         EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
  1237         self.Element = SFC_Transition(self.Preview)
       
  1238         
       
  1239     def SetElementSize(self, size):
       
  1240         min_width, min_height = self.Element.GetMinSize()
       
  1241         width, height = max(min_width, size[0]), max(min_height, size[1])
       
  1242         self.Element.SetSize(width, height)
  1257     
  1243     
  1258     def OnOK(self, event):
  1244     def OnOK(self, event):
  1259         error = []
  1245         error = []
  1260         if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "":
  1246         if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "":
  1261             error.append("Reference")
  1247             error.append("Reference")
  1268                     text += item
  1254                     text += item
  1269                 elif i == len(error) - 1:
  1255                 elif i == len(error) - 1:
  1270                     text += " and %s"%item
  1256                     text += " and %s"%item
  1271                 else:
  1257                 else:
  1272                     text += ", %s"%item 
  1258                     text += ", %s"%item 
  1273             message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR)
  1259             message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
  1274             message.ShowModal()
  1260             message.ShowModal()
  1275             message.Destroy()
  1261             message.Destroy()
  1276         else:
  1262         else:
  1277             self.EndModal(wxID_OK)
  1263             self.EndModal(wx.ID_OK)
  1278 
  1264 
  1279     def OnTypeChanged(self, event):
  1265     def OnTypeChanged(self, event):
  1280         if self.radioButton1.GetValue():
  1266         if self.radioButton1.GetValue():
       
  1267             self.Element.SetType("reference", self.Reference.GetStringSelection())
  1281             self.Reference.Enable(True)
  1268             self.Reference.Enable(True)
  1282             self.Inline.Enable(False)
  1269             self.Inline.Enable(False)
  1283         else:
  1270         elif self.radioButton2.GetValue():
       
  1271             self.Element.SetType("inline", self.Inline.GetValue())
  1284             self.Reference.Enable(False)
  1272             self.Reference.Enable(False)
  1285             self.Inline.Enable(True)
  1273             self.Inline.Enable(True)
       
  1274         else:
       
  1275             self.Element.SetType("connection")
       
  1276             self.Reference.Enable(False)
       
  1277             self.Inline.Enable(False)
       
  1278         self.RefreshPreview()
       
  1279         event.Skip()
       
  1280 
       
  1281     def OnReferenceChanged(self, event):
       
  1282         self.Element.SetType("reference", self.Reference.GetStringSelection())
       
  1283         self.RefreshPreview()
       
  1284         event.Skip()
       
  1285 
       
  1286     def OnInlineChanged(self, event):
       
  1287         self.Element.SetType("inline", self.Inline.GetValue())
       
  1288         self.RefreshPreview()
  1286         event.Skip()
  1289         event.Skip()
  1287 
  1290 
  1288     def SetTransitions(self, transitions):
  1291     def SetTransitions(self, transitions):
       
  1292         self.Reference.Append("")
  1289         for transition in transitions:
  1293         for transition in transitions:
  1290             self.Reference.Append(transition)
  1294             self.Reference.Append(transition)
  1291 
  1295 
  1292     def SetValues(self, values):
  1296     def SetValues(self, values):
  1293         if values["type"] == "reference":
  1297         if values["type"] == "reference":
  1294             self.radioButton1.SetValue(True)
  1298             self.radioButton1.SetValue(True)
  1295             self.radioButton2.SetValue(False)
  1299             self.radioButton2.SetValue(False)
       
  1300             self.radioButton3.SetValue(False)
  1296             self.Reference.Enable(True)
  1301             self.Reference.Enable(True)
  1297             self.Inline.Enable(False)
  1302             self.Inline.Enable(False)
  1298             self.Reference.SetStringSelection(values["value"])
  1303             self.Reference.SetStringSelection(values["value"])
       
  1304             self.Element.SetType("reference", values["value"])
  1299         elif values["type"] == "inline":
  1305         elif values["type"] == "inline":
  1300             self.radioButton1.SetValue(False)
  1306             self.radioButton1.SetValue(False)
  1301             self.radioButton2.SetValue(True)
  1307             self.radioButton2.SetValue(True)
       
  1308             self.radioButton3.SetValue(False)
  1302             self.Reference.Enable(False)
  1309             self.Reference.Enable(False)
  1303             self.Inline.Enable(True)
  1310             self.Inline.Enable(True)
  1304             self.Inline.SetValue(values["value"])
  1311             self.Inline.SetValue(values["value"])
  1305                 
  1312             self.Element.SetType("inline", values["value"])
       
  1313         elif values["type"] == "connection" and self.Connection:
       
  1314             self.radioButton1.SetValue(False)
       
  1315             self.radioButton2.SetValue(False)
       
  1316             self.radioButton3.SetValue(True)
       
  1317             self.Reference.Enable(False)
       
  1318             self.Inline.Enable(False)
       
  1319             self.Element.SetType("connection")
       
  1320         self.RefreshPreview()
       
  1321         
  1306     def GetValues(self):
  1322     def GetValues(self):
  1307         values = {}
  1323         values = {}
  1308         if self.radioButton1.GetValue():
  1324         if self.radioButton1.GetValue():
  1309             values["type"] = "reference"
  1325             values["type"] = "reference"
  1310             values["value"] = self.Reference.GetStringSelection()
  1326             values["value"] = self.Reference.GetStringSelection()
  1311         else:
  1327         elif self.radioButton2.GetValue():
  1312             values["type"] = "inline"
  1328             values["type"] = "inline"
  1313             values["value"] = self.Inline.GetValue()
  1329             values["value"] = self.Inline.GetValue()
       
  1330         else:
       
  1331             values["type"] = "connection"
       
  1332             values["value"] = None
  1314         return values
  1333         return values
       
  1334 
       
  1335     def RefreshPreview(self):
       
  1336         dc = wx.ClientDC(self.Preview)
       
  1337         dc.Clear()
       
  1338         clientsize = self.Preview.GetClientSize()
       
  1339         posx, posy = self.Element.GetPosition()
       
  1340         rect = self.Element.GetBoundingBox()
       
  1341         diffx, diffy = posx - rect.x, posy - rect.y
       
  1342         self.Element.SetPosition((clientsize.width - rect.width) / 2 + diffx, (clientsize.height - rect.height) / 2 + diffy)
       
  1343         self.Element.Draw(dc)
       
  1344 
       
  1345     def OnPaint(self, event):
       
  1346         self.RefreshPreview()
  1315 
  1347 
  1316 #-------------------------------------------------------------------------------
  1348 #-------------------------------------------------------------------------------
  1317 #                         Create New Divergence Dialog
  1349 #                         Create New Divergence Dialog
  1318 #-------------------------------------------------------------------------------
  1350 #-------------------------------------------------------------------------------
  1319 
  1351 
  1320 [wxID_DIVERGENCECREATEDIALOG, wxID_DIVERGENCECREATEDIALOGMAINPANEL, 
  1352 [ID_DIVERGENCECREATEDIALOG, ID_DIVERGENCECREATEDIALOGSPACER, 
  1321  wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
  1353  ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, ID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
  1322  wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, 
  1354  ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, 
  1323  wxID_DIVERGENCECREATEDIALOGSEQUENCES, wxID_DIVERGENCECREATEDIALOGPREVIEW, 
  1355  ID_DIVERGENCECREATEDIALOGSEQUENCES, ID_DIVERGENCECREATEDIALOGPREVIEW, 
  1324  wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, 
  1356  ID_DIVERGENCECREATEDIALOGSTATICTEXT1, ID_DIVERGENCECREATEDIALOGSTATICTEXT2, 
  1325  wxID_DIVERGENCECREATEDIALOGSTATICTEXT3,  
  1357  ID_DIVERGENCECREATEDIALOGSTATICTEXT3,  
  1326 ] = [wx.NewId() for _init_ctrls in range(11)]
  1358 ] = [wx.NewId() for _init_ctrls in range(11)]
  1327 
  1359 
  1328 class DivergenceCreateDialog(wx.Dialog):
  1360 class DivergenceCreateDialog(wx.Dialog):
  1329     def _init_coll_flexGridSizer1_Items(self, parent):
  1361     def _init_coll_flexGridSizer1_Items(self, parent):
  1330         # generated method, don't edit
  1362         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1331 
  1363         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1332         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
  1364         
       
  1365     def _init_coll_flexGridSizer1_Growables(self, parent):
       
  1366         parent.AddGrowableCol(0)
       
  1367         parent.AddGrowableRow(0)
       
  1368     
       
  1369     def _init_coll_MainSizer_Items(self, parent):
       
  1370         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
       
  1371         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
       
  1372     
       
  1373     def _init_coll_LeftGridSizer_Items(self, parent):
       
  1374         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
       
  1375         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
       
  1376         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
       
  1377         parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
       
  1378         parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW)
       
  1379         parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
       
  1380         parent.AddWindow(self.Sequences, 0, border=0, flag=wx.GROW)
       
  1381         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
       
  1382     
       
  1383     def _init_coll_LeftGridSizer_Growables(self, parent):
       
  1384         parent.AddGrowableCol(0)
       
  1385         parent.AddGrowableRow(7)
       
  1386             
       
  1387     def _init_coll_RightGridSizer_Items(self, parent):
       
  1388         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
       
  1389         parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
       
  1390         
       
  1391     def _init_coll_RightGridSizer_Growables(self, parent):
       
  1392         parent.AddGrowableCol(0)
       
  1393         parent.AddGrowableRow(1)
  1333 
  1394 
  1334     def _init_sizers(self):
  1395     def _init_sizers(self):
  1335         # generated method, don't edit
  1396         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  1336         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  1397         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
       
  1398         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
       
  1399         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1337 
  1400 
  1338         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1401         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
       
  1402         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
  1403         self._init_coll_MainSizer_Items(self.MainSizer)
       
  1404         self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
       
  1405         self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
       
  1406         self._init_coll_RightGridSizer_Items(self.RightGridSizer)
       
  1407         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
  1339 
  1408 
  1340         self.SetSizer(self.flexGridSizer1)
  1409         self.SetSizer(self.flexGridSizer1)
  1341 
  1410     
  1342     def _init_ctrls(self, prnt):
  1411     def _init_ctrls(self, prnt):
  1343         # generated method, don't edit
  1412         wx.Dialog.__init__(self, id=ID_DIVERGENCECREATEDIALOG,
  1344         wx.Dialog.__init__(self, id=wxID_DIVERGENCECREATEDIALOG,
       
  1345               name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
  1413               name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
  1346               size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
  1414               size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
  1347               title='Create a new divergence or convergence')
  1415               title='Create a new divergence or convergence')
  1348         self.SetClientSize(wx.Size(500, 260))
  1416         self.SetClientSize(wx.Size(500, 300))
  1349 
  1417 
  1350         self.MainPanel = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGMAINPANEL,
  1418         self.staticText1 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT1,
  1351               name='MainPanel', parent=self, pos=wx.Point(0, 0),
  1419               label='Type:', name='staticText1', parent=self,
  1352               size=wx.Size(600, 220), style=wx.TAB_TRAVERSAL)
  1420               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1353         self.MainPanel.SetAutoLayout(True)
  1421 
  1354 
  1422         self.radioButton1 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1,
  1355         self.staticText1 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT1,
  1423               label='Selection Divergence', name='radioButton1', parent=self,
  1356               label='Type:', name='staticText1', parent=self.MainPanel,
  1424               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1357               pos=wx.Point(24, 24), size=wx.Size(200, 17), style=0)
  1425         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1)
  1358 
       
  1359         self.radioButton1 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1,
       
  1360               label='Selection Divergence', name='radioButton1', parent=self.MainPanel,
       
  1361               pos=wx.Point(24, 48), size=wx.Size(200, 24), style=0)
       
  1362         EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, self.OnTypeChanged)
       
  1363         self.radioButton1.SetValue(True)
  1426         self.radioButton1.SetValue(True)
  1364 
  1427 
  1365         self.radioButton2 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
  1428         self.radioButton2 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2,
  1366               label='Selection Convergence', name='radioButton2', parent=self.MainPanel, 
  1429               label='Selection Convergence', name='radioButton2', parent=self, 
  1367               pos=wx.Point(24, 72), size=wx.Size(200, 24), style=0)
  1430               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1368         EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, self.OnTypeChanged)
  1431         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2)
  1369         self.radioButton2.SetValue(False)
  1432         self.radioButton2.SetValue(False)
  1370 
  1433 
  1371         self.radioButton3 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3,
  1434         self.radioButton3 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3,
  1372               label='Simultaneous Divergence', name='radioButton3', parent=self.MainPanel,
  1435               label='Simultaneous Divergence', name='radioButton3', parent=self,
  1373               pos=wx.Point(24, 96), size=wx.Size(200, 24), style=0)
  1436               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1374         EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, self.OnTypeChanged)
  1437         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3)
  1375         self.radioButton3.SetValue(False)
  1438         self.radioButton3.SetValue(False)
  1376 
  1439 
  1377         self.radioButton4 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4,
  1440         self.radioButton4 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4,
  1378               label='Simultaneous Convergence', name='radioButton4', parent=self.MainPanel, 
  1441               label='Simultaneous Convergence', name='radioButton4', parent=self, 
  1379               pos=wx.Point(24, 120), size=wx.Size(200, 24), style=0)
  1442               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1380         EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, self.OnTypeChanged)
  1443         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4)
  1381         self.radioButton4.SetValue(False)
  1444         self.radioButton4.SetValue(False)
  1382 
  1445 
  1383         self.staticText2 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT2,
  1446         self.staticText2 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT2,
  1384               label='Number of sequences:', name='staticText2', parent=self.MainPanel,
  1447               label='Number of sequences:', name='staticText2', parent=self,
  1385               pos=wx.Point(24, 150), size=wx.Size(200, 17), style=0)
  1448               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1386 
  1449 
  1387         self.Sequences = wx.SpinCtrl(id=wxID_DIVERGENCECREATEDIALOGSEQUENCES,
  1450         self.Sequences = wx.SpinCtrl(id=ID_DIVERGENCECREATEDIALOGSEQUENCES,
  1388               name='Sequences', parent=self.MainPanel, pos=wx.Point(24, 174),
  1451               name='Sequences', parent=self, pos=wx.Point(0, 0),
  1389               size=wx.Size(200, 24), style=0, min=2, max=20)
  1452               size=wx.Size(0, 24), style=0, min=2, max=20)
  1390         EVT_SPINCTRL(self, wxID_DIVERGENCECREATEDIALOGSEQUENCES, self.OnSequencesChanged)
  1453         self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, id=ID_DIVERGENCECREATEDIALOGSEQUENCES)
  1391 
  1454 
  1392         self.staticText3 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT3,
  1455         self.staticText3 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT3,
  1393               label='Preview:', name='staticText3', parent=self.MainPanel,
  1456               label='Preview:', name='staticText3', parent=self,
  1394               pos=wx.Point(250, 24), size=wx.Size(100, 17), style=0)
  1457               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1395 
  1458 
  1396         self.Preview = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGPREVIEW,
  1459         self.Preview = wx.Panel(id=ID_DIVERGENCECREATEDIALOGPREVIEW,
  1397               name='Preview', parent=self.MainPanel, pos=wx.Point(250, 48),
  1460               name='Preview', parent=self, pos=wx.Point(0, 0),
  1398               size=wx.Size(225, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1461               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1399         self.Preview.SetBackgroundColour(wxColour(255,255,255))
  1462         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
  1400         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
  1463         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
  1401 
  1464 
       
  1465         self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
       
  1466               name='Spacer', parent=self, pos=wx.Point(0, 0),
       
  1467               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
       
  1468 
       
  1469         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
       
  1470         
       
  1471         self.Bind(wx.EVT_PAINT, self.OnPaint)
       
  1472         
  1402         self._init_sizers()
  1473         self._init_sizers()
  1403 
  1474 
  1404     def __init__(self, parent):
  1475     def __init__(self, parent):
  1405         self._init_ctrls(parent)
  1476         self._init_ctrls(parent)
  1406         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
  1407         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
       
  1408         
  1477         
  1409         self.Divergence = None
  1478         self.Divergence = None
  1410         self.MinSize = (0, 0)
  1479         self.MinSize = (0, 0)
  1411         
  1480         
  1412         EVT_PAINT(self, self.OnPaint)
       
  1413 
       
  1414     def GetValues(self):
  1481     def GetValues(self):
  1415         values = {}
  1482         values = {}
  1416         if self.radioButton1.GetValue():
  1483         if self.radioButton1.GetValue():
  1417             values["type"] = SELECTION_DIVERGENCE
  1484             values["type"] = SELECTION_DIVERGENCE
  1418         elif self.radioButton2.GetValue():
  1485         elif self.radioButton2.GetValue():
  1434     def OnSequencesChanged(self, event):
  1501     def OnSequencesChanged(self, event):
  1435         self.RefreshPreview()
  1502         self.RefreshPreview()
  1436         event.Skip()
  1503         event.Skip()
  1437         
  1504         
  1438     def RefreshPreview(self):
  1505     def RefreshPreview(self):
  1439         dc = wxClientDC(self.Preview)
  1506         dc = wx.ClientDC(self.Preview)
  1440         dc.Clear()
  1507         dc.Clear()
  1441         if self.radioButton1.GetValue():
  1508         if self.radioButton1.GetValue():
  1442             self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue())
  1509             self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue())
  1443         elif self.radioButton2.GetValue():
  1510         elif self.radioButton2.GetValue():
  1444             self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue())
  1511             self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue())
  1461 
  1528 
  1462 #-------------------------------------------------------------------------------
  1529 #-------------------------------------------------------------------------------
  1463 #                            Action Block Dialog
  1530 #                            Action Block Dialog
  1464 #-------------------------------------------------------------------------------
  1531 #-------------------------------------------------------------------------------
  1465 
  1532 
  1466 class ActionTable(wxPyGridTableBase):
  1533 class ActionTable(wx.grid.PyGridTableBase):
  1467     
  1534     
  1468     """
  1535     """
  1469     A custom wxGrid Table using user supplied data
  1536     A custom wx.Grid Table using user supplied data
  1470     """
  1537     """
  1471     def __init__(self, parent, data, colnames):
  1538     def __init__(self, parent, data, colnames):
  1472         # The base class must be initialized *first*
  1539         # The base class must be initialized *first*
  1473         wxPyGridTableBase.__init__(self)
  1540         wx.grid.PyGridTableBase.__init__(self)
  1474         self.data = data
  1541         self.data = data
  1475         self.colnames = colnames
  1542         self.colnames = colnames
  1476         self.Parent = parent
  1543         self.Parent = parent
  1477         # XXX
  1544         # XXX
  1478         # we need to store the row length and collength to
  1545         # we need to store the row length and collength to
  1505         if col < len(self.colnames):
  1572         if col < len(self.colnames):
  1506             self.data[row][self.GetColLabelValue(col)] = value
  1573             self.data[row][self.GetColLabelValue(col)] = value
  1507         
  1574         
  1508     def ResetView(self, grid):
  1575     def ResetView(self, grid):
  1509         """
  1576         """
  1510         (wxGrid) -> Reset the grid view.   Call this to
  1577         (wx.Grid) -> Reset the grid view.   Call this to
  1511         update the grid if rows and columns have been added or deleted
  1578         update the grid if rows and columns have been added or deleted
  1512         """
  1579         """
  1513         grid.BeginBatch()
  1580         grid.BeginBatch()
  1514         for current, new, delmsg, addmsg in [
  1581         for current, new, delmsg, addmsg in [
  1515             (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
  1582             (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
  1516             (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
  1583             (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
  1517         ]:
  1584         ]:
  1518             if new < current:
  1585             if new < current:
  1519                 msg = wxGridTableMessage(self,delmsg,new,current-new)
  1586                 msg = wx.grid.GridTableMessage(self,delmsg,new,current-new)
  1520                 grid.ProcessTableMessage(msg)
  1587                 grid.ProcessTableMessage(msg)
  1521             elif new > current:
  1588             elif new > current:
  1522                 msg = wxGridTableMessage(self,addmsg,new-current)
  1589                 msg = wx.grid.GridTableMessage(self,addmsg,new-current)
  1523                 grid.ProcessTableMessage(msg)
  1590                 grid.ProcessTableMessage(msg)
  1524                 self.UpdateValues(grid)
  1591                 self.UpdateValues(grid)
  1525         grid.EndBatch()
  1592         grid.EndBatch()
  1526 
  1593 
  1527         self._rows = self.GetNumberRows()
  1594         self._rows = self.GetNumberRows()
  1534         grid.ForceRefresh()
  1601         grid.ForceRefresh()
  1535 
  1602 
  1536     def UpdateValues(self, grid):
  1603     def UpdateValues(self, grid):
  1537         """Update all displayed values"""
  1604         """Update all displayed values"""
  1538         # This sends an event to the grid table to update all of the values
  1605         # This sends an event to the grid table to update all of the values
  1539         msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
  1606         msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
  1540         grid.ProcessTableMessage(msg)
  1607         grid.ProcessTableMessage(msg)
  1541 
  1608 
  1542     def _updateColAttrs(self, grid):
  1609     def _updateColAttrs(self, grid):
  1543         """
  1610         """
  1544         wxGrid -> update the column attributes to add the
  1611         wx.Grid -> update the column attributes to add the
  1545         appropriate renderer given the column name.
  1612         appropriate renderer given the column name.
  1546 
  1613 
  1547         Otherwise default to the default renderer.
  1614         Otherwise default to the default renderer.
  1548         """
  1615         """
  1549         
  1616         
  1550         for col in range(self.GetNumberCols()):
  1617         for col in range(self.GetNumberCols()):
  1551             attr = wxGridCellAttr()
  1618             attr = wx.grid.GridCellAttr()
  1552             attr.SetAlignment(self.Parent.ColAlignements[col], wxALIGN_CENTRE)
  1619             attr.SetAlignment(self.Parent.ColAlignements[col], wx.ALIGN_CENTRE)
  1553             grid.SetColAttr(col, attr)
  1620             grid.SetColAttr(col, attr)
  1554             grid.SetColSize(col, self.Parent.ColSizes[col])
  1621             grid.SetColSize(col, self.Parent.ColSizes[col])
  1555         
  1622         
  1556         typelist = None
  1623         typelist = None
  1557         accesslist = None
  1624         accesslist = None
  1560                 editor = None
  1627                 editor = None
  1561                 renderer = None
  1628                 renderer = None
  1562                 readonly = False
  1629                 readonly = False
  1563                 colname = self.GetColLabelValue(col)
  1630                 colname = self.GetColLabelValue(col)
  1564                 if colname == "Qualifier":
  1631                 if colname == "Qualifier":
  1565                     editor = wxGridCellChoiceEditor()
  1632                     editor = wx.grid.GridCellChoiceEditor()
  1566                     editor.SetParameters(self.Parent.QualifierList)
  1633                     editor.SetParameters(self.Parent.QualifierList)
  1567                 if colname == "Duration":
  1634                 if colname == "Duration":
  1568                     editor = wxGridCellTextEditor()
  1635                     editor = wx.grid.GridCellTextEditor()
  1569                     renderer = wxGridCellStringRenderer()
  1636                     renderer = wx.grid.GridCellStringRenderer()
  1570                     if self.Parent.DurationList[self.data[row]["Qualifier"]]:
  1637                     if self.Parent.DurationList[self.data[row]["Qualifier"]]:
  1571                         readonly = False
  1638                         readonly = False
  1572                     else:
  1639                     else:
  1573                         readonly = True
  1640                         readonly = True
  1574                         self.data[row]["Duration"] = ""
  1641                         self.data[row]["Duration"] = ""
  1575                 elif colname == "Type":
  1642                 elif colname == "Type":
  1576                     editor = wxGridCellChoiceEditor()
  1643                     editor = wx.grid.GridCellChoiceEditor()
  1577                     editor.SetParameters(self.Parent.TypeList)
  1644                     editor.SetParameters(self.Parent.TypeList)
  1578                 elif colname == "Value":
  1645                 elif colname == "Value":
  1579                     type = self.data[row]["Type"]
  1646                     type = self.data[row]["Type"]
  1580                     if type == "Action":
  1647                     if type == "Action":
  1581                         editor = wxGridCellChoiceEditor()
  1648                         editor = wx.grid.GridCellChoiceEditor()
  1582                         editor.SetParameters(self.Parent.ActionList)
  1649                         editor.SetParameters(self.Parent.ActionList)
  1583                     elif type == "Variable":
  1650                     elif type == "Variable":
  1584                         editor = wxGridCellChoiceEditor()
  1651                         editor = wx.grid.GridCellChoiceEditor()
  1585                         editor.SetParameters(self.Parent.VariableList)
  1652                         editor.SetParameters(self.Parent.VariableList)
  1586                     elif type == "Inline":
  1653                     elif type == "Inline":
  1587                         editor = wxGridCellTextEditor()
  1654                         editor = wx.grid.GridCellTextEditor()
  1588                         renderer = wxGridCellStringRenderer()
  1655                         renderer = wx.grid.GridCellStringRenderer()
  1589                 elif colname == "Indicator":
  1656                 elif colname == "Indicator":
  1590                     editor = wxGridCellChoiceEditor()
  1657                     editor = wx.grid.GridCellChoiceEditor()
  1591                     editor.SetParameters(self.Parent.VariableList)
  1658                     editor.SetParameters(self.Parent.VariableList)
  1592                     
  1659                     
  1593                 grid.SetCellEditor(row, col, editor)
  1660                 grid.SetCellEditor(row, col, editor)
  1594                 grid.SetCellRenderer(row, col, renderer)
  1661                 grid.SetCellRenderer(row, col, renderer)
  1595                 grid.SetReadOnly(row, col, readonly)
  1662                 grid.SetReadOnly(row, col, readonly)
  1596                 
  1663                 
  1597                 grid.SetCellBackgroundColour(row, col, wxWHITE)
  1664                 grid.SetCellBackgroundColour(row, col, wx.WHITE)
  1598     
  1665     
  1599     def SetData(self, data):
  1666     def SetData(self, data):
  1600         self.data = data
  1667         self.data = data
  1601     
  1668     
  1602     def GetData(self):
  1669     def GetData(self):
  1622 
  1689 
  1623     def Empty(self):
  1690     def Empty(self):
  1624         self.data = []
  1691         self.data = []
  1625         self.editors = []
  1692         self.editors = []
  1626 
  1693 
  1627 [wxID_ACTIONBLOCKDIALOG, wxID_ACTIONBLOCKDIALOGMAINPANEL, 
  1694 [ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID, 
  1628  wxID_ACTIONBLOCKDIALOGVARIABLESGRID, wxID_ACTIONBLOCKDIALOGSTATICTEXT1, 
  1695  ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON,
  1629  wxID_ACTIONBLOCKDIALOGADDBUTTON,wxID_ACTIONBLOCKDIALOGDELETEBUTTON, 
  1696  ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON, 
  1630  wxID_ACTIONBLOCKDIALOGUPBUTTON, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, 
  1697  ID_ACTIONBLOCKDIALOGDOWNBUTTON, 
  1631 ] = [wx.NewId() for _init_ctrls in range(8)]
  1698 ] = [wx.NewId() for _init_ctrls in range(7)]
  1632 
  1699 
  1633 class ActionBlockDialog(wx.Dialog):
  1700 class ActionBlockDialog(wx.Dialog):
  1634     def _init_coll_flexGridSizer1_Items(self, parent):
  1701     def _init_coll_flexGridSizer1_Items(self, parent):
  1635         # generated method, don't edit
  1702         parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1636 
  1703         parent.AddSizer(self.GridButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
  1637         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
  1704         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
       
  1705         
       
  1706     def _init_coll_flexGridSizer1_Growables(self, parent):
       
  1707         parent.AddGrowableCol(0)
       
  1708         parent.AddGrowableRow(0)
       
  1709         
       
  1710     def _init_coll_TopSizer_Items(self, parent):
       
  1711         parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
       
  1712         parent.AddWindow(self.ActionsGrid, 0, border=0, flag=wx.GROW)
       
  1713     
       
  1714     def _init_coll_TopSizer_Growables(self, parent):
       
  1715         parent.AddGrowableCol(0)
       
  1716         parent.AddGrowableRow(1)
       
  1717 
       
  1718     def _init_coll_GridButtonSizer_Items(self, parent):
       
  1719         parent.AddWindow(self.AddButton, 0, border=10, flag=wx.GROW|wx.LEFT)
       
  1720         parent.AddWindow(self.DeleteButton, 0, border=10, flag=wx.GROW|wx.LEFT)
       
  1721         parent.AddWindow(self.UpButton, 0, border=10, flag=wx.GROW|wx.LEFT)
       
  1722         parent.AddWindow(self.DownButton, 0, border=10, flag=wx.GROW|wx.LEFT)
  1638 
  1723 
  1639     def _init_sizers(self):
  1724     def _init_sizers(self):
  1640         # generated method, don't edit
  1725         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
  1641         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  1726         self.TopSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1642 
  1727         self.GridButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
       
  1728         
  1643         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1729         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1644 
  1730         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
  1731         self._init_coll_TopSizer_Items(self.TopSizer)
       
  1732         self._init_coll_TopSizer_Growables(self.TopSizer)
       
  1733         self._init_coll_GridButtonSizer_Items(self.GridButtonSizer)
       
  1734         
  1645         self.SetSizer(self.flexGridSizer1)
  1735         self.SetSizer(self.flexGridSizer1)
  1646 
  1736     
  1647     def _init_ctrls(self, prnt):
  1737     def _init_ctrls(self, prnt):
  1648         # generated method, don't edit
  1738         wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG,
  1649         wx.Dialog.__init__(self, id=wxID_ACTIONBLOCKDIALOG,
       
  1650               name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223),
  1739               name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223),
  1651               size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
  1740               size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
  1652               title='Edit action block properties')
  1741               title='Edit action block properties')
  1653         self.SetClientSize(wx.Size(500, 300))
  1742         self.SetClientSize(wx.Size(500, 300))
  1654 
  1743 
  1655         self.MainPanel = wx.Panel(id=wxID_ACTIONBLOCKDIALOGMAINPANEL,
  1744         self.staticText1 = wx.StaticText(id=ID_ACTIONBLOCKDIALOGSTATICTEXT1,
  1656               name='MainPanel', parent=self, pos=wx.Point(0, 0),
  1745               label='Actions:', name='staticText1', parent=self,
  1657               size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL)
  1746               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1658         self.MainPanel.SetAutoLayout(True)
  1747 
  1659 
  1748         self.ActionsGrid = wx.grid.Grid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID,
  1660         self.staticText1 = wx.StaticText(id=wxID_ACTIONBLOCKDIALOGSTATICTEXT1,
  1749               name='ActionsGrid', parent=self, pos=wx.Point(0, 0), 
  1661               label='Actions:', name='staticText1', parent=self.MainPanel,
  1750               size=wx.Size(0, 0), style=wx.VSCROLL)
  1662               pos=wx.Point(24, 24), size=wx.Size(95, 17), style=0)
       
  1663 
       
  1664         self.ActionsGrid = wx.grid.Grid(id=wxID_ACTIONBLOCKDIALOGVARIABLESGRID,
       
  1665               name='ActionsGrid', parent=self.MainPanel, pos=wx.Point(24, 44), 
       
  1666               size=wx.Size(450, 150), style=wxVSCROLL)
       
  1667         self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
  1751         self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
  1668               'Sans'))
  1752               'Sans'))
  1669         self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
  1753         self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
  1670               False, 'Sans'))
  1754               False, 'Sans'))
  1671         self.ActionsGrid.DisableDragGridSize()
  1755         self.ActionsGrid.DisableDragGridSize()
  1672         self.ActionsGrid.EnableScrolling(False, True)
  1756         self.ActionsGrid.EnableScrolling(False, True)
  1673         EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange)
  1757         self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnActionsGridCellChange)
  1674 
  1758 
  1675         self.AddButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGADDBUTTON, label='Add',
  1759         self.AddButton = wx.Button(id=ID_ACTIONBLOCKDIALOGADDBUTTON, label='Add',
  1676               name='AddButton', parent=self.MainPanel, pos=wx.Point(245, 204),
  1760               name='AddButton', parent=self, pos=wx.Point(0, 0),
  1677               size=wx.Size(72, 32), style=0)
  1761               size=wx.Size(72, 32), style=0)
  1678         EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGADDBUTTON, self.OnAddButton)
  1762         self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_ACTIONBLOCKDIALOGADDBUTTON)
  1679 
  1763 
  1680         self.DeleteButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete',
  1764         self.DeleteButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete',
  1681               name='DeleteButton', parent=self.MainPanel, pos=wx.Point(325, 204),
  1765               name='DeleteButton', parent=self, pos=wx.Point(0, 0),
  1682               size=wx.Size(72, 32), style=0)
  1766               size=wx.Size(72, 32), style=0)
  1683         EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDELETEBUTTON, self.OnDeleteButton)
  1767         self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_ACTIONBLOCKDIALOGDELETEBUTTON)
  1684 
  1768 
  1685         self.UpButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGUPBUTTON, label='^',
  1769         self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^',
  1686               name='UpButton', parent=self.MainPanel, pos=wx.Point(405, 204),
  1770               name='UpButton', parent=self, pos=wx.Point(0, 0),
  1687               size=wx.Size(32, 32), style=0)
  1771               size=wx.Size(32, 32), style=0)
  1688         EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGUPBUTTON, self.OnUpButton)
  1772         self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_ACTIONBLOCKDIALOGUPBUTTON)
  1689 
  1773 
  1690         self.DownButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v',
  1774         self.DownButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v',
  1691               name='DownButton', parent=self.MainPanel, pos=wx.Point(445, 204),
  1775               name='DownButton', parent=self, pos=wx.Point(0, 0),
  1692               size=wx.Size(32, 32), style=0)
  1776               size=wx.Size(32, 32), style=0)
  1693         EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, self.OnDownButton)
  1777         self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_ACTIONBLOCKDIALOGDOWNBUTTON)
       
  1778 
       
  1779         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
  1694 
  1780 
  1695         self._init_sizers()
  1781         self._init_sizers()
  1696 
  1782 
  1697     def __init__(self, parent):
  1783     def __init__(self, parent):
  1698         self._init_ctrls(parent)
  1784         self._init_ctrls(parent)
  1699         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
  1700         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
       
  1701         
  1785         
  1702         self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""}
  1786         self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""}
  1703         self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"])
  1787         self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"])
  1704         self.TypeList = "Action,Variable,Inline"
  1788         self.TypeList = "Action,Variable,Inline"
  1705         self.ColSizes = [60, 90, 80, 110, 80]
  1789         self.ColSizes = [60, 90, 80, 110, 80]
  1706         self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT]
  1790         self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]
  1707         
  1791         
  1708         self.ActionsGrid.SetTable(self.Table)
  1792         self.ActionsGrid.SetTable(self.Table)
  1709         self.ActionsGrid.SetRowLabelSize(0)
  1793         self.ActionsGrid.SetRowLabelSize(0)
  1710         
  1794         
  1711         self.Table.ResetView(self.ActionsGrid)
  1795         self.Table.ResetView(self.ActionsGrid)
  1800 
  1884 
  1801 #-------------------------------------------------------------------------------
  1885 #-------------------------------------------------------------------------------
  1802 #                          Edit Step Name Dialog
  1886 #                          Edit Step Name Dialog
  1803 #-------------------------------------------------------------------------------
  1887 #-------------------------------------------------------------------------------
  1804 
  1888 
  1805 class StepNameDialog(wxTextEntryDialog):
  1889 class StepNameDialog(wx.TextEntryDialog):
  1806 
  1890 
  1807     def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
  1891     def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", 
  1808                        style = wxOK|wxCANCEL|wxCENTRE, pos = wxDefaultPosition):
  1892                        style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
  1809         wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
  1893         wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
  1810         
  1894         
  1811         self.PouNames = []
  1895         self.PouNames = []
  1812         self.Variables = []
  1896         self.Variables = []
  1813         self.StepNames = []
  1897         self.StepNames = []
  1814         
  1898         
  1815         EVT_BUTTON(self, self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId(), self.OnOK)
  1899         self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
  1816         
  1900         
  1817     def OnOK(self, event):
  1901     def OnOK(self, event):
  1818         step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
  1902         step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
  1819         if step_name == "":
  1903         if step_name == "":
  1820             message = wxMessageDialog(self, "You must type a name!", "Error", wxOK|wxICON_ERROR)
  1904             message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR)
  1821             message.ShowModal()
  1905             message.ShowModal()
  1822             message.Destroy()
  1906             message.Destroy()
  1823         elif not TestIdentifier(step_name):
  1907         elif not TestIdentifier(step_name):
  1824             message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wxOK|wxICON_ERROR)
  1908             message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wx.OK|wx.ICON_ERROR)
  1825             message.ShowModal()
  1909             message.ShowModal()
  1826             message.Destroy()
  1910             message.Destroy()
  1827         elif step_name.upper() in IEC_KEYWORDS:
  1911         elif step_name.upper() in IEC_KEYWORDS:
  1828             message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wxOK|wxICON_ERROR)
  1912             message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wx.OK|wx.ICON_ERROR)
  1829             message.ShowModal()
  1913             message.ShowModal()
  1830             message.Destroy()
  1914             message.Destroy()
  1831         elif step_name.upper() in self.PouNames:
  1915         elif step_name.upper() in self.PouNames:
  1832             message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR)
  1916             message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR)
  1833             message.ShowModal()
  1917             message.ShowModal()
  1834             message.Destroy()
  1918             message.Destroy()
  1835         elif step_name.upper() in self.Variables:
  1919         elif step_name.upper() in self.Variables:
  1836             message = wxMessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR)
  1920             message = wx.MessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR)
  1837             message.ShowModal()
  1921             message.ShowModal()
  1838             message.Destroy()
  1922             message.Destroy()
  1839         elif step_name.upper() in self.StepNames:
  1923         elif step_name.upper() in self.StepNames:
  1840             message = wxMessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wxOK|wxICON_ERROR)
  1924             message = wx.MessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR)
  1841             message.ShowModal()
  1925             message.ShowModal()
  1842             message.Destroy()
  1926             message.Destroy()
  1843         else:
  1927         else:
  1844             self.EndModal(wxID_OK)
  1928             self.EndModal(wx.ID_OK)
  1845 
  1929 
  1846     def SetPouNames(self, pou_names):
  1930     def SetPouNames(self, pou_names):
  1847         self.PouNames = [pou_name.upper() for pou_name in pou_names]
  1931         self.PouNames = [pou_name.upper() for pou_name in pou_names]
  1848 
  1932 
  1849     def SetVariables(self, variables):
  1933     def SetVariables(self, variables):