dialogs/ConnectionDialog.py
changeset 1696 8043f32de7b8
parent 1571 486f94a8032c
child 1730 64d8f52bc8c8
equal deleted inserted replaced
1695:a63bb4025852 1696:8043f32de7b8
     3 
     3 
     4 # This file is part of Beremiz, a Integrated Development Environment for
     4 # This file is part of Beremiz, a Integrated Development Environment for
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     6 #
     6 #
     7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
     7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
       
     8 # Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com>
     8 #
     9 #
     9 # See COPYING file for copyrights details.
    10 # See COPYING file for copyrights details.
    10 #
    11 #
    11 # This program is free software; you can redistribute it and/or
    12 # This program is free software; you can redistribute it and/or
    12 # modify it under the terms of the GNU General Public License
    13 # modify it under the terms of the GNU General Public License
    47         @param tagname: Tagname of project POU edited
    48         @param tagname: Tagname of project POU edited
    48         @param apply_button: Enable button for applying connector modification
    49         @param apply_button: Enable button for applying connector modification
    49         to all connector having the same name in POU (default: False)
    50         to all connector having the same name in POU (default: False)
    50         """
    51         """
    51         BlockPreviewDialog.__init__(self, parent, controller, tagname, 
    52         BlockPreviewDialog.__init__(self, parent, controller, tagname, 
    52               size=wx.Size(350, 250), title=_('Connection Properties'))
    53               title=_('Connection Properties'))
    53         
    54         
    54         # Init common sizers
    55         # Init common sizers
    55         self._init_sizers(2, 0, 5, None, 2, 1)
    56         self._init_sizers(2, 0, 7, 1, 0, None)
    56         
    57         
    57         # Create label for connection type
    58         # Create label for connection type
    58         type_label = wx.StaticText(self, label=_('Type:'))
    59         type_label = wx.StaticText(self, label=_('Type:'))
    59         self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
    60         self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
    60         
    61         
    75         name_label = wx.StaticText(self, label=_('Name:'))
    76         name_label = wx.StaticText(self, label=_('Name:'))
    76         self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)
    77         self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)
    77         
    78         
    78         # Create text control for defining connection name
    79         # Create text control for defining connection name
    79         self.ConnectionName = wx.TextCtrl(self)
    80         self.ConnectionName = wx.TextCtrl(self)
       
    81         self.ConnectionName.SetMinSize(wx.Size(200,-1))
    80         self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
    82         self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
    81         self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW)
    83         self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW)
    82         
    84         
    83         # Add preview panel and associated label to sizers
    85         # Add preview panel and associated label to sizers
    84         self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
    86         self.Preview.SetMinSize(wx.Size(-1,100))
    85         self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
    87         self.LeftGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
       
    88         self.LeftGridSizer.AddWindow(self.Preview, flag=wx.GROW)
    86         
    89         
    87         # Add buttons sizer to sizers
    90         # Add buttons sizer to sizers
    88         self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
    91         self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
    89               flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
    92               flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
       
    93         self.ColumnSizer.RemoveSizer(self.RightGridSizer)
    90         
    94         
    91         # Add button for applying connection name modification to all connection
    95         # Add button for applying connection name modification to all connection
    92         # of POU
    96         # of POU
    93         if apply_button:
    97         if apply_button:
    94             self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name"))
    98             self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name"))
    95             self.ApplyToAllButton.SetToolTipString(
    99             self.ApplyToAllButton.SetToolTipString(
    96                 _("Apply name modification to all continuations with the same name"))
   100                 _("Apply name modification to all continuations with the same name"))
    97             self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton)
   101             self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton)
    98             self.ButtonSizer.AddWindow(self.ApplyToAllButton, 
   102             self.ButtonSizer.AddWindow(self.ApplyToAllButton, flag=wx.LEFT)
    99                     border=(3 if wx.Platform == '__WXMSW__' else 10),
       
   100                     flag=wx.LEFT)
       
   101         else:
   103         else:
   102             self.ConnectionName.ChangeValue(
   104             self.ConnectionName.ChangeValue(
   103                 controller.GenerateNewName(
   105                 controller.GenerateNewName(
   104                         tagname, None, "Connection%d", 0))
   106                         tagname, None, "Connection%d", 0))
       
   107         self.Fit()
   105         
   108         
   106         # Connector radio button is default control having keyboard focus
   109         # Connector radio button is default control having keyboard focus
   107         self.TypeRadioButtons[CONNECTOR].SetFocus()
   110         self.TypeRadioButtons[CONNECTOR].SetFocus()
   108     
   111     
   109     def GetConnectionType(self):
   112     def GetConnectionType(self):