def __init__(self, parent, controller, tagname):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        """
        BlockPreviewDialog.__init__(self,
                                    parent,
                                    controller,
                                    tagname,
                                    size=wx.Size(350, 260),
                                    title=_('Power Rail Properties'))

        # Init common sizers
        self._init_sizers(2, 0, 5, None, 2, 1)

        # Create label for connection type
        type_label = wx.StaticText(self, label=_('Type:'))
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)

        # Create radio buttons for selecting power rail type
        self.TypeRadioButtons = {}
        first = True
        for type, label in [(LEFTRAIL, _('Left PowerRail')),
                            (RIGHTRAIL, _('Right PowerRail'))]:
            radio_button = wx.RadioButton(self,
                                          label=label,
                                          style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            self.TypeRadioButtons[type] = radio_button
            first = False

        # Create label for power rail pin number
        pin_number_label = wx.StaticText(self, label=_('Pin number:'))
        self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW)

        # Create spin control for defining power rail pin number
        self.PinNumber = wx.SpinCtrl(self,
                                     min=1,
                                     max=50,
                                     style=wx.SP_ARROW_KEYS)
        self.PinNumber.SetValue(1)
        self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber)
        self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Left Power Rail radio button is default control having keyboard focus
        self.TypeRadioButtons[LEFTRAIL].SetFocus()
Example #2
0
    def __init__(self, parent, controller, tagname, initial=False):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param initial: True if step is initial (default: False)
        """
        BlockPreviewDialog.__init__(self,
                                    parent,
                                    controller,
                                    tagname,
                                    size=wx.Size(400, 250),
                                    title=_('Edit Step'))

        # Init common sizers
        self._init_sizers(2, 0, 6, None, 2, 1)

        # Create label for SFC step name
        name_label = wx.StaticText(self, label=_('Name:'))
        self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)

        # Create text control for defining SFC step name
        self.StepName = wx.TextCtrl(self)
        self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.StepName)
        self.LeftGridSizer.AddWindow(self.StepName, flag=wx.GROW)

        # Create label for SFC step connectors
        connectors_label = wx.StaticText(self, label=_('Connectors:'))
        self.LeftGridSizer.AddWindow(connectors_label, flag=wx.GROW)

        # Create check boxes for defining connectors available on SFC step
        self.ConnectorsCheckBox = {}
        for name, label in [("input", _("Input")), ("output", _("Output")),
                            ("action", _("Action"))]:
            check_box = wx.CheckBox(self, label=label)
            self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, check_box)
            self.LeftGridSizer.AddWindow(check_box, flag=wx.GROW)
            self.ConnectorsCheckBox[name] = check_box

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Save flag that indicates that step is initial
        self.Initial = initial

        # Set default name for step
        self.StepName.ChangeValue(
            controller.GenerateNewName(tagname, None, "Step%d", 0))

        # Step name text control is default control having keyboard focus
        self.StepName.SetFocus()
    def __init__(self, parent, controller, tagname):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        """
        BlockPreviewDialog.__init__(self, parent, controller, tagname, 
              size=wx.Size(500, 300), 
              title=_('Create a new divergence or convergence'))
        
        # Init common sizers
        self._init_sizers(2, 0, 7, None, 2, 1)
        
        # Create label for divergence type
        type_label = wx.StaticText(self, label=_('Type:'))
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
        
        # Create radio buttons for selecting divergence type
        self.TypeRadioButtons = {}
        first = True
        for type, label in [
                (SELECTION_DIVERGENCE, _('Selection Divergence')),
                (SELECTION_CONVERGENCE, _('Selection Convergence')),
                (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')),
                (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))]:
            radio_button = wx.RadioButton(self, label=label, 
                  style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            self.TypeRadioButtons[type] = radio_button
            first = False

        # Create label for number of divergence sequences
        sequences_label = wx.StaticText(self, 
              label=_('Number of sequences:'))
        self.LeftGridSizer.AddWindow(sequences_label, flag=wx.GROW)
        
        # Create spin control for defining number of divergence sequences
        self.Sequences = wx.SpinCtrl(self, min=2, max=20)
        self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences)
        self.LeftGridSizer.AddWindow(self.Sequences, flag=wx.GROW)
        
        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
        
        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
              flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
        
        # Selection divergence radio button is default control having keyboard
        # focus
        self.TypeRadioButtons[SELECTION_DIVERGENCE].SetFocus()
 def __init__(self, parent, controller, tagname):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname,
           size=wx.Size(350, 260), title=_('Power Rail Properties'))
     
     # Init common sizers
     self._init_sizers(2, 0, 5, None, 2, 1)
     
     # Create label for connection type
     type_label = wx.StaticText(self, label=_('Type:'))
     self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
     
     # Create radio buttons for selecting power rail type
     self.TypeRadioButtons = {}
     first = True
     for type, label in [(LEFTRAIL, _('Left PowerRail')),
                         (RIGHTRAIL, _('Right PowerRail'))]:
         radio_button = wx.RadioButton(self, label=label, 
               style=(wx.RB_GROUP if first else 0))
         radio_button.SetValue(first)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
         self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
         self.TypeRadioButtons[type] = radio_button
         first = False
     
     # Create label for power rail pin number
     pin_number_label = wx.StaticText(self, label=_('Pin number:'))
     self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW)
     
     # Create spin control for defining power rail pin number
     self.PinNumber = wx.SpinCtrl(self, min=1, max=50,
           style=wx.SP_ARROW_KEYS)
     self.PinNumber.SetValue(1)
     self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber)
     self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Left Power Rail radio button is default control having keyboard focus
     self.TypeRadioButtons[LEFTRAIL].SetFocus()
Example #5
0
    def __init__(self, parent, controller, tagname, initial=False):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param initial: True if step is initial (default: False)
        """
        BlockPreviewDialog.__init__(self, parent, controller, tagname, size=wx.Size(400, 250), title=_("Edit Step"))

        # Init common sizers
        self._init_sizers(2, 0, 6, None, 2, 1)

        # Create label for SFC step name
        name_label = wx.StaticText(self, label=_("Name:"))
        self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)

        # Create text control for defining SFC step name
        self.StepName = wx.TextCtrl(self)
        self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.StepName)
        self.LeftGridSizer.AddWindow(self.StepName, flag=wx.GROW)

        # Create label for SFC step connectors
        connectors_label = wx.StaticText(self, label=_("Connectors:"))
        self.LeftGridSizer.AddWindow(connectors_label, flag=wx.GROW)

        # Create check boxes for defining connectors available on SFC step
        self.ConnectorsCheckBox = {}
        for name, label in [("input", _("Input")), ("output", _("Output")), ("action", _("Action"))]:
            check_box = wx.CheckBox(self, label=label)
            self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, check_box)
            self.LeftGridSizer.AddWindow(check_box, flag=wx.GROW)
            self.ConnectorsCheckBox[name] = check_box

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)

        # Save flag that indicates that step is initial
        self.Initial = initial

        # Set default name for step
        self.StepName.ChangeValue(controller.GenerateNewName(tagname, None, "Step%d", 0))

        # Step name text control is default control having keyboard focus
        self.StepName.SetFocus()
    def OnOK(self, event):
        """
        Called when dialog OK button is pressed
        Test if parameters defined are valid
        @param event: wx.Event from OK button
        """
        message = None

        # Get block type selected
        selected = self.LibraryPanel.GetSelectedBlock()

        # Get block type name and if block is a function block
        block_name = self.BlockName.GetValue()
        name_enabled = self.BlockName.IsEnabled()

        # Test that a type has been selected for block
        if selected is None:
            message = _(
                "Form isn't complete. Valid block type must be selected!")

        # Test, if block is a function block, that a name have been defined
        elif name_enabled and block_name == "":
            message = _("Form isn't complete. Name must be filled!")

        # Show error message if an error is detected
        if message is not None:
            self.ShowErrorMessage(message)

        # Test block name validity if necessary
        elif not name_enabled or self.TestElementName(block_name):
            # Call BlockPreviewDialog function
            BlockPreviewDialog.OnOK(self, event)
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Get type selected in library panel
        values = self.LibraryPanel.GetSelectedBlock()

        # If a block type is selected in library panel
        if values is not None:
            # Set graphic element displayed, creating a FBD block element
            self.Element = FBD_Block(
                self.Preview,
                values["type"], (self.BlockName.GetValue()
                                 if self.BlockName.IsEnabled() else ""),
                extension=self.Inputs.GetValue(),
                inputs=values["inputs"],
                executionControl=self.ExecutionControl.GetValue(),
                executionOrder=self.ExecutionOrder.GetValue())

        # Reset graphic element displayed
        else:
            self.Element = None

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #8
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Set graphic element displayed, creating a SFC divergence
        self.Element = SFC_Divergence(self.Preview, self.GetDivergenceType(),
                                      self.Sequences.GetValue())

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #9
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Set graphic element displayed, creating a FBD connection element
        self.Element = FBD_Connector(self.Preview, self.GetConnectionType(),
                                     self.ConnectionName.GetValue())

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #10
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Set graphic element displayed, creating a SFC transition
        self.Element = SFC_Transition(self.Preview)
        self.Element.SetType(*self.GetTransitionType())
        self.Element.SetPriority(self.Priority.GetValue())

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #11
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Set graphic element displayed, creating a LD element
        self.Element = self.ElementClass(self.Preview,
                                         self.GetElementModifier(),
                                         self.ElementVariable.GetValue())

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
 def RefreshPreview(self):
     """
     Refresh preview panel of graphic element
     Override BlockPreviewDialog function
     """
     
     # Set graphic element displayed, creating a power rail element
     self.Element = LD_PowerRail(self.Preview, 
             self.GetPowerRailType(), 
             connectors = self.PinNumber.GetValue())
     
     # Call BlockPreviewDialog function
     BlockPreviewDialog.RefreshPreview(self)
