diff -r 04a02b4b2a57 -r dd6f693e46a1 Dialogs.py --- a/Dialogs.py Tue Aug 07 17:37:38 2007 +0200 +++ b/Dialogs.py Tue Aug 07 17:38:48 2007 +0200 @@ -22,9 +22,8 @@ #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from wxPython.wx import * -from wxPython.grid import * import wx +import wx.grid from graphics import * @@ -32,66 +31,51 @@ # Create New Block Dialog #------------------------------------------------------------------------------- -[wxID_BLOCKPROPERTIESDIALOG, wxID_BLOCKPROPERTIESDIALOGNAME, - wxID_BLOCKPROPERTIESDIALOGTYPETREE, wxID_BLOCKPROPERTIESDIALOGTYPEDESC, - wxID_BLOCKPROPERTIESDIALOGINPUTS, wxID_BLOCKPROPERTIESDIALOGPREVIEW, - wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, - wxID_BLOCKPROPERTIESDIALOGSTATICTEXT3, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4, +[ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME, + ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC, + ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW, + ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, + ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, ] = [wx.NewId() for _init_ctrls in range(10)] [CATEGORY, BLOCK] = range(2) class BlockPropertiesDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_flexGridSizer1_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_MainSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wxGROW|wxRIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) + parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) def _init_coll_LeftBoxSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.TypeTree, 3, border=5, flag=wxGROW|wxBOTTOM) - parent.AddWindow(self.TypeDesc, 1, border=0, flag=wxGROW) + parent.AddWindow(self.TypeTree, 3, border=5, flag=wx.GROW|wx.BOTTOM) + parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) + parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(2) def _init_coll_RightUpGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM) - parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM) - parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Inputs, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM) + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW|wx.ALIGN_BOTTOM) + parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW) def _init_sizers(self): - # generated method, don't edit self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wxHORIZONTAL) - self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wxVERTICAL) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) + self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL) self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=2, vgap=5) @@ -106,55 +90,58 @@ self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_BLOCKPROPERTIESDIALOG, + wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG, name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), - size=wx.Size(600, 360), style=wx.DEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, + size=wx.Size(600, 360), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, title='Block Properties') self.SetClientSize(wx.Size(600, 360)) - self.staticbox1 = wx.StaticBox(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1, + self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, label='Type:', name='staticBox1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) - self.staticText2 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, + self.staticText2 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, label='Name:', name='staticText2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText3 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, + self.staticText3 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, label='Inputs:', name='staticText4', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText4 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4, + self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, label='Preview:', name='staticText4', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.TypeTree = wx.TreeCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPETREE, + self.TypeTree = wx.TreeCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPETREE, name='TypeTree', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER) - EVT_TREE_SEL_CHANGED(self, wxID_BLOCKPROPERTIESDIALOGTYPETREE, self.OnTypeTreeItemSelected) - - self.TypeDesc = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPEDESC, + self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypeTreeItemSelected, + id=ID_BLOCKPROPERTIESDIALOGTYPETREE) + + self.TypeDesc = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPEDESC, name='TypeDesc', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE) - self.Name = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGNAME, value='', + self.Name = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGNAME, value='', name='Name', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_TEXT(self, wxID_BLOCKPROPERTIESDIALOGNAME, self.OnNameChanged) - - self.Inputs = wx.SpinCtrl(id=wxID_BLOCKPROPERTIESDIALOGINPUTS, + self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_BLOCKPROPERTIESDIALOGNAME) + + self.Inputs = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGINPUTS, name='Inputs', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=2, max=20) - EVT_SPINCTRL(self, wxID_BLOCKPROPERTIESDIALOGINPUTS, self.OnInputsChanged) - - self.Preview = wx.Panel(id=wxID_BLOCKPROPERTIESDIALOGPREVIEW, + size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=2, max=20) + self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, id=ID_BLOCKPROPERTIESDIALOGINPUTS) + + self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW, name='Preview', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) + + self.Bind(wx.EVT_PAINT, self.OnPaint) self._init_sizers() @@ -165,9 +152,6 @@ self.Inputs.Enable(False) self.Block = None self.MinBlockSize = None - - EVT_PAINT(self, self.OnPaint) - EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) def FindTreeItem(self, root, name, inputs = None): if root.IsOk(): @@ -191,15 +175,15 @@ error = [] selected = self.TypeTree.GetSelection() if not selected.IsOk() or self.TypeTree.GetItemParent(selected) == self.TypeTree.GetRootItem() or selected == self.TypeTree.GetRootItem(): - message = wxMessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif self.Name.IsEnabled() and self.Name.GetValue() == "": - message = wxMessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() else: - self.EndModal(wxID_OK) + self.EndModal(wx.ID_OK) def SetBlockList(self, blocktypes): root = self.TypeTree.AddRoot("") @@ -251,19 +235,19 @@ self.Inputs.Enable(blocktype["extensible"]) self.Name.Enable(blocktype["type"] != "function") self.TypeDesc.SetValue(blocktype["comment"]) - wxCallAfter(self.RefreshPreview) + wx.CallAfter(self.RefreshPreview) else: self.Name.Enable(False) self.Inputs.Enable(False) self.Inputs.SetValue(2) self.TypeDesc.SetValue("") - wxCallAfter(self.ErasePreview) + wx.CallAfter(self.ErasePreview) else: self.Name.Enable(False) self.Inputs.Enable(False) self.Inputs.SetValue(2) self.TypeDesc.SetValue("") - wxCallAfter(self.ErasePreview) + wx.CallAfter(self.ErasePreview) event.Skip() def OnNameChanged(self, event): @@ -277,12 +261,12 @@ event.Skip() def ErasePreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() self.Block = None def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() item = self.TypeTree.GetSelection() pydata = self.TypeTree.GetPyData(item) @@ -313,77 +297,58 @@ # Create New Variable Dialog #------------------------------------------------------------------------------- -[wxID_VARIABLEPROPERTIESDIALOG, wxID_VARIABLEPROPERTIESDIALOGSPACER, - wxID_VARIABLEPROPERTIESDIALOGNAME, wxID_VARIABLEPROPERTIESDIALOGCLASS, - wxID_VARIABLEPROPERTIESDIALOGPREVIEW, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, - wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, - wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, +[ID_VARIABLEPROPERTIESDIALOG, ID_VARIABLEPROPERTIESDIALOGSPACER, + ID_VARIABLEPROPERTIESDIALOGNAME, ID_VARIABLEPROPERTIESDIALOGCLASS, + ID_VARIABLEPROPERTIESDIALOGPREVIEW, ID_VARIABLEPROPERTIESDIALOGEXPRESSION, + ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, + ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, ] = [wx.NewId() for _init_ctrls in range(10)] class VariablePropertiesDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_flexGridSizer1_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_MainSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.TopSizer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) + parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) def _init_coll_MainSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(2) def _init_coll_TopSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) def _init_coll_LeftGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Class, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Expression, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Class, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW) def _init_coll_LeftGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(2) def _init_coll_RightGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) - self.TopSizer = wx.BoxSizer(wxHORIZONTAL) + self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) @@ -400,55 +365,56 @@ self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_VARIABLEPROPERTIESDIALOG, + wx.Dialog.__init__(self, id=ID_VARIABLEPROPERTIESDIALOG, name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE, title='Variable Properties') self.SetClientSize(wx.Size(400, 380)) - self.staticText1 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, + self.staticText1 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, label='Class:', name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText2 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, + self.staticText2 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, label='Expression:', name='staticText2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText3 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, + self.staticText3 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, label='Name:', name='staticText3', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText4 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, + self.staticText4 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, label='Preview:', name='staticText4', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.Class = wx.Choice(id=wxID_VARIABLEPROPERTIESDIALOGCLASS, + self.Class = wx.Choice(id=ID_VARIABLEPROPERTIESDIALOGCLASS, name='Class', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_CHOICE(self, wxID_VARIABLEPROPERTIESDIALOGCLASS, self.OnClassChanged) - - self.Name = wx.ListBox(id=wxID_VARIABLEPROPERTIESDIALOGNAME, + self.Bind(wx.EVT_CHOICE, self.OnClassChanged, id=ID_VARIABLEPROPERTIESDIALOGCLASS) + + self.Name = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME, name='Name', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 90), style=wx.LB_SINGLE) - EVT_LISTBOX(self, wxID_VARIABLEPROPERTIESDIALOGNAME, self.OnNameChanged) - - self.Expression = wx.TextCtrl(id=wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, + self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_VARIABLEPROPERTIESDIALOGNAME) + + self.Expression = wx.TextCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION, name='Expression', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_TEXT(self, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, self.OnExpressionChanged) - - self.Spacer = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGSPACER, + self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION) + + self.Spacer = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGSPACER, name='Spacer', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.Preview = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGPREVIEW, + self.Preview = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGPREVIEW, name='Preview', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + + self.Bind(wx.EVT_PAINT, self.OnPaint) self._init_sizers() @@ -462,8 +428,6 @@ for choice in ["Input", "Output", "InOut"]: self.Class.Append(choice) self.Class.SetStringSelection("Input") - - EVT_PAINT(self, self.OnPaint) def RefreshNameList(self): selected = self.Name.GetStringSelection() @@ -478,7 +442,7 @@ self.Name.Append(name) elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut": self.Name.Append(name) - if self.Name.FindString(selected) != wxNOT_FOUND: + if self.Name.FindString(selected) != wx.NOT_FOUND: self.Name.SetStringSelection(selected) else: self.Name.SetStringSelection("") @@ -503,7 +467,7 @@ self.Class.SetStringSelection("InOut") self.RefreshNameList() if value_name: - if self.Name.FindString(value_name) != wxNOT_FOUND: + if self.Name.FindString(value_name) != wx.NOT_FOUND: self.Name.SetStringSelection(value_name) self.Expression.Enable(False) else: @@ -558,7 +522,7 @@ event.Skip() def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() expression = self.Expression.GetValue() if self.Expression.IsEnabled() and expression != "": @@ -593,64 +557,49 @@ # Create New Connection Dialog #------------------------------------------------------------------------------- -[wxID_CONNECTIONPROPERTIESDIALOG, wxID_CONNECTIONPROPERTIESDIALOGSPACER, - wxID_CONNECTIONPROPERTIESDIALOGNAME, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, - wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, wxID_CONNECTIONPROPERTIESDIALOGPREVIEW, - wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, - wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, +[ID_CONNECTIONPROPERTIESDIALOG, ID_CONNECTIONPROPERTIESDIALOGSPACER, + ID_CONNECTIONPROPERTIESDIALOGNAME, ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, + ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, ID_CONNECTIONPROPERTIESDIALOGPREVIEW, + ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, + ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, ] = [wx.NewId() for _init_ctrls in range(9)] class ConnectionPropertiesDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_flexGridSizer1_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_MainSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) def _init_coll_LeftGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) def _init_coll_LeftGridSizer_Growables(self, parent): - # generated method, don't edit - - parent.AddGrowableCol(0) - parent.AddGrowableRow(3) + parent.AddGrowableCol(0) + parent.AddGrowableRow(5) def _init_coll_RightGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wxHORIZONTAL) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) @@ -665,53 +614,54 @@ self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_CONNECTIONPROPERTIESDIALOG, + wx.Dialog.__init__(self, id=ID_CONNECTIONPROPERTIESDIALOG, name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE, title='Connection Properties') self.SetClientSize(wx.Size(350, 220)) - self.staticText1 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, + self.staticText1 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, label='Type:', name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText2 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, + self.staticText2 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, label='Name:', name='staticText2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText3 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, + self.staticText3 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, label='Preview:', name='staticText3', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.radioButton1 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, + self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, label='Connector', name='radioButton1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, self.OnTypeChanged) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1) self.radioButton1.SetValue(True) - self.radioButton2 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, + self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, label='Continuation', name='radioButton2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, self.OnTypeChanged) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2) self.radioButton2.SetValue(False) - self.Name = wx.TextCtrl(id=wxID_CONNECTIONPROPERTIESDIALOGNAME, + self.Name = wx.TextCtrl(id=ID_CONNECTIONPROPERTIESDIALOGNAME, name='Name', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_TEXT(self, wxID_CONNECTIONPROPERTIESDIALOGNAME, self.OnNameChanged) - - self.Preview = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGPREVIEW, + self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_CONNECTIONPROPERTIESDIALOGNAME) + + self.Preview = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGPREVIEW, name='Preview', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - self.Spacer = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGSPACER, + self.Spacer = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGSPACER, name='Spacer', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + + self.Bind(wx.EVT_PAINT, self.OnPaint) self._init_sizers() @@ -719,8 +669,6 @@ self._init_ctrls(parent) self.Connection = None self.MinConnectionSize = None - - EVT_PAINT(self, self.OnPaint) def SetMinConnectionSize(self, size): self.MinConnectionSize = size @@ -755,7 +703,7 @@ event.Skip() def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() if self.radioButton1.GetValue(): self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.Name.GetValue()) @@ -780,67 +728,52 @@ #------------------------------------------------------------------------------- -[wxID_LDELEMENTDIALOG, wxID_LDELEMENTDIALOGSPACER, - wxID_LDELEMENTDIALOGNAME, wxID_LDELEMENTDIALOGRADIOBUTTON1, - wxID_LDELEMENTDIALOGRADIOBUTTON2, wxID_LDELEMENTDIALOGRADIOBUTTON3, - wxID_LDELEMENTDIALOGRADIOBUTTON4, wxID_LDELEMENTDIALOGPREVIEW, - wxID_LDELEMENTDIALOGSTATICTEXT1, wxID_LDELEMENTDIALOGSTATICTEXT2, - wxID_LDELEMENTDIALOGSTATICTEXT3, +[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, + ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, + ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3, + ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGPREVIEW, + ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, + ID_LDELEMENTDIALOGSTATICTEXT3, ] = [wx.NewId() for _init_ctrls in range(11)] class LDElementDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_flexGridSizer1_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_MainSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) def _init_coll_LeftGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton3, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton4, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) - + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) + def _init_coll_LeftGridSizer_Growables(self, parent): - # generated method, don't edit - - parent.AddGrowableCol(0) - parent.AddGrowableRow(5) + parent.AddGrowableCol(0) + parent.AddGrowableRow(7) def _init_coll_RightGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wxHORIZONTAL) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) @@ -855,63 +788,64 @@ self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt, title, labels): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_LDELEMENTDIALOG, + wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG, name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, title=title) self.SetClientSize(wx.Size(350, 260)) - self.staticText1 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT1, + self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1, label='Modifier:', name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText2 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT2, + self.staticText2 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT2, label='Name:', name='staticText2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText3 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT3, + self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3, label='Preview:', name='staticText3', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.radioButton1 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON1, + self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1, label=labels[0], name='radioButton1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON1, self.OnTypeChanged) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1) self.radioButton1.SetValue(True) - self.radioButton2 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON2, + self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2, label=labels[1], name='radioButton2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON2, self.OnTypeChanged) - - self.radioButton3 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON3, + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2) + + self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3, label=labels[2], name='radioButton3', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON3, self.OnTypeChanged) - - self.radioButton4 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON4, + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3) + + self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4, label=labels[3], name='radioButton4', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON4, self.OnTypeChanged) - - self.Name = wx.Choice(id=wxID_LDELEMENTDIALOGNAME, + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4) + + self.Name = wx.Choice(id=ID_LDELEMENTDIALOGNAME, name='Name', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_CHOICE(self, wxID_LDELEMENTDIALOGNAME, self.OnNameChanged) - - self.Preview = wx.Panel(id=wxID_LDELEMENTDIALOGPREVIEW, + self.Bind(wx.EVT_CHOICE, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME) + + self.Preview = wx.Panel(id=ID_LDELEMENTDIALOGPREVIEW, name='Preview', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER, + self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER, name='Spacer', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) - + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self._init_sizers() def __init__(self, parent, type): @@ -922,16 +856,12 @@ elif type == "coil": self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset']) self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") - self.Element.SetPosition((150 - LD_ELEMENT_SIZE[0]) / 2, (150 - LD_ELEMENT_SIZE[1]) / 2) - - EVT_PAINT(self, self.OnPaint) - + def SetElementSize(self, size): min_width, min_height = self.Element.GetMinSize() width, height = max(min_width, size[0]), max(min_height, size[1]) self.Element.SetSize(width, height) - self.Element.SetPosition((150 - width) / 2, (150 - height) / 2) - + def SetVariables(self, vars): self.Name.Clear() for name in vars: @@ -999,7 +929,7 @@ event.Skip() def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() clientsize = self.Preview.GetClientSize() width, height = self.Element.GetSize() @@ -1016,64 +946,49 @@ #------------------------------------------------------------------------------- -[wxID_LDPOWERRAILDIALOG, wxID_LDPOWERRAILDIALOGSPACER, - wxID_LDPOWERRAILDIALOGTYPE, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, - wxID_LDPOWERRAILDIALOGRADIOBUTTON2, wxID_LDPOWERRAILDIALOGPREVIEW, - wxID_LDPOWERRAILDIALOGSTATICTEXT1, wxID_LDPOWERRAILDIALOGSTATICTEXT2, - wxID_LDPOWERRAILDIALOGSTATICTEXT3, wxID_LDPOWERRAILDIALOGPINNUMBER, +[ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, + ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, + ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW, + ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, + ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER, ] = [wx.NewId() for _init_ctrls in range(10)] class LDPowerRailDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) def _init_coll_flexGridSizer1_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_MainSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) def _init_coll_LeftGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) - parent.AddWindow(self.PinNumber, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.PinNumber, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) def _init_coll_LeftGridSizer_Growables(self, parent): - # generated method, don't edit - - parent.AddGrowableCol(0) - parent.AddGrowableRow(3) + parent.AddGrowableCol(0) + parent.AddGrowableRow(5) def _init_coll_RightGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) def _init_coll_RightGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wxHORIZONTAL) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) @@ -1088,53 +1003,54 @@ self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_LDPOWERRAILDIALOG, + wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG, name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223), size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, title='Power Rail Properties') self.SetClientSize(wx.Size(350, 260)) - self.staticText1 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT1, + self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1, label='Type:', name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText2 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT2, + self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2, label='Pin number:', name='staticText2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.staticText3 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT3, + self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3, label='Preview:', name='staticText3', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - self.radioButton1 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON1, + self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1, label='Left PowerRail', name='radioButton1', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, self.OnTypeChanged) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1) self.radioButton1.SetValue(True) - self.radioButton2 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON2, + self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2, label='Right PowerRail', name='radioButton2', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON2, self.OnTypeChanged) - - self.PinNumber = wx.SpinCtrl(id=wxID_LDPOWERRAILDIALOGPINNUMBER, + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON2) + + self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER, name='PinNumber', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=1, max=20) - EVT_SPINCTRL(self, wxID_LDPOWERRAILDIALOGPINNUMBER, self.OnPinNumberChanged) - - self.Preview = wx.Panel(id=wxID_LDPOWERRAILDIALOGPREVIEW, + size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=1, max=20) + self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, id=ID_LDPOWERRAILDIALOGPINNUMBER) + + self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW, name='Preview', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER, + self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER, name='Spacer', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) - + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self._init_sizers() def __init__(self, parent, type = LEFTRAIL, number = 1): @@ -1149,8 +1065,6 @@ self.PowerRailMinSize = (0, 0) self.PowerRail = None - EVT_PAINT(self, self.OnPaint) - def SetMinSize(self, size): self.PowerRailMinSize = size self.RefreshPreview() @@ -1175,7 +1089,7 @@ event.Skip() def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())]) min_width, min_height = self.PowerRail.GetMinSize() @@ -1194,66 +1108,138 @@ # Edit Transition Content Dialog #------------------------------------------------------------------------------- -[wxID_TRANSITIONCONTENTDIALOG, wxID_TRANSITIONCONTENTDIALOGMAINPANEL, - wxID_TRANSITIONCONTENTDIALOGREFERENCE, wxID_TRANSITIONCONTENTDIALOGINLINE, - wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, -] = [wx.NewId() for _init_ctrls in range(6)] +[ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, + ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, + ID_TRANSITIONCONTENTDIALOGPREVIEW, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, + ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, + ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, +] = [wx.NewId() for _init_ctrls in range(10)] class TransitionContentDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.MainPanel, 0, border=0, flag=0) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + def _init_coll_flexGridSizer1_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(0) + + def _init_coll_MainSizer_Items(self, parent): + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) + + def _init_coll_LeftGridSizer_Items(self, parent): + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) + + def _init_coll_LeftGridSizer_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(6) + + def _init_coll_RightGridSizer_Items(self, parent): + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) + + def _init_coll_RightGridSizer_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) + self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) + self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) + self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) + self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) + self._init_coll_MainSizer_Items(self.MainSizer) + self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) + self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) + self._init_coll_RightGridSizer_Items(self.RightGridSizer) + self._init_coll_RightGridSizer_Growables(self.RightGridSizer) self.SetSizer(self.flexGridSizer1) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_TRANSITIONCONTENTDIALOG, + wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG, name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), - size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE, + size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, title='Edit transition') - self.SetClientSize(wx.Size(300, 200)) - - self.MainPanel = wx.Panel(id=wxID_TRANSITIONCONTENTDIALOGMAINPANEL, - name='MainPanel', parent=self, pos=wx.Point(0, 0), - size=wx.Size(300, 200), style=wx.TAB_TRAVERSAL) - self.MainPanel.SetAutoLayout(True) - - self.radioButton1 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, - label='Reference', name='radioButton1', parent=self.MainPanel, - pos=wx.Point(24, 24), size=wx.Size(114, 24), style=0) - EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, self.OnTypeChanged) + self.SetClientSize(wx.Size(350, 260)) + + self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, + label='Type:', name='staticText1', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, + label='Preview:', name='staticText2', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, + label='Reference', name='radioButton1', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1) self.radioButton1.SetValue(True) - self.Reference = wx.Choice(id=wxID_TRANSITIONCONTENTDIALOGREFERENCE, - name='Reference', parent=self.MainPanel, pos=wx.Point(48, 48), - size=wx.Size(200, 24), style=0) - - self.radioButton2 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, - label='Inline', name='radioButton2', parent=self.MainPanel, - pos=wx.Point(24, 72), size=wx.Size(114, 24), style=0) - EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, self.OnTypeChanged) + self.Reference = wx.Choice(id=ID_TRANSITIONCONTENTDIALOGREFERENCE, + name='Reference', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_CHOICE, self.OnReferenceChanged, id=ID_TRANSITIONCONTENTDIALOGREFERENCE) + + self.radioButton2 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, + label='Inline', name='radioButton2', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2) self.radioButton2.SetValue(False) - self.Inline = wx.TextCtrl(id=wxID_TRANSITIONCONTENTDIALOGINLINE, - name='Inline', parent=self.MainPanel, pos=wx.Point(48, 96), - size=wx.Size(200, 24), style=0) - + self.Inline = wx.TextCtrl(id=ID_TRANSITIONCONTENTDIALOGINLINE, + name='Inline', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_TEXT, self.OnInlineChanged, id=ID_TRANSITIONCONTENTDIALOGINLINE) + + self.radioButton3 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, + label='Connection', name='radioButton3', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3) + self.radioButton3.SetValue(False) + if not self.Connection: + self.radioButton3.Hide() + + self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW, + name='Preview', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) + setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) + setattr(self.Preview, "RefreshTransitionModel", lambda x:None) + + self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER, + name='Spacer', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self._init_sizers() - def __init__(self, parent): + def __init__(self, parent, connection): + self.Connection = connection self._init_ctrls(parent) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) - self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) - - EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) + self.Transition = None + self.MinTransitionSize = None + + self.Element = SFC_Transition(self.Preview) + + def SetElementSize(self, size): + min_width, min_height = self.Element.GetMinSize() + width, height = max(min_width, size[0]), max(min_height, size[1]) + self.Element.SetSize(width, height) def OnOK(self, event): error = [] @@ -1270,22 +1256,40 @@ text += " and %s"%item else: text += ", %s"%item - message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() else: - self.EndModal(wxID_OK) + self.EndModal(wx.ID_OK) def OnTypeChanged(self, event): if self.radioButton1.GetValue(): + self.Element.SetType("reference", self.Reference.GetStringSelection()) self.Reference.Enable(True) self.Inline.Enable(False) - else: + elif self.radioButton2.GetValue(): + self.Element.SetType("inline", self.Inline.GetValue()) self.Reference.Enable(False) self.Inline.Enable(True) + else: + self.Element.SetType("connection") + self.Reference.Enable(False) + self.Inline.Enable(False) + self.RefreshPreview() + event.Skip() + + def OnReferenceChanged(self, event): + self.Element.SetType("reference", self.Reference.GetStringSelection()) + self.RefreshPreview() + event.Skip() + + def OnInlineChanged(self, event): + self.Element.SetType("inline", self.Inline.GetValue()) + self.RefreshPreview() event.Skip() def SetTransitions(self, transitions): + self.Reference.Append("") for transition in transitions: self.Reference.Append(transition) @@ -1293,124 +1297,187 @@ if values["type"] == "reference": self.radioButton1.SetValue(True) self.radioButton2.SetValue(False) + self.radioButton3.SetValue(False) self.Reference.Enable(True) self.Inline.Enable(False) self.Reference.SetStringSelection(values["value"]) + self.Element.SetType("reference", values["value"]) elif values["type"] == "inline": self.radioButton1.SetValue(False) self.radioButton2.SetValue(True) + self.radioButton3.SetValue(False) self.Reference.Enable(False) self.Inline.Enable(True) self.Inline.SetValue(values["value"]) - + self.Element.SetType("inline", values["value"]) + elif values["type"] == "connection" and self.Connection: + self.radioButton1.SetValue(False) + self.radioButton2.SetValue(False) + self.radioButton3.SetValue(True) + self.Reference.Enable(False) + self.Inline.Enable(False) + self.Element.SetType("connection") + self.RefreshPreview() + def GetValues(self): values = {} if self.radioButton1.GetValue(): values["type"] = "reference" values["value"] = self.Reference.GetStringSelection() - else: + elif self.radioButton2.GetValue(): values["type"] = "inline" values["value"] = self.Inline.GetValue() + else: + values["type"] = "connection" + values["value"] = None return values + def RefreshPreview(self): + dc = wx.ClientDC(self.Preview) + dc.Clear() + clientsize = self.Preview.GetClientSize() + posx, posy = self.Element.GetPosition() + rect = self.Element.GetBoundingBox() + diffx, diffy = posx - rect.x, posy - rect.y + self.Element.SetPosition((clientsize.width - rect.width) / 2 + diffx, (clientsize.height - rect.height) / 2 + diffy) + self.Element.Draw(dc) + + def OnPaint(self, event): + self.RefreshPreview() + #------------------------------------------------------------------------------- # Create New Divergence Dialog #------------------------------------------------------------------------------- -[wxID_DIVERGENCECREATEDIALOG, wxID_DIVERGENCECREATEDIALOGMAINPANEL, - wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, - wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, - wxID_DIVERGENCECREATEDIALOGSEQUENCES, wxID_DIVERGENCECREATEDIALOGPREVIEW, - wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, - wxID_DIVERGENCECREATEDIALOGSTATICTEXT3, +[ID_DIVERGENCECREATEDIALOG, ID_DIVERGENCECREATEDIALOGSPACER, + ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, ID_DIVERGENCECREATEDIALOGRADIOBUTTON2, + ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, + ID_DIVERGENCECREATEDIALOGSEQUENCES, ID_DIVERGENCECREATEDIALOGPREVIEW, + ID_DIVERGENCECREATEDIALOGSTATICTEXT1, ID_DIVERGENCECREATEDIALOGSTATICTEXT2, + ID_DIVERGENCECREATEDIALOGSTATICTEXT3, ] = [wx.NewId() for _init_ctrls in range(11)] class DivergenceCreateDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.MainPanel, 0, border=0, flag=0) + parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + def _init_coll_flexGridSizer1_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(0) + + def _init_coll_MainSizer_Items(self, parent): + parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) + parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) + + def _init_coll_LeftGridSizer_Items(self, parent): + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Sequences, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) + + def _init_coll_LeftGridSizer_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(7) + + def _init_coll_RightGridSizer_Items(self, parent): + parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) + + def _init_coll_RightGridSizer_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) + self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) + self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) + self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) + self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) + self._init_coll_MainSizer_Items(self.MainSizer) + self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) + self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) + self._init_coll_RightGridSizer_Items(self.RightGridSizer) + self._init_coll_RightGridSizer_Growables(self.RightGridSizer) self.SetSizer(self.flexGridSizer1) - + def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_DIVERGENCECREATEDIALOG, + wx.Dialog.__init__(self, id=ID_DIVERGENCECREATEDIALOG, name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, title='Create a new divergence or convergence') - self.SetClientSize(wx.Size(500, 260)) - - self.MainPanel = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGMAINPANEL, - name='MainPanel', parent=self, pos=wx.Point(0, 0), - size=wx.Size(600, 220), style=wx.TAB_TRAVERSAL) - self.MainPanel.SetAutoLayout(True) - - self.staticText1 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, - label='Type:', name='staticText1', parent=self.MainPanel, - pos=wx.Point(24, 24), size=wx.Size(200, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, - label='Selection Divergence', name='radioButton1', parent=self.MainPanel, - pos=wx.Point(24, 48), size=wx.Size(200, 24), style=0) - EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, self.OnTypeChanged) + self.SetClientSize(wx.Size(500, 300)) + + self.staticText1 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT1, + label='Type:', name='staticText1', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.radioButton1 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, + label='Selection Divergence', name='radioButton1', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1) self.radioButton1.SetValue(True) - self.radioButton2 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, - label='Selection Convergence', name='radioButton2', parent=self.MainPanel, - pos=wx.Point(24, 72), size=wx.Size(200, 24), style=0) - EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, self.OnTypeChanged) + self.radioButton2 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2, + label='Selection Convergence', name='radioButton2', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2) self.radioButton2.SetValue(False) - self.radioButton3 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, - label='Simultaneous Divergence', name='radioButton3', parent=self.MainPanel, - pos=wx.Point(24, 96), size=wx.Size(200, 24), style=0) - EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, self.OnTypeChanged) + self.radioButton3 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, + label='Simultaneous Divergence', name='radioButton3', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3) self.radioButton3.SetValue(False) - self.radioButton4 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, - label='Simultaneous Convergence', name='radioButton4', parent=self.MainPanel, - pos=wx.Point(24, 120), size=wx.Size(200, 24), style=0) - EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, self.OnTypeChanged) + self.radioButton4 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, + label='Simultaneous Convergence', name='radioButton4', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4) self.radioButton4.SetValue(False) - self.staticText2 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, - label='Number of sequences:', name='staticText2', parent=self.MainPanel, - pos=wx.Point(24, 150), size=wx.Size(200, 17), style=0) - - self.Sequences = wx.SpinCtrl(id=wxID_DIVERGENCECREATEDIALOGSEQUENCES, - name='Sequences', parent=self.MainPanel, pos=wx.Point(24, 174), - size=wx.Size(200, 24), style=0, min=2, max=20) - EVT_SPINCTRL(self, wxID_DIVERGENCECREATEDIALOGSEQUENCES, self.OnSequencesChanged) - - self.staticText3 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT3, - label='Preview:', name='staticText3', parent=self.MainPanel, - pos=wx.Point(250, 24), size=wx.Size(100, 17), style=0) - - self.Preview = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGPREVIEW, - name='Preview', parent=self.MainPanel, pos=wx.Point(250, 48), - size=wx.Size(225, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) - self.Preview.SetBackgroundColour(wxColour(255,255,255)) + self.staticText2 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT2, + label='Number of sequences:', name='staticText2', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.Sequences = wx.SpinCtrl(id=ID_DIVERGENCECREATEDIALOGSEQUENCES, + name='Sequences', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 24), style=0, min=2, max=20) + self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, id=ID_DIVERGENCECREATEDIALOGSEQUENCES) + + self.staticText3 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT3, + label='Preview:', name='staticText3', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.Preview = wx.Panel(id=ID_DIVERGENCECREATEDIALOGPREVIEW, + name='Preview', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) + self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER, + name='Spacer', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self._init_sizers() def __init__(self, parent): self._init_ctrls(parent) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) - self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) self.Divergence = None self.MinSize = (0, 0) - EVT_PAINT(self, self.OnPaint) - def GetValues(self): values = {} if self.radioButton1.GetValue(): @@ -1436,7 +1503,7 @@ event.Skip() def RefreshPreview(self): - dc = wxClientDC(self.Preview) + dc = wx.ClientDC(self.Preview) dc.Clear() if self.radioButton1.GetValue(): self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue()) @@ -1463,14 +1530,14 @@ # Action Block Dialog #------------------------------------------------------------------------------- -class ActionTable(wxPyGridTableBase): +class ActionTable(wx.grid.PyGridTableBase): """ - A custom wxGrid Table using user supplied data + A custom wx.Grid Table using user supplied data """ def __init__(self, parent, data, colnames): # The base class must be initialized *first* - wxPyGridTableBase.__init__(self) + wx.grid.PyGridTableBase.__init__(self) self.data = data self.colnames = colnames self.Parent = parent @@ -1507,19 +1574,19 @@ def ResetView(self, grid): """ - (wxGrid) -> Reset the grid view. Call this to + (wx.Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid.BeginBatch() for current, new, delmsg, addmsg in [ - (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED), - (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED), + (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), + (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), ]: if new < current: - msg = wxGridTableMessage(self,delmsg,new,current-new) + msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) grid.ProcessTableMessage(msg) elif new > current: - msg = wxGridTableMessage(self,addmsg,new-current) + msg = wx.grid.GridTableMessage(self,addmsg,new-current) grid.ProcessTableMessage(msg) self.UpdateValues(grid) grid.EndBatch() @@ -1536,20 +1603,20 @@ def UpdateValues(self, grid): """Update all displayed values""" # This sends an event to the grid table to update all of the values - msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES) + msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) grid.ProcessTableMessage(msg) def _updateColAttrs(self, grid): """ - wxGrid -> update the column attributes to add the + wx.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for col in range(self.GetNumberCols()): - attr = wxGridCellAttr() - attr.SetAlignment(self.Parent.ColAlignements[col], wxALIGN_CENTRE) + attr = wx.grid.GridCellAttr() + attr.SetAlignment(self.Parent.ColAlignements[col], wx.ALIGN_CENTRE) grid.SetColAttr(col, attr) grid.SetColSize(col, self.Parent.ColSizes[col]) @@ -1562,39 +1629,39 @@ readonly = False colname = self.GetColLabelValue(col) if colname == "Qualifier": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.QualifierList) if colname == "Duration": - editor = wxGridCellTextEditor() - renderer = wxGridCellStringRenderer() + editor = wx.grid.GridCellTextEditor() + renderer = wx.grid.GridCellStringRenderer() if self.Parent.DurationList[self.data[row]["Qualifier"]]: readonly = False else: readonly = True self.data[row]["Duration"] = "" elif colname == "Type": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.TypeList) elif colname == "Value": type = self.data[row]["Type"] if type == "Action": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.ActionList) elif type == "Variable": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.VariableList) elif type == "Inline": - editor = wxGridCellTextEditor() - renderer = wxGridCellStringRenderer() + editor = wx.grid.GridCellTextEditor() + renderer = wx.grid.GridCellStringRenderer() elif colname == "Indicator": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.VariableList) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) grid.SetReadOnly(row, col, readonly) - grid.SetCellBackgroundColour(row, col, wxWHITE) + grid.SetCellBackgroundColour(row, col, wx.WHITE) def SetData(self, data): self.data = data @@ -1624,86 +1691,103 @@ self.data = [] self.editors = [] -[wxID_ACTIONBLOCKDIALOG, wxID_ACTIONBLOCKDIALOGMAINPANEL, - wxID_ACTIONBLOCKDIALOGVARIABLESGRID, wxID_ACTIONBLOCKDIALOGSTATICTEXT1, - wxID_ACTIONBLOCKDIALOGADDBUTTON,wxID_ACTIONBLOCKDIALOGDELETEBUTTON, - wxID_ACTIONBLOCKDIALOGUPBUTTON, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, -] = [wx.NewId() for _init_ctrls in range(8)] +[ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID, + ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON, + ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON, + ID_ACTIONBLOCKDIALOGDOWNBUTTON, +] = [wx.NewId() for _init_ctrls in range(7)] class ActionBlockDialog(wx.Dialog): def _init_coll_flexGridSizer1_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.MainPanel, 0, border=0, flag=0) + parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.GridButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) + parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + def _init_coll_flexGridSizer1_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(0) + + def _init_coll_TopSizer_Items(self, parent): + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.ActionsGrid, 0, border=0, flag=wx.GROW) + + def _init_coll_TopSizer_Growables(self, parent): + parent.AddGrowableCol(0) + parent.AddGrowableRow(1) + + def _init_coll_GridButtonSizer_Items(self, parent): + parent.AddWindow(self.AddButton, 0, border=10, flag=wx.GROW|wx.LEFT) + parent.AddWindow(self.DeleteButton, 0, border=10, flag=wx.GROW|wx.LEFT) + parent.AddWindow(self.UpButton, 0, border=10, flag=wx.GROW|wx.LEFT) + parent.AddWindow(self.DownButton, 0, border=10, flag=wx.GROW|wx.LEFT) def _init_sizers(self): - # generated method, don't edit - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) - + self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) + self.TopSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + self.GridButtonSizer = wx.BoxSizer(wx.HORIZONTAL) + self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - + self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) + self._init_coll_TopSizer_Items(self.TopSizer) + self._init_coll_TopSizer_Growables(self.TopSizer) + self._init_coll_GridButtonSizer_Items(self.GridButtonSizer) + self.SetSizer(self.flexGridSizer1) - + def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Dialog.__init__(self, id=wxID_ACTIONBLOCKDIALOG, + wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG, name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223), - size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, + size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, title='Edit action block properties') self.SetClientSize(wx.Size(500, 300)) - self.MainPanel = wx.Panel(id=wxID_ACTIONBLOCKDIALOGMAINPANEL, - name='MainPanel', parent=self, pos=wx.Point(0, 0), - size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL) - self.MainPanel.SetAutoLayout(True) - - self.staticText1 = wx.StaticText(id=wxID_ACTIONBLOCKDIALOGSTATICTEXT1, - label='Actions:', name='staticText1', parent=self.MainPanel, - pos=wx.Point(24, 24), size=wx.Size(95, 17), style=0) - - self.ActionsGrid = wx.grid.Grid(id=wxID_ACTIONBLOCKDIALOGVARIABLESGRID, - name='ActionsGrid', parent=self.MainPanel, pos=wx.Point(24, 44), - size=wx.Size(450, 150), style=wxVSCROLL) + self.staticText1 = wx.StaticText(id=ID_ACTIONBLOCKDIALOGSTATICTEXT1, + label='Actions:', name='staticText1', parent=self, + pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) + + self.ActionsGrid = wx.grid.Grid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID, + name='ActionsGrid', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.VSCROLL) self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.ActionsGrid.DisableDragGridSize() self.ActionsGrid.EnableScrolling(False, True) - EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange) - - self.AddButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGADDBUTTON, label='Add', - name='AddButton', parent=self.MainPanel, pos=wx.Point(245, 204), + self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnActionsGridCellChange) + + self.AddButton = wx.Button(id=ID_ACTIONBLOCKDIALOGADDBUTTON, label='Add', + name='AddButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(72, 32), style=0) - EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGADDBUTTON, self.OnAddButton) - - self.DeleteButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete', - name='DeleteButton', parent=self.MainPanel, pos=wx.Point(325, 204), + self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_ACTIONBLOCKDIALOGADDBUTTON) + + self.DeleteButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete', + name='DeleteButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(72, 32), style=0) - EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDELETEBUTTON, self.OnDeleteButton) - - self.UpButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGUPBUTTON, label='^', - name='UpButton', parent=self.MainPanel, pos=wx.Point(405, 204), + self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_ACTIONBLOCKDIALOGDELETEBUTTON) + + self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^', + name='UpButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGUPBUTTON, self.OnUpButton) - - self.DownButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v', - name='DownButton', parent=self.MainPanel, pos=wx.Point(445, 204), + self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_ACTIONBLOCKDIALOGUPBUTTON) + + self.DownButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v', + name='DownButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, self.OnDownButton) + self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_ACTIONBLOCKDIALOGDOWNBUTTON) + + self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) self._init_sizers() def __init__(self, parent): self._init_ctrls(parent) - self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) - self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""} self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"]) self.TypeList = "Action,Variable,Inline" self.ColSizes = [60, 90, 80, 110, 80] - self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT] + self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] self.ActionsGrid.SetTable(self.Table) self.ActionsGrid.SetRowLabelSize(0) @@ -1802,46 +1886,46 @@ # Edit Step Name Dialog #------------------------------------------------------------------------------- -class StepNameDialog(wxTextEntryDialog): +class StepNameDialog(wx.TextEntryDialog): def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", - style = wxOK|wxCANCEL|wxCENTRE, pos = wxDefaultPosition): + style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) self.PouNames = [] self.Variables = [] self.StepNames = [] - EVT_BUTTON(self, self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId(), self.OnOK) + self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) def OnOK(self, event): step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() if step_name == "": - message = wxMessageDialog(self, "You must type a name!", "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif not TestIdentifier(step_name): - message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif step_name.upper() in IEC_KEYWORDS: - message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif step_name.upper() in self.PouNames: - message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif step_name.upper() in self.Variables: - message = wxMessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() elif step_name.upper() in self.StepNames: - message = wxMessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wxOK|wxICON_ERROR) + message = wx.MessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() else: - self.EndModal(wxID_OK) + self.EndModal(wx.ID_OK) def SetPouNames(self, pou_names): self.PouNames = [pou_name.upper() for pou_name in pou_names]