# HG changeset patch
# User Laurent Bessard
# Date 1340647433 -7200
# Node ID 131ea7f237b9bf22af6ddf858e49ccc665fb6a15
# Parent 95a0a427f3ef335ee8ec3b2cca19fed7cb9989f4
Replacing buttons with text by buttons with icons
Adding support for bitmap library to have a common API for icon request handling
Simplify wx controls and sizers creation in dialogs and custom controls and panels
diff -r 95a0a427f3ef -r 131ea7f237b9 DataTypeEditor.py
--- a/DataTypeEditor.py Fri Jun 15 18:03:25 2012 +0200
+++ b/DataTypeEditor.py Mon Jun 25 20:03:53 2012 +0200
@@ -22,31 +22,39 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import re
+
import wx
import wx.grid
+import wx.lib.buttons
from plcopen.structures import IEC_KEYWORDS, TestIdentifier
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD
from controls import CustomEditableListBox, CustomGrid, CustomTable, EditorPanel
-
-import re
+from utils.BitmapLibrary import GetBitmap
+
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
def AppendMenu(parent, help, id, kind, text):
- if wx.VERSION >= (2, 6, 0):
- parent.Append(help=help, id=id, kind=kind, text=text)
- else:
- parent.Append(helpString=help, id=id, kind=kind, item=text)
+ parent.Append(help=help, id=id, kind=kind, text=text)
+
+def GetElementsTableColnames():
+ _ = lambda x : x
+ return ["#", _("Name"), _("Type"), _("Initial Value")]
+
+def GetDatatypeTypes():
+ _ = lambda x : x
+ return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")]
+DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()])
#-------------------------------------------------------------------------------
# Structure Elements Table
#-------------------------------------------------------------------------------
-def GetElementsTableColnames():
- _ = lambda x : x
- return ["#", _("Name"), _("Type"), _("Initial Value")]
-
class ElementsTable(CustomTable):
"""
@@ -121,329 +129,240 @@
# Datatype Editor class
#-------------------------------------------------------------------------------
-[ID_DATATYPEEDITOR, ID_DATATYPEEDITORPANEL, ID_DATATYPEEDITORSTATICBOX,
- ID_DATATYPEEDITORDERIVATIONTYPE, ID_DATATYPEEDITORDIRECTLYPANEL,
- ID_DATATYPEEDITORSUBRANGEPANEL, ID_DATATYPEEDITORDIRECTLYBASETYPE,
- ID_DATATYPEEDITORSUBRANGEBASETYPE, ID_DATATYPEEDITORSUBRANGEMINIMUM,
- ID_DATATYPEEDITORSUBRANGEMAXIMUM, ID_DATATYPEEDITORDIRECTLYINITIALVALUE,
- ID_DATATYPEEDITORSUBRANGEINITIALVALUE, ID_DATATYPEEDITORENUMERATEDPANEL,
- ID_DATATYPEEDITORENUMERATEDVALUES, ID_DATATYPEEDITORENUMERATEDINITIALVALUE,
- ID_DATATYPEEDITORARRAYPANEL, ID_DATATYPEEDITORARRAYBASETYPE,
- ID_DATATYPEEDITORARRAYDIMENSIONS, ID_DATATYPEEDITORARRAYINITIALVALUE,
- ID_DATATYPEEDITORSTRUCTUREPANEL, ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID,
- ID_DATATYPEEDITORSTRUCTUREADDBUTTON, ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON,
- ID_DATATYPEEDITORSTRUCTUREUPBUTTON, ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON,
- ID_DATATYPEEDITORSTATICTEXT1, ID_DATATYPEEDITORSTATICTEXT2,
- ID_DATATYPEEDITORSTATICTEXT3, ID_DATATYPEEDITORSTATICTEXT4,
- ID_DATATYPEEDITORSTATICTEXT5, ID_DATATYPEEDITORSTATICTEXT6,
- ID_DATATYPEEDITORSTATICTEXT7, ID_DATATYPEEDITORSTATICTEXT8,
- ID_DATATYPEEDITORSTATICTEXT9, ID_DATATYPEEDITORSTATICTEXT10,
- ID_DATATYPEEDITORSTATICTEXT11,
-] = [wx.NewId() for _init_ctrls in range(36)]
-
-def GetDatatypeTypes():
- _ = lambda x : x
- return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")]
-DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()])
-
class DataTypeEditor(EditorPanel):
- ID = ID_DATATYPEEDITOR
-
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddSizer(self.TopSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- parent.AddSizer(self.TypeInfosSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_TopSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT)
- parent.AddWindow(self.DerivationType, 0, border=5, flag=wx.GROW|wx.RIGHT)
-
- def _init_coll_TypeInfosSizer_Items(self, parent):
- parent.AddWindow(self.DirectlyPanel, 1, border=0, flag=wx.ALL)
- parent.AddWindow(self.SubrangePanel, 1, border=0, flag=wx.ALL)
- parent.AddWindow(self.EnumeratedPanel, 1, border=0, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.ArrayPanel, 1, border=0, flag=wx.ALL)
- parent.AddWindow(self.StructurePanel, 1, border=0, flag=wx.GROW|wx.ALL)
-
- def _init_coll_DirectlyPanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText2, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.DirectlyBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.staticText3, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.DirectlyInitialValue, 1, border=5, flag=wx.ALL)
-
- def _init_coll_SubrangePanelSizer_Items(self, parent):
- parent.AddWindow(self.staticText4, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.SubrangeBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.staticText5, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.SubrangeInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.staticText6, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.SubrangeMinimum, 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.staticText7, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.SubrangeMaximum, 1, border=5, flag=wx.GROW|wx.ALL)
-
- def _init_coll_EnumeratedPanelSizer_Items(self, parent):
- parent.AddWindow(self.EnumeratedValues, 1, border=5, flag=wx.GROW|wx.ALL)
- parent.AddSizer(self.EnumeratedPanelRightSizer, 1, border=0, flag=0)
-
- def _init_coll_EnumeratedPanelRightSizer_Items(self, parent):
- parent.AddWindow(self.staticText8, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.EnumeratedInitialValue, 1, border=5, flag=wx.ALL)
-
- def _init_coll_ArrayPanelSizer_Items(self, parent):
- parent.AddSizer(self.ArrayPanelLeftSizer, 0, border=0, flag=wx.GROW)
- parent.AddSizer(self.ArrayPanelRightSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.ArrayDimensions, 0, border=5, flag=wx.GROW|wx.ALL)
-
- def _init_coll_ArrayPanelSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableCol(1)
- parent.AddGrowableRow(1)
-
- def _init_coll_ArrayPanelLeftSizer_Items(self, parent):
- parent.AddWindow(self.staticText9, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.ArrayBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
-
- def _init_coll_ArrayPanelRightSizer_Items(self, parent):
- parent.AddWindow(self.staticText10, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
- parent.AddWindow(self.ArrayInitialValue, 1, border=5, flag=wx.ALL)
-
- def _init_coll_StructurePanelSizer_Items(self, parent):
- parent.AddSizer(self.StructurePanelButtonSizer, 0, border=5, flag=wx.ALL|wx.GROW)
- parent.AddWindow(self.StructureElementsGrid, 0, border=0, flag=wx.GROW)
-
- def _init_coll_StructurePanelSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_StructurePanelButtonSizer_Items(self, parent):
- parent.AddWindow(self.staticText11, 0, border=0, flag=wx.ALIGN_BOTTOM)
- parent.AddWindow(self.StructureAddButton, 0, border=0, flag=0)
- parent.AddWindow(self.StructureDeleteButton, 0, border=0, flag=0)
- parent.AddWindow(self.StructureUpButton, 0, border=0, flag=0)
- parent.AddWindow(self.StructureDownButton, 0, border=0, flag=0)
-
- def _init_coll_StructurePanelButtonSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
-
- def _init_sizers(self):
+ def _init_Editor(self, parent):
+ self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER)
+
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.TypeInfosSizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
- self.DirectlyPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.SubrangePanelSizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0)
- self.EnumeratedPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.EnumeratedPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.ArrayPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0)
- self.ArrayPanelLeftSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.ArrayPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.StructurePanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
- self.StructurePanelButtonSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
-
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_TopSizer_Items(self.TopSizer)
- self._init_coll_TypeInfosSizer_Items(self.TypeInfosSizer)
- self._init_coll_DirectlyPanelSizer_Items(self.DirectlyPanelSizer)
- self._init_coll_SubrangePanelSizer_Items(self.SubrangePanelSizer)
- self._init_coll_EnumeratedPanelSizer_Items(self.EnumeratedPanelSizer)
- self._init_coll_EnumeratedPanelRightSizer_Items(self.EnumeratedPanelRightSizer)
- self._init_coll_ArrayPanelSizer_Items(self.ArrayPanelSizer)
- self._init_coll_ArrayPanelSizer_Growables(self.ArrayPanelSizer)
- self._init_coll_ArrayPanelLeftSizer_Items(self.ArrayPanelLeftSizer)
- self._init_coll_ArrayPanelRightSizer_Items(self.ArrayPanelRightSizer)
- self._init_coll_StructurePanelSizer_Items(self.StructurePanelSizer)
- self._init_coll_StructurePanelSizer_Growables(self.StructurePanelSizer)
- self._init_coll_StructurePanelButtonSizer_Items(self.StructurePanelButtonSizer)
- self._init_coll_StructurePanelButtonSizer_Growables(self.StructurePanelButtonSizer)
-
- self.Editor.SetSizer(self.MainSizer)
- self.DirectlyPanel.SetSizer(self.DirectlyPanelSizer)
- self.SubrangePanel.SetSizer(self.SubrangePanelSizer)
- self.EnumeratedPanel.SetSizer(self.EnumeratedPanelSizer)
- self.ArrayPanel.SetSizer(self.ArrayPanelSizer)
- self.StructurePanel.SetSizer(self.StructurePanelSizer)
-
- def _init_Editor(self, prnt):
- self.Editor = wx.Panel(id=ID_DATATYPEEDITORPANEL, name='', parent=prnt,
- size=wx.Size(0, 0), style=wx.SUNKEN_BORDER)
-
- self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX,
- label=_('Type infos:'), name='staticBox1', parent=self.Editor,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1,
- label=_('Derivation Type:'), name='staticText1', parent=self.Editor,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.DerivationType = wx.ComboBox(id=ID_DATATYPEEDITORDERIVATIONTYPE,
- name='DerivationType', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(200, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, id=ID_DATATYPEEDITORDERIVATIONTYPE)
-
+ self.MainSizer.AddGrowableCol(0)
+ self.MainSizer.AddGrowableRow(1)
+
+ top_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.MainSizer.AddSizer(top_sizer, border=5,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ derivation_type_label = wx.StaticText(self.Editor, label=_('Derivation Type:'))
+ top_sizer.AddWindow(derivation_type_label, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT)
+
+ self.DerivationType = wx.ComboBox(self.Editor,
+ size=wx.Size(200, -1), style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, self.DerivationType)
+ top_sizer.AddWindow(self.DerivationType, border=5, flag=wx.GROW|wx.RIGHT)
+
+ typeinfos_staticbox = wx.StaticBox(self.Editor, label=_('Type infos:'))
+ typeinfos_sizer = wx.StaticBoxSizer(typeinfos_staticbox, wx.HORIZONTAL)
+ self.MainSizer.AddSizer(typeinfos_sizer, border=5,
+ flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
# Panel for Directly derived data types
- self.DirectlyPanel = wx.Panel(id=ID_DATATYPEEDITORDIRECTLYPANEL,
- name='DirectlyPanel', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.staticText2 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT2,
- label=_('Base Type:'), name='staticText2', parent=self.DirectlyPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.DirectlyBaseType = wx.ComboBox(id=ID_DATATYPEEDITORDIRECTLYBASETYPE,
- name='DirectlyBaseType', parent=self.DirectlyPanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYBASETYPE)
-
- self.staticText3 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT3,
- label=_('Initial Value:'), name='staticText3', parent=self.DirectlyPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE,
- name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH)
- self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE)
-
+ self.DirectlyPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL)
+ typeinfos_sizer.AddWindow(self.DirectlyPanel, 1)
+
+ directly_panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ directly_basetype_label = wx.StaticText(self.DirectlyPanel,
+ label=_('Base Type:'))
+ directly_panel_sizer.AddWindow(directly_basetype_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.DirectlyBaseType = wx.ComboBox(self.DirectlyPanel, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.DirectlyPanel)
+ directly_panel_sizer.AddWindow(self.DirectlyBaseType, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ directly_initialvalue_label = wx.StaticText(self.DirectlyPanel,
+ label=_('Initial Value:'))
+ directly_panel_sizer.AddWindow(directly_initialvalue_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.DirectlyInitialValue = wx.TextCtrl(self.DirectlyPanel,
+ style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_RICH)
+ self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.DirectlyInitialValue)
+ directly_panel_sizer.AddWindow(self.DirectlyInitialValue, 1, border=5,
+ flag=wx.ALL)
+
+ self.DirectlyPanel.SetSizer(directly_panel_sizer)
+
# Panel for Subrange data types
- self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL,
- name='SubrangePanel', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.staticText4 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT4,
- label=_('Base Type:'), name='staticText4', parent=self.SubrangePanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.SubrangeBaseType = wx.ComboBox(id=ID_DATATYPEEDITORSUBRANGEBASETYPE,
- name='SubrangeBaseType', parent=self.SubrangePanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.SubrangeBaseType.SetBackgroundColour(wx.BLUE)
- self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged, id=ID_DATATYPEEDITORSUBRANGEBASETYPE)
-
- self.staticText5 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT5,
- label=_('Initial Value:'), name='staticText5', parent=self.SubrangePanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.SubrangeInitialValue = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE,
- name='SubrangeInitialValue', parent=self.SubrangePanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
- self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE)
-
- self.staticText6 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT6,
- label=_('Minimum:'), name='staticText6', parent=self.SubrangePanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.SubrangeMinimum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMINIMUM,
- name='SubrangeMinimum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
- self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, id=ID_DATATYPEEDITORSUBRANGEMINIMUM)
-
- self.staticText7 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT7,
- label=_('Maximum:'), name='staticText7', parent=self.SubrangePanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.SubrangeMaximum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMAXIMUM,
- name='SubrangeMaximum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
- self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, id=ID_DATATYPEEDITORSUBRANGEMAXIMUM)
-
+ self.SubrangePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL)
+ typeinfos_sizer.AddWindow(self.SubrangePanel, 1)
+
+ subrange_panel_sizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0)
+
+ subrange_basetype_label = wx.StaticText(self.SubrangePanel,
+ label=_('Base Type:'))
+ subrange_panel_sizer.AddWindow(subrange_basetype_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.SubrangeBaseType = wx.ComboBox(self.SubrangePanel, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged,
+ self.SubrangeBaseType)
+ subrange_panel_sizer.AddWindow(self.SubrangeBaseType, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ subrange_initialvalue_label = wx.StaticText(self.SubrangePanel,
+ label=_('Initial Value:'))
+ subrange_panel_sizer.AddWindow(subrange_initialvalue_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.SubrangeInitialValue = wx.SpinCtrl(self.SubrangePanel,
+ style=wx.TAB_TRAVERSAL)
+ self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, self.SubrangeInitialValue)
+ subrange_panel_sizer.AddWindow(self.SubrangeInitialValue, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ subrange_minimum_label = wx.StaticText(self.SubrangePanel, label=_('Minimum:'))
+ subrange_panel_sizer.AddWindow(subrange_minimum_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.SubrangeMinimum = wx.SpinCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL)
+ self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, self.SubrangeMinimum)
+ subrange_panel_sizer.AddWindow(self.SubrangeMinimum, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ for i in xrange(2):
+ subrange_panel_sizer.AddWindow(wx.Size(0, 0), 1)
+
+ subrange_maximum_label = wx.StaticText(self.SubrangePanel,
+ label=_('Maximum:'))
+ subrange_panel_sizer.AddWindow(subrange_maximum_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.SubrangeMaximum = wx.SpinCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL)
+ self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, self.SubrangeMaximum)
+
+ subrange_panel_sizer.AddWindow(self.SubrangeMaximum, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ self.SubrangePanel.SetSizer(subrange_panel_sizer)
+
# Panel for Enumerated data types
-
- self.EnumeratedPanel = wx.Panel(id=ID_DATATYPEEDITORENUMERATEDPANEL,
- name='EnumeratedPanel', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.EnumeratedValues = CustomEditableListBox(id=ID_DATATYPEEDITORENUMERATEDVALUES,
- name='EnumeratedValues', parent=self.EnumeratedPanel, label=_("Values:"), pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
+
+ self.EnumeratedPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL)
+ typeinfos_sizer.AddWindow(self.EnumeratedPanel, 1)
+
+ enumerated_panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ self.EnumeratedValues = CustomEditableListBox(self.EnumeratedPanel,
+ label=_("Values:"), style=wx.gizmos.EL_ALLOW_NEW|
+ wx.gizmos.EL_ALLOW_EDIT|
+ wx.gizmos.EL_ALLOW_DELETE)
setattr(self.EnumeratedValues, "_OnLabelEndEdit", self.OnEnumeratedValueEndEdit)
for func in ["_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]:
setattr(self.EnumeratedValues, func, self.OnEnumeratedValuesChanged)
-
- self.staticText8 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT8,
- label=_('Initial Value:'), name='staticText8', parent=self.EnumeratedPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.EnumeratedInitialValue = wx.ComboBox(id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE,
- name='EnumeratedInitialValue', parent=self.EnumeratedPanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE)
+ enumerated_panel_sizer.AddWindow(self.EnumeratedValues, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ enumerated_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL)
+ enumerated_panel_sizer.AddSizer(enumerated_panel_rightsizer, 1)
+
+ enumerated_initialvalue_label = wx.StaticText(self.EnumeratedPanel,
+ label=_('Initial Value:'))
+ enumerated_panel_rightsizer.AddWindow(enumerated_initialvalue_label, 1,
+ border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.EnumeratedInitialValue = wx.ComboBox(self.EnumeratedPanel,
+ style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.EnumeratedInitialValue)
+ enumerated_panel_rightsizer.AddWindow(self.EnumeratedInitialValue, 1,
+ border=5, flag=wx.ALL)
+
+ self.EnumeratedPanel.SetSizer(enumerated_panel_sizer)
# Panel for Array data types
- self.ArrayPanel = wx.Panel(id=ID_DATATYPEEDITORARRAYPANEL,
- name='ArrayPanel', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.staticText9 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT9,
- label=_('Base Type:'), name='staticText9', parent=self.ArrayPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.ArrayBaseType = wx.ComboBox(id=ID_DATATYPEEDITORARRAYBASETYPE,
- name='ArrayBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE)
-
- self.ArrayDimensions = CustomEditableListBox(id=ID_DATATYPEEDITORARRAYDIMENSIONS,
- name='ArrayDimensions', parent=self.ArrayPanel, label=_("Dimensions:"), pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
- for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]:
+ self.ArrayPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL)
+ typeinfos_sizer.AddWindow(self.ArrayPanel, 1)
+
+ array_panel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0)
+ array_panel_sizer.AddGrowableCol(0)
+ array_panel_sizer.AddGrowableCol(1)
+ array_panel_sizer.AddGrowableRow(1)
+
+ array_panel_leftSizer = wx.BoxSizer(wx.HORIZONTAL)
+ array_panel_sizer.AddSizer(array_panel_leftSizer, flag=wx.GROW)
+
+ array_basetype_label = wx.StaticText(self.ArrayPanel, label=_('Base Type:'))
+ array_panel_leftSizer.AddWindow(array_basetype_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.ArrayBaseType = wx.ComboBox(self.ArrayPanel, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.ArrayBaseType)
+ array_panel_leftSizer.AddWindow(self.ArrayBaseType, 1, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ array_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL)
+ array_panel_sizer.AddSizer(array_panel_rightsizer, flag=wx.GROW)
+
+ array_initialvalue_label = wx.StaticText(self.ArrayPanel,
+ label=_('Initial Value:'))
+ array_panel_rightsizer.AddWindow(array_initialvalue_label, 1, border=5,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL)
+
+ self.ArrayInitialValue = wx.TextCtrl(self.ArrayPanel,
+ style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_RICH)
+ self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.ArrayInitialValue)
+ array_panel_rightsizer.AddWindow(self.ArrayInitialValue, 1, border=5,
+ flag=wx.ALL)
+
+ self.ArrayDimensions = CustomEditableListBox(self.ArrayPanel,
+ label=_("Dimensions:"), style=wx.gizmos.EL_ALLOW_NEW|
+ wx.gizmos.EL_ALLOW_EDIT|
+ wx.gizmos.EL_ALLOW_DELETE)
+ for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton",
+ "_OnUpButton", "_OnDownButton"]:
setattr(self.EnumeratedValues, func, self.OnDimensionsChanged)
-
- self.staticText10 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT10,
- label=_('Initial Value:'), name='staticText10', parent=self.ArrayPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE,
- name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH)
- self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE)
+ array_panel_sizer.AddWindow(self.ArrayDimensions, 0, border=5,
+ flag=wx.GROW|wx.ALL)
+
+ self.ArrayPanel.SetSizer(array_panel_sizer)
# Panel for Structure data types
- self.StructurePanel = wx.Panel(id=ID_DATATYPEEDITORSTRUCTUREPANEL,
- name='StructurePanel', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.staticText11 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT11,
- label=_('Elements :'), name='staticText11', parent=self.StructurePanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.StructureElementsGrid = CustomGrid(id=ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID,
- name='StructureElementsGrid', parent=self.StructurePanel, pos=wx.Point(0, 0),
+ self.StructurePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL)
+ typeinfos_sizer.AddWindow(self.StructurePanel, 1)
+
+ structure_panel_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
+ structure_panel_sizer.AddGrowableCol(0)
+ structure_panel_sizer.AddGrowableRow(1)
+
+ structure_button_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
+ structure_button_sizer.AddGrowableCol(0)
+ structure_button_sizer.AddGrowableRow(0)
+ structure_panel_sizer.AddSizer(structure_button_sizer, 0, border=5,
+ flag=wx.ALL|wx.GROW)
+
+ structure_elements_label = wx.StaticText(self.StructurePanel,
+ label=_('Elements :'))
+ structure_button_sizer.AddWindow(structure_elements_label, flag=wx.ALIGN_BOTTOM)
+
+ for name, bitmap, help in [
+ ("StructureAddButton", "add_element", _("Add element")),
+ ("StructureDeleteButton", "remove_element", _("Remove element")),
+ ("StructureUpButton", "up", _("Move element up")),
+ ("StructureDownButton", "down", _("Move element down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self.StructurePanel,
+ bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ structure_button_sizer.AddWindow(button)
+
+ self.StructureElementsGrid = CustomGrid(self.StructurePanel,
size=wx.Size(0, 150), style=wx.VSCROLL)
- if wx.VERSION >= (2, 6, 0):
- self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnStructureElementsGridCellChange)
- self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnStructureElementsGridEditorShown)
- else:
- wx.grid.EVT_GRID_CELL_CHANGE(self.StructureElementsGrid, self.OnStructureElementsGridCellChange)
- wx.grid.EVT_GRID_EDITOR_SHOWN(self.StructureElementsGrid, self.OnStructureElementsGridEditorShown)
-
- self.StructureAddButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREADDBUTTON, label=_('Add'),
- name='StructureAddButton', parent=self.StructurePanel, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.StructureDeleteButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON, label=_('Delete'),
- name='StructureDeleteButton', parent=self.StructurePanel, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.StructureUpButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREUPBUTTON, label='^',
- name='StructureUpButton', parent=self.StructurePanel, pos=wx.Point(0, 0),
- size=wx.Size(32, 32), style=0)
-
- self.StructureDownButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON, label='v',
- name='StructureDownButton', parent=self.StructurePanel, pos=wx.Point(0, 0),
- size=wx.Size(32, 32), style=0)
-
- self._init_sizers()
-
+ self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
+ self.OnStructureElementsGridCellChange)
+ self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN,
+ self.OnStructureElementsGridEditorShown)
+ structure_panel_sizer.AddWindow(self.StructureElementsGrid, flag=wx.GROW)
+
+ self.StructurePanel.SetSizer(structure_panel_sizer)
+
+ self.Editor.SetSizer(self.MainSizer)
+
def __init__(self, parent, tagname, window, controler):
EditorPanel.__init__(self, parent, tagname, window, controler)
diff -r 95a0a427f3ef -r 131ea7f237b9 GraphicViewer.py
--- a/GraphicViewer.py Fri Jun 15 18:03:25 2012 +0200
+++ b/GraphicViewer.py Mon Jun 25 20:03:53 2012 +0200
@@ -31,6 +31,7 @@
from graphics.GraphicCommons import DebugViewer, MODE_SELECTION, MODE_MOTION
from controls import EditorPanel
+from utils.BitmapLibrary import GetBitmap
colours = ['blue', 'red', 'green', 'yellow', 'orange', 'purple', 'brown', 'cyan',
'pink', 'grey']
@@ -90,7 +91,7 @@
self.CanvasRange = wx.ComboBox(self.Editor,
size=wx.Size(100, 28), style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, self.CanvasRange)
- range_sizer.AddWindow(self.CanvasRange, 0, border=0, flag=0)
+ range_sizer.AddWindow(self.CanvasRange, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
zoom_label = wx.StaticText(self.Editor, label=_('Zoom:'))
range_sizer.AddWindow(zoom_label, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
@@ -98,7 +99,7 @@
self.CanvasZoom = wx.ComboBox(self.Editor,
size=wx.Size(70, 28), style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnZoomChanged, self.CanvasZoom)
- range_sizer.AddWindow(self.CanvasZoom, 0, border=0, flag=0)
+ range_sizer.AddWindow(self.CanvasZoom, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
position_label = wx.StaticText(self.Editor, label=_('Position:'))
range_sizer.AddWindow(position_label, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
@@ -118,17 +119,21 @@
self.OnPositionChanging, self.CanvasPosition)
range_sizer.AddWindow(self.CanvasPosition, 0, border=5, flag=wx.GROW|wx.ALL)
- self.ResetButton = wx.Button(self.Editor, label='Reset', size=wx.Size(72, 24))
+ self.ResetButton = wx.lib.buttons.GenBitmapButton(self.Editor,
+ bitmap=GetBitmap("reset"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.ResetButton.SetToolTipString(_("Clear the graph values"))
self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton)
range_sizer.AddWindow(self.ResetButton, 0, border=0, flag=0)
- self.CurrentButton = wx.Button(self.Editor, label='Current', size=wx.Size(72, 24))
+ self.CurrentButton = wx.lib.buttons.GenBitmapButton(self.Editor,
+ bitmap=GetBitmap("current"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.CurrentButton.SetToolTipString(_("Go to current value"))
self.Bind(wx.EVT_BUTTON, self.OnCurrentButton, self.CurrentButton)
range_sizer.AddWindow(self.CurrentButton, 0, border=0, flag=0)
self.ExportGraphButton = wx.lib.buttons.GenBitmapButton(self.Editor,
- bitmap=self.ParentWindow.GenerateBitmap("export_graph"),
- size=wx.Size(28, 28), style=wx.NO_BORDER)
+ bitmap=GetBitmap("export_graph"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.ExportGraphButton.SetToolTipString(_("Export graph values to clipboard"))
self.Bind(wx.EVT_BUTTON, self.OnExportGraphButtonClick,
self.ExportGraphButton)
range_sizer.AddWindow(self.ExportGraphButton, 0, border=0, flag=0)
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/add_element.png
Binary file Images/add_element.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/current.png
Binary file Images/current.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/debug.png
Binary file Images/debug.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/debug_instance.png
Binary file Images/debug_instance.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/down.png
Binary file Images/down.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/graph.png
Binary file Images/graph.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/icons.svg
--- a/Images/icons.svg Fri Jun 15 18:03:25 2012 +0200
+++ b/Images/icons.svg Mon Jun 25 20:03:53 2012 +0200
@@ -6523,7 +6523,7 @@
xlink:href="#linearGradient2264"
gradientUnits="userSpaceOnUse"
x2="12"
- gradientTransform="matrix(0.66667,0,0,0.6,186.09982,116.85104)"
+ gradientTransform="matrix(0.66667,0,0,0.6,185.74627,11.9117)"
y1="2"
x1="12" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% ST IL FBD LD SFC FUNCTION FUNCTIONBLOCK PROJECT TRANSITION ACTION CONFIGURATION RESOURCE DATATYPE DATATYPES PROGRAM TRANSITIONS ACTIONS CONFIGURATIONS RESOURCES PROPERTIES%%
+ y="-14">%% ST IL FBD LD SFC FUNCTION FUNCTIONBLOCK PROJECT TRANSITION ACTION CONFIGURATION RESOURCE DATATYPE DATATYPES PROGRAM TRANSITIONS ACTIONS CONFIGURATIONS RESOURCES GRAPH%%
@@ -8717,99 +10463,6 @@
style="opacity:1;fill:url(#linearGradient4307);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.43299961;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
-
-
-
-
-
-
-
-
-
-
-
-
-
%%custom_tree_background%%
%%up%%
+ transform="translate(-233.09946,219.05807)">
%%edit%%
+ x="-233.67409"
+ y="215.06073">%%edit%%
+ transform="matrix(0.36763942,0,0,0.36763942,-262.23385,204.36126)">
%%debug%%
+ x="-204"
+ y="215">%%debug_instance%%
+ transform="matrix(0.23162724,0,0,0.23162724,-154.66454,145.99446)">
%%graph%%
+ x="-148"
+ y="215">%%instance_graph%%
+ d="m 4.38811,202.24651 a 11.999905,2.0000054 0 0 1 -23.999809,0 11.999905,2.0000054 0 1 1 23.999809,0 z" />
+ d="M -16.111699,182.74627 H 0.88831 v 17 h -17.000009 v -17 z" />
+ y="182.74625"
+ x="-16.111702" />
+ y="189.24625"
+ x="-15.611702" />
+ y="192.24625"
+ x="-15.611702" />
+ y="13.111702"
+ x="187.74625" />
%%export_graph%%
+ x="-30.037788"
+ y="177.11613">%%export_graph%%
+
+ %%down%%
+
+ %%top%%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %%add_element%%
+
+ %%remove_element%%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %%reset%%
+
+ %%current%%
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/instance_graph.png
Binary file Images/instance_graph.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/remove_element.png
Binary file Images/remove_element.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/reset.png
Binary file Images/reset.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 Images/top.png
Binary file Images/top.png has changed
diff -r 95a0a427f3ef -r 131ea7f237b9 PLCOpenEditor.py
--- a/PLCOpenEditor.py Fri Jun 15 18:03:25 2012 +0200
+++ b/PLCOpenEditor.py Mon Jun 25 20:03:53 2012 +0200
@@ -31,6 +31,10 @@
CWD = os.path.split(os.path.realpath(__file__))[0]
base_folder = os.path.split(CWD)[0]
sys.path.append(base_folder)
+
+from utils.BitmapLibrary import AddBitmapFolder, GetBitmap
+AddBitmapFolder(os.path.join(CWD, "Images"))
+
from docutil import *
from types import TupleType
@@ -165,93 +169,93 @@
EditorToolBarItems = {
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move.png", _("Move the view")),
+ "move", _("Move the view")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", _("Create a new comment")),
+ "add_comment", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", _("Create a new variable")),
+ "add_variable", _("Create a new variable")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", _("Create a new block")),
+ "add_block", _("Create a new block")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", _("Create a new connection"))],
+ "add_connection", _("Create a new connection"))],
"LD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move.png", _("Move the view")),
+ "move", _("Move the view")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", _("Create a new comment")),
+ "add_comment", _("Create a new comment")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail.png", _("Create a new power rail")),
+ "add_powerrail", _("Create a new power rail")),
(False, DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool",
- "add_rung.png", _("Create a new rung")),
+ "add_rung", _("Create a new rung")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool",
- "add_coil.png", _("Create a new coil")),
+ "add_coil", _("Create a new coil")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact.png", _("Create a new contact")),
+ "add_contact", _("Create a new contact")),
(False, DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool",
- "add_branch.png", _("Create a new branch")),
+ "add_branch", _("Create a new branch")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", _("Create a new variable")),
+ "add_variable", _("Create a new variable")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", _("Create a new block")),
+ "add_block", _("Create a new block")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", _("Create a new connection"))],
+ "add_connection", _("Create a new connection"))],
"SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move.png", _("Move the view")),
+ "move", _("Move the view")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool",
- "add_comment.png", _("Create a new comment")),
+ "add_comment", _("Create a new comment")),
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool",
- "add_initial_step.png", _("Create a new initial step")),
+ "add_initial_step", _("Create a new initial step")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool",
- "add_step.png", _("Create a new step")),
+ "add_step", _("Create a new step")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool",
- "add_transition.png", _("Create a new transition")),
+ "add_transition", _("Create a new transition")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool",
- "add_action.png", _("Create a new action block")),
+ "add_action", _("Create a new action block")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool",
- "add_divergence.png", _("Create a new divergence")),
+ "add_divergence", _("Create a new divergence")),
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool",
- "add_jump.png", _("Create a new jump")),
+ "add_jump", _("Create a new jump")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool",
- "add_variable.png", _("Create a new variable")),
+ "add_variable", _("Create a new variable")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool",
- "add_block.png", _("Create a new block")),
+ "add_block", _("Create a new block")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool",
- "add_connection.png", _("Create a new connection")),
+ "add_connection", _("Create a new connection")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool",
- "add_powerrail.png", _("Create a new power rail")),
+ "add_powerrail", _("Create a new power rail")),
(True, FREEDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool",
- "add_contact.png", _("Create a new contact"))],
+ "add_contact", _("Create a new contact"))],
"ST" : [],
"IL" : [],
"debug": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE,
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool",
- "move.png", _("Move the view"))],
+ "move", _("Move the view"))],
}
#-------------------------------------------------------------------------------
@@ -460,14 +464,14 @@
self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL)
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE)
- self.AddToMenuToolBar([(wx.ID_UNDO, "undo.png", _(u'Undo'), None),
- (wx.ID_REDO, "redo.png", _(u'Redo'), None),
+ self.AddToMenuToolBar([(wx.ID_UNDO, "undo", _(u'Undo'), None),
+ (wx.ID_REDO, "redo", _(u'Redo'), None),
None,
- (wx.ID_CUT, "cut.png", _(u'Cut'), None),
- (wx.ID_COPY, "copy.png", _(u'Copy'), None),
- (wx.ID_PASTE, "paste.png", _(u'Paste'), None),
+ (wx.ID_CUT, "cut", _(u'Cut'), None),
+ (wx.ID_COPY, "copy", _(u'Copy'), None),
+ (wx.ID_PASTE, "paste", _(u'Paste'), None),
None,
- (ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find.png", _(u'Search in Project'), None)])
+ (ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find", _(u'Search in Project'), None)])
def _init_coll_DisplayMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_REFRESH,
@@ -586,7 +590,7 @@
name='ProjectTree', parent=self.ProjectPanel,
pos=wx.Point(0, 0), size=wx.Size(0, 0),
style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_EDIT_LABELS)
- self.ProjectTree.SetBackgroundBitmap(wx.Bitmap(os.path.join(CWD, 'Images', 'custom_tree_background.png')),
+ self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"),
wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM)
add_menu = wx.Menu()
self._init_coll_AddMenu_Items(add_menu)
@@ -639,7 +643,7 @@
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER)
EditorToolBar.SetToolBitmapSize(wx.Size(25, 25))
EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION,
- wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object"))
+ GetBitmap("select"), wx.NullBitmap, _("Select an object"))
EditorToolBar.Realize()
self.Panes["EditorToolBar"] = EditorToolBar
self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo().
@@ -670,7 +674,7 @@
self.SetMenuBar(self.MenuBar)
if self.EnableDebug:
- self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self, self.Controler)
+ self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self.Controler)
self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger"))
self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"])
@@ -694,7 +698,7 @@
# Icons for languages
for language in LANGUAGES:
- self.TreeImageDict[language]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%language)))
+ self.TreeImageDict[language] = self.TreeImageList.Add(GetBitmap(language))
# Icons for other items
for imgname, itemtype in [
@@ -724,7 +728,7 @@
("CONFIGURATIONS", ITEM_CONFIGURATIONS),
("RESOURCES", ITEM_RESOURCES),
("PROPERTIES", ITEM_PROPERTIES)]:
- self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname)))
+ self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))
# Assign icon list to TreeCtrls
self.ProjectTree.SetImageList(self.TreeImageList)
@@ -1088,42 +1092,6 @@
#-------------------------------------------------------------------------------
# Notebook Unified Functions
#-------------------------------------------------------------------------------
-
- ## Function that generate bitmap for
- # for wx.aui.AUINotebook.
- # @param window Panel to display in tab.
- # @param text title for the tab ctrl.
- def GenerateBitmap(self, icon1_name, icon2_name = None):
- # Find index of bitmap if already created
- index = self.TabsImageListIndexes.get((icon1_name, icon2_name), None)
- # Return index or bitmap if found
- if index is not None:
- return self.TabsImageList.GetBitmap(index)
- if icon2_name is None:
- # Bitmap with only one icon
- bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
- else:
- # Bitmap with two icon
- icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
- icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name))
-
- # Calculate bitmap size
- width = icon1.GetWidth() + icon2.GetWidth() - 1
- height = max(icon1.GetHeight(), icon2.GetHeight())
- # Create bitmap with both icons
- bitmap = wx.EmptyBitmap(width, height)
- dc = wx.MemoryDC()
- dc.SelectObject(bitmap)
- dc.Clear()
- dc.DrawBitmap(icon1, 0, 0)
- dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0)
- dc.Destroy()
-
- # Store bitmap in ImageList
- index = self.TabsImageList.Add(bitmap)
- # Save bitmap index in ImageList in dictionary
- self.TabsImageListIndexes[(icon1_name, icon2_name)] = index
- return bitmap
## Function that add a tab in Notebook, calling refresh for tab DClick event
# for wx.aui.AUINotebook.
@@ -1196,7 +1164,7 @@
self.ProjectTree.Enable(False)
self.PouInstanceVariablesPanel.ResetView()
self.LibraryPanel.ResetTree()
- self.LibraryPanel.SetControler(None)
+ self.LibraryPanel.SetController(None)
self.Controler = None
def OnCloseTabMenu(self, event):
@@ -1603,10 +1571,10 @@
if infos["type"] == ITEM_POU:
self.ProjectTree.SetItemImage(root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])])
elif infos.has_key("icon") and infos["icon"] is not None:
- icon_path = infos["icon"]
- if not self.TreeImageDict.has_key(icon_path):
- self.TreeImageDict[icon_path] = self.TreeImageList.Add(wx.Bitmap(icon_path))
- self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_path])
+ icon_name = infos["icon"]
+ if not self.TreeImageDict.has_key(icon_name):
+ self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name))
+ self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name])
elif self.TreeImageDict.has_key(infos["type"]):
self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]])
@@ -1853,11 +1821,11 @@
new_window = None
if element == ITEM_CONFIGURATION:
new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler)
- new_window.SetIcon(self.GenerateBitmap("CONFIGURATION"))
+ new_window.SetIcon(GetBitmap("CONFIGURATION"))
self.AddPage(new_window, "")
elif element == ITEM_RESOURCE:
new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler)
- new_window.SetIcon(self.GenerateBitmap("RESOURCE"))
+ new_window.SetIcon(GetBitmap("RESOURCE"))
self.AddPage(new_window, "")
elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]:
bodytype = self.Controler.GetEditedElementBodyType(tagname)
@@ -1879,16 +1847,16 @@
new_window.SetKeywords(ST_KEYWORDS)
if element == ITEM_POU:
pou_type = self.Controler.GetEditedElementType(tagname)[1].upper()
- icon = self.GenerateBitmap(pou_type, bodytype)
+ icon = GetBitmap(pou_type, bodytype)
elif element == ITEM_TRANSITION:
- icon = self.GenerateBitmap("TRANSITION", bodytype)
+ icon = GetBitmap("TRANSITION", bodytype)
elif element == ITEM_ACTION:
- icon = self.GenerateBitmap("ACTION", bodytype)
+ icon = GetBitmap("ACTION", bodytype)
new_window.SetIcon(icon)
self.AddPage(new_window, "")
elif element == ITEM_DATATYPE:
new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler)
- new_window.SetIcon(self.GenerateBitmap("DATATYPE"))
+ new_window.SetIcon(GetBitmap("DATATYPE"))
self.AddPage(new_window, "")
elif isinstance(element, EditorPanel):
new_window = element
@@ -2098,11 +2066,11 @@
if instance_category in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM]:
pou_type = self.Controler.GetEditedElementType(instance_type, True)[1].upper()
- icon = self.GenerateBitmap(pou_type, bodytype)
+ icon = GetBitmap(pou_type, bodytype)
elif instance_category == ITEM_TRANSITION:
- icon = self.GenerateBitmap("TRANSITION", bodytype)
+ icon = GetBitmap("TRANSITION", bodytype)
elif instance_category == ITEM_ACTION:
- icon = self.GenerateBitmap("ACTION", bodytype)
+ icon = GetBitmap("ACTION", bodytype)
new_window.SetIcon(icon)
self.AddPage(new_window, "")
new_window.RefreshView()
@@ -2114,6 +2082,7 @@
def OpenGraphicViewer(self, var_path):
new_window = GraphicViewer(self.TabsOpened, self, self.Controler, var_path)
+ new_window.SetIcon(GetBitmap("GRAPH"))
self.AddPage(new_window, "")
new_window.RefreshView()
new_window.SetFocus()
@@ -2167,7 +2136,7 @@
MenuToolBar.AddSeparator()
else:
id, bitmap, help, callback = toolbar_item
- MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=wx.Bitmap(os.path.join(CWD, 'Images', bitmap)))
+ MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=GetBitmap(bitmap))
if callback is not None:
self.Bind(wx.EVT_TOOL, callback, id=id)
MenuToolBar.Realize()
@@ -2210,9 +2179,9 @@
for radio, modes, id, method, picture, help in EditorToolBarItems[menu]:
if modes & self.DrawingMode:
if radio or self.DrawingMode == FREEDRAWING_MODE:
- EditorToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help)
+ EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help)
else:
- EditorToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help)
+ EditorToolBar.AddSimpleTool(id, GetBitmap(picture), help)
self.Bind(wx.EVT_MENU, getattr(self, method), id=id)
self.CurrentEditorToolBar.append(id)
EditorToolBar.Realize()
@@ -2667,11 +2636,11 @@
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
- self.AddToMenuToolBar([(wx.ID_NEW, "new.png", _(u'New'), None),
- (wx.ID_OPEN, "open.png", _(u'Open'), None),
- (wx.ID_SAVE, "save.png", _(u'Save'), None),
- (wx.ID_SAVEAS, "saveas.png", _(u'Save As...'), None),
- (wx.ID_PRINT, "print.png", _(u'Print'), None)])
+ self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None),
+ (wx.ID_OPEN, "open", _(u'Open'), None),
+ (wx.ID_SAVE, "save", _(u'Save'), None),
+ (wx.ID_SAVEAS, "saveas", _(u'Save As...'), None),
+ (wx.ID_PRINT, "print", _(u'Print'), None)])
def _init_coll_HelpMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_HELP,
@@ -2703,13 +2672,13 @@
result = controler.OpenXMLFile(fileOpen)
if result is None:
self.Controler = controler
- self.LibraryPanel.SetControler(controler)
+ self.LibraryPanel.SetController(controler)
self.ProjectTree.Enable(True)
self.PouInstanceVariablesPanel.SetController(controler)
self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE)
# Define PLCOpenEditor icon
- self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
+ self.SetIcon(wx.Icon(os.path.join(CWD, "Images", "poe.ico"),wx.BITMAP_TYPE_ICO))
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
@@ -2794,7 +2763,7 @@
self.ResetView()
self.Controler = PLCControler()
self.Controler.CreateNewProject(properties)
- self.LibraryPanel.SetControler(self.Controler)
+ self.LibraryPanel.SetController(self.Controler)
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL,
LIBRARYTREE)
@@ -2820,7 +2789,7 @@
result = controler.OpenXMLFile(filepath)
if result is None:
self.Controler = controler
- self.LibraryPanel.SetControler(controler)
+ self.LibraryPanel.SetController(controler)
self.ProjectTree.Enable(True)
self.PouInstanceVariablesPanel.SetController(controler)
self.LoadProjectLayout()
diff -r 95a0a427f3ef -r 131ea7f237b9 RessourceEditor.py
--- a/RessourceEditor.py Fri Jun 15 18:03:25 2012 +0200
+++ b/RessourceEditor.py Mon Jun 25 20:03:53 2012 +0200
@@ -23,10 +23,12 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import wx
+import wx.lib.buttons
import wx.grid
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD
from controls import CustomGrid, CustomTable, EditorPanel, DurationCellEditor
+from utils.BitmapLibrary import GetBitmap
#-------------------------------------------------------------------------------
# Configuration Editor class
@@ -187,149 +189,81 @@
if len(col_highlights) == 0:
row_highlights.pop(col)
-[ID_RESOURCEEDITOR, ID_RESOURCEEDITORPANEL, ID_RESOURCEEDITORSTATICTEXT1,
- ID_RESOURCEEDITORSTATICTEXT2, ID_RESOURCEEDITORINSTANCESGRID,
- ID_RESOURCEEDITORTASKSGRID, ID_RESOURCEEDITORADDINSTANCEBUTTON,
- ID_RESOURCEEDITORDELETEINSTANCEBUTTON, ID_RESOURCEEDITORUPINSTANCEBUTTON,
- ID_RESOURCEEDITORDOWNINSTANCEBUTTON, ID_RESOURCEEDITORADDTASKBUTTON,
- ID_RESOURCEEDITORDELETETASKBUTTON, ID_RESOURCEEDITORUPTASKBUTTON,
- ID_RESOURCEEDITORDOWNTASKBUTTON,
-] = [wx.NewId() for _init_ctrls in range(14)]
+
class ResourceEditor(EditorPanel):
- ID = ID_RESOURCEEDITOR
VARIABLE_PANEL_TYPE = "resource"
-
- def _init_coll_InstancesSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_InstancesSizer_Items(self, parent):
- parent.AddSizer(self.InstancesButtonsSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.InstancesGrid, 0, border=0, flag=wx.GROW)
-
- def _init_coll_InstancesButtonsSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
-
- def _init_coll_InstancesButtonsSizer_Items(self, parent):
- parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_BOTTOM)
- parent.AddWindow(self.AddInstanceButton, 0, border=0, flag=0)
- parent.AddWindow(self.DeleteInstanceButton, 0, border=0, flag=0)
- parent.AddWindow(self.UpInstanceButton, 0, border=0, flag=0)
- parent.AddWindow(self.DownInstanceButton, 0, border=0, flag=0)
-
- def _init_coll_TasksSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_TasksSizer_Items(self, parent):
- parent.AddSizer(self.TasksButtonsSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.TasksGrid, 0, border=0, flag=wx.GROW)
-
- def _init_coll_TasksButtonsSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
-
- def _init_coll_TasksButtonsSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=0, flag=wx.ALIGN_BOTTOM)
- parent.AddWindow(self.AddTaskButton, 0, border=0, flag=0)
- parent.AddWindow(self.DeleteTaskButton, 0, border=0, flag=0)
- parent.AddWindow(self.UpTaskButton, 0, border=0, flag=0)
- parent.AddWindow(self.DownTaskButton, 0, border=0, flag=0)
-
- def _init_coll_MainGridSizer_Items(self, parent):
- parent.AddSizer(self.TasksSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- parent.AddSizer(self.InstancesSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-
- def _init_coll_MainGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
- parent.AddGrowableRow(1)
-
- def _init_sizers(self):
- self.MainGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
- self.InstancesSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
- self.InstancesButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
- self.TasksSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
- self.TasksButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
-
- self._init_coll_MainGridSizer_Growables(self.MainGridSizer)
- self._init_coll_MainGridSizer_Items(self.MainGridSizer)
- self._init_coll_InstancesSizer_Growables(self.InstancesSizer)
- self._init_coll_InstancesSizer_Items(self.InstancesSizer)
- self._init_coll_InstancesButtonsSizer_Growables(self.InstancesButtonsSizer)
- self._init_coll_InstancesButtonsSizer_Items(self.InstancesButtonsSizer)
- self._init_coll_TasksSizer_Growables(self.TasksSizer)
- self._init_coll_TasksSizer_Items(self.TasksSizer)
- self._init_coll_TasksButtonsSizer_Growables(self.TasksButtonsSizer)
- self._init_coll_TasksButtonsSizer_Items(self.TasksButtonsSizer)
-
- self.Editor.SetSizer(self.MainGridSizer)
-
- def _init_Editor(self, prnt):
- self.Editor = wx.Panel(id=ID_RESOURCEEDITORPANEL, name='ResourceEditor', parent=prnt,
- size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.TAB_TRAVERSAL)
-
- self.staticText1 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT1,
- label=_(u'Tasks:'), name='staticText2', parent=self.Editor, pos=wx.Point(0,
- 0), size=wx.DefaultSize, style=0)
-
- self.TasksGrid = CustomGrid(id=ID_RESOURCEEDITORTASKSGRID,
- name='TasksGrid', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(-1, -1), style=wx.VSCROLL)
- if wx.VERSION >= (2, 6, 0):
- self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange)
- else:
- wx.grid.EVT_GRID_CELL_CHANGE(self.TasksGrid, self.OnTasksGridCellChange)
-
- self.AddTaskButton = wx.Button(id=ID_RESOURCEEDITORADDTASKBUTTON, label=_('Add Task'),
- name='AddTaskButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.DeleteTaskButton = wx.Button(id=ID_RESOURCEEDITORDELETETASKBUTTON, label=_('Delete Task'),
- name='DeleteTaskButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.UpTaskButton = wx.Button(id=ID_RESOURCEEDITORUPTASKBUTTON, label='^',
- name='UpTaskButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(32, -1), style=0)
-
- self.DownTaskButton = wx.Button(id=ID_RESOURCEEDITORDOWNTASKBUTTON, label='v',
- name='DownTaskButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(32, -1), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT2,
- label=_(u'Instances:'), name='staticText1', parent=self.Editor,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.InstancesGrid = CustomGrid(id=ID_RESOURCEEDITORINSTANCESGRID,
- name='InstancesGrid', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(-1, -1), style=wx.VSCROLL)
- if wx.VERSION >= (2, 6, 0):
- self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnInstancesGridCellChange)
- else:
- wx.grid.EVT_GRID_CELL_CHANGE(self.InstancesGrid, self.OnInstancesGridCellChange)
-
- self.AddInstanceButton = wx.Button(id=ID_RESOURCEEDITORADDINSTANCEBUTTON, label=_('Add Instance'),
- name='AddInstanceButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.DeleteInstanceButton = wx.Button(id=ID_RESOURCEEDITORDELETEINSTANCEBUTTON, label=_('Delete Instance'),
- name='DeleteInstanceButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.UpInstanceButton = wx.Button(id=ID_RESOURCEEDITORUPINSTANCEBUTTON, label='^',
- name='UpInstanceButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(32, -1), style=0)
-
- self.DownInstanceButton = wx.Button(id=ID_RESOURCEEDITORDOWNINSTANCEBUTTON, label='v',
- name='DownInstanceButton', parent=self.Editor, pos=wx.Point(0, 0),
- size=wx.Size(32, -1), style=0)
-
- self._init_sizers()
-
+
+ def _init_Editor(self, parent):
+ self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER|wx.TAB_TRAVERSAL)
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+ main_sizer.AddGrowableRow(1)
+
+ tasks_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ tasks_sizer.AddGrowableCol(0)
+ tasks_sizer.AddGrowableRow(1)
+ main_sizer.AddSizer(tasks_sizer, border=5,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ tasks_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
+ tasks_buttons_sizer.AddGrowableCol(0)
+ tasks_buttons_sizer.AddGrowableRow(0)
+ tasks_sizer.AddSizer(tasks_buttons_sizer, flag=wx.GROW)
+
+ tasks_label = wx.StaticText(self.Editor, label=_(u'Tasks:'))
+ tasks_buttons_sizer.AddWindow(tasks_label, flag=wx.ALIGN_BOTTOM)
+
+ for name, bitmap, help in [
+ ("AddTaskButton", "add_element", _("Add task")),
+ ("DeleteTaskButton", "remove_element", _("Remove task")),
+ ("UpTaskButton", "up", _("Move task up")),
+ ("DownTaskButton", "down", _("Move task down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self.Editor,
+ bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ tasks_buttons_sizer.AddWindow(button)
+
+ self.TasksGrid = CustomGrid(self.Editor, style=wx.VSCROLL)
+ self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange)
+ tasks_sizer.AddWindow(self.TasksGrid, flag=wx.GROW)
+
+ instances_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ instances_sizer.AddGrowableCol(0)
+ instances_sizer.AddGrowableRow(1)
+ main_sizer.AddSizer(instances_sizer, border=5,
+ flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ instances_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
+ instances_buttons_sizer.AddGrowableCol(0)
+ instances_buttons_sizer.AddGrowableRow(0)
+ instances_sizer.AddSizer(instances_buttons_sizer, flag=wx.GROW)
+
+ instances_label = wx.StaticText(self.Editor, label=_(u'Instances:'))
+ instances_buttons_sizer.AddWindow(instances_label, flag=wx.ALIGN_BOTTOM)
+
+ for name, bitmap, help in [
+ ("AddInstanceButton", "add_element", _("Add instance")),
+ ("DeleteInstanceButton", "remove_element", _("Remove instance")),
+ ("UpInstanceButton", "up", _("Move instance up")),
+ ("DownInstanceButton", "down", _("Move instance down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self.Editor,
+ bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ instances_buttons_sizer.AddWindow(button)
+
+ self.InstancesGrid = CustomGrid(self.Editor, style=wx.VSCROLL)
+ self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
+ self.OnInstancesGridCellChange)
+ instances_sizer.AddWindow(self.InstancesGrid, flag=wx.GROW)
+
+ self.Editor.SetSizer(main_sizer)
+
def __init__(self, parent, tagname, window, controler):
EditorPanel.__init__(self, parent, tagname, window, controler)
diff -r 95a0a427f3ef -r 131ea7f237b9 SearchResultPanel.py
--- a/SearchResultPanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/SearchResultPanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -25,11 +25,11 @@
from types import TupleType
import wx
+import wx.lib.buttons
import wx.lib.agw.customtreectrl as CT
from PLCControler import *
-
-CWD = os.path.split(os.path.realpath(__file__))[0]
+from utils.BitmapLibrary import GetBitmap
def GenerateName(infos):
if infos[0] in ["input", "output", "value"]:
@@ -100,17 +100,17 @@
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
- self.ResetButton = wx.Button(id=ID_SEARCHRESULTPANELRESETBUTTON, label=_('Reset'),
- name='ResetButton', parent=self, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
- self.Bind(wx.EVT_BUTTON, self.OnResetButton,
- id=ID_SEARCHRESULTPANELRESETBUTTON)
+ self.ResetButton = wx.lib.buttons.GenBitmapButton(self,
+ bitmap=GetBitmap("reset"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.ResetButton.SetToolTipString(_("Reset search result"))
+ self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton)
self._init_sizers()
def __init__(self, parent, window):
+ self.ParentWindow = window
+
self._init_ctrls(parent)
- self.ParentWindow = window
# Define Tree item icon list
self.TreeImageList = wx.ImageList(16, 16)
@@ -128,7 +128,7 @@
("ACTION", "action_block"),
("IL", "IL"),
("ST", "ST")]:
- self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname)))
+ self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname))
for itemtype in ["function", "functionBlock", "program",
"comment", "block", "io_variable",
@@ -136,7 +136,7 @@
"step", "transition", "jump",
"var_local", "var_input",
"var_inout", "var_output"]:
- self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%itemtype.upper())))
+ self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(itemtype.upper()))
# Assign icon list to TreeCtrl
self.SearchResultsTree.SetImageList(self.TreeImageList)
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomEditableListBox.py
--- a/controls/CustomEditableListBox.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/CustomEditableListBox.py Mon Jun 25 20:03:53 2012 +0200
@@ -35,11 +35,12 @@
listbox.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnLabelBeginEdit)
listbox.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnLabelEndEdit)
- for button, tooltip, call_function in [(self.GetEditButton(), _("Edit item"), "_OnEditButton"),
- (self.GetNewButton(), _("New item"), "_OnNewButton"),
- (self.GetDelButton(), _("Delete item"), "_OnDelButton"),
- (self.GetUpButton(), _("Move up"), "_OnUpButton"),
- (self.GetDownButton(), _("Move down"), "_OnDownButton")]:
+ for button, tooltip, call_function in [
+ (self.GetEditButton(), _("Edit item"), "_OnEditButton"),
+ (self.GetNewButton(), _("New item"), "_OnNewButton"),
+ (self.GetDelButton(), _("Delete item"), "_OnDelButton"),
+ (self.GetUpButton(), _("Move up"), "_OnUpButton"),
+ (self.GetDownButton(), _("Move down"), "_OnDownButton")]:
button.SetToolTipString(tooltip)
button.Bind(wx.EVT_BUTTON, self.GetButtonPressedFunction(call_function))
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomGrid.py
--- a/controls/CustomGrid.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/CustomGrid.py Mon Jun 25 20:03:53 2012 +0200
@@ -27,13 +27,6 @@
class CustomGrid(wx.grid.Grid):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
def __init__(self, *args, **kwargs):
wx.grid.Grid.__init__(self, *args, **kwargs)
@@ -50,11 +43,8 @@
self.SetSelectionForeground(wx.BLACK)
self.DisableDragRowSize()
- if wx.VERSION >= (2, 6, 0):
- self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
- self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
- else:
- wx.grid.EVT_GRID_SELECT_CELL(self, self.OnSelectCell)
+ self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)
+ self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
def SetDefaultValue(self, default_value):
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomTree.py
--- a/controls/CustomTree.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/CustomTree.py Mon Jun 25 20:03:53 2012 +0200
@@ -92,7 +92,6 @@
event.Skip()
def OnScroll(self, event):
- print "scroll event"
self.RefreshBackground(True)
event.Skip()
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/DebugVariablePanel.py
--- a/controls/DebugVariablePanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/DebugVariablePanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -23,9 +23,11 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import wx
+import wx.lib.buttons
from graphics import DebugDataConsumer, DebugViewer
from controls import CustomGrid, CustomTable
+from utils.BitmapLibrary import GetBitmap
def GetDebugVariablesTableColnames():
_ = lambda x : x
@@ -159,7 +161,7 @@
class DebugVariablePanel(wx.Panel, DebugViewer):
- def __init__(self, parent, window, producer):
+ def __init__(self, parent, producer):
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
DebugViewer.__init__(self, producer, True)
@@ -171,14 +173,15 @@
main_sizer.AddSizer(button_sizer, border=5,
flag=wx.ALIGN_RIGHT|wx.ALL)
- up_button = wx.Button(self, label='^', size=wx.Size(28, 28))
- button_sizer.AddWindow(up_button, border=5, flag=wx.RIGHT)
-
- down_button = wx.Button(self, label='v', size=wx.Size(28, 28))
- button_sizer.AddWindow(down_button, border=5, flag=wx.RIGHT)
-
- delete_button = wx.Button(self, label=_('Delete'), size=wx.DefaultSize)
- button_sizer.AddWindow(delete_button)
+ for name, bitmap, help in [
+ ("DeleteButton", "remove_element", _("Remove debug variable")),
+ ("UpButton", "up", _("Move debug variable up")),
+ ("DownButton", "down", _("Move debug variable down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
self.VariablesGrid = CustomGrid(self, size=wx.Size(0, 150), style=wx.VSCROLL)
self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self))
@@ -192,9 +195,9 @@
self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames())
self.VariablesGrid.SetTable(self.Table)
- self.VariablesGrid.SetButtons({"Delete": delete_button,
- "Up": up_button,
- "Down": down_button})
+ self.VariablesGrid.SetButtons({"Delete": self.DeleteButton,
+ "Up": self.UpButton,
+ "Down": self.DownButton})
def _AddVariable(new_row):
return self.VariablesGrid.GetGridCursorRow()
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/DurationCellEditor.py
--- a/controls/DurationCellEditor.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/DurationCellEditor.py Mon Jun 25 20:03:53 2012 +0200
@@ -28,48 +28,30 @@
class DurationCellControl(wx.PyControl):
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.Duration, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.EditButton, 0, border=0, flag=wx.GROW)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
-
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
-
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Control.__init__(self, id=-1,
- name='DurationCellControl', parent=prnt,
- size=wx.DefaultSize, style=0)
-
- # create location text control
- self.Duration = wx.TextCtrl(id=-1, name='Duration', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER)
- self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar)
-
- # create browse button
- self.EditButton = wx.Button(id=-1, label='...',
- name='EditButton', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(30, 0), style=0)
- self.EditButton.Bind(wx.EVT_BUTTON, self.OnEditButtonClick)
-
- self.Bind(wx.EVT_SIZE, self.OnSize)
-
- self._init_sizers()
-
'''
Custom cell editor control with a text box and a button that launches
the DurationEditorDialog.
'''
def __init__(self, parent):
- self._init_ctrls(parent)
+ wx.Control.__init__(self, parent)
+
+ main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ # create location text control
+ self.Duration = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER)
+ self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar)
+ main_sizer.AddWindow(self.Duration, flag=wx.GROW)
+
+ # create browse button
+ self.EditButton = wx.Button(self, label='...', size=wx.Size(30, 0))
+ self.Bind(wx.EVT_BUTTON, self.OnEditButtonClick, self.EditButton)
+ main_sizer.AddWindow(self.EditButton, flag=wx.GROW)
+
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+
+ self.SetSizer(main_sizer)
self.Default = None
@@ -117,6 +99,7 @@
'''
def __init__(self, table):
wx.grid.PyGridCellEditor.__init__(self)
+
self.Table = table
def __del__(self):
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/EditorPanel.py
--- a/controls/EditorPanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/EditorPanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -28,25 +28,17 @@
class EditorPanel(wx.SplitterWindow):
- ID = wx.NewId()
VARIABLE_PANEL_TYPE = None
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
def _init_Editor(self, prnt):
self.Editor = None
def _init_MenuItems(self):
self.MenuItems = []
- def _init_ctrls(self, prnt):
- wx.SplitterWindow.__init__(self, id=self.ID, name='MainSplitter', parent=prnt,
- size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.SP_3D)
+ def _init_ctrls(self, parent):
+ wx.SplitterWindow.__init__(self, parent,
+ style=wx.SUNKEN_BORDER|wx.SP_3D)
self.SetNeedUpdating(True)
self.SetMinimumPaneSize(1)
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/LibraryPanel.py
--- a/controls/LibraryPanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/LibraryPanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -24,78 +24,61 @@
import wx
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
[CATEGORY, BLOCK] = range(2)
-[ID_LIBRARYPANEL, ID_LIBRARYSEARCHCTRL,
- ID_LIBRARYTREE, ID_LIBRARYCOMMENT,
-] = [wx.NewId() for _init_ctrls in range(4)]
+#-------------------------------------------------------------------------------
+# Library Panel
+#-------------------------------------------------------------------------------
class LibraryPanel(wx.Panel):
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.SearchCtrl, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Tree, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Comment, 0, border=0, flag=wx.GROW)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
-
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_MainSizer_Items(self.MainSizer)
-
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt, enable_drag=False):
- wx.Panel.__init__(self, id=ID_LIBRARYPANEL,
- name='LibraryPanel', parent=prnt,
- pos=wx.Point(0, 0), size=wx.Size(0, 0),
- style=wx.TAB_TRAVERSAL)
-
- self.SearchCtrl = wx.SearchCtrl(id=ID_LIBRARYSEARCHCTRL,
- name='SearchCtrl', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 28), style=0)
+ def __init__(self, parent, enable_drag=False):
+ wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(1)
+
+ self.SearchCtrl = wx.SearchCtrl(self)
self.SearchCtrl.ShowSearchButton(True)
- self.Bind(wx.EVT_TEXT, self.OnSearchCtrlChanged,
- id=ID_LIBRARYSEARCHCTRL)
- self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearchButtonClick,
- id=ID_LIBRARYSEARCHCTRL)
+ self.Bind(wx.EVT_TEXT, self.OnSearchCtrlChanged, self.SearchCtrl)
+ self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN,
+ self.OnSearchButtonClick, self.SearchCtrl)
search_textctrl = self.SearchCtrl.GetChildren()[0]
search_textctrl.Bind(wx.EVT_CHAR, self.OnKeyDown)
-
- self.Tree = wx.TreeCtrl(id=ID_LIBRARYTREE,
- name='Tree', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0),
- style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT)
- self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeItemSelected,
- id=ID_LIBRARYTREE)
+ main_sizer.AddWindow(self.SearchCtrl, flag=wx.GROW)
+
+ self.Tree = wx.TreeCtrl(self,
+ style=wx.TR_HAS_BUTTONS|
+ wx.TR_SINGLE|
+ wx.SUNKEN_BORDER|
+ wx.TR_HIDE_ROOT|
+ wx.TR_LINES_AT_ROOT)
+ self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeItemSelected, self.Tree)
self.Tree.Bind(wx.EVT_CHAR, self.OnKeyDown)
if enable_drag:
- self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTreeBeginDrag,
- id=ID_LIBRARYTREE)
-
- self.Comment = wx.TextCtrl(id=ID_LIBRARYCOMMENT,
- name='Comment', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 80),
+ self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTreeBeginDrag, self.Tree)
+ main_sizer.AddWindow(self.Tree, flag=wx.GROW)
+
+ self.Comment = wx.TextCtrl(self, size=wx.Size(0, 80),
style=wx.TE_READONLY|wx.TE_MULTILINE)
-
- self._init_sizers()
-
- def __init__(self, parent, enable_drag=False):
- self._init_ctrls(parent, enable_drag)
-
- self.Controler = None
+ main_sizer.AddWindow(self.Comment, flag=wx.GROW)
+
+ self.SetSizer(main_sizer)
+
+ self.Controller = None
self.BlockList = None
def __del__(self):
- self.Controler = None
-
- def SetControler(self, controler):
- self.Controler = controler
+ self.Controller = None
+
+ def SetController(self, controller):
+ self.Controller = controller
def SetBlockList(self, blocklist):
self.BlockList = blocklist
@@ -110,7 +93,7 @@
self.Comment.SetValue("")
def RefreshTree(self):
- if self.Controler is not None:
+ if self.Controller is not None:
to_delete = []
selected_name = None
selected = self.Tree.GetSelection()
@@ -121,14 +104,11 @@
if self.BlockList is not None:
blocktypes = self.BlockList
else:
- blocktypes = self.Controler.GetBlockTypes()
+ blocktypes = self.Controller.GetBlockTypes()
root = self.Tree.GetRootItem()
if not root.IsOk():
root = self.Tree.AddRoot("")
- if wx.VERSION >= (2, 6, 0):
- category_item, root_cookie = self.Tree.GetFirstChild(root)
- else:
- category_item, root_cookie = self.Tree.GetFirstChild(root, 0)
+ category_item, root_cookie = self.Tree.GetFirstChild(root)
for category in blocktypes:
category_name = category["name"]
if not category_item.IsOk():
@@ -138,10 +118,7 @@
else:
self.Tree.SetItemText(category_item, _(category_name))
self.Tree.SetPyData(category_item, {"type" : CATEGORY})
- if wx.VERSION >= (2, 6, 0):
- blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item)
- else:
- blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item, 0)
+ blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item)
for blocktype in category["list"]:
if not blocktype_item.IsOk():
blocktype_item = self.Tree.AppendItem(category_item, blocktype["name"])
@@ -280,7 +257,7 @@
selected = event.GetItem()
pydata = self.Tree.GetPyData(selected)
if pydata is not None and pydata["type"] != CATEGORY:
- blocktype = self.Controler.GetBlockType(self.Tree.GetItemText(selected), pydata["inputs"])
+ blocktype = self.Controller.GetBlockType(self.Tree.GetItemText(selected), pydata["inputs"])
if blocktype:
comment = blocktype["comment"]
self.Comment.SetValue(_(comment) + blocktype.get("usage", ""))
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/LocationCellEditor.py
--- a/controls/LocationCellEditor.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/LocationCellEditor.py Mon Jun 25 20:03:53 2012 +0200
@@ -28,48 +28,31 @@
class LocationCellControl(wx.PyControl):
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.Location, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.BrowseButton, 0, border=0, flag=wx.GROW)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
-
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
-
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Control.__init__(self, id=-1,
- name='LocationCellControl', parent=prnt,
- size=wx.DefaultSize, style=0)
-
- # create location text control
- self.Location = wx.TextCtrl(id=-1, name='Location', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER)
- self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar)
-
- # create browse button
- self.BrowseButton = wx.Button(id=-1, label='...',
- name='BrowseButton', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(30, 0), style=0)
- self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick)
-
- self.Bind(wx.EVT_SIZE, self.OnSize)
-
- self._init_sizers()
-
'''
Custom cell editor control with a text box and a button that launches
the BrowseLocationsDialog.
'''
def __init__(self, parent):
- self._init_ctrls(parent)
+ wx.Control.__init__(self, parent)
+
+ main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ # create location text control
+ self.Location = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER)
+ self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar)
+ main_sizer.AddWindow(self.Location, flag=wx.GROW)
+
+ # create browse button
+ self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, 0))
+ self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick)
+ main_sizer.AddWindow(self.BrowseButton, flag=wx.GROW)
+
+ self.Bind(wx.EVT_SIZE, self.OnSize)
+
+ self.SetSizer(main_sizer)
+
self.Locations = None
self.VarType = None
self.Default = False
@@ -123,10 +106,11 @@
'''
Grid cell editor that uses LocationCellControl to display a browse button.
'''
- def __init__(self, table, controler):
+ def __init__(self, table, controller):
wx.grid.PyGridCellEditor.__init__(self)
+
self.Table = table
- self.Controler = controler
+ self.Controller = controller
def __del__(self):
self.CellControl = None
@@ -139,10 +123,10 @@
def BeginEdit(self, row, col, grid):
self.CellControl.Enable()
- self.CellControl.SetLocations(self.Controler.GetVariableLocationTree())
+ self.CellControl.SetLocations(self.Controller.GetVariableLocationTree())
self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location'))
if isinstance(self.CellControl, LocationCellControl):
- self.CellControl.SetVarType(self.Controler.GetBaseType(self.Table.GetValueByName(row, 'Type')))
+ self.CellControl.SetVarType(self.Controller.GetBaseType(self.Table.GetValueByName(row, 'Type')))
self.CellControl.SetFocus()
def EndEdit(self, row, col, grid):
@@ -160,5 +144,5 @@
wx.SIZE_ALLOW_MINUS_ONE)
def Clone(self):
- return LocationCellEditor(self.Table, self.Controler)
+ return LocationCellEditor(self.Table, self.Controller)
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/PouInstanceVariablesPanel.py
--- a/controls/PouInstanceVariablesPanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/PouInstanceVariablesPanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -27,6 +27,7 @@
import wx.lib.agw.customtreectrl as CT
from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU
+from utils.BitmapLibrary import GetBitmap
class PouInstanceVariablesPanel(wx.Panel):
@@ -35,32 +36,24 @@
parent=parent, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
- self.ParentButton = wx.lib.buttons.GenBitmapButton(
- name='ParentButton', parent=self,
- bitmap=window.GenerateBitmap("up"),
- pos=wx.Point(0, 0), size=wx.Size(28, 28),
- style=wx.NO_BORDER)
+ self.ParentButton = wx.lib.buttons.GenBitmapButton(self,
+ bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.ParentButton.SetToolTipString(_("Parent instance"))
self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick,
self.ParentButton)
- self.InstanceChoice = wx.ComboBox(name='InstanceChoice',
- parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
+ self.InstanceChoice = wx.ComboBox(self, style=wx.CB_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged,
self.InstanceChoice)
self.InstanceChoice.Bind(wx.EVT_LEFT_DOWN, self.OnInstanceChoiceLeftDown)
- self.DebugButton = wx.lib.buttons.GenBitmapButton(
- name='DebugButton', parent=self,
- bitmap=window.GenerateBitmap("debug"),
- pos=wx.Point(0, 0), size=wx.Size(28, 28),
- style=wx.NO_BORDER)
+ self.DebugButton = wx.lib.buttons.GenBitmapButton(self,
+ bitmap=GetBitmap("debug_instance"), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ self.ParentButton.SetToolTipString(_("Debug instance"))
self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick,
self.DebugButton)
- self.VariablesList = CT.CustomTreeCtrl(
- name='VariablesList', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0),
+ self.VariablesList = CT.CustomTreeCtrl(self,
style=wx.SUNKEN_BORDER,
agwStyle=CT.TR_NO_BUTTONS|
CT.TR_SINGLE|
@@ -76,15 +69,15 @@
self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown)
buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0)
- buttons_sizer.AddWindow(self.ParentButton, 0, border=0, flag=0)
- buttons_sizer.AddWindow(self.InstanceChoice, 0, border=0, flag=wx.GROW)
- buttons_sizer.AddWindow(self.DebugButton, 0, border=0, flag=0)
+ buttons_sizer.AddWindow(self.ParentButton)
+ buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW)
+ buttons_sizer.AddWindow(self.DebugButton)
buttons_sizer.AddGrowableCol(1)
buttons_sizer.AddGrowableRow(0)
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
- main_sizer.AddSizer(buttons_sizer, 0, border=0, flag=wx.GROW)
- main_sizer.AddWindow(self.VariablesList, 0, border=0, flag=wx.GROW)
+ main_sizer.AddSizer(buttons_sizer, flag=wx.GROW)
+ main_sizer.AddWindow(self.VariablesList, flag=wx.GROW)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(1)
@@ -151,22 +144,22 @@
if (var_infos["debug"] and self.Debug and
(self.Controller.IsOfType(var_infos["type"], "ANY_NUM", True) or
self.Controller.IsOfType(var_infos["type"], "ANY_BIT", True))):
- graph_button = wx.lib.buttons.GenBitmapButton(name="graph",
- parent=panel, bitmap=self.ParentWindow.GenerateBitmap("graph"),
- pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ graph_button = wx.lib.buttons.GenBitmapButton(panel,
+ bitmap=GetBitmap("instance_graph"),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
self.Bind(wx.EVT_BUTTON, self.GenGraphButtonCallback(var_infos), graph_button)
buttons.append(graph_button)
elif var_infos["edit"]:
- edit_button = wx.lib.buttons.GenBitmapButton(name="edit",
- parent=panel, bitmap=self.ParentWindow.GenerateBitmap("edit"),
- pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ edit_button = wx.lib.buttons.GenBitmapButton(panel,
+ bitmap=GetBitmap("edit"),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
self.Bind(wx.EVT_BUTTON, self.GenEditButtonCallback(var_infos), edit_button)
buttons.append(edit_button)
if var_infos["debug"] and self.Debug:
- debug_button = wx.lib.buttons.GenBitmapButton(name="debug",
- parent=panel, bitmap=self.ParentWindow.GenerateBitmap("debug"),
- pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER)
+ debug_button = wx.lib.buttons.GenBitmapButton(panel,
+ bitmap=GetBitmap("debug_instance"),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
self.Bind(wx.EVT_BUTTON, self.GenDebugButtonCallback(var_infos), debug_button)
buttons.append(debug_button)
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/ProjectPropertiesPanel.py
--- a/controls/ProjectPropertiesPanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/ProjectPropertiesPanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -24,8 +24,20 @@
import wx
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"]
+[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE,
+ POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES
+] = range(10)
+
+#-------------------------------------------------------------------------------
+# Project Properties Panel
+#-------------------------------------------------------------------------------
+
class ProjectPropertiesPanel(wx.Notebook):
def AddSizerParams(self, parent, sizer, params):
@@ -36,25 +48,20 @@
elif idx == len(params) - 1:
border |= wx.BOTTOM
- st = wx.StaticText(id=-1, parent=parent,
- label=label, name=name + '_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
+ st = wx.StaticText(parent, label=label)
+ sizer.AddWindow(st, border=10,
+ flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
- tc_id = wx.NewId()
- tc = wx.TextCtrl(id=tc_id, parent=parent,
- name=name, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
+ tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER)
setattr(self, name, tc)
callback = self.GetTextCtrlChangedFunction(tc, name)
- self.Bind(wx.EVT_TEXT_ENTER, callback, id=tc_id)
+ self.Bind(wx.EVT_TEXT_ENTER, callback, tc)
tc.Bind(wx.EVT_KILL_FOCUS, callback)
- sizer.AddWindow(tc, 0, border=10, flag=wx.GROW|border|wx.RIGHT)
+ sizer.AddWindow(tc, border=10,
+ flag=wx.GROW|border|wx.RIGHT)
def __init__(self, parent, controller=None, window=None, enable_required=True):
- wx.Notebook.__init__(self, id=-1, parent=parent,
- name='ProjectPropertiesPanel', style=0,
- pos=wx.Point(0, 0), size=wx.Size(500, 300))
+ wx.Notebook.__init__(self, parent, size=wx.Size(500, 300))
self.Controller = controller
self.ParentWindow = window
@@ -62,9 +69,7 @@
# Project Panel elements
- self.ProjectPanel = wx.Panel(id=-1, parent=self,
- name='ProjectPanel', pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+ self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15)
projectpanel_sizer.AddGrowableCol(1)
self.ProjectPanel.SetSizer(projectpanel_sizer)
@@ -80,9 +85,7 @@
# Author Panel elements
- self.AuthorPanel = wx.Panel(id=-1, parent=self,
- name='AuthorPanel', pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+ self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15)
authorpanel_sizer.AddGrowableCol(1)
self.AuthorPanel.SetSizer(authorpanel_sizer)
@@ -97,56 +100,48 @@
# Graphics Panel elements
- self.GraphicsPanel = wx.Panel(id=-1, parent=self,
- name='GraphicsPanel', pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+ self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5)
graphicpanel_sizer.AddGrowableCol(0)
graphicpanel_sizer.AddGrowableRow(3)
self.GraphicsPanel.SetSizer(graphicpanel_sizer)
- pageSize_st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
- label=_('Page Size (optional):'), name='pageSize_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- graphicpanel_sizer.AddWindow(pageSize_st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT)
+ pageSize_st = wx.StaticText(self.GraphicsPanel,
+ label=_('Page Size (optional):'))
+ graphicpanel_sizer.AddWindow(pageSize_st, border=10,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT)
pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
pageSize_sizer.AddGrowableCol(1)
- graphicpanel_sizer.AddSizer(pageSize_sizer, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
+ graphicpanel_sizer.AddSizer(pageSize_sizer, border=10,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
for name, label in [('PageWidth', _('Width:')),
('PageHeight', _('Height:'))]:
- st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
- label=label, name=name + "_label",
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- pageSize_sizer.AddWindow(st, 0, border=12, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
+ st = wx.StaticText(self.GraphicsPanel, label=label)
+ pageSize_sizer.AddWindow(st, border=12,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
- sp_id = wx.NewId()
- sp = wx.SpinCtrl(id=sp_id, parent=self.GraphicsPanel,
- name=name, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER,
- min=0, max=2**16)
+ sp = wx.SpinCtrl(self.GraphicsPanel,
+ min=0, max=2**16, style=wx.TE_PROCESS_ENTER)
setattr(self, name, sp)
callback = self.GetPageSizeChangedFunction(sp, name)
- self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id)
+ self.Bind(wx.EVT_TEXT_ENTER, callback, sp)
sp.Bind(wx.EVT_KILL_FOCUS, callback)
- pageSize_sizer.AddWindow(sp, 0, border=0, flag=wx.GROW)
-
- scaling_st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
- label=_('Grid Resolution:'), name='scaling_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- graphicpanel_sizer.AddWindow(scaling_st, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
-
- scaling_nb = wx.Notebook(id=-1, parent=self.GraphicsPanel,
- name='ScalingNotebook', pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=0)
- graphicpanel_sizer.AddWindow(scaling_nb, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ pageSize_sizer.AddWindow(sp, flag=wx.GROW)
+
+ scaling_st = wx.StaticText(self.GraphicsPanel,
+ label=_('Grid Resolution:'))
+ graphicpanel_sizer.AddWindow(scaling_st, border=10,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
+
+ scaling_nb = wx.Notebook(self.GraphicsPanel)
+ graphicpanel_sizer.AddWindow(scaling_nb, border=10,
+ flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.Scalings = {}
for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]:
- scaling_panel = wx.Panel(id=-1, parent=scaling_nb,
- name=language + '_panel', pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+ scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL)
scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
scalingpanel_sizer.AddGrowableCol(1)
scaling_panel.SetSizer(scalingpanel_sizer)
@@ -159,21 +154,18 @@
else:
border = wx.BOTTOM
- st = wx.StaticText(id=-1, parent=scaling_panel,
- label=label, name=name + '_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- scalingpanel_sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
+ st = wx.StaticText(scaling_panel, label=label)
+ scalingpanel_sizer.AddWindow(st, border=10,
+ flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
- sp_id = wx.NewId()
- sp = wx.SpinCtrl(id=sp_id, parent=scaling_panel,
- name=name, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER,
- min=0, max=2**16)
+ sp = wx.SpinCtrl(scaling_panel,
+ min=0, max=2**16, style=wx.TE_PROCESS_ENTER)
scaling_controls.append(sp)
callback = self.GetScalingChangedFunction(sp, language, name)
- self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id)
+ self.Bind(wx.EVT_TEXT_ENTER, callback, sp)
sp.Bind(wx.EVT_KILL_FOCUS, callback)
- scalingpanel_sizer.AddWindow(sp, 0, border=10, flag=wx.GROW|border|wx.RIGHT)
+ scalingpanel_sizer.AddWindow(sp, border=10,
+ flag=wx.GROW|border|wx.RIGHT)
self.Scalings[language] = scaling_controls
scaling_nb.AddPage(scaling_panel, translation)
@@ -190,30 +182,30 @@
miscellaneouspanel_sizer.AddGrowableRow(1)
self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer)
- language_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel,
- label=_('Language (optional):'), name='language_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- miscellaneouspanel_sizer.AddWindow(language_label, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
-
- language_id = wx.NewId()
- self.Language = wx.ComboBox(id=language_id, parent=self.MiscellaneousPanel,
- name='Language', pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, id=language_id)
- miscellaneouspanel_sizer.AddWindow(self.Language, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
-
- description_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel,
- label=_('Content Description (optional):'), name='description_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- miscellaneouspanel_sizer.AddWindow(description_label, 0, border=10, flag=wx.BOTTOM|wx.LEFT)
-
- description_id = wx.NewId()
- self.ContentDescription = wx.TextCtrl(id=description_id, parent=self.MiscellaneousPanel,
- name='ContentDescription', pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, id=description_id)
- self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, self.OnContentDescriptionChanged)
- miscellaneouspanel_sizer.AddWindow(self.ContentDescription, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
+ language_label = wx.StaticText(self.MiscellaneousPanel,
+ label=_('Language (optional):'))
+ miscellaneouspanel_sizer.AddWindow(language_label, border=10,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
+
+ self.Language = wx.ComboBox(self.MiscellaneousPanel,
+ style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language)
+ miscellaneouspanel_sizer.AddWindow(self.Language, border=10,
+ flag=wx.GROW|wx.TOP|wx.RIGHT)
+
+ description_label = wx.StaticText(self.MiscellaneousPanel,
+ label=_('Content Description (optional):'))
+ miscellaneouspanel_sizer.AddWindow(description_label, border=10,
+ flag=wx.BOTTOM|wx.LEFT)
+
+ self.ContentDescription = wx.TextCtrl(self.MiscellaneousPanel,
+ style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
+ self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged,
+ self.ContentDescription)
+ self.ContentDescription.Bind(wx.EVT_KILL_FOCUS,
+ self.OnContentDescriptionChanged)
+ miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10,
+ flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
self.AddPage(self.MiscellaneousPanel, _("Miscellaneous"))
@@ -290,11 +282,8 @@
new_value = None
if old_value != new_value:
self.Controller.SetProjectProperties(properties={name: new_value})
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshFileMenu()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshProjectTree()
- self.ParentWindow.RefreshPageTitles()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
+ PROJECTTREE, PAGETITLES)
wx.CallAfter(self.RefreshView)
event.Skip()
return TextCtrlChangedFunction
@@ -312,11 +301,8 @@
new_value = (old_value[0], spinctrl.GetValue())
if old_value != new_value:
self.Controller.SetProjectProperties(properties={"pageSize": new_value})
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshFileMenu()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshPageTitles()
- self.ParentWindow.RefreshScaling()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
+ PAGETITLES, SCALING)
wx.CallAfter(self.RefreshView)
event.Skip()
return PageSizeChangedFunction
@@ -335,11 +321,8 @@
new_value = (old_value[0], spinctrl.GetValue())
if old_value != new_value:
self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}})
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshFileMenu()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshPageTitles()
- self.ParentWindow.RefreshScaling()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
+ PAGETITLES, SCALING)
wx.CallAfter(self.RefreshView)
event.Skip()
return ScalingChangedFunction
@@ -355,10 +338,7 @@
new_value = None
if old_value != new_value:
self.Controller.SetProjectProperties(properties={"language": new_value})
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshFileMenu()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshPageTitles()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
wx.CallAfter(self.RefreshView)
event.Skip()
@@ -373,9 +353,6 @@
new_value = None
if old_value != new_value:
self.Controller.SetProjectProperties(properties={"contentDescription": new_value})
- self.ParentWindow.RefreshTitle()
- self.ParentWindow.RefreshFileMenu()
- self.ParentWindow.RefreshEditMenu()
- self.ParentWindow.RefreshPageTitles()
+ self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
wx.CallAfter(self.RefreshView)
event.Skip()
diff -r 95a0a427f3ef -r 131ea7f237b9 controls/VariablePanel.py
--- a/controls/VariablePanel.py Fri Jun 15 18:03:25 2012 +0200
+++ b/controls/VariablePanel.py Mon Jun 25 20:03:53 2012 +0200
@@ -23,32 +23,34 @@
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import wx, wx.grid
import re
-
from types import TupleType, StringType, UnicodeType
+import wx
+import wx.grid
+import wx.lib.buttons
+
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT
from dialogs.ArrayTypeDialog import ArrayTypeDialog
from CustomGrid import CustomGrid
from CustomTable import CustomTable
from LocationCellEditor import LocationCellEditor
-
-# Compatibility function for wx versions < 2.6
+from utils.BitmapLibrary import GetBitmap
+
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
def AppendMenu(parent, help, id, kind, text):
if wx.VERSION >= (2, 6, 0):
parent.Append(help=help, id=id, kind=kind, text=text)
else:
parent.Append(helpString=help, id=id, kind=kind, item=text)
-[TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE,
- POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING
-] = range(9)
-
-#-------------------------------------------------------------------------------
-# Variables Editor Panel
-#-------------------------------------------------------------------------------
+[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE,
+ POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES
+] = range(10)
def GetVariableTableColnames(location):
_ = lambda x : x
@@ -88,6 +90,10 @@
LOCATION_MODEL = re.compile("((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$")
+#-------------------------------------------------------------------------------
+# Variables Panel Table
+#-------------------------------------------------------------------------------
+
class VariableTable(CustomTable):
"""
@@ -205,7 +211,10 @@
grid.SetCellBackgroundColour(row, col, highlight_colours[0])
grid.SetCellTextColour(row, col, highlight_colours[1])
self.ResizeRow(grid, row)
-
+
+#-------------------------------------------------------------------------------
+# Variable Panel Drop Target
+#-------------------------------------------------------------------------------
class VariableDropTarget(wx.TextDropTarget):
'''
@@ -301,154 +310,101 @@
if message is not None:
wx.CallAfter(self.ShowMessage, message)
-
-
+
def ShowMessage(self, message):
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
-[ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID,
- ID_VARIABLEEDITORCONTROLPANEL, ID_VARIABLEEDITORPANELRETURNTYPELABEL,
- ID_VARIABLEEDITORPANELRETURNTYPE, ID_VARIABLEEDITORPANELDESCRIPTIONLABEL,
- ID_VARIABLEEDITORPANELDESCRIPTION, ID_VARIABLEEDITORPANELCLASSFILTERLABEL,
- ID_VARIABLEEDITORPANELCLASSFILTER, ID_VARIABLEEDITORPANELADDBUTTON,
- ID_VARIABLEEDITORPANELDELETEBUTTON, ID_VARIABLEEDITORPANELUPBUTTON,
- ID_VARIABLEEDITORPANELDOWNBUTTON,
-] = [wx.NewId() for _init_ctrls in range(13)]
+#-------------------------------------------------------------------------------
+# Variable Panel
+#-------------------------------------------------------------------------------
class VariablePanel(wx.Panel):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.ControlPanel, 0, border=5, flag=wx.GROW|wx.ALL)
- parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_ControlPanelSizer_Items(self, parent):
- parent.AddWindow(self.ReturnTypeLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
- parent.AddWindow(self.ReturnType, 0, border=0, flag=0)
- parent.AddWindow(self.DescriptionLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
- parent.AddWindow(self.Description, 0, border=0, flag=0)
- parent.AddWindow(self.ClassFilterLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
- parent.AddWindow(self.ClassFilter, 0, border=0, flag=0)
- parent.AddWindow(self.AddButton, 0, border=0, flag=0)
- parent.AddWindow(self.DeleteButton, 0, border=0, flag=0)
- parent.AddWindow(self.UpButton, 0, border=0, flag=0)
- parent.AddWindow(self.DownButton, 0, border=0, flag=0)
-
- def _init_coll_ControlPanelSizer_Growables(self, parent):
- parent.AddGrowableCol(5)
- parent.AddGrowableRow(0)
-
- def _init_sizers(self):
+ def __init__(self, parent, window, controler, element_type, debug=False):
+ wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
+
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=0)
- self.ControlPanelSizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5)
-
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer)
- self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer)
-
- self.ControlPanel.SetSizer(self.ControlPanelSizer)
+ self.MainSizer.AddGrowableCol(0)
+ self.MainSizer.AddGrowableRow(1)
+
+ controls_sizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5)
+ controls_sizer.AddGrowableCol(5)
+ controls_sizer.AddGrowableRow(0)
+ self.MainSizer.AddSizer(controls_sizer, border=5, flag=wx.GROW|wx.ALL)
+
+ self.ReturnTypeLabel = wx.StaticText(self, label=_('Return Type:'))
+ controls_sizer.AddWindow(self.ReturnTypeLabel, flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.ReturnType = wx.ComboBox(self,
+ size=wx.Size(145, -1), style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, self.ReturnType)
+ controls_sizer.AddWindow(self.ReturnType)
+
+ self.DescriptionLabel = wx.StaticText(self, label=_('Description:'))
+ controls_sizer.AddWindow(self.DescriptionLabel, flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.Description = wx.TextCtrl(self,
+ size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER)
+ self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, self.Description)
+ self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged)
+ controls_sizer.AddWindow(self.Description)
+
+ class_filter_label = wx.StaticText(self, label=_('Class Filter:'))
+ controls_sizer.AddWindow(class_filter_label, flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.ClassFilter = wx.ComboBox(self,
+ size=wx.Size(145, -1), style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, self.ClassFilter)
+ controls_sizer.AddWindow(self.ClassFilter)
+
+ for name, bitmap, help in [
+ ("AddButton", "add_element", _("Add variable")),
+ ("DeleteButton", "remove_element", _("Remove variable")),
+ ("UpButton", "up", _("Move variable up")),
+ ("DownButton", "down", _("Move variable down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ controls_sizer.AddWindow(button)
+
+ self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL)
+ self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
+ self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
+ self.OnVariablesGridCellChange)
+ self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
+ self.OnVariablesGridCellLeftClick)
+ self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN,
+ self.OnVariablesGridEditorShown)
+ self.MainSizer.AddWindow(self.VariablesGrid, flag=wx.GROW)
+
self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL,
- name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.VariablesGrid = CustomGrid(id=ID_VARIABLEEDITORPANELVARIABLESGRID,
- name='VariablesGrid', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.VSCROLL)
- self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
- if wx.VERSION >= (2, 6, 0):
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange)
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick)
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown)
- else:
- wx.grid.EVT_GRID_CELL_CHANGE(self.VariablesGrid, self.OnVariablesGridCellChange)
- wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick)
- wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown)
-
- self.ControlPanel = wx.ScrolledWindow(id=ID_VARIABLEEDITORCONTROLPANEL,
- name='ControlPanel', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
- self.ControlPanel.SetScrollRate(10, 0)
-
- self.ReturnTypeLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELRETURNTYPELABEL,
- label=_('Return Type:'), name='ReturnTypeLabel', parent=self.ControlPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE,
- name='ReturnType', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(145, -1), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE)
-
- self.DescriptionLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELDESCRIPTIONLABEL,
- label=_('Description:'), name='DescriptionLabel', parent=self.ControlPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.Description = wx.TextCtrl(id=ID_VARIABLEEDITORPANELDESCRIPTION,
- name='Description', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, id=ID_VARIABLEEDITORPANELDESCRIPTION)
- self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged)
-
- self.ClassFilterLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELCLASSFILTERLABEL,
- label=_('Class Filter:'), name='ClassFilterLabel', parent=self.ControlPanel,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER,
- name='ClassFilter', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(145, -1), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER)
-
- self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label=_('Add'),
- name='AddButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label=_('Delete'),
- name='DeleteButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^',
- name='UpButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(28, -1), style=0)
-
- self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v',
- name='DownButton', parent=self.ControlPanel, pos=wx.Point(0, 0),
- size=wx.Size(28, -1), style=0)
-
- self._init_sizers()
-
- def __init__(self, parent, window, controler, element_type, debug=False):
- self._init_ctrls(parent)
+
self.ParentWindow = window
self.Controler = controler
self.ElementType = element_type
self.Debug = debug
self.RefreshHighlightsTimer = wx.Timer(self, -1)
- self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer)
+ self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer,
+ self.RefreshHighlightsTimer)
self.Filter = "All"
self.FilterChoices = []
self.FilterChoiceTransfer = GetFilterChoiceTransfer()
- self.DefaultValue = { "Name" : "", "Class" : "", "Type" : "INT", "Location" : "",
- "Initial Value" : "", "Option" : "",
- "Documentation" : "", "Edit" : True
- }
+ self.DefaultValue = {
+ "Name" : "",
+ "Class" : "",
+ "Type" : "INT",
+ "Location" : "",
+ "Initial Value" : "",
+ "Option" : "",
+ "Documentation" : "",
+ "Edit" : True
+ }
if element_type in ["config", "resource"]:
self.DefaultTypes = {"All" : "Global"}
@@ -636,7 +592,6 @@
self.RefreshValues()
self.VariablesGrid.RefreshButtons()
- self.ControlPanelSizer.Layout()
self.MainSizer.Layout()
def OnReturnTypeChanged(self, event):
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ActionBlockDialog.py
--- a/dialogs/ActionBlockDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/ActionBlockDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -23,11 +23,13 @@
import wx
import wx.grid
+import wx.lib.buttons
from controls import CustomGrid, CustomTable
-
-#-------------------------------------------------------------------------------
-# Action Block Dialog
+from utils.BitmapLibrary import GetBitmap
+
+#-------------------------------------------------------------------------------
+# Helpers
#-------------------------------------------------------------------------------
def GetActionTableColnames():
@@ -38,6 +40,10 @@
_ = lambda x: x
return [_("Action"), _("Variable"), _("Inline")]
+#-------------------------------------------------------------------------------
+# Action Table
+#-------------------------------------------------------------------------------
+
class ActionTable(CustomTable):
def GetValue(self, row, col):
@@ -105,105 +111,54 @@
grid.SetCellBackgroundColour(row, col, wx.WHITE)
self.ResizeRow(grid, row)
-
-[ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID,
- ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON,
- ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON,
- ID_ACTIONBLOCKDIALOGDOWNBUTTON,
-] = [wx.NewId() for _init_ctrls in range(7)]
+#-------------------------------------------------------------------------------
+# Action Block Dialog
+#-------------------------------------------------------------------------------
class ActionBlockDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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):
- 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):
- wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG,
- name='ActionBlockDialog', parent=prnt,
- 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.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 = CustomGrid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID,
- name='ActionsGrid', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.VSCROLL)
+ def __init__(self, parent):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(500, 300), title=_('Edit action block properties'))
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(1)
+
+ top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
+ top_sizer.AddGrowableCol(0)
+ top_sizer.AddGrowableRow(0)
+ main_sizer.AddSizer(top_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ actions_label = wx.StaticText(self, label=_('Actions:'))
+ top_sizer.AddWindow(actions_label, flag=wx.ALIGN_BOTTOM)
+
+ for name, bitmap, help in [
+ ("AddButton", "add_element", _("Add action")),
+ ("DeleteButton", "remove_element", _("Remove action")),
+ ("UpButton", "up", _("Move action up")),
+ ("DownButton", "down", _("Move action down"))]:
+ button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap),
+ size=wx.Size(28, 28), style=wx.NO_BORDER)
+ button.SetToolTipString(help)
+ setattr(self, name, button)
+ top_sizer.AddWindow(button)
+
+ self.ActionsGrid = CustomGrid(self, style=wx.VSCROLL)
self.ActionsGrid.DisableDragGridSize()
self.ActionsGrid.EnableScrolling(False, True)
- if wx.VERSION >= (2, 6, 0):
- self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnActionsGridCellChange)
- else:
- wx.grid.EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange)
-
- self.AddButton = wx.Button(id=ID_ACTIONBLOCKDIALOGADDBUTTON, label=_('Add'),
- name='AddButton', parent=self, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.DeleteButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDELETEBUTTON, label=_('Delete'),
- name='DeleteButton', parent=self, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=0)
-
- self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^',
- name='UpButton', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(32, 32), style=0)
-
- 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)
-
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
- self._init_sizers()
-
- def __init__(self, parent):
- self._init_ctrls(parent)
+ self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
+ self.OnActionsGridCellChange)
+ main_sizer.AddSizer(self.ActionsGrid, border=20,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
+
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
self.Table = ActionTable(self, [], GetActionTableColnames())
typelist = GetTypeList()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ArrayTypeDialog.py
--- a/dialogs/ArrayTypeDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/ArrayTypeDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -28,75 +28,55 @@
from controls import CustomEditableListBox
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
-[ID_ARRAYTYPEDIALOG, ID_ARRAYTYPEDIALOGBASETYPE,
- ID_ARRAYTYPEDIALOGDIMENSIONS, ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1,
-] = [wx.NewId() for _init_ctrls in range(4)]
+#-------------------------------------------------------------------------------
+# Array Type Dialog
+#-------------------------------------------------------------------------------
class ArrayTypeDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- parent.AddWindow(self.Dimensions, 0, border=20, flag=wx.GROW|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__(self, parent, datatypes, infos):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(500, 300), title=_('Edit array type properties'))
- def _init_coll_flexGridSizer1_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(1)
- def _init_coll_TopSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 1, border=0, flag=wx.GROW)
- parent.AddWindow(self.BaseType, 1, border=0, flag=wx.GROW)
-
- def _init_sizers(self):
- self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
- self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
+ top_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(top_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
- self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
- self._init_coll_TopSizer_Items(self.TopSizer)
+ basetype_label = wx.StaticText(self, label=_('Base Type:'))
+ top_sizer.AddWindow(basetype_label, 1, flag=wx.ALIGN_BOTTOM)
- self.SetSizer(self.flexGridSizer1)
-
- def _init_ctrls(self, prnt):
- wx.Dialog.__init__(self, id=ID_ARRAYTYPEDIALOG,
- name='ArrayTypeDialog', parent=prnt,
- size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title=_('Edit array type properties'))
- self.SetClientSize(wx.Size(500, 300))
+ self.BaseType = wx.ComboBox(self, style=wx.CB_READONLY)
+ top_sizer.AddWindow(self.BaseType, 1, flag=wx.GROW)
- self.staticText1 = wx.StaticText(id=ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1,
- label=_('Base Type:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.BaseType = wx.ComboBox(id=ID_ARRAYTYPEDIALOGBASETYPE,
- name='BaseType', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
+ self.Dimensions = CustomEditableListBox(self, label=_("Dimensions:"),
+ style=wx.gizmos.EL_ALLOW_NEW|
+ wx.gizmos.EL_ALLOW_EDIT|
+ wx.gizmos.EL_ALLOW_DELETE)
+ for func in ["_OnLabelEndEdit",
+ "_OnAddButton",
+ "_OnDelButton",
+ "_OnUpButton",
+ "_OnDownButton"]:
+ setattr(self.Dimensions, func, self.OnDimensionsChanged)
+ main_sizer.AddSizer(self.Dimensions, border=20,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
- self.Dimensions = CustomEditableListBox(id=ID_ARRAYTYPEDIALOGDIMENSIONS,
- name='ArrayDimensions', parent=self, label=_("Dimensions:"), pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
- for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]:
- setattr(self.Dimensions, func, self.OnDimensionsChanged)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
- self._init_sizers()
-
- def __init__(self, parent, datatypes, infos):
- self._init_ctrls(parent)
+ self.SetSizer(main_sizer)
for datatype in datatypes:
self.BaseType.Append(datatype)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/BrowseLocationsDialog.py
--- a/dialogs/BrowseLocationsDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/BrowseLocationsDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -24,6 +24,10 @@
from plcopen.structures import LOCATIONDATATYPES
from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
CWD = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
def GetDirChoiceOptions():
@@ -40,88 +44,52 @@
for type in types:
LOCATION_SIZES[type] = size
-[ID_BROWSELOCATIONSDIALOG, ID_BROWSELOCATIONSDIALOGLOCATIONSTREE,
- ID_BROWSELOCATIONSDIALOGDIRCHOICE, ID_BROWSELOCATIONSDIALOGSTATICTEXT1,
- ID_BROWSELOCATIONSDIALOGSTATICTEXT2,
-] = [wx.NewId() for _init_ctrls in range(5)]
+#-------------------------------------------------------------------------------
+# Browse Locations Dialog
+#-------------------------------------------------------------------------------
class BrowseLocationsDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddWindow(self.staticText1, 0, border=20, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
- parent.AddWindow(self.LocationsTree, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.GROW)
- parent.AddSizer(self.ButtonGridSizer, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.GROW)
+ def __init__(self, parent, var_type, locations):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(600, 400), title=_('Browse Locations'))
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_ButtonGridSizer_Items(self, parent):
- parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
- parent.AddWindow(self.DirChoice, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL)
- parent.AddSizer(self.ButtonSizer, 0, border=0, flag=wx.ALIGN_RIGHT)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(1)
- def _init_coll_ButtonGridSizer_Growables(self, parent):
- parent.AddGrowableCol(2)
- parent.AddGrowableRow(0)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
- self.ButtonGridSizer = wx.FlexGridSizer(cols=3, hgap=5, rows=1, vgap=0)
+ locations_label = wx.StaticText(self, label=_('Locations available:'))
+ main_sizer.AddWindow(locations_label, border=20,
+ flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_ButtonGridSizer_Items(self.ButtonGridSizer)
- self._init_coll_ButtonGridSizer_Growables(self.ButtonGridSizer)
+ self.LocationsTree = wx.TreeCtrl(self,
+ style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT)
+ self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated,
+ self.LocationsTree)
+ main_sizer.AddWindow(self.LocationsTree, border=20,
+ flag=wx.LEFT|wx.RIGHT|wx.GROW)
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Dialog.__init__(self, id=ID_BROWSELOCATIONSDIALOG,
- name='BrowseLocationsDialog', parent=prnt,
- size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title=_('Browse Locations'))
-
- self.staticText1 = wx.StaticText(id=ID_BROWSELOCATIONSDIALOGSTATICTEXT1,
- label=_('Locations available:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
+ button_gridsizer = wx.FlexGridSizer(cols=3, hgap=5, rows=1, vgap=0)
+ button_gridsizer.AddGrowableCol(2)
+ button_gridsizer.AddGrowableRow(0)
+ main_sizer.AddSizer(button_gridsizer, border=20,
+ flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW)
- if wx.Platform == '__WXMSW__':
- treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER
- else:
- treestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER
- self.LocationsTree = wx.TreeCtrl(id=ID_BROWSELOCATIONSDIALOGLOCATIONSTREE,
- name='LocationsTree', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=treestyle)
- self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated,
- id=ID_BROWSELOCATIONSDIALOGLOCATIONSTREE)
+ direction_label = wx.StaticText(self, label=_('Direction:'))
+ button_gridsizer.AddWindow(direction_label,
+ flag=wx.ALIGN_CENTER_VERTICAL)
- self.staticText2 = wx.StaticText(id=ID_BROWSELOCATIONSDIALOGSTATICTEXT2,
- label=_('Direction:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
+ self.DirChoice = wx.ComboBox(self, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnDirChoice, self.DirChoice)
+ button_gridsizer.AddWindow(self.DirChoice,
+ flag=wx.ALIGN_CENTER_VERTICAL)
- self.DirChoice = wx.ComboBox(id=ID_BROWSELOCATIONSDIALOGDIRCHOICE,
- name='DirChoice', parent=self, pos=wx.Point(0, 0),
- size=wx.DefaultSize, style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnDirChoice, id=ID_BROWSELOCATIONSDIALOGDIRCHOICE)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ button_gridsizer.AddWindow(button_sizer, flag=wx.ALIGN_RIGHT)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
+ self.SetSizer(main_sizer)
- self._init_sizers()
-
- def __init__(self, parent, var_type, locations):
- self._init_ctrls(parent)
self.VarType = var_type
self.Locations = locations
@@ -156,19 +124,13 @@
def RefreshLocationsTree(self):
root = self.LocationsTree.GetRootItem()
if not root.IsOk():
- if wx.Platform == '__WXMSW__':
- root = self.LocationsTree.AddRoot(_('ConfNodes'))
- else:
- root = self.LocationsTree.AddRoot("")
+ root = self.LocationsTree.AddRoot("")
self.GenerateLocationsTreeBranch(root, self.Locations)
self.LocationsTree.Expand(root)
def GenerateLocationsTreeBranch(self, root, locations):
to_delete = []
- if wx.VERSION >= (2, 6, 0):
- item, root_cookie = self.LocationsTree.GetFirstChild(root)
- else:
- item, root_cookie = self.LocationsTree.GetFirstChild(root, 0)
+ item, root_cookie = self.LocationsTree.GetFirstChild(root)
for loc_infos in locations:
infos = loc_infos.copy()
if infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP] or\
@@ -211,8 +173,8 @@
if selected.IsOk():
var_infos = self.LocationsTree.GetPyData(selected)
if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
- message = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ConnectionDialog.py
--- a/dialogs/ConnectionDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/ConnectionDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -30,137 +30,77 @@
# Create New Connection Dialog
#-------------------------------------------------------------------------------
-[ID_CONNECTIONDIALOG, ID_CONNECTIONDIALOGSPACER,
- ID_CONNECTIONDIALOGNAME, ID_CONNECTIONDIALOGRADIOBUTTON1,
- ID_CONNECTIONDIALOGRADIOBUTTON2, ID_CONNECTIONDIALOGPREVIEW,
- ID_CONNECTIONDIALOGSTATICTEXT1, ID_CONNECTIONDIALOGSTATICTEXT2,
- ID_CONNECTIONDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(9)]
-
class ConnectionDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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__(self, parent, controller):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(350, 220), title=_('Connection Properties'))
- 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.staticText2, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.ConnectionName, 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(5)
-
- 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)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
- def _init_coll_RightGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_sizers(self):
- 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=6, 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, ctrler):
- wx.Dialog.__init__(self, id=ID_CONNECTIONDIALOG,
- name='ConnectionDialog', parent=prnt,
- size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
- title=_('Connection Properties'))
- self.SetClientSize(wx.Size(350, 220))
-
- self.staticText1 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT1,
- label=_('Type:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT2,
- label=_('Name:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText3 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT3,
- label=_('Preview:'), name='staticText3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONDIALOGRADIOBUTTON1,
- label=_('Connector'), name='radioButton1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONDIALOGRADIOBUTTON1)
- self.radioButton1.SetValue(True)
-
- self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONDIALOGRADIOBUTTON2,
- label=_('Continuation'), 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_CONNECTIONDIALOGRADIOBUTTON2)
- self.radioButton2.SetValue(False)
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- self.ConnectionName = wx.TextCtrl(id=ID_CONNECTIONDIALOGNAME,
- name='Name', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_CONNECTIONDIALOGNAME)
-
- self.Preview = wx.Panel(id=ID_CONNECTIONDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ type_label = wx.StaticText(self, label=_('Type:'))
+ left_gridsizer.AddWindow(type_label, flag=wx.GROW)
+
+ self.ConnectorRadioButton = wx.RadioButton(self,
+ label=_('Connector'), style=wx.RB_GROUP)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectorRadioButton)
+ self.ConnectorRadioButton.SetValue(True)
+ left_gridsizer.AddWindow(self.ConnectorRadioButton, flag=wx.GROW)
+
+ self.ConnectionRadioButton = wx.RadioButton(self, label=_('Continuation'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectionRadioButton)
+ left_gridsizer.AddWindow(self.ConnectionRadioButton, flag=wx.GROW)
+
+ name_label = wx.StaticText(self, label=_('Name:'))
+ left_gridsizer.AddWindow(name_label, flag=wx.GROW)
+
+ self.ConnectionName = wx.TextCtrl(self)
+ self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
+ left_gridsizer.AddWindow(self.ConnectionName, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
- self.Spacer = wx.Panel(id=ID_CONNECTIONDIALOGSPACER,
- name='Spacer', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
- wx.EVT_PAINT(self.Preview, self.OnPaint)
+ self.SetSizer(main_sizer)
- self._init_sizers()
-
- def __init__(self, parent, controler):
- self._init_ctrls(parent, controler)
self.Connection = None
self.MinConnectionSize = None
self.PouNames = []
self.PouElementNames = []
- self.radioButton1.SetFocus()
+ self.ConnectorRadioButton.SetFocus()
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
@@ -172,16 +112,16 @@
for name, value in values.items():
if name == "type":
if value == CONNECTOR:
- self.radioButton1.SetValue(True)
+ self.ConnectorRadioButton.SetValue(True)
elif value == CONTINUATION:
- self.radioButton2.SetValue(True)
+ self.ConnectionRadioButton.SetValue(True)
elif name == "name":
self.ConnectionName.SetValue(value)
self.RefreshPreview()
def GetValues(self):
values = {}
- if self.radioButton1.GetValue():
+ if self.ConnectorRadioButton.GetValue():
values["type"] = CONNECTOR
else:
values["type"] = CONTINUATION
@@ -196,27 +136,22 @@
self.PouElementNames = [element_name.upper() for element_name in element_names]
def OnOK(self, event):
+ message = None
connection_name = self.ConnectionName.GetValue()
if connection_name == "":
- message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("Form isn't complete. Name must be filled!")
elif not TestIdentifier(connection_name):
- message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is not a valid identifier!") % connection_name
elif connection_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is a keyword. It can't be used!") % connection_name
elif connection_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" pou already exists!") % connection_name
elif connection_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" element for this pou already exists!") % connection_name
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
@@ -232,7 +167,7 @@
dc = wx.ClientDC(self.Preview)
dc.SetFont(self.Preview.GetFont())
dc.Clear()
- if self.radioButton1.GetValue():
+ if self.ConnectorRadioButton.GetValue():
self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.ConnectionName.GetValue())
else:
self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.ConnectionName.GetValue())
@@ -248,4 +183,4 @@
def OnPaint(self, event):
self.RefreshPreview()
- event.Skip()
\ No newline at end of file
+ event.Skip()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/DurationEditorDialog.py
--- a/dialogs/DurationEditorDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/DurationEditorDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -26,6 +26,10 @@
import wx
+#-------------------------------------------------------------------------------
+# Helpers
+#-------------------------------------------------------------------------------
+
MICROSECONDS = 0.001
MILLISECONDS = 1
SECOND = 1000
@@ -35,139 +39,58 @@
IEC_TIME_MODEL = re.compile("(?:(?:T|TIME)#)?(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?" % {"float": "[0-9]+(?:\.[0-9]+)?"})
+CONTROLS = [
+ ("Days", _('Days:')),
+ ("Hours", _('Hours:')),
+ ("Minutes", _('Minutes:')),
+ ("Seconds", _('Seconds:')),
+ ("Milliseconds", _('Milliseconds:')),
+ ("Microseconds", _('Microseconds:')),
+]
+
#-------------------------------------------------------------------------------
# Edit Duration Value Dialog
#-------------------------------------------------------------------------------
-[ID_DURATIONEDITORDIALOG, ID_DURATIONEDITORDIALOGDAYSLABEL,
- ID_DURATIONEDITORDIALOGDAYS, ID_DURATIONEDITORDIALOGHOURSLABEL,
- ID_DURATIONEDITORDIALOGHOURS, ID_DURATIONEDITORDIALOGMINUTESLABEL,
- ID_DURATIONEDITORDIALOGMINUTES, ID_DURATIONEDITORDIALOGSECONDSLABEL,
- ID_DURATIONEDITORDIALOGSECONDS, ID_DURATIONEDITORDIALOGMILLISECONDSLABEL,
- ID_DURATIONEDITORDIALOGMILLISECONDS, ID_DURATIONEDITORDIALOGMICROSECONDSLABEL,
- ID_DURATIONEDITORDIALOGMICROSECONDS,
-] = [wx.NewId() for _init_ctrls in range(13)]
+class DurationEditorDialog(wx.Dialog):
-class DurationEditorDialog(wx.Dialog):
-
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddSizer(self.ControlsSizer, 0, border=20, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
- parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.GROW)
+ def __init__(self, parent):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(700, 200), title=_('Edit Duration'))
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(0)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
- def _init_coll_ControlsSizer_Items(self, parent):
- parent.AddWindow(self.DaysLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.HoursLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.MinutesLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.SecondsLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.MillisecondsLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.MicrosecondsLabel, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Days, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Hours, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Minutes, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Seconds, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Milliseconds, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Microseconds, 0, border=0, flag=wx.GROW)
+ controls_sizer = wx.FlexGridSizer(cols=len(CONTROLS), hgap=10, rows=2, vgap=10)
+ main_sizer.AddSizer(controls_sizer, border=20,
+ flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW)
- def _init_coll_ControlsSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableCol(1)
- parent.AddGrowableCol(2)
- parent.AddGrowableCol(3)
- parent.AddGrowableCol(4)
- parent.AddGrowableCol(5)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- self.ControlsSizer = wx.FlexGridSizer(cols=6, hgap=10, rows=2, vgap=10)
+ controls = []
+ for i, (name, label) in enumerate(CONTROLS):
+ controls_sizer.AddGrowableCol(i)
+
+ st = wx.StaticText(self, label=label)
+ txtctrl = wx.TextCtrl(self, value='0', style=wx.TE_PROCESS_ENTER)
+ self.Bind(wx.EVT_TEXT_ENTER,
+ self.GetControlValueTestFunction(txtctrl),
+ txtctrl)
+ setattr(self, name, txtctrl)
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_ControlsSizer_Items(self.ControlsSizer)
- self._init_coll_ControlsSizer_Growables(self.ControlsSizer)
+ controls.append((st, txtctrl))
+
+ for st, txtctrl in controls:
+ controls_sizer.AddWindow(st, flag=wx.GROW)
+
+ for st, txtctrl in controls:
+ controls_sizer.AddWindow(txtctrl, flag=wx.GROW)
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Dialog.__init__(self, id=ID_DURATIONEDITORDIALOG,
- name='DurationEditorDialog', parent=prnt,
- size=wx.Size(700, 200), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title=_('Edit Duration'))
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self.DaysLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGDAYSLABEL,
- label=_('Days:'), name='DaysLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Days = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGDAYS, value='0',
- name='Days', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Days), id=ID_DURATIONEDITORDIALOGDAYS)
-
- self.HoursLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGHOURSLABEL,
- label=_('Hours:'), name='HoursLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Hours = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGHOURS, value='0',
- name='Hours', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Hours), id=ID_DURATIONEDITORDIALOGHOURS)
-
- self.MinutesLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMINUTESLABEL,
- label=_('Minutes:'), name='MinutesLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Minutes = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMINUTES, value='0',
- name='Minutes', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Minutes), id=ID_DURATIONEDITORDIALOGMINUTES)
-
- self.SecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGSECONDSLABEL,
- label=_('Seconds:'), name='SecondsLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Seconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGSECONDS, value='0',
- name='Seconds', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Seconds), id=ID_DURATIONEDITORDIALOGSECONDS)
-
- self.MillisecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMILLISECONDSLABEL,
- label=_('Milliseconds:'), name='MillisecondsLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Milliseconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMILLISECONDS, value='0',
- name='Milliseconds', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Milliseconds), id=ID_DURATIONEDITORDIALOGMILLISECONDS)
-
- self.MicrosecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMICROSECONDSLABEL,
- label=_('Microseconds:'), name='MicrosecondsLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Microseconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMICROSECONDS, value='0',
- name='Microseconds', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
- self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Milliseconds), id=ID_DURATIONEDITORDIALOGMICROSECONDS)
-
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
- self._init_sizers()
-
- def __init__(self, parent):
- self._init_ctrls(parent)
+ self.SetSizer(main_sizer)
self.Days.SetFocus()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/FBDBlockDialog.py
--- a/dialogs/FBDBlockDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/FBDBlockDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -31,156 +31,97 @@
# Create New Block Dialog
#-------------------------------------------------------------------------------
-[ID_FBDBLOCKDIALOG, ID_FBDBLOCKDIALOGNAME,
- ID_FBDBLOCKDIALOGTYPETREE, ID_FBDBLOCKDIALOGTYPEDESC,
- ID_FBDBLOCKDIALOGINPUTS, ID_FBDBLOCKDIALOGPREVIEW,
- ID_FBDBLOCKDIALOGEXECUTIONORDER, ID_FBDBLOCKDIALOGEXECUTIONCONTROL,
- ID_FBDBLOCKDIALOGSTATICTEXT1, ID_FBDBLOCKDIALOGSTATICTEXT2,
- ID_FBDBLOCKDIALOGSTATICTEXT3, ID_FBDBLOCKDIALOGSTATICTEXT4,
- ID_FBDBLOCKDIALOGSTATICTEXT5, ID_FBDBLOCKDIALOGSTATICTEXT6,
-] = [wx.NewId() for _init_ctrls in range(14)]
-
-[CATEGORY, BLOCK] = range(2)
-
class FBDBlockDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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.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):
- parent.AddWindow(self.LibraryPanel, 1, border=5, flag=wx.GROW|wx.TOP)
-
- def _init_coll_RightGridSizer_Items(self, parent):
- parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText6, 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(2)
-
- def _init_coll_RightUpGridSizer_Items(self, parent):
- parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText3, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText4, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText5, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW)
-
- def _init_coll_RightUpGridSizer_Growables(self, parent):
- parent.AddGrowableCol(1)
-
- def _init_sizers(self):
- self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
- 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.FlexGridSizer(cols=2, hgap=5, rows=4, 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_LeftBoxSizer_Items(self.LeftBoxSizer)
- self._init_coll_RightGridSizer_Items(self.RightGridSizer)
- self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
- self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer)
- self._init_coll_RightUpGridSizer_Growables(self.RightUpGridSizer)
-
- self.SetSizer(self.flexGridSizer1)
-
- def _init_ctrls(self, prnt):
- wx.Dialog.__init__(self, id=ID_FBDBLOCKDIALOG,
- name='FBDBlockDialog', parent=prnt,
- size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title=_('Block Properties'))
- self.SetClientSize(wx.Size(600, 400))
-
- self.staticbox1 = wx.StaticBox(id=ID_FBDBLOCKDIALOGSTATICTEXT1,
- label=_('Type:'), name='staticBox1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT2,
- label=_('Name:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.staticText3 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT2,
- label=_('Inputs:'), name='staticText4', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.staticText4 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT4,
- label=_('Execution Order:'), name='staticText4', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.staticText5 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT5,
- label=_('Execution Control:'), name='staticText5', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.staticText6 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT6,
- label=_('Preview:'), name='staticText6', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
+ def __init__(self, parent, controller):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(600, 400), title=_('Block Properties'))
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ type_staticbox = wx.StaticBox(self, label=_('Type:'))
+ left_staticboxsizer = wx.StaticBoxSizer(type_staticbox, wx.VERTICAL)
+ column_sizer.AddSizer(left_staticboxsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
self.LibraryPanel = LibraryPanel(self)
-
- self.BlockName = wx.TextCtrl(id=ID_FBDBLOCKDIALOGNAME, value='',
- name='BlockName', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_FBDBLOCKDIALOGNAME)
-
- self.Inputs = wx.SpinCtrl(id=ID_FBDBLOCKDIALOGINPUTS,
- name='Inputs', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=2, max=20)
- self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, id=ID_FBDBLOCKDIALOGINPUTS)
-
- self.ExecutionOrder = wx.SpinCtrl(id=ID_FBDBLOCKDIALOGEXECUTIONORDER,
- name='ExecutionOrder', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
- self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_FBDBLOCKDIALOGEXECUTIONORDER)
-
- self.ExecutionControl = wx.CheckBox(id=ID_FBDBLOCKDIALOGEXECUTIONCONTROL,
- name='ExecutionControl', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_FBDBLOCKDIALOGEXECUTIONCONTROL)
-
- self.Preview = wx.Panel(id=ID_FBDBLOCKDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+ self.LibraryPanel.SetController(controller)
+ setattr(self.LibraryPanel, "_OnTreeItemSelected",
+ self.OnLibraryTreeItemSelected)
+ left_staticboxsizer.AddWindow(self.LibraryPanel, 1, border=5,
+ flag=wx.GROW|wx.TOP)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(2)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5)
+ top_right_gridsizer.AddGrowableCol(1)
+ right_gridsizer.AddSizer(top_right_gridsizer, flag=wx.GROW)
+
+ name_label = wx.StaticText(self, label=_('Name:'))
+ top_right_gridsizer.AddWindow(name_label,
+ flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.BlockName = wx.TextCtrl(self)
+ self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName)
+ top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW)
+
+ inputs_label = wx.StaticText(self, label=_('Inputs:'))
+ top_right_gridsizer.AddWindow(inputs_label,
+ flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.Inputs = wx.SpinCtrl(self, min=2, max=20,
+ style=wx.SP_ARROW_KEYS)
+ self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, self.Inputs)
+ top_right_gridsizer.AddWindow(self.Inputs, flag=wx.GROW)
+
+ execution_order_label = wx.StaticText(self, label=_('Execution Order:'))
+ top_right_gridsizer.AddWindow(execution_order_label,
+ flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
+ self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, self.ExecutionOrder)
+ top_right_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW)
+
+ execution_control_label = wx.StaticText(self, label=_('Execution Control:'))
+ top_right_gridsizer.AddWindow(execution_control_label,
+ flag=wx.ALIGN_CENTER_VERTICAL)
+
+ self.ExecutionControl = wx.CheckBox(self)
+ self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, self.ExecutionControl)
+ top_right_gridsizer.AddWindow(self.ExecutionControl, flag=wx.GROW)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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, "GetScaling", lambda:None)
- setattr(self.Preview, "GetBlockType", self.Controler.GetBlockType)
- setattr(self.Preview, "IsOfType", self.Controler.IsOfType)
-
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
- wx.EVT_PAINT(self.Preview, self.OnPaint)
-
- self._init_sizers()
-
- def __init__(self, parent, controler):
- self.Controler = controler
- self._init_ctrls(parent)
+ setattr(self.Preview, "GetBlockType", controller.GetBlockType)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
+
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
+
+ self.Controller = controller
+
self.BlockName.SetValue("")
self.BlockName.Enable(False)
self.Inputs.Enable(False)
@@ -191,8 +132,6 @@
self.PouNames = []
self.PouElementNames = []
- self.LibraryPanel.SetControler(controler)
- setattr(self.LibraryPanel, "_OnTreeItemSelected", self.OnLibraryTreeItemSelected)
self.LibraryPanel.SetFocus()
def SetBlockList(self, blocklist):
@@ -202,33 +141,26 @@
self.Preview.SetFont(font)
def OnOK(self, event):
+ message = None
selected = self.LibraryPanel.GetSelectedBlock()
block_name = self.BlockName.GetValue()
name_enabled = self.BlockName.IsEnabled()
if selected is None:
- message = wx.MessageDialog(self, _("Form isn't complete. Valid block type must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("Form isn't complete. Valid block type must be selected!")
elif name_enabled and block_name == "":
- message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("Form isn't complete. Name must be filled!")
elif name_enabled and not TestIdentifier(block_name):
- message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is not a valid identifier!") % block_name
elif name_enabled and block_name.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is a keyword. It can't be used!") % block_name
elif name_enabled and block_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" pou already exists!") % block_name
elif name_enabled and block_name.upper() in self.PouElementNames:
- message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" element for this pou already exists!") % block_name
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
@@ -269,7 +201,7 @@
def OnLibraryTreeItemSelected(self, event):
values = self.LibraryPanel.GetSelectedBlock()
if values is not None:
- blocktype = self.Controler.GetBlockType(values["type"], values["inputs"])
+ blocktype = self.Controller.GetBlockType(values["type"], values["inputs"])
else:
blocktype = None
if blocktype is not None:
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/FBDVariableDialog.py
--- a/dialogs/FBDVariableDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/FBDVariableDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -27,163 +27,93 @@
from graphics import *
#-------------------------------------------------------------------------------
-# Create New Variable Dialog
-#-------------------------------------------------------------------------------
-
-[ID_FBDVARIABLEDIALOG, ID_FBDVARIABLEDIALOGSPACER,
- ID_FBDVARIABLEDIALOGNAME, ID_FBDVARIABLEDIALOGCLASS,
- ID_FBDVARIABLEDIALOGPREVIEW, ID_FBDVARIABLEDIALOGEXPRESSION,
- ID_FBDVARIABLEDIALOGEXECUTIONORDER, ID_FBDVARIABLEDIALOGSTATICTEXT1,
- ID_FBDVARIABLEDIALOGSTATICTEXT2, ID_FBDVARIABLEDIALOGSTATICTEXT3,
- ID_FBDVARIABLEDIALOGSTATICTEXT4, ID_FBDVARIABLEDIALOGSTATICTEXT5
-] = [wx.NewId() for _init_ctrls in range(12)]
+# Helpers
+#-------------------------------------------------------------------------------
VARIABLE_CLASSES_DICT = {INPUT : _("Input"),
INOUT : _("InOut"),
OUTPUT : _("Output")}
-VARIABLE_CLASSES_DICT_REVERSE = dict([(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()])
+VARIABLE_CLASSES_DICT_REVERSE = dict(
+ [(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()])
+
+#-------------------------------------------------------------------------------
+# Create New Variable Dialog
+#-------------------------------------------------------------------------------
class FBDVariableDialog(wx.Dialog):
-
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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.TopSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(2)
-
- def _init_coll_TopSizer_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.Class, 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)
- parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.ExecutionOrder, 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(2)
-
- def _init_coll_RightGridSizer_Items(self, parent):
- parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.VariableName, 0, border=0, flag=wx.GROW)
-
- def _init_coll_RightGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_sizers(self):
- 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(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_MainSizer_Growables(self.MainSizer)
- self._init_coll_TopSizer_Items(self.TopSizer)
- 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, ctrler):
- wx.Dialog.__init__(self, id=ID_FBDVARIABLEDIALOG,
- name='FBDVariableDialog', parent=prnt,
- size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
- title=_('Variable Properties'))
- self.SetClientSize(wx.Size(400, 380))
-
- self.staticText1 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT1,
- label=_('Class:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT2,
- label=_('Expression:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText3 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT3,
- label=_('Execution Order:'), name='staticText3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText4 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT4,
- label=_('Name:'), name='staticText4', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText5 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT5,
- label=_('Preview:'), name='staticText5', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Class = wx.ComboBox(id=ID_FBDVARIABLEDIALOGCLASS,
- name='Class', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, id=ID_FBDVARIABLEDIALOGCLASS)
-
- self.VariableName = wx.ListBox(id=ID_FBDVARIABLEDIALOGNAME,
- name='Name', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 90), style=wx.LB_SINGLE|wx.LB_SORT)
- self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_FBDVARIABLEDIALOGNAME)
-
- self.Expression = wx.TextCtrl(id=ID_FBDVARIABLEDIALOGEXPRESSION,
- name='Expression', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_FBDVARIABLEDIALOGEXPRESSION)
-
- self.ExecutionOrder = wx.SpinCtrl(id=ID_FBDVARIABLEDIALOGEXECUTIONORDER,
- name='ExecutionOrder', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
- self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_FBDVARIABLEDIALOGEXECUTIONORDER)
-
- self.Spacer = wx.Panel(id=ID_FBDVARIABLEDIALOGSPACER,
- name='Spacer', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.Preview = wx.Panel(id=ID_FBDVARIABLEDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+
+ def __init__(self, parent, controller, transition = ""):
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(400, 380), title=_('Variable Properties'))
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(2)
+
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ class_label = wx.StaticText(self, label=_('Class:'))
+ left_gridsizer.AddWindow(class_label, flag=wx.GROW)
+
+ self.Class = wx.ComboBox(self, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, self.Class)
+ left_gridsizer.AddWindow(self.Class, flag=wx.GROW)
+
+ expression_label = wx.StaticText(self, label=_('Expression:'))
+ left_gridsizer.AddWindow(expression_label, flag=wx.GROW)
+
+ self.Expression = wx.TextCtrl(self)
+ self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, self.Expression)
+ left_gridsizer.AddWindow(self.Expression, flag=wx.GROW)
+
+ execution_order_label = wx.StaticText(self, label=_('Execution Order:'))
+ left_gridsizer.AddWindow(execution_order_label, flag=wx.GROW)
+
+ self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
+ self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, self.ExecutionOrder)
+ left_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ name_label = wx.StaticText(self, label=_('Name:'))
+ right_gridsizer.AddWindow(name_label, flag=wx.GROW)
+
+ self.VariableName = wx.ListBox(self, style=wx.LB_SINGLE|wx.LB_SORT)
+ self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, self.VariableName)
+ right_gridsizer.AddWindow(self.VariableName, flag=wx.GROW)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ main_sizer.AddWindow(preview_label, border=20,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
+
+ self.Preview = wx.Panel(self,
+ 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, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
- wx.EVT_PAINT(self.Preview, self.OnPaint)
-
- self._init_sizers()
-
- def __init__(self, parent, controler, transition = ""):
- self._init_ctrls(parent, controler)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ main_sizer.AddWindow(self.Preview, border=20,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
+
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
+
self.Transition = transition
self.Variable = None
self.VarList = []
@@ -256,17 +186,18 @@
return values
def OnOK(self, event):
+ message = None
expression = self.Expression.GetValue()
if self.Expression.IsEnabled():
value = expression
else:
value = self.VariableName.GetStringSelection()
if value == "":
- message = wx.MessageDialog(self, _("At least a variable or an expression must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("At least a variable or an expression must be selected!")
elif value.upper() in IEC_KEYWORDS:
- message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
+ message = _("\"%s\" is a keyword. It can't be used!") % value
+ if message is not None:
+ message = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ForceVariableDialog.py
--- a/dialogs/ForceVariableDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/ForceVariableDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -21,12 +21,13 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import wx
import re
import datetime
+import wx
+
#-------------------------------------------------------------------------------
-# Force Variable Dialog
+# Helpers
#-------------------------------------------------------------------------------
LOCATIONDATATYPES = {"X" : ["BOOL"],
@@ -141,41 +142,35 @@
"DT": getdatetime,
"TOD": gettimeofday}
+#-------------------------------------------------------------------------------
+# Force Variable Dialog
+#-------------------------------------------------------------------------------
class ForceVariableDialog(wx.TextEntryDialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
def __init__(self, parent, iec_type, defaultValue=""):
wx.TextEntryDialog.__init__(self, parent, message = _("Forcing Variable Value"),
caption = _("Please enter value for a \"%s\" variable:"%iec_type), defaultValue = defaultValue,
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition)
self.IEC_Type = iec_type
- if wx.VERSION >= (2, 8, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
- elif wx.VERSION >= (2, 6, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
+
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
+
def OnOK(self, event):
+ message = None
value = self.GetSizer().GetItem(1).GetWindow().GetValue()
if value == "":
- message = wx.MessageDialog(self, _("You must type a value!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("You must type a value!")
elif GetTypeValue[self.IEC_Type](value) is None:
- message = wx.MessageDialog(self, _("Invalid value \"%s\" for \"%s\" variable!")%(value, self.IEC_Type), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("Invalid value \"%s\" for \"%s\" variable!") % (value, self.IEC_Type)
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
def GetValue(self):
- return GetTypeValue[self.IEC_Type](self.GetSizer().GetItem(1).GetWindow().GetValue())
+ return GetTypeValue[self.IEC_Type](wx.TextEntryDialog.GetValue(self))
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/LDElementDialog.py
--- a/dialogs/LDElementDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/LDElementDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -30,170 +30,99 @@
# Edit Ladder Element Properties Dialog
#-------------------------------------------------------------------------------
-
-[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER,
- ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1,
- ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3,
- ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5,
- ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW,
- ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2,
- ID_LDELEMENTDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(13)]
-
class LDElementDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.ElementName, 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_RadioButtonSizer_Items(self, parent):
- 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.radioButton5, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW)
-
- 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):
- 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=5, vgap=5)
- self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL)
- 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_RadioButtonSizer_Items(self.RadioButtonSizer)
- self._init_coll_RightGridSizer_Items(self.RightGridSizer)
- self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
-
- self.SetSizer(self.flexGridSizer1)
-
- def _init_ctrls(self, prnt, ctrler, title, extra_size = 0):
- wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG,
- name='LDElementDialog', parent=prnt,
- size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE,
- title=title)
- self.SetClientSize(wx.Size(350, 260 + extra_size))
-
- 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=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=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=ID_LDELEMENTDIALOGRADIOBUTTON1,
- label=_("Normal"), name='radioButton1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1)
- self.radioButton1.SetValue(True)
-
- self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2,
- label=_("Negated"), 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_LDELEMENTDIALOGRADIOBUTTON2)
-
- self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3,
- label=_("Set"), 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_LDELEMENTDIALOGRADIOBUTTON3)
-
- self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4,
- label=_("Reset"), 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_LDELEMENTDIALOGRADIOBUTTON4)
-
- self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5,
- label=_("Rising Edge"), name='radioButton5', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5)
-
- self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6,
- label=_("Falling Edge"), name='radioButton6', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6)
-
- self.ElementName = wx.ComboBox(id=ID_LDELEMENTDIALOGNAME,
- name='Name', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, 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)
+ def __init__(self, parent, controller, type):
+ if type == "contact":
+ wx.Dialog.__init__(self, parent, size=wx.Size(350, 310),
+ title=_("Edit Contact Values"))
+ else:
+ wx.Dialog.__init__(self, parent, size=wx.Size(350, 260),
+ title=_("Edit Coil Values"))
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ if type == "contact":
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5)
+ else:
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ modifier_label = wx.StaticText(self, label=_('Modifier:'))
+ left_gridsizer.AddWindow(modifier_label, flag=wx.GROW)
+
+ self.Normal = wx.RadioButton(self, label=_("Normal"), style=wx.RB_GROUP)
+ self.Normal.SetValue(True)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Normal)
+ left_gridsizer.AddWindow(self.Normal, flag=wx.GROW)
+
+ self.Negated = wx.RadioButton(self, label=_("Negated"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Negated)
+ left_gridsizer.AddWindow(self.Negated, flag=wx.GROW)
+
+ if type == "contact":
+ self.Set = wx.RadioButton(self, label=_("Set"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Set)
+ left_gridsizer.AddWindow(self.Set, flag=wx.GROW)
+
+ self.Reset = wx.RadioButton(self, label=_("Reset"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Reset)
+ left_gridsizer.AddWindow(self.Reset, flag=wx.GROW)
+
+ self.RisingEdge = wx.RadioButton(self, label=_("Rising Edge"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.RisingEdge)
+ left_gridsizer.AddWindow(self.RisingEdge, flag=wx.GROW)
+
+ self.FallingEdge = wx.RadioButton(self, label=_("Falling Edge"))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.FallingEdge)
+ left_gridsizer.AddWindow(self.FallingEdge, flag=wx.GROW)
+
+ element_name_label = wx.StaticText(self, label=_('Name:'))
+ left_gridsizer.AddWindow(element_name_label, flag=wx.GROW)
+
+ self.ElementName = wx.ComboBox(self, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, self.ElementName)
+ left_gridsizer.AddWindow(self.ElementName, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_sizer = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_sizer, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- 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(wx.OK|wx.CANCEL|wx.CENTRE)
-
- if wx.VERSION >= (2, 5, 0):
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
+
+ if type == "contact":
+ self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
else:
- wx.EVT_PAINT(self.Preview, self.OnPaint)
-
- self._init_sizers()
-
- def __init__(self, parent, controler, type):
+ self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
+
self.Type = type
- if type == "contact":
- self._init_ctrls(parent, controler, _("Edit Contact Values"))
- self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
- self.radioButton3.Hide()
- self.radioButton4.Hide()
- elif type == "coil":
- self._init_ctrls(parent, controler, _("Edit Coil Values"), 50)
- self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
-
- self.radioButton1.SetFocus()
+
+ self.Normal.SetFocus()
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
@@ -218,26 +147,26 @@
self.Element.SetType(value)
if self.Type == "contact":
if value == CONTACT_NORMAL:
- self.radioButton1.SetValue(True)
+ self.Normal.SetValue(True)
elif value == CONTACT_REVERSE:
- self.radioButton2.SetValue(True)
+ self.Negated.SetValue(True)
elif value == CONTACT_RISING:
- self.radioButton5.SetValue(True)
+ self.RisingEdge.SetValue(True)
elif value == CONTACT_FALLING:
- self.radioButton6.SetValue(True)
+ self.FallingEdge.SetValue(True)
elif self.Type == "coil":
if value == COIL_NORMAL:
- self.radioButton1.SetValue(True)
+ self.Normal.SetValue(True)
elif value == COIL_REVERSE:
- self.radioButton2.SetValue(True)
+ self.Negated.SetValue(True)
elif value == COIL_SET:
- self.radioButton3.SetValue(True)
+ self.Set.SetValue(True)
elif value == COIL_RESET:
- self.radioButton4.SetValue(True)
+ self.Reset.SetValue(True)
elif value == COIL_RISING:
- self.radioButton5.SetValue(True)
+ self.RisingEdge.SetValue(True)
elif value == COIL_FALLING:
- self.radioButton6.SetValue(True)
+ self.FallingEdge.SetValue(True)
def GetValues(self):
values = {}
@@ -248,26 +177,26 @@
def OnTypeChanged(self, event):
if self.Type == "contact":
- if self.radioButton1.GetValue():
+ if self.Normal.GetValue():
self.Element.SetType(CONTACT_NORMAL)
- elif self.radioButton2.GetValue():
+ elif self.Negated.GetValue():
self.Element.SetType(CONTACT_REVERSE)
- elif self.radioButton5.GetValue():
+ elif self.RisingEdge.GetValue():
self.Element.SetType(CONTACT_RISING)
- elif self.radioButton6.GetValue():
+ elif self.FallingEdge.GetValue():
self.Element.SetType(CONTACT_FALLING)
elif self.Type == "coil":
- if self.radioButton1.GetValue():
+ if self.Normal.GetValue():
self.Element.SetType(COIL_NORMAL)
- elif self.radioButton2.GetValue():
+ elif self.Negated.GetValue():
self.Element.SetType(COIL_REVERSE)
- elif self.radioButton3.GetValue():
+ elif self.Set.GetValue():
self.Element.SetType(COIL_SET)
- elif self.radioButton4.GetValue():
+ elif self.Reset.GetValue():
self.Element.SetType(COIL_RESET)
- elif self.radioButton5.GetValue():
+ elif self.RisingEdge.GetValue():
self.Element.SetType(COIL_RISING)
- elif self.radioButton6.GetValue():
+ elif self.FallingEdge.GetValue():
self.Element.SetType(COIL_FALLING)
self.RefreshPreview()
event.Skip()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/LDPowerRailDialog.py
--- a/dialogs/LDPowerRailDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/LDPowerRailDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -25,145 +25,85 @@
from graphics import *
-
#-------------------------------------------------------------------------------
# Edit Ladder Power Rail Properties Dialog
#-------------------------------------------------------------------------------
-
-[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):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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__(self, parent, controller, type = LEFTRAIL, number = 1):
+ wx.Dialog.__init__(self, parent, size=wx.Size(350, 260),
+ title=_('Power Rail Properties'))
- 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.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):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(5)
-
- 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)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
- def _init_coll_RightGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_sizers(self):
- 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=6, 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, ctrler):
- wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG,
- name='PowerRailDialog', parent=prnt,
- 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=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=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=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=ID_LDPOWERRAILDIALOGRADIOBUTTON1,
- label=_('Left PowerRail'), name='radioButton1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1)
- self.radioButton1.SetValue(True)
-
- 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)
- 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=wx.SP_ARROW_KEYS, min=1, max=50)
- 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)
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ type_label = wx.StaticText(self, label=_('Type:'))
+ left_gridsizer.AddWindow(type_label, flag=wx.GROW)
+
+ self.LeftPowerRail = wx.RadioButton(self,
+ label=_('Left PowerRail'), style=wx.RB_GROUP)
+ self.LeftPowerRail.SetValue(True)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.LeftPowerRail)
+ left_gridsizer.AddWindow(self.LeftPowerRail, flag=wx.GROW)
+
+ self.RightPowerRail = wx.RadioButton(self, label=_('Right PowerRail'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.RightPowerRail)
+ left_gridsizer.AddWindow(self.RightPowerRail, flag=wx.GROW)
+
+ pin_number_label = wx.StaticText(self, label=_('Pin number:'))
+ left_gridsizer.AddWindow(pin_number_label, flag=wx.GROW)
+
+ self.PinNumber = wx.SpinCtrl(self, min=1, max=50,
+ style=wx.SP_ARROW_KEYS)
+ self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber)
+ left_gridsizer.AddWindow(self.PinNumber, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- self.Spacer = wx.Panel(id=ID_LDPOWERRAILDIALOGSPACER,
- 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)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
- if wx.VERSION >= (2, 5, 0):
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- wx.EVT_PAINT(self.Preview, self.OnPaint)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self._init_sizers()
-
- def __init__(self, parent, controler, type = LEFTRAIL, number = 1):
- self._init_ctrls(parent, controler)
+ self.SetSizer(main_sizer)
+
self.Type = type
if type == LEFTRAIL:
- self.radioButton1.SetValue(True)
+ self.LeftPowerRail.SetValue(True)
elif type == RIGHTRAIL:
- self.radioButton2.SetValue(True)
+ self.RightPowerRail.SetValue(True)
self.PinNumber.SetValue(number)
self.PowerRailMinSize = (0, 0)
self.PowerRail = None
- self.radioButton1.SetFocus()
+ self.LeftPowerRail.SetFocus()
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
@@ -180,9 +120,9 @@
return values
def OnTypeChanged(self, event):
- if self.radioButton1.GetValue():
+ if self.LeftPowerRail.GetValue():
self.Type = LEFTRAIL
- elif self.radioButton2.GetValue():
+ elif self.RightPowerRail.GetValue():
self.Type = RIGHTRAIL
self.RefreshPreview()
event.Skip()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouActionDialog.py
--- a/dialogs/PouActionDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/PouActionDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -34,10 +34,8 @@
class PouActionDialog(wx.Dialog):
def __init__(self, parent):
- wx.Dialog.__init__(self, id=-1, parent=parent,
- name='PouActionDialog', title=_('Create a new action'),
- size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE)
- self.SetClientSize(wx.Size(320, 160))
+ wx.Dialog.__init__(self, parent, size=wx.Size(320, 160),
+ title=_('Create a new action'))
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
main_sizer.AddGrowableCol(0)
@@ -45,35 +43,28 @@
infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15)
infos_sizer.AddGrowableCol(1)
- main_sizer.AddSizer(infos_sizer, 0, border=20,
- flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+ main_sizer.AddSizer(infos_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- actionname_label = wx.StaticText(id=-1, parent=self,
- label=_('Action Name:'), name='actionname_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(actionname_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ actionname_label = wx.StaticText(self, label=_('Action Name:'))
+ infos_sizer.AddWindow(actionname_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.ActionName = wx.TextCtrl(id=-1, parent=self,
- name='ActionName', pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- infos_sizer.AddWindow(self.ActionName, 0, border=0, flag=wx.GROW)
+ self.ActionName = wx.TextCtrl(self)
+ infos_sizer.AddWindow(self.ActionName, flag=wx.GROW)
- language_label = wx.StaticText(id=-1, parent=self,
- label=_('Language:'), name='language_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(language_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ language_label = wx.StaticText(self, label=_('Language:'))
+ infos_sizer.AddWindow(language_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.Language = wx.ComboBox(id=ID_POUACTIONDIALOGLANGUAGE,
- name='Language', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
+ self.Language = wx.ComboBox(self, style=wx.CB_READONLY)
+ infos_sizer.AddWindow(self.Language, flag=wx.GROW)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- main_sizer.AddSizer(self.ButtonSizer, 0, border=20,
- flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(self.ButtonSizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.SetSizer(main_sizer)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouDialog.py
--- a/dialogs/PouDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/PouDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -50,47 +50,35 @@
infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15)
infos_sizer.AddGrowableCol(1)
- main_sizer.AddSizer(infos_sizer, 0, border=20,
- flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+ main_sizer.AddSizer(infos_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- pouname_label = wx.StaticText(id=-1, parent=self,
- label=_('POU Name:'), name='pouname_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(pouname_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ pouname_label = wx.StaticText(self, label=_('POU Name:'))
+ infos_sizer.AddWindow(pouname_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.PouName = wx.TextCtrl(id=-1, parent=self,
- name='POUName', pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- infos_sizer.AddWindow(self.PouName, 0, border=0, flag=wx.GROW)
+ self.PouName = wx.TextCtrl(self)
+ infos_sizer.AddWindow(self.PouName, flag=wx.GROW)
- poutype_label = wx.StaticText(id=-1, parent=self,
- label=_('POU Type:'), name='poutype_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(poutype_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ poutype_label = wx.StaticText(self, label=_('POU Type:'))
+ infos_sizer.AddWindow(poutype_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.PouType = wx.ComboBox(id=-1, parent=self,
- name='POUType', pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnTypeChanged, id=self.PouType.GetId())
- infos_sizer.AddWindow(self.PouType, 0, border=0, flag=wx.GROW)
+ self.PouType = wx.ComboBox(self, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnTypeChanged, self.PouType)
+ infos_sizer.AddWindow(self.PouType, flag=wx.GROW)
- language_label = wx.StaticText(id=-1, parent=self,
- label=_('Language:'), name='language_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(language_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ language_label = wx.StaticText(self, label=_('Language:'))
+ infos_sizer.AddWindow(language_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.Language = wx.ComboBox(id=-1, parent=self,
- name='Language', pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
+ self.Language = wx.ComboBox(self, style=wx.CB_READONLY)
+ infos_sizer.AddWindow(self.Language, flag=wx.GROW)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- main_sizer.AddSizer(self.ButtonSizer, 0, border=20,
- flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.SetSizer(main_sizer)
@@ -181,5 +169,3 @@
values["pouType"] = POU_TYPES_DICT[self.PouType.GetStringSelection()]
values["language"] = POU_LANGUAGES_DICT[self.Language.GetStringSelection()]
return values
-
-
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouNameDialog.py
--- a/dialogs/PouNameDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/PouNameDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,49 +29,33 @@
class PouNameDialog(wx.TextEntryDialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
-
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "",
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
self.PouNames = []
- if wx.VERSION >= (2, 8, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
- elif wx.VERSION >= (2, 6, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
+
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
+
def OnOK(self, event):
+ message = None
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if step_name == "":
- message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("You must type a name!")
elif not TestIdentifier(step_name):
- message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is not a valid identifier!") % step_name
elif step_name.upper() in IEC_KEYWORDS:
- 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()
+ message = _("\"%s\" is a keyword. It can't be used!") % step_name
elif step_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("A POU named \"%s\" already exists!") % step_name
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
def SetPouNames(self, pou_names):
self.PouNames = [pou_name.upper() for pou_name in pou_names]
- def GetValue(self):
- return self.GetSizer().GetItem(1).GetWindow().GetValue()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouTransitionDialog.py
--- a/dialogs/PouTransitionDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/PouTransitionDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -26,6 +26,10 @@
from plcopen.structures import TestIdentifier, IEC_KEYWORDS
+#-------------------------------------------------------------------------------
+# POU Transition Dialog
+#-------------------------------------------------------------------------------
+
def GetTransitionLanguages():
_ = lambda x : x
return [_("IL"), _("ST"), _("LD"), _("FBD")]
@@ -34,10 +38,8 @@
class PouTransitionDialog(wx.Dialog):
def __init__(self, parent):
- wx.Dialog.__init__(self, id=-1, parent=parent,
- name='PouTransitionDialog', title=_('Create a new transition'),
- size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE)
- self.SetClientSize(wx.Size(350, 160))
+ wx.Dialog.__init__(self, parent, size=wx.Size(350, 160),
+ title=_('Create a new transition'))
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
main_sizer.AddGrowableCol(0)
@@ -45,35 +47,27 @@
infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15)
infos_sizer.AddGrowableCol(1)
- main_sizer.AddSizer(infos_sizer, 0, border=20,
- flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+ main_sizer.AddSizer(infos_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- transitionname_label = wx.StaticText(id=-1, parent=self,
- label=_('Transition Name:'), name='transitionname_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(transitionname_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ transitionname_label = wx.StaticText(self, label=_('Transition Name:'))
+ infos_sizer.AddWindow(transitionname_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.TransitionName = wx.TextCtrl(id=-1, parent=self,
- name='TransitionName', pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- infos_sizer.AddWindow(self.TransitionName, 0, border=0, flag=wx.GROW)
+ self.TransitionName = wx.TextCtrl(self)
+ infos_sizer.AddWindow(self.TransitionName, flag=wx.GROW)
- language_label = wx.StaticText(id=-1, parent=self,
- label=_('Language:'), name='language_label',
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
- infos_sizer.AddWindow(language_label, 0, border=4,
- flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
+ language_label = wx.StaticText(self, label=_('Language:'))
+ infos_sizer.AddWindow(language_label, border=4,
+ flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP)
- self.Language = wx.ComboBox(id=-1, parent=self,
- name='Language', pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW)
+ self.Language = wx.ComboBox(self, style=wx.CB_READONLY)
+ infos_sizer.AddWindow(self.Language, flag=wx.GROW)
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- main_sizer.AddSizer(self.ButtonSizer, 0, border=20,
- flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.SetSizer(main_sizer)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ProjectDialog.py
--- a/dialogs/ProjectDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/ProjectDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,21 +29,22 @@
class ProjectDialog(wx.Dialog):
def __init__(self, parent, enable_required=True):
- wx.Dialog.__init__(self, id=-1, parent=parent,
- name='ProjectDialog', title=_('Project properties'),
+ wx.Dialog.__init__(self, parent, title=_('Project properties'),
size=wx.Size(500, 350), style=wx.DEFAULT_DIALOG_STYLE)
- self.SetClientSize(wx.Size(500, 350))
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(0)
- self.ProjectProperties = ProjectPropertiesPanel(self, enable_required=enable_required)
- main_sizer.AddWindow(self.ProjectProperties, 0, border=0, flag=wx.GROW)
+ self.ProjectProperties = ProjectPropertiesPanel(self,
+ enable_required=enable_required)
+ main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW)
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- main_sizer.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ self.ButtonSizer.GetAffirmativeButton())
+ main_sizer.AddSizer(self.ButtonSizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.SetSizer(main_sizer)
@@ -65,9 +66,11 @@
text += " and %s"%item
else:
text += ", %s"%item
- message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ dialog = wx.MessageDialog(self,
+ _("Form isn't complete. %s must be filled!") % text,
+ _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCDivergenceDialog.py
--- a/dialogs/SFCDivergenceDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/SFCDivergenceDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,159 +29,97 @@
# Create New Divergence Dialog
#-------------------------------------------------------------------------------
-[ID_SFCDIVERGENCEDIALOG, ID_SFCDIVERGENCEDIALOGSPACER,
- ID_SFCDIVERGENCEDIALOGRADIOBUTTON1, ID_SFCDIVERGENCEDIALOGRADIOBUTTON2,
- ID_SFCDIVERGENCEDIALOGRADIOBUTTON3, ID_SFCDIVERGENCEDIALOGRADIOBUTTON4,
- ID_SFCDIVERGENCEDIALOGSEQUENCES, ID_SFCDIVERGENCEDIALOGPREVIEW,
- ID_SFCDIVERGENCEDIALOGSTATICTEXT1, ID_SFCDIVERGENCEDIALOGSTATICTEXT2,
- ID_SFCDIVERGENCEDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(11)]
-
class SFCDivergenceDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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__(self, parent, controller):
+ wx.Dialog.__init__(self, parent, size=wx.Size(500, 300),
+ title=_('Create a new divergence or convergence'))
- 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)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
- def _init_coll_RightGridSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ type_label = wx.StaticText(self, label=_('Type:'))
+ left_gridsizer.AddWindow(type_label, flag=wx.GROW)
- def _init_sizers(self):
- 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, ctrler):
- wx.Dialog.__init__(self, id=ID_SFCDIVERGENCEDIALOG,
- name='SFCDivergenceDialog', parent=prnt,
- size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
- title=_('Create a new divergence or convergence'))
- self.SetClientSize(wx.Size(500, 300))
-
- self.staticText1 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT1,
- label=_('Type:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.radioButton1 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON1,
- label=_('Selection Divergence'), name='radioButton1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON1)
- self.radioButton1.SetValue(True)
-
- self.radioButton2 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON2,
- 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_SFCDIVERGENCEDIALOGRADIOBUTTON2)
- self.radioButton2.SetValue(False)
-
- self.radioButton3 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON3,
- 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_SFCDIVERGENCEDIALOGRADIOBUTTON3)
- self.radioButton3.SetValue(False)
-
- self.radioButton4 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON4,
- 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_SFCDIVERGENCEDIALOGRADIOBUTTON4)
- self.radioButton4.SetValue(False)
-
- self.staticText2 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT2,
- 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_SFCDIVERGENCEDIALOGSEQUENCES,
- 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_SFCDIVERGENCEDIALOGSEQUENCES)
-
- self.staticText3 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT3,
- label=_('Preview:'), name='staticText3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.Preview = wx.Panel(id=ID_SFCDIVERGENCEDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+ self.SelectionDivergence = wx.RadioButton(self,
+ label=_('Selection Divergence'), style=wx.RB_GROUP)
+ self.SelectionDivergence.SetValue(True)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged,
+ self.SelectionDivergence)
+ left_gridsizer.AddWindow(self.SelectionDivergence, flag=wx.GROW)
+
+ self.SelectionConvergence = wx.RadioButton(self,
+ label=_('Selection Convergence'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged,
+ self.SelectionConvergence)
+ left_gridsizer.AddWindow(self.SelectionConvergence, flag=wx.GROW)
+
+ self.SimultaneousDivergence = wx.RadioButton(self,
+ label=_('Simultaneous Divergence'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged,
+ self.SimultaneousDivergence)
+ left_gridsizer.AddWindow(self.SimultaneousDivergence, flag=wx.GROW)
+
+ self.SimultaneousConvergence = wx.RadioButton(self,
+ label=_('Simultaneous Convergence'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged,
+ self.SimultaneousConvergence)
+ left_gridsizer.AddWindow(self.SimultaneousConvergence, flag=wx.GROW)
+
+ sequences_label = wx.StaticText(self,
+ label=_('Number of sequences:'))
+ left_gridsizer.AddWindow(sequences_label, flag=wx.GROW)
+
+ self.Sequences = wx.SpinCtrl(self, min=2, max=20)
+ self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences)
+ left_gridsizer.AddWindow(self.Sequences, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self, style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- self.Spacer = wx.Panel(id=ID_SFCDIVERGENCEDIALOGSPACER,
- 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)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
- if wx.VERSION >= (2, 5, 0):
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- wx.EVT_PAINT(self.Preview, self.OnPaint)
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ main_sizer.AddSizer(button_sizer, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self._init_sizers()
-
- def __init__(self, parent, controler):
- self._init_ctrls(parent, controler)
+ self.SetSizer(main_sizer)
self.Divergence = None
self.MinSize = (0, 0)
- self.radioButton1.SetFocus()
+ self.SelectionDivergence.SetFocus()
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
def GetValues(self):
values = {}
- if self.radioButton1.GetValue():
+ if self.SelectionDivergence.GetValue():
values["type"] = SELECTION_DIVERGENCE
- elif self.radioButton2.GetValue():
+ elif self.SelectionConvergence.GetValue():
values["type"] = SELECTION_CONVERGENCE
- elif self.radioButton3.GetValue():
+ elif self.SimultaneousDivergence.GetValue():
values["type"] = SIMULTANEOUS_DIVERGENCE
else:
values["type"] = SIMULTANEOUS_CONVERGENCE
@@ -203,11 +141,11 @@
dc = wx.ClientDC(self.Preview)
dc.SetFont(self.Preview.GetFont())
dc.Clear()
- if self.radioButton1.GetValue():
+ if self.SelectionDivergence.GetValue():
self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue())
- elif self.radioButton2.GetValue():
+ elif self.SelectionConvergence.GetValue():
self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue())
- elif self.radioButton3.GetValue():
+ elif self.SimultaneousDivergence.GetValue():
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue())
else:
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue())
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCStepDialog.py
--- a/dialogs/SFCStepDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/SFCStepDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,135 +29,75 @@
# Edit Step Content Dialog
#-------------------------------------------------------------------------------
-[ID_SFCSTEPDIALOG, ID_SFCSTEPDIALOGSPACER,
- ID_SFCSTEPDIALOGNAME, ID_SFCSTEPDIALOGPREVIEW,
- ID_SFCSTEPDIALOGCHECKBOX1, ID_SFCSTEPDIALOGCHECKBOX2,
- ID_SFCSTEPDIALOGCHECKBOX3, ID_SFCSTEPDIALOGSTATICTEXT1,
- ID_SFCSTEPDIALOGSTATICTEXT2, ID_SFCSTEPDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(10)]
-
class SFCStepDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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.StepName, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.checkBox1, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.checkBox2, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.checkBox3, 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.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):
- 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, ctrler):
- wx.Dialog.__init__(self, id=ID_SFCSTEPDIALOG,
- name='SFCStepDialog', parent=prnt,
- size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE,
- title=_('Edit Step'))
- self.SetClientSize(wx.Size(400, 250))
-
- self.staticText1 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT1,
- label=_('Name:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT2,
- label=_('Connectors:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText3 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT3,
- label=_('Preview:'), name='staticText4', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.StepName = wx.TextCtrl(id=ID_SFCSTEPDIALOGNAME,
- name='Name', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_SFCSTEPDIALOGNAME)
-
- self.checkBox1 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX1,
- label=_("Input"), name='checkBox1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX1)
-
- self.checkBox2 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX2,
- label=_("Output"), name='checkBox2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX2)
-
- self.checkBox3 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX3,
- label=_("Action"), name='checkBox3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX3)
-
- self.Spacer = wx.Panel(id=ID_SFCSTEPDIALOGSPACER,
- name='Spacer', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
-
- self.Preview = wx.Panel(id=ID_SFCSTEPDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+ def __init__(self, parent, controller, initial = False):
+ wx.Dialog.__init__(self, parent, title=_('Edit Step'),
+ size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE)
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ name_label = wx.StaticText(self, label=_('Name:'))
+ left_gridsizer.AddWindow(name_label, flag=wx.GROW)
+
+ self.StepName = wx.TextCtrl(self)
+ self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.StepName)
+ left_gridsizer.AddWindow(self.StepName, flag=wx.GROW)
+
+ connectors_label = wx.StaticText(self, label=_('Connectors:'))
+ left_gridsizer.AddWindow(connectors_label, flag=wx.GROW)
+
+ self.Input = wx.CheckBox(self, label=_("Input"))
+ self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Input)
+ left_gridsizer.AddWindow(self.Input, flag=wx.GROW)
+
+ self.Output = wx.CheckBox(self, label=_("Output"))
+ self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Output)
+ left_gridsizer.AddWindow(self.Output, flag=wx.GROW)
+
+ self.Action = wx.CheckBox(self, label=_("Action"))
+ self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Action)
+ left_gridsizer.AddWindow(self.Action, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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, "RefreshStepModel", lambda x:None)
setattr(self.Preview, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
- wx.EVT_PAINT(self.Preview, self.OnPaint)
-
- self._init_sizers()
-
- def __init__(self, parent, controler, initial = False):
- self._init_ctrls(parent, controler)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
+
+ button_sizer = self.CreateButtonSizer(
+ wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
+
self.Step = None
self.Initial = initial
self.MinStepSize = None
@@ -172,31 +112,24 @@
self.Preview.SetFont(font)
def OnOK(self, event):
+ message = None
step_name = self.StepName.GetValue()
if step_name == "":
- message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("You must type a name!")
elif not TestIdentifier(step_name):
- message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is not a valid identifier!") % step_name
elif step_name.upper() in IEC_KEYWORDS:
- 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()
+ message = _("\"%s\" is a keyword. It can't be used!") % step_name
elif step_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("A POU named \"%s\" already exists!") % step_name
elif step_name.upper() in self.Variables:
- message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("A variable with \"%s\" as name already exists in this pou!") % step_name
elif step_name.upper() in self.StepNames:
- message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" step already exists!") % step_name
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
@@ -218,17 +151,17 @@
self.StepName.SetValue(value_name)
else:
self.StepName.SetValue("")
- self.checkBox1.SetValue(values.get("input", False))
- self.checkBox2.SetValue(values.get("output", False))
- self.checkBox3.SetValue(values.get("action", False))
+ self.Input.SetValue(values.get("input", False))
+ self.Output.SetValue(values.get("output", False))
+ self.Action.SetValue(values.get("action", False))
self.RefreshPreview()
def GetValues(self):
values = {}
values["name"] = self.StepName.GetValue()
- values["input"] = self.checkBox1.IsChecked()
- values["output"] = self.checkBox2.IsChecked()
- values["action"] = self.checkBox3.IsChecked()
+ values["input"] = self.Input.IsChecked()
+ values["output"] = self.Output.IsChecked()
+ values["action"] = self.Action.IsChecked()
values["width"], values["height"] = self.Step.GetSize()
return values
@@ -245,15 +178,15 @@
dc.SetFont(self.Preview.GetFont())
dc.Clear()
self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial)
- if self.checkBox1.IsChecked():
+ if self.Input.IsChecked():
self.Step.AddInput()
else:
self.Step.RemoveInput()
- if self.checkBox2.IsChecked():
+ if self.Output.IsChecked():
self.Step.AddOutput()
else:
self.Step.RemoveOutput()
- if self.checkBox3.IsChecked():
+ if self.Action.IsChecked():
self.Step.AddAction()
else:
self.Step.RemoveAction()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCStepNameDialog.py
--- a/dialogs/SFCStepNameDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/SFCStepNameDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,14 +29,6 @@
class SFCStepNameDialog(wx.TextEntryDialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
-
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "",
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition):
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
@@ -44,39 +36,29 @@
self.PouNames = []
self.Variables = []
self.StepNames = []
- if wx.VERSION >= (2, 8, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId())
- elif wx.VERSION >= (2, 6, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId())
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
-
+
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton())
+
def OnOK(self, event):
+ message = None
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
if step_name == "":
- message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("You must type a name!")
elif not TestIdentifier(step_name):
- message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" is not a valid identifier!") % step_name
elif step_name.upper() in IEC_KEYWORDS:
- 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()
+ message = _("\"%s\" is a keyword. It can't be used!") % step_name
elif step_name.upper() in self.PouNames:
- message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("A POU named \"%s\" already exists!") % step_name
elif step_name.upper() in self.Variables:
- message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("A variable with \"%s\" as name already exists in this pou!") % step_name
elif step_name.upper() in self.StepNames:
- message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("\"%s\" step already exists!") % step_name
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
@@ -88,6 +70,3 @@
def SetStepNames(self, step_names):
self.StepNames = [step_name.upper() for step_name in step_names]
-
- def GetValue(self):
- return self.GetSizer().GetItem(1).GetWindow().GetValue()
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCTransitionDialog.py
--- a/dialogs/SFCTransitionDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/SFCTransitionDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -29,161 +29,97 @@
# Edit Transition Content Dialog
#-------------------------------------------------------------------------------
-[ID_SFCTRANSITIONDIALOG, ID_SFCTRANSITIONDIALOGSPACER,
- ID_SFCTRANSITIONDIALOGREFERENCE, ID_SFCTRANSITIONDIALOGINLINE,
- ID_SFCTRANSITIONDIALOGPRIORITY, ID_SFCTRANSITIONDIALOGPREVIEW,
- ID_SFCTRANSITIONDIALOGRADIOBUTTON1, ID_SFCTRANSITIONDIALOGRADIOBUTTON2,
- ID_SFCTRANSITIONDIALOGRADIOBUTTON3, ID_SFCTRANSITIONDIALOGSTATICTEXT1,
- ID_SFCTRANSITIONDIALOGSTATICTEXT2, ID_SFCTRANSITIONDIALOGSTATICTEXT3,
-] = [wx.NewId() for _init_ctrls in range(12)]
-
class SFCTransitionDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_flexGridSizer1_Items(self, parent):
- 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.staticText3, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Priority, 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):
- 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=9, 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, ctrler):
- wx.Dialog.__init__(self, id=ID_SFCTRANSITIONDIALOG,
- name='SFCTransitionDialog', parent=prnt,
- size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE,
- title=_('Edit transition'))
- self.SetClientSize(wx.Size(350, 300))
-
- self.staticText1 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT1,
- label=_('Type:'), name='staticText1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText2 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT2,
- label=_('Preview:'), name='staticText2', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.staticText3 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT3,
- label=_('Priority:'), name='staticText3', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
-
- self.radioButton1 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON1,
- label=_('Reference'), name='radioButton1', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCTRANSITIONDIALOGRADIOBUTTON1)
- self.radioButton1.SetValue(True)
-
- self.Reference = wx.ComboBox(id=ID_SFCTRANSITIONDIALOGREFERENCE,
- name='Reference', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 28), style=wx.CB_READONLY)
- self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, id=ID_SFCTRANSITIONDIALOGREFERENCE)
-
- self.radioButton2 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON2,
- 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_SFCTRANSITIONDIALOGRADIOBUTTON2)
- self.radioButton2.SetValue(False)
-
- self.Inline = wx.TextCtrl(id=ID_SFCTRANSITIONDIALOGINLINE,
- 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_SFCTRANSITIONDIALOGINLINE)
+ def __init__(self, parent, controller, connection):
+ self.Connection = connection
+
+ wx.Dialog.__init__(self, parent,
+ size=wx.Size(350, 300), title=_('Edit transition'))
+
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(0)
+
+ column_sizer = wx.BoxSizer(wx.HORIZONTAL)
+ main_sizer.AddSizer(column_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
+
+ left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
+ left_gridsizer.AddGrowableCol(0)
+ column_sizer.AddSizer(left_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.RIGHT)
+
+ type_label = wx.StaticText(self, label=_('Type:'))
+ left_gridsizer.AddWindow(type_label, flag=wx.GROW)
+
+ self.ReferenceRadioButton = wx.RadioButton(self,
+ label=_('Reference'), style=wx.RB_GROUP)
+ self.ReferenceRadioButton.SetValue(True)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ReferenceRadioButton)
+ left_gridsizer.AddWindow(self.ReferenceRadioButton, flag=wx.GROW)
+
+ self.Reference = wx.ComboBox(self, style=wx.CB_READONLY)
+ self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, self.Reference)
+ left_gridsizer.AddWindow(self.Reference, flag=wx.GROW)
+
+ self.InlineRadioButton = wx.RadioButton(self, label=_('Inline'))
+ self.InlineRadioButton.SetValue(False)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.InlineRadioButton)
+ left_gridsizer.AddWindow(self.InlineRadioButton, flag=wx.GROW)
+
+ self.Inline = wx.TextCtrl(self)
self.Inline.Enable(False)
-
- self.radioButton3 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON3,
- 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_SFCTRANSITIONDIALOGRADIOBUTTON3)
- self.radioButton3.SetValue(False)
+ self.Bind(wx.EVT_TEXT, self.OnInlineChanged, self.Inline)
+ left_gridsizer.AddWindow(self.Inline, flag=wx.GROW)
+
+ self.ConnectionRadioButton = wx.RadioButton(self, label=_('Connection'))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectionRadioButton)
+ self.ConnectionRadioButton.SetValue(False)
if not self.Connection:
- self.radioButton3.Hide()
-
- self.Priority = wx.SpinCtrl(id=ID_SFCTRANSITIONDIALOGPRIORITY,
- name='Priority', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
- self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, id=ID_SFCTRANSITIONDIALOGPRIORITY)
-
- self.Preview = wx.Panel(id=ID_SFCTRANSITIONDIALOGPREVIEW,
- name='Preview', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
+ self.ConnectionRadioButton.Hide()
+ left_gridsizer.AddWindow(self.ConnectionRadioButton, flag=wx.GROW)
+
+ priority_label = wx.StaticText(self, label=_('Priority:'))
+ left_gridsizer.AddWindow(priority_label, flag=wx.GROW)
+
+ self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
+ self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority)
+ left_gridsizer.AddWindow(self.Priority, flag=wx.GROW)
+
+ right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
+ right_gridsizer.AddGrowableCol(0)
+ right_gridsizer.AddGrowableRow(1)
+ column_sizer.AddSizer(right_gridsizer, 1, border=5,
+ flag=wx.GROW|wx.LEFT)
+
+ preview_label = wx.StaticText(self, label=_('Preview:'))
+ right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
+
+ self.Preview = wx.Panel(self,
+ 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)
setattr(self.Preview, "GetScaling", lambda:None)
- setattr(self.Preview, "IsOfType", ctrler.IsOfType)
-
- self.Spacer = wx.Panel(id=ID_SFCTRANSITIONDIALOGSPACER,
- 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)
- if wx.VERSION >= (2, 5, 0):
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
- self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
- else:
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
- wx.EVT_PAINT(self.Preview, self.OnPaint)
-
- self._init_sizers()
-
- def __init__(self, parent, controler, connection):
- self.Connection = connection
- self._init_ctrls(parent, controler)
+ setattr(self.Preview, "IsOfType", controller.IsOfType)
+ self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
+ right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
+
+ button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
+ self.Bind(wx.EVT_BUTTON, self.OnOK,
+ button_sizer.GetAffirmativeButton())
+ main_sizer.AddSizer(button_sizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+
+ self.SetSizer(main_sizer)
+
self.Transition = None
self.MinTransitionSize = None
self.Element = SFC_Transition(self.Preview)
- self.radioButton1.SetFocus()
+ self.ReferenceRadioButton.SetFocus()
def SetPreviewFont(self, font):
self.Preview.SetFont(font)
@@ -195,9 +131,9 @@
def OnOK(self, event):
error = []
- if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "":
+ if self.ReferenceRadioButton.GetValue() and self.Reference.GetStringSelection() == "":
error.append(_("Reference"))
- if self.radioButton2.GetValue() and self.Inline.GetValue() == "":
+ if self.InlineRadioButton.GetValue() and self.Inline.GetValue() == "":
error.append(_("Inline"))
if len(error) > 0:
text = ""
@@ -208,18 +144,18 @@
text += _(" and %s")%item
else:
text += _(", %s")%item
- message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ dialog = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
else:
self.EndModal(wx.ID_OK)
def OnTypeChanged(self, event):
- if self.radioButton1.GetValue():
+ if self.ReferenceRadioButton.GetValue():
self.Element.SetType("reference", self.Reference.GetStringSelection())
self.Reference.Enable(True)
self.Inline.Enable(False)
- elif self.radioButton2.GetValue():
+ elif self.InlineRadioButton.GetValue():
self.Element.SetType("inline", self.Inline.GetValue())
self.Reference.Enable(False)
self.Inline.Enable(True)
@@ -252,25 +188,25 @@
def SetValues(self, values):
if values["type"] == "reference":
- self.radioButton1.SetValue(True)
- self.radioButton2.SetValue(False)
- self.radioButton3.SetValue(False)
+ self.ReferenceRadioButton.SetValue(True)
+ self.InlineRadioButton.SetValue(False)
+ self.ConnectionRadioButton.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.ReferenceRadioButton.SetValue(False)
+ self.InlineRadioButton.SetValue(True)
+ self.ConnectionRadioButton.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.ReferenceRadioButton.SetValue(False)
+ self.InlineRadioButton.SetValue(False)
+ self.ConnectionRadioButton.SetValue(True)
self.Reference.Enable(False)
self.Inline.Enable(False)
self.Element.SetType("connection")
@@ -280,10 +216,10 @@
def GetValues(self):
values = {"priority" : int(self.Priority.GetValue())}
- if self.radioButton1.GetValue():
+ if self.ReferenceRadioButton.GetValue():
values["type"] = "reference"
values["value"] = self.Reference.GetStringSelection()
- elif self.radioButton2.GetValue():
+ elif self.InlineRadioButton.GetValue():
values["type"] = "inline"
values["value"] = self.Inline.GetValue()
else:
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SearchInProjectDialog.py
--- a/dialogs/SearchInProjectDialog.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/SearchInProjectDialog.py Mon Jun 25 20:03:53 2012 +0200
@@ -46,119 +46,70 @@
("program", _("Program")),
("configuration", _("Configuration"))]
-[ID_SEARCHINPROJECTDIALOG, ID_SEARCHINPROJECTDIALOGPATTERNLABEL,
- ID_SEARCHINPROJECTDIALOGPATTERN, ID_SEARCHINPROJECTDIALOGCASESENSITIVE,
- ID_SEARCHINPROJECTDIALOGREGULAREXPRESSION, ID_SEARCHINPROJECTDIALOGSCOPESTATICBOX,
- ID_SEARCHINPROJECTDIALOGWHOLEPROJECT, ID_SEARCHINPROJECTDIALOGONLYELEMENTS,
- ID_SEARCHINPROJECTDIALOGELEMENTSLIST,
-] = [wx.NewId() for _init_ctrls in range(9)]
-
class SearchInProjectDialog(wx.Dialog):
- if wx.VERSION < (2, 6, 0):
- def Bind(self, event, function, id = None):
- if id is not None:
- event(self, id, function)
- else:
- event(self, function)
-
- def _init_coll_MainSizer_Items(self, parent):
- parent.AddSizer(self.PatternSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- parent.AddSizer(self.ScopeSizer, 0, border=20, flag=wx.GROW|wx.LEFT|wx.RIGHT)
- parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
-
- def _init_coll_MainSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
- parent.AddGrowableRow(1)
-
- def _init_coll_PatternSizer_Items(self, parent):
- parent.AddWindow(self.PatternLabel, 0, border=0, flag=wx.ALIGN_BOTTOM)
- parent.AddWindow(self.CaseSensitive, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.Pattern, 0, border=0, flag=wx.GROW)
- parent.AddWindow(self.RegularExpression, 0, border=0, flag=wx.GROW)
-
- def _init_coll_PatternSizer_Growables(self, parent):
- parent.AddGrowableCol(0)
-
- def _init_coll_ScopeSizer_Items(self, parent):
- parent.AddSizer(self.ScopeSelectionSizer, 1, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.BOTTOM)
- parent.AddWindow(self.ElementsList, 1, border=5, flag=wx.GROW|wx.TOP|wx.RIGHT|wx.BOTTOM)
-
- def _init_coll_ScopeSelectionSizer_Items(self, parent):
- parent.AddWindow(self.WholeProject, 0, border=5, flag=wx.GROW|wx.BOTTOM)
- parent.AddWindow(self.OnlyElements, 0, border=0, flag=wx.GROW)
-
- def _init_sizers(self):
- self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
- self.PatternSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
- self.ScopeSizer = wx.StaticBoxSizer(self.ScopeStaticBox, wx.HORIZONTAL)
- self.ScopeSelectionSizer = wx.BoxSizer(wx.VERTICAL)
+ def __init__(self, parent):
+ wx.Dialog.__init__(self, parent, title=_('Search in Project'),
+ size=wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE|
+ wx.RESIZE_BORDER)
- self._init_coll_MainSizer_Items(self.MainSizer)
- self._init_coll_MainSizer_Growables(self.MainSizer)
- self._init_coll_PatternSizer_Items(self.PatternSizer)
- self._init_coll_PatternSizer_Growables(self.PatternSizer)
- self._init_coll_ScopeSizer_Items(self.ScopeSizer)
- self._init_coll_ScopeSelectionSizer_Items(self.ScopeSelectionSizer)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ main_sizer.AddGrowableCol(0)
+ main_sizer.AddGrowableRow(1)
- self.SetSizer(self.MainSizer)
-
- def _init_ctrls(self, prnt):
- wx.Dialog.__init__(self, id=ID_SEARCHINPROJECTDIALOG,
- name='SearchInProjectDialog', parent=prnt,
- size=wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
- title=_('Search in Project'))
+ pattern_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
+ pattern_sizer.AddGrowableCol(0)
+ main_sizer.AddSizer(pattern_sizer, border=20,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
- self.PatternLabel = wx.StaticText(id=ID_SEARCHINPROJECTDIALOGPATTERNLABEL,
- label=_('Pattern to search:'), name='PatternLabel', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
-
- self.Pattern = wx.TextCtrl(id=ID_SEARCHINPROJECTDIALOGPATTERN,
- name='Pattern', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 24), style=0)
-
- self.CaseSensitive = wx.CheckBox(id=ID_SEARCHINPROJECTDIALOGCASESENSITIVE,
- label=_('Case sensitive'), name='CaseSensitive', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
+ pattern_label = wx.StaticText(self, label=_('Pattern to search:'))
+ pattern_sizer.AddWindow(pattern_label, flag=wx.ALIGN_BOTTOM)
- self.RegularExpression = wx.CheckBox(id=ID_SEARCHINPROJECTDIALOGREGULAREXPRESSION,
- label=_('Regular expression'), name='RegularExpression', parent=self,
- pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
+ self.CaseSensitive = wx.CheckBox(self, label=_('Case sensitive'))
+ pattern_sizer.AddWindow(self.CaseSensitive, flag=wx.GROW)
- self.ScopeStaticBox = wx.StaticBox(id=ID_SEARCHINPROJECTDIALOGSCOPESTATICBOX,
- label=_('Scope'), name='ScopeStaticBox', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
+ self.Pattern = wx.TextCtrl(self, size=wx.Size(0, 24))
+ pattern_sizer.AddWindow(self.Pattern, flag=wx.GROW)
- self.WholeProject = wx.RadioButton(id=ID_SEARCHINPROJECTDIALOGWHOLEPROJECT,
- label=_('Whole Project'), name='WholeProject', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, id=ID_SEARCHINPROJECTDIALOGWHOLEPROJECT)
+ self.RegularExpression = wx.CheckBox(self, label=_('Regular expression'))
+ pattern_sizer.AddWindow(self.RegularExpression, flag=wx.GROW)
+
+ scope_staticbox = wx.StaticBox(self, label=_('Scope'))
+ scope_sizer = wx.StaticBoxSizer(scope_staticbox, wx.HORIZONTAL)
+ main_sizer.AddSizer(scope_sizer, border=20,
+ flag=wx.GROW|wx.LEFT|wx.RIGHT)
+
+ scope_selection_sizer = wx.BoxSizer(wx.VERTICAL)
+ scope_sizer.AddSizer(scope_selection_sizer, 1, border=5,
+ flag=wx.GROW|wx.TOP|wx.LEFT|wx.BOTTOM)
+
+ self.WholeProject = wx.RadioButton(self, label=_('Whole Project'),
+ size=wx.Size(0, 24), style=wx.RB_GROUP)
self.WholeProject.SetValue(True)
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.WholeProject)
+ scope_selection_sizer.AddWindow(self.WholeProject, border=5,
+ flag=wx.GROW|wx.BOTTOM)
- self.OnlyElements = wx.RadioButton(id=ID_SEARCHINPROJECTDIALOGONLYELEMENTS,
- label=_('Only Elements'), name='OnlyElements', parent=self,
- pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
- self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, id=ID_SEARCHINPROJECTDIALOGONLYELEMENTS)
+ self.OnlyElements = wx.RadioButton(self,
+ label=_('Only Elements'), size=wx.Size(0, 24))
+ self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.OnlyElements)
self.OnlyElements.SetValue(False)
+ scope_selection_sizer.AddWindow(self.OnlyElements, flag=wx.GROW)
- self.ElementsList = wx.CheckListBox(id=ID_SEARCHINPROJECTDIALOGELEMENTSLIST,
- name='ElementsList', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(0, 0), style=0)
+ self.ElementsList = wx.CheckListBox(self)
self.ElementsList.Enable(False)
+ scope_sizer.AddWindow(self.ElementsList, 1, border=5,
+ flag=wx.GROW|wx.TOP|wx.RIGHT|wx.BOTTOM)
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
- if wx.VERSION >= (2, 5, 0):
- ok_button = self.ButtonSizer.GetAffirmativeButton()
- else:
- ok_button = self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow()
+ ok_button = self.ButtonSizer.GetAffirmativeButton()
ok_button.SetLabel(_('Search'))
- self.Bind(wx.EVT_BUTTON, self.OnOK, id=ok_button.GetId())
+ self.Bind(wx.EVT_BUTTON, self.OnOK, ok_button)
+ main_sizer.AddSizer(self.ButtonSizer, border=20,
+ flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
- self._init_sizers()
-
- def __init__(self, parent):
- self._init_ctrls(parent)
-
+ self.SetSizer(main_sizer)
+
for name, label in GetElementsChoices():
self.ElementsList.Append(_(label))
@@ -191,9 +142,7 @@
def OnOK(self, event):
if self.Pattern.GetValue() == "":
- message = wx.MessageDialog(self, _("Form isn't complete. Pattern to search must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
+ message = _("Form isn't complete. Pattern to search must be filled!")
else:
wrong_pattern = False
if self.RegularExpression.GetValue():
@@ -202,8 +151,11 @@
except:
wrong_pattern = True
if wrong_pattern:
- message = wx.MessageDialog(self, _("Syntax error in regular expression of pattern to search!"), _("Error"), wx.OK|wx.ICON_ERROR)
- message.ShowModal()
- message.Destroy()
- else:
- self.EndModal(wx.ID_OK)
+ message = _("Syntax error in regular expression of pattern to search!")
+
+ if message is not None:
+ dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR)
+ dialog.ShowModal()
+ dialog.Destroy()
+ else:
+ self.EndModal(wx.ID_OK)
diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/__init__.py
--- a/dialogs/__init__.py Fri Jun 15 18:03:25 2012 +0200
+++ b/dialogs/__init__.py Mon Jun 25 20:03:53 2012 +0200
@@ -26,7 +26,7 @@
from ConnectionDialog import ConnectionDialog
from ActionBlockDialog import ActionBlockDialog
-from FBDBlockDialog import FBDBlockDialog, CATEGORY, BLOCK
+from FBDBlockDialog import FBDBlockDialog
from FBDVariableDialog import FBDVariableDialog
from LDElementDialog import LDElementDialog
from LDPowerRailDialog import LDPowerRailDialog
diff -r 95a0a427f3ef -r 131ea7f237b9 utils/BitmapLibrary.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/BitmapLibrary.py Mon Jun 25 20:03:53 2012 +0200
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
+#based on the plcopen standard.
+#
+#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
+#
+#See COPYING file for copyrights details.
+#
+#This library is free software; you can redistribute it and/or
+#modify it under the terms of the GNU General Public
+#License as published by the Free Software Foundation; either
+#version 2.1 of the License, or (at your option) any later version.
+#
+#This library is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+#General Public License for more details.
+#
+#You should have received a copy of the GNU General Public
+#License along with this library; if not, write to the Free Software
+#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+
+import wx
+
+#-------------------------------------------------------------------------------
+# Library Structures
+#-------------------------------------------------------------------------------
+
+BitmapLibrary = {}
+BitmapFolders = []
+
+#-------------------------------------------------------------------------------
+# Library Helpers
+#-------------------------------------------------------------------------------
+
+def AddBitmapFolder(path):
+ if path not in BitmapFolders:
+ BitmapFolders.append(path)
+
+def SearchBitmap(bmp_name):
+ for folder in BitmapFolders:
+ bmp_path = os.path.join(folder, bmp_name + ".png")
+ if os.path.isfile(bmp_path):
+ return wx.Bitmap(bmp_path)
+ return None
+
+def GetBitmap(bmp_name1, bmp_name2=None, size=None):
+ bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size))
+ if bmp is not None:
+ return bmp
+
+ if bmp_name2 is None:
+ bmp = SearchBitmap(bmp_name1)
+ else:
+ # Bitmap with two icon
+ bmp1 = SearchBitmap(bmp_name1)
+ bmp2 = SearchBitmap(bmp_name2)
+
+ if bmp1 is not None and bmp2 is not None:
+ # Calculate bitmap size
+ width = bmp1.GetWidth() + bmp2.GetWidth() - 1
+ height = max(bmp1.GetHeight(), bmp2.GetHeight())
+
+ # Create bitmap with both icons
+ bmp = wx.EmptyBitmap(width, height)
+ dc = wx.MemoryDC()
+ dc.SelectObject(bmp)
+ dc.Clear()
+ dc.DrawBitmap(bmp1, 0, 0)
+ dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0)
+ dc.Destroy()
+
+ elif bmp1 is not None:
+ bmp = bmp1
+ elif bmp2 is not None:
+ bmp = bmp2
+
+ if bmp is not None:
+ BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp
+
+ return bmp