Example #13
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        value = self.ElementVariable.GetValue()

        # Set graphic element displayed, creating a LD element
        self.Element = self.ElementClass(self.Preview,
                                         self.GetElementModifier(), value)

        button = self.ButtonSizer.GetAffirmativeButton()
        button.Enable(value != "")

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #14
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Set graphic element displayed, creating a SFC step element
        self.Element = SFC_Step(self.Preview, self.StepName.GetValue(),
                                self.Initial)

        # Update connectors of SFC step element according to check boxes value
        for name, control in self.ConnectorsCheckBox.iteritems():
            if control.IsChecked():
                getattr(self.Element, "Add" + name.capitalize())()
            else:
                getattr(self.Element, "Remove" + name.capitalize())()

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #15
0
    def RefreshPreview(self):
        """
        Refresh preview panel of graphic element
        Override BlockPreviewDialog function
        """
        # Get expression value to put in FBD variable element
        name = self.Expression.GetValue()

        # Set graphic element displayed, creating a FBD variable element
        self.Element = FBD_Variable(
            self.Preview,
            VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()],
            name,
            self.VariableList.get(name, ("", ""))[1],
            executionOrder=self.ExecutionOrder.GetValue())

        # Call BlockPreviewDialog function
        BlockPreviewDialog.RefreshPreview(self)
Example #16
0
    def OnOK(self, event):
        """
        Called when dialog OK button is pressed
        Test if parameters defined are valid
        @param event: wx.Event from OK button
        """
        message = None

        # Test that an expression have been selected or typed by user
        value = self.Expression.GetValue()
        if value == "":
            message = _("At least a variable or an expression must be selected!")

        # Show error message if an error is detected
        if message is not None:
            self.ShowErrorMessage(message)

        else:
            # Call BlockPreviewDialog function
            BlockPreviewDialog.OnOK(self, event)
Example #17
0
    def OnOK(self, event):
        """
        Called when dialog OK button is pressed
        Test if parameters defined are valid
        @param event: wx.Event from OK button
        """
        message = None

        # Get transition type and value associated
        type, value = self.GetTransitionType()

        # Test that value associated to type is defined
        if type != "connection" and value == "":
            message = _("Form isn't complete. %s must be filled!") % type

        # Show error message if an error is detected
        if message is not None:
            self.ShowErrorMessage(message)

        else:
            # Call BlockPreviewDialog function
            BlockPreviewDialog.OnOK(self, event)
Example #18
0
    def OnOK(self, event):
        """
        Called when dialog OK button is pressed
        Test if step name defined is valid
        @param event: wx.Event from OK button
        """
        message = None

        # Get step name typed by user
        step_name = self.StepName.GetValue()

        # Test that a name have been defined
        if step_name == "":
            message = _("Form isn't complete. Name must be filled!")

        # If an error have been identify, show error message dialog
        if message is not None:
            self.ShowErrorMessage(message)

        # Test step name validity
        elif self.TestElementName(step_name):
            # Call BlockPreviewDialog function
            BlockPreviewDialog.OnOK(self, event)
Example #19
0
    def __init__(self, parent, controller, tagname, exclude_input=False):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param exclude_input: Exclude input from variable class selection
        """
        BlockPreviewDialog.__init__(self,
                                    parent,
                                    controller,
                                    tagname,
                                    size=wx.Size(400, 380),
                                    title=_('Variable Properties'))

        # Init common sizers
        self._init_sizers(4, 2, 4, None, 3, 2)

        # Create label for variable class
        class_label = wx.StaticText(self, label=_('Class:'))
        self.LeftGridSizer.AddWindow(class_label, flag=wx.GROW)

        # Create a combo box for defining variable class
        self.Class = wx.ComboBox(self, style=wx.CB_READONLY)
        self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, self.Class)
        self.LeftGridSizer.AddWindow(self.Class, flag=wx.GROW)

        # Create label for variable execution order
        execution_order_label = wx.StaticText(self,
                                              label=_('Execution Order:'))
        self.LeftGridSizer.AddWindow(execution_order_label, flag=wx.GROW)

        # Create spin control for defining variable execution order
        self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
        self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged,
                  self.ExecutionOrder)
        self.LeftGridSizer.AddWindow(self.ExecutionOrder, flag=wx.GROW)

        # Create label for variable expression
        name_label = wx.StaticText(self, label=_('Expression:'))
        self.RightGridSizer.AddWindow(name_label,
                                      border=5,
                                      flag=wx.GROW | wx.BOTTOM)

        # Create text control for defining variable expression
        self.Expression = wx.TextCtrl(self)
        self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, self.Expression)
        self.RightGridSizer.AddWindow(self.Expression, flag=wx.GROW)

        # Create a list box to selected variable expression in the list of
        # variables defined in POU
        self.VariableName = wx.ListBox(self,
                                       size=wx.Size(0, 120),
                                       style=wx.LB_SINGLE | wx.LB_SORT)
        self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, self.VariableName)
        self.RightGridSizer.AddWindow(self.VariableName, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.MainSizer.AddWindow(self.PreviewLabel,
                                 border=20,
                                 flag=wx.GROW | wx.LEFT | wx.RIGHT)
        self.MainSizer.AddWindow(self.Preview,
                                 border=20,
                                 flag=wx.GROW | wx.LEFT | wx.RIGHT)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Set options that can be selected in class combo box
        for var_class, choice in VARIABLE_CLASSES_DICT.iteritems():
            if not exclude_input or var_class != INPUT:
                self.Class.Append(choice)
        self.Class.SetSelection(0)

        # Extract list of variables defined in POU
        self.RefreshVariableList()

        # Refresh values in name list box
        self.RefreshNameList()

        # Class combo box is default control having keyboard focus
        self.Class.SetFocus()
 def __init__(self, parent, controller, tagname, apply_button=False):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     @param apply_button: Enable button for applying connector modification
     to all connector having the same name in POU (default: False)
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname, 
           size=wx.Size(350, 250), title=_('Connection Properties'))
     
     # Init common sizers
     self._init_sizers(2, 0, 5, None, 2, 1)
     
     # Create label for connection type
     type_label = wx.StaticText(self, label=_('Type:'))
     self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
     
     # Create radio buttons for selecting connection type
     self.TypeRadioButtons = {}
     first = True
     for type, label in [(CONNECTOR, _('Connector')),
                         (CONTINUATION, _('Continuation'))]:
         radio_button = wx.RadioButton(self, label=label, 
               style=(wx.RB_GROUP if first else 0))
         radio_button.SetValue(first)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
         self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
         self.TypeRadioButtons[type] = radio_button
         first = False
     
     # Create label for connection name
     name_label = wx.StaticText(self, label=_('Name:'))
     self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)
     
     # Create text control for defining connection name
     self.ConnectionName = wx.TextCtrl(self)
     self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
     self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Add button for applying connection name modification to all connection
     # of POU
     if apply_button:
         self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name"))
         self.ApplyToAllButton.SetToolTipString(
             _("Apply name modification to all continuations with the same name"))
         self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton)
         self.ButtonSizer.AddWindow(self.ApplyToAllButton, 
                 border=(3 if wx.Platform == '__WXMSW__' else 10),
                 flag=wx.LEFT)
     else:
         self.ConnectionName.ChangeValue(
             controller.GenerateNewName(
                     tagname, None, "Connection%d", 0))
     
     # Connector radio button is default control having keyboard focus
     self.TypeRadioButtons[CONNECTOR].SetFocus()
    def __init__(self, parent, controller, tagname):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        """
        BlockPreviewDialog.__init__(self,
                                    parent,
                                    controller,
                                    tagname,
                                    size=wx.Size(600, 450),
                                    title=_('Block Properties'))

        # Init common sizers
        self._init_sizers(2, 0, 1, 0, 3, 2)

        # Create static box around library panel
        type_staticbox = wx.StaticBox(self, label=_('Type:'))
        left_staticboxsizer = wx.StaticBoxSizer(type_staticbox, wx.VERTICAL)
        self.LeftGridSizer.AddSizer(left_staticboxsizer,
                                    border=5,
                                    flag=wx.GROW)

        # Create Library panel and add it to static box
        self.LibraryPanel = LibraryPanel(self)
        # Set function to call when selection in Library panel changed
        setattr(self.LibraryPanel, "_OnTreeItemSelected",
                self.OnLibraryTreeItemSelected)
        left_staticboxsizer.AddWindow(self.LibraryPanel,
                                      1,
                                      border=5,
                                      flag=wx.GROW | wx.TOP)

        # Create sizer for other block parameters
        top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5)
        top_right_gridsizer.AddGrowableCol(1)
        self.RightGridSizer.AddSizer(top_right_gridsizer, flag=wx.GROW)

        # Create label for block name
        name_label = wx.StaticText(self, label=_('Name:'))
        top_right_gridsizer.AddWindow(name_label,
                                      flag=wx.ALIGN_CENTER_VERTICAL)

        # Create text control for defining block name
        self.BlockName = wx.TextCtrl(self)
        self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName)
        top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW)

        # Create label for extended block input number
        inputs_label = wx.StaticText(self, label=_('Inputs:'))
        top_right_gridsizer.AddWindow(inputs_label,
                                      flag=wx.ALIGN_CENTER_VERTICAL)

        # Create spin control for defining extended block input number
        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)

        # Create label for block execution order
        execution_order_label = wx.StaticText(self,
                                              label=_('Execution Order:'))
        top_right_gridsizer.AddWindow(execution_order_label,
                                      flag=wx.ALIGN_CENTER_VERTICAL)

        # Create spin control for defining block execution order
        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)

        # Create label for block execution control
        execution_control_label = wx.StaticText(self,
                                                label=_('Execution Control:'))
        top_right_gridsizer.AddWindow(execution_control_label,
                                      flag=wx.ALIGN_CENTER_VERTICAL)

        # Create check box to enable block execution control
        self.ExecutionControl = wx.CheckBox(self)
        self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged,
                  self.ExecutionControl)
        top_right_gridsizer.AddWindow(self.ExecutionControl, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Dictionary containing correspondence between parameter exchanged and
        # control to fill with parameter value
        self.ParamsControl = {
            "extension": self.Inputs,
            "executionOrder": self.ExecutionOrder,
            "executionControl": self.ExecutionControl
        }

        # Init controls value and sensibility
        self.BlockName.SetValue("")
        self.BlockName.Enable(False)
        self.Inputs.Enable(False)

        # Variable containing last name typed
        self.CurrentBlockName = None

        # Refresh Library panel values
        self.LibraryPanel.SetBlockList(controller.GetBlockTypes(tagname))
        self.LibraryPanel.SetFocus()
 def __init__(self, parent, controller, tagname, connection=True):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     @param connection: True if transition value can be defined by a
     connection (default: True)
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname,
           size=wx.Size(350, 300), title=_('Edit transition'))
     
     # Init common sizers
     self._init_sizers(2, 0, 8, None, 2, 1)
     
     # Create label for transition type
     type_label = wx.StaticText(self, label=_('Type:'))
     self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
     
     # Create combo box for selecting reference value
     reference = wx.ComboBox(self, style=wx.CB_READONLY)
     reference.Append("")
     for transition in controller.GetEditedElementTransitions(tagname):
         reference.Append(transition)
     self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, reference)
     
     # Create Text control for defining inline value
     inline = wx.TextCtrl(self)
     self.Bind(wx.EVT_TEXT, self.OnInlineChanged, inline)
     
     # Create radio buttons for selecting power rail type
     self.TypeRadioButtons = {}
     first = True
     for type, label, control in [('reference', _('Reference'), reference),
                                  ('inline', _('Inline'), inline),
                                  ('connection', _('Connection'), None)]:
         radio_button = wx.RadioButton(self, label=label, 
               style=(wx.RB_GROUP if first else 0))
         radio_button.SetValue(first)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
         self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
         if control is not None:
             control.Enable(first)
             self.LeftGridSizer.AddWindow(control, flag=wx.GROW)
         self.TypeRadioButtons[type] = (radio_button, control)
         first = False
     
     # Create label for transition priority
     priority_label = wx.StaticText(self, label=_('Priority:'))
     self.LeftGridSizer.AddWindow(priority_label, flag=wx.GROW)
     
     # Create spin control for defining priority value
     self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
     self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority)
     self.LeftGridSizer.AddWindow(self.Priority, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Reference radio button is default control having keyboard focus
     self.TypeRadioButtons["reference"][0].SetFocus()
Example #23
0
 def __init__(self, parent, controller, tagname, type):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     @param type: Type of LD element ('contact or 'coil')
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname, 
           size=wx.Size(350, 280 if type == "contact" else 330),
           title=(_("Edit Contact Values")
                  if type == "contact"
                  else _("Edit Coil Values")))
     
     # Init common sizers
     self._init_sizers(2, 0, 
           (7 if type == "contact" else 9), None, 2, 1)
     
     # Create label for LD element modifier
     modifier_label = wx.StaticText(self, label=_('Modifier:'))
     self.LeftGridSizer.AddWindow(modifier_label, border=5, 
           flag=wx.GROW|wx.BOTTOM)
     
     # Create radio buttons for selecting LD element modifier
     self.ModifierRadioButtons = {}
     first = True
     element_modifiers = ([CONTACT_NORMAL, CONTACT_REVERSE, 
                           CONTACT_RISING, CONTACT_FALLING]
                          if type == "contact"
                          else [COIL_NORMAL, COIL_REVERSE, COIL_SET,
                                COIL_RESET, COIL_RISING, COIL_FALLING])
     modifiers_label = [_("Normal"), _("Negated")] + \
                       ([_("Set"), _("Reset")] if type == "coil" else []) + \
                       [_("Rising Edge"), _("Falling Edge")]
     
     for modifier, label in zip(element_modifiers, modifiers_label):
         radio_button = wx.RadioButton(self, label=label, 
               style=(wx.RB_GROUP if first else 0))
         radio_button.SetValue(first)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button)
         self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
         self.ModifierRadioButtons[modifier] = radio_button
         first = False
     
     # Create label for LD element variable
     element_variable_label = wx.StaticText(self, label=_('Variable:'))
     self.LeftGridSizer.AddWindow(element_variable_label, border=5,
           flag=wx.GROW|wx.TOP)
     
     # Create a combo box for defining LD element variable
     self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT)
     self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, 
               self.ElementVariable)
     self.LeftGridSizer.AddWindow(self.ElementVariable, border=5,
          flag=wx.GROW|wx.TOP)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Save LD element class
     self.ElementClass = (LD_Contact if type == "contact" else LD_Coil)
     
     # Extract list of variables defined in POU
     self.RefreshVariableList()
     
     # Set values in ElementVariable
     for name, (var_type, value_type) in self.VariableList.iteritems():
         # Only select BOOL variable and avoid input for coil
         if (type == "contact" or var_type != "Input") and \
            value_type == "BOOL":
             self.ElementVariable.Append(name)
     
     # Normal radio button is default control having keyboard focus
     self.ModifierRadioButtons[element_modifiers[0]].SetFocus()
Example #24
0
    def __init__(self, parent, controller, tagname, type):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param type: Type of LD element ('contact or 'coil')
        """
        BlockPreviewDialog.__init__(
            self,
            parent,
            controller,
            tagname,
            size=wx.Size(350, 320 if type == "contact" else 380),
            title=(_("Edit Contact Values")
                   if type == "contact" else _("Edit Coil Values")))

        # Init common sizers
        self._init_sizers(2, 0, (7 if type == "contact" else 9), None, 2, 1)

        # Create label for LD element modifier
        modifier_label = wx.StaticText(self, label=_('Modifier:'))
        self.LeftGridSizer.AddWindow(modifier_label,
                                     border=5,
                                     flag=wx.GROW | wx.BOTTOM)

        # Create radio buttons for selecting LD element modifier
        self.ModifierRadioButtons = {}
        first = True
        element_modifiers = ([
            CONTACT_NORMAL, CONTACT_REVERSE, CONTACT_RISING, CONTACT_FALLING
        ] if type == "contact" else [
            COIL_NORMAL, COIL_REVERSE, COIL_SET, COIL_RESET, COIL_RISING,
            COIL_FALLING
        ])
        modifiers_label = [_("Normal"), _("Negated")] + \
                          ([_("Set"), _("Reset")] if type == "coil" else []) + \
                          [_("Rising Edge"), _("Falling Edge")]

        for modifier, label in zip(element_modifiers, modifiers_label):
            radio_button = wx.RadioButton(self,
                                          label=label,
                                          style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            self.ModifierRadioButtons[modifier] = radio_button
            first = False

        # Create label for LD element variable
        element_variable_label = wx.StaticText(self, label=_('Variable:'))
        self.LeftGridSizer.AddWindow(element_variable_label,
                                     border=5,
                                     flag=wx.GROW | wx.TOP)

        # Create a combo box for defining LD element variable
        self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT)
        self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged,
                  self.ElementVariable)
        self.LeftGridSizer.AddWindow(self.ElementVariable,
                                     border=5,
                                     flag=wx.GROW | wx.TOP)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Save LD element class
        self.ElementClass = (LD_Contact if type == "contact" else LD_Coil)

        # Extract list of variables defined in POU
        self.RefreshVariableList()

        # Set values in ElementVariable
        for name, (var_type, value_type) in self.VariableList.iteritems():
            # Only select BOOL variable and avoid input for coil
            if (type == "contact" or var_type != "Input") and \
               value_type == "BOOL":
                self.ElementVariable.Append(name)

        # Normal radio button is default control having keyboard focus
        self.ModifierRadioButtons[element_modifiers[0]].SetFocus()
Example #25
0
 def __init__(self, parent, controller, tagname, apply_button=False):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     @param apply_button: Enable button for applying connector modification
     to all connector having the same name in POU (default: False)
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname, 
           size=wx.Size(350, 220), title=_('Connection Properties'))
     
     # Init common sizers
     self._init_sizers(2, 0, 5, None, 2, 1)
     
     # Create label for connection type
     type_label = wx.StaticText(self, label=_('Type:'))
     self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
     
     # Create radio buttons for selecting connection type
     self.TypeRadioButtons = {}
     first = True
     for type, label in [(CONNECTOR, _('Connector')),
                         (CONTINUATION, _('Continuation'))]:
         radio_button = wx.RadioButton(self, label=label, 
               style=(wx.RB_GROUP if first else 0))
         radio_button.SetValue(first)
         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
         self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
         self.TypeRadioButtons[type] = radio_button
         first = False
     
     # Create label for connection name
     name_label = wx.StaticText(self, label=_('Name:'))
     self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)
     
     # Create text control for defining connection name
     self.ConnectionName = wx.TextCtrl(self)
     self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
     self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Add button for applying connection name modification to all connection
     # of POU
     if apply_button:
         self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name"))
         self.ApplyToAllButton.SetToolTipString(
             _("Apply name modification to all continuations with the same name"))
         self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton)
         self.ButtonSizer.AddWindow(self.ApplyToAllButton, 
                 border=(3 if wx.Platform == '__WXMSW__' else 10),
                 flag=wx.LEFT)
     else:
         self.ConnectionName.ChangeValue(
             controller.GenerateNewName(
                     tagname, None, "Connection%d", 0))
     
     # Connector radio button is default control having keyboard focus
     self.TypeRadioButtons[CONNECTOR].SetFocus()
Example #26
0
    def __init__(self, parent, controller, tagname, connection=True):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param connection: True if transition value can be defined by a
        connection (default: True)
        """
        BlockPreviewDialog.__init__(self,
                                    parent,
                                    controller,
                                    tagname,
                                    size=wx.Size(350, 350),
                                    title=_('Edit transition'))

        # Init common sizers
        self._init_sizers(2, 0, 8, None, 2, 1)

        # Create label for transition type
        type_label = wx.StaticText(self, label=_('Type:'))
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)

        # Create combo box for selecting reference value
        reference = wx.ComboBox(self, style=wx.CB_READONLY)
        reference.Append("")
        for transition in controller.GetEditedElementTransitions(tagname):
            reference.Append(transition)
        self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, reference)

        # Create Text control for defining inline value
        inline = wx.TextCtrl(self)
        self.Bind(wx.EVT_TEXT, self.OnInlineChanged, inline)

        # Create radio buttons for selecting power rail type
        self.TypeRadioButtons = {}
        first = True
        for type, label, control in [('reference', _('Reference'), reference),
                                     ('inline', _('Inline'), inline),
                                     ('connection', _('Connection'), None)]:
            radio_button = wx.RadioButton(self,
                                          label=label,
                                          style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            if control is not None:
                control.Enable(first)
                self.LeftGridSizer.AddWindow(control, flag=wx.GROW)
            self.TypeRadioButtons[type] = (radio_button, control)
            first = False

        # Create label for transition priority
        priority_label = wx.StaticText(self, label=_('Priority:'))
        self.LeftGridSizer.AddWindow(priority_label, flag=wx.GROW)

        # Create spin control for defining priority value
        self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
        self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority)
        self.LeftGridSizer.AddWindow(self.Priority, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Reference radio button is default control having keyboard focus
        self.TypeRadioButtons["reference"][0].SetFocus()
Example #27
0
 def __init__(self, parent, controller, tagname, exclude_input=False):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     @param exclude_input: Exclude input from variable class selection
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname,
           size=wx.Size(400, 380), title=_('Variable Properties'))
     
     # Init common sizers
     self._init_sizers(4, 2, 4, None, 3, 2)
     
     # Create label for variable class
     class_label = wx.StaticText(self, label=_('Class:'))
     self.LeftGridSizer.AddWindow(class_label, flag=wx.GROW)
     
     # Create a combo box for defining variable class
     self.Class = wx.ComboBox(self, style=wx.CB_READONLY)
     self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, self.Class)
     self.LeftGridSizer.AddWindow(self.Class, flag=wx.GROW)
     
     # Create label for variable execution order
     execution_order_label = wx.StaticText(self, 
           label=_('Execution Order:'))
     self.LeftGridSizer.AddWindow(execution_order_label, flag=wx.GROW)
     
     # Create spin control for defining variable execution order
     self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
     self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, 
               self.ExecutionOrder)
     self.LeftGridSizer.AddWindow(self.ExecutionOrder, flag=wx.GROW)
     
     # Create label for variable expression
     name_label = wx.StaticText(self, label=_('Expression:'))
     self.RightGridSizer.AddWindow(name_label, border=5, 
           flag=wx.GROW|wx.BOTTOM)
     
     # Create text control for defining variable expression
     self.Expression = wx.TextCtrl(self)
     self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, self.Expression)
     self.RightGridSizer.AddWindow(self.Expression, flag=wx.GROW)
     
     # Create a list box to selected variable expression in the list of
     # variables defined in POU
     self.VariableName = wx.ListBox(self, size=wx.Size(0, 120), 
           style=wx.LB_SINGLE|wx.LB_SORT)
     self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, self.VariableName)
     self.RightGridSizer.AddWindow(self.VariableName, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.MainSizer.AddWindow(self.PreviewLabel, border=20,
           flag=wx.GROW|wx.LEFT|wx.RIGHT)
     self.MainSizer.AddWindow(self.Preview, border=20,
           flag=wx.GROW|wx.LEFT|wx.RIGHT)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Set options that can be selected in class combo box
     for var_class, choice in VARIABLE_CLASSES_DICT.iteritems():
         if not exclude_input or var_class != INPUT:
             self.Class.Append(choice)
     self.Class.SetSelection(0)
     
     # Extract list of variables defined in POU
     self.RefreshVariableList()
     
     # Refresh values in name list box
     self.RefreshNameList()
     
     # Class combo box is default control having keyboard focus
     self.Class.SetFocus()
Example #28
0
 def __init__(self, parent, controller, tagname):
     """
     Constructor
     @param parent: Parent wx.Window of dialog for modal
     @param controller: Reference to project controller
     @param tagname: Tagname of project POU edited
     """
     BlockPreviewDialog.__init__(self, parent, controller, tagname,
           size=wx.Size(600, 450), title=_('Block Properties'))
     
     # Init common sizers
     self._init_sizers(2, 0, 1, 0, 3, 2)
     
     # Create static box around library panel
     type_staticbox = wx.StaticBox(self, label=_('Type:'))
     left_staticboxsizer = wx.StaticBoxSizer(type_staticbox, wx.VERTICAL)
     self.LeftGridSizer.AddSizer(left_staticboxsizer, border=5, flag=wx.GROW)
     
     # Create Library panel and add it to static box
     self.LibraryPanel = LibraryPanel(self)
     # Set function to call when selection in Library panel changed
     setattr(self.LibraryPanel, "_OnTreeItemSelected", 
           self.OnLibraryTreeItemSelected)
     left_staticboxsizer.AddWindow(self.LibraryPanel, 1, border=5, 
           flag=wx.GROW|wx.TOP)
     
     # Create sizer for other block parameters
     top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5)
     top_right_gridsizer.AddGrowableCol(1)
     self.RightGridSizer.AddSizer(top_right_gridsizer, flag=wx.GROW)
     
     # Create label for block name
     name_label = wx.StaticText(self, label=_('Name:'))
     top_right_gridsizer.AddWindow(name_label, 
           flag=wx.ALIGN_CENTER_VERTICAL)
     
     # Create text control for defining block name
     self.BlockName = wx.TextCtrl(self)
     self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName)
     top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW)
     
     # Create label for extended block input number
     inputs_label = wx.StaticText(self, label=_('Inputs:'))
     top_right_gridsizer.AddWindow(inputs_label, 
           flag=wx.ALIGN_CENTER_VERTICAL)
     
     # Create spin control for defining extended block input number
     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)
     
     # Create label for block execution order
     execution_order_label = wx.StaticText(self, 
           label=_('Execution Order:'))
     top_right_gridsizer.AddWindow(execution_order_label, 
           flag=wx.ALIGN_CENTER_VERTICAL)
     
     # Create spin control for defining block execution order
     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)
             
     # Create label for block execution control
     execution_control_label = wx.StaticText(self, 
           label=_('Execution Control:'))
     top_right_gridsizer.AddWindow(execution_control_label, 
           flag=wx.ALIGN_CENTER_VERTICAL)
     
     # Create check box to enable block execution control
     self.ExecutionControl = wx.CheckBox(self)
     self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, 
               self.ExecutionControl)
     top_right_gridsizer.AddWindow(self.ExecutionControl, flag=wx.GROW)
     
     # Add preview panel and associated label to sizers
     self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
     self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
     
     # Add buttons sizer to sizers
     self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
           flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
     
     # Dictionary containing correspondence between parameter exchanged and
     # control to fill with parameter value
     self.ParamsControl = {
         "extension": self.Inputs,
         "executionOrder": self.ExecutionOrder,
         "executionControl": self.ExecutionControl
     }
     
     # Init controls value and sensibility
     self.BlockName.SetValue("")
     self.BlockName.Enable(False)
     self.Inputs.Enable(False)
     
     # Variable containing last name typed
     self.CurrentBlockName = None
     
     # Refresh Library panel values
     self.LibraryPanel.SetBlockList(controller.GetBlockTypes(tagname))
     self.LibraryPanel.SetFocus()
Example #29
0
    def __init__(self, parent, controller, tagname, poss_div_types=None):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        @param poss_div_types: Types of divergence that will be available in the dialog window
        """
        BlockPreviewDialog.__init__(
            self,
            parent,
            controller,
            tagname,
            size=wx.Size(500, 300),
            title=_('Create a new divergence or convergence'))

        # Init common sizers
        self._init_sizers(2, 0, 7, None, 2, 1)

        # Create label for divergence type
        type_label = wx.StaticText(self, label=_('Type:'))
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)

        # Create radio buttons for selecting divergence type
        divergence_buttons = [
            (SELECTION_DIVERGENCE, _('Selection Divergence')),
            (SELECTION_CONVERGENCE, _('Selection Convergence')),
            (SIMULTANEOUS_DIVERGENCE, _('Simultaneous Divergence')),
            (SIMULTANEOUS_CONVERGENCE, _('Simultaneous Convergence'))
        ]
        poss_div_btns = []
        if poss_div_types is not None:
            for val in poss_div_types:
                poss_div_btns.append(divergence_buttons[val])
        else:
            poss_div_btns = divergence_buttons
        self.TypeRadioButtons = {}
        first = True
        focusbtn = None
        for type, label in poss_div_btns:
            radio_button = wx.RadioButton(self,
                                          label=label,
                                          style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            self.TypeRadioButtons[type] = radio_button
            if first: focusbtn = type
            first = False

        # Create label for number of divergence sequences
        sequences_label = wx.StaticText(self, label=_('Number of sequences:'))
        self.LeftGridSizer.AddWindow(sequences_label, flag=wx.GROW)

        # Create spin control for defining number of divergence sequences
        self.Sequences = wx.SpinCtrl(self, min=2, max=20, initial=2)
        self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences)
        self.LeftGridSizer.AddWindow(self.Sequences, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(self.ButtonSizer,
                                border=20,
                                flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT
                                | wx.RIGHT)

        # Selection divergence radio button is default control having keyboard
        # focus
        self.TypeRadioButtons[focusbtn].SetFocus()