controls/ProjectPropertiesPanel.py
author Laurent Bessard
Mon, 04 Jun 2012 02:04:29 +0200
changeset 703 1a14560e10ed
parent 702 ece862b07321
child 711 5f6a743dcde5
permissions -rw-r--r--
Fix bug when reloading project layout, PouIntanceVariablesPanel not updated
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     3
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     5
#based on the plcopen standard. 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     6
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     7
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     8
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     9
#See COPYING file for copyrights details.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    10
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    15
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    19
#General Public License for more details.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    20
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    24
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    25
import wx
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    26
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    27
REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"]
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    28
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    29
class ProjectPropertiesPanel(wx.Notebook):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    30
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    31
    def AddSizerParams(self, parent, sizer, params):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    32
        for idx, (name, label) in enumerate(params):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    33
            border = 0
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    34
            if idx == 0:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    35
                border |= wx.TOP
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    36
            elif idx == len(params) - 1:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    37
                border |= wx.BOTTOM
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    38
            
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    39
            st = wx.StaticText(id=-1, parent=parent, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    40
                  label=label, name=name + '_label',
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    41
                  pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    42
            sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    43
            
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    44
            tc_id = wx.NewId()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    45
            tc = wx.TextCtrl(id=tc_id, parent=parent, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    46
                  name=name, pos=wx.Point(0, 0), 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    47
                  size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    48
            setattr(self, name, tc)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    49
            callback = self.GetTextCtrlChangedFunction(tc, name)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    50
            self.Bind(wx.EVT_TEXT_ENTER, callback, id=tc_id)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    51
            tc.Bind(wx.EVT_KILL_FOCUS, callback)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    52
            sizer.AddWindow(tc, 0, border=10, flag=wx.GROW|border|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    53
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    54
    def __init__(self, parent, controller=None, window=None, enable_required=True):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    55
        wx.Notebook.__init__(self, id=-1, parent=parent, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    56
              name='ProjectPropertiesPanel', style=0, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    57
              pos=wx.Point(0, 0), size=wx.Size(500, 300))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    58
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    59
        self.Controller = controller
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    60
        self.ParentWindow = window
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    61
        self.Values = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    62
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    63
        # Project Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    64
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    65
        self.ProjectPanel = wx.Panel(id=-1, parent=self, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    66
              name='ProjectPanel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    67
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    68
        projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    69
        projectpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    70
        self.ProjectPanel.SetSizer(projectpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    71
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    72
        self.AddSizerParams(self.ProjectPanel, projectpanel_sizer,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    73
              [("projectName", _('Project Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    74
               ("projectVersion", _('Project Version (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    75
               ("productName", _('Product Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    76
               ("productVersion", _('Product Version (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    77
               ("productRelease", _('Product Release (optional):'))])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    78
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    79
        self.AddPage(self.ProjectPanel, _("Project"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    80
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    81
        # Author Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    82
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    83
        self.AuthorPanel = wx.Panel(id=-1, parent=self,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    84
              name='AuthorPanel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    85
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    86
        authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    87
        authorpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    88
        self.AuthorPanel.SetSizer(authorpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    89
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    90
        self.AddSizerParams(self.AuthorPanel, authorpanel_sizer,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    91
              [("companyName", _('Company Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    92
               ("companyURL", _('Company URL (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    93
               ("authorName", _('Author Name (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    94
               ("organization", _('Organization (optional):'))])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    95
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    96
        self.AddPage(self.AuthorPanel, _("Author"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    97
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    98
        # Graphics Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    99
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   100
        self.GraphicsPanel = wx.Panel(id=-1, parent=self, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   101
              name='GraphicsPanel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   102
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   103
        graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   104
        graphicpanel_sizer.AddGrowableCol(0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   105
        graphicpanel_sizer.AddGrowableRow(3)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   106
        self.GraphicsPanel.SetSizer(graphicpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   107
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   108
        pageSize_st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   109
              label=_('Page Size (optional):'), name='pageSize_label', 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   110
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   111
        graphicpanel_sizer.AddWindow(pageSize_st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   112
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   113
        pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   114
        pageSize_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   115
        graphicpanel_sizer.AddSizer(pageSize_sizer, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   116
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   117
        for name, label in [('PageWidth', _('Width:')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   118
                            ('PageHeight', _('Height:'))]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   119
            st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   120
                  label=label, name=name + "_label",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   121
                  pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   122
            pageSize_sizer.AddWindow(st, 0, border=12, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   123
            
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   124
            sp_id = wx.NewId()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   125
            sp = wx.SpinCtrl(id=sp_id, parent=self.GraphicsPanel, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   126
                  name=name, pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   127
                  size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   128
                  min=0, max=2**16)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   129
            setattr(self, name, sp)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   130
            callback = self.GetPageSizeChangedFunction(sp, name)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   131
            self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   132
            sp.Bind(wx.EVT_KILL_FOCUS, callback)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   133
            pageSize_sizer.AddWindow(sp, 0, border=0, flag=wx.GROW)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   134
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   135
        scaling_st = wx.StaticText(id=-1, parent=self.GraphicsPanel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   136
              label=_('Grid Resolution:'), name='scaling_label', 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   137
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   138
        graphicpanel_sizer.AddWindow(scaling_st, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   139
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   140
        scaling_nb = wx.Notebook(id=-1, parent=self.GraphicsPanel, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   141
              name='ScalingNotebook', pos=wx.Point(0, 0), 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   142
              size=wx.Size(0, 0), style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   143
        graphicpanel_sizer.AddWindow(scaling_nb, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   144
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   145
        self.Scalings = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   146
        for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   147
            scaling_panel = wx.Panel(id=-1, parent=scaling_nb, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   148
                  name=language + '_panel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   149
                  size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   150
            scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   151
            scalingpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   152
            scaling_panel.SetSizer(scalingpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   153
            
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   154
            scaling_controls = []
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   155
            for idx, (name, label) in enumerate([('XScale', _('Horizontal:')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   156
                                                 ('YScale', _('Vertical:'))]):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   157
                if idx == 0:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   158
                    border = wx.TOP
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   159
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   160
                    border = wx.BOTTOM
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   161
                
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   162
                st = wx.StaticText(id=-1, parent=scaling_panel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   163
                      label=label, name=name + '_label', 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   164
                      pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   165
                scalingpanel_sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   166
                
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   167
                sp_id = wx.NewId()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   168
                sp = wx.SpinCtrl(id=sp_id, parent=scaling_panel, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   169
                      name=name, pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   170
                      size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   171
                      min=0, max=2**16)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   172
                scaling_controls.append(sp)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   173
                callback = self.GetScalingChangedFunction(sp, language, name)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   174
                self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   175
                sp.Bind(wx.EVT_KILL_FOCUS, callback)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   176
                scalingpanel_sizer.AddWindow(sp, 0, border=10, flag=wx.GROW|border|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   177
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   178
            self.Scalings[language] = scaling_controls
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   179
            scaling_nb.AddPage(scaling_panel, translation)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   180
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   181
        self.AddPage(self.GraphicsPanel, _("Graphics"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   182
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   183
        # Miscellaneous Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   184
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   185
        self.MiscellaneousPanel = wx.Panel(id=-1, parent=self, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   186
              name='MiscellaneousPanel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   187
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   188
        miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   189
        miscellaneouspanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   190
        miscellaneouspanel_sizer.AddGrowableRow(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   191
        self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   192
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   193
        language_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   194
              label=_('Language (optional):'), name='language_label', 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   195
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   196
        miscellaneouspanel_sizer.AddWindow(language_label, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   197
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   198
        language_id = wx.NewId()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   199
        self.Language = wx.ComboBox(id=language_id, parent=self.MiscellaneousPanel, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   200
              name='Language', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   201
              size=wx.Size(0, 28), style=wx.CB_READONLY)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   202
        self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, id=language_id)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   203
        miscellaneouspanel_sizer.AddWindow(self.Language, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   204
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   205
        description_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   206
              label=_('Content Description (optional):'), name='description_label', 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   207
              pos=wx.Point(0, 0), size=wx.DefaultSize, style=0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   208
        miscellaneouspanel_sizer.AddWindow(description_label, 0, border=10, flag=wx.BOTTOM|wx.LEFT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   209
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   210
        description_id = wx.NewId()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   211
        self.ContentDescription = wx.TextCtrl(id=description_id, parent=self.MiscellaneousPanel, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   212
              name='ContentDescription', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   213
              size=wx.Size(0, 24), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   214
        self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, id=description_id)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   215
        self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, self.OnContentDescriptionChanged)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   216
        miscellaneouspanel_sizer.AddWindow(self.ContentDescription, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   217
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   218
        self.AddPage(self.MiscellaneousPanel, _("Miscellaneous"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   219
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   220
        for param in REQUIRED_PARAMS:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   221
            getattr(self, param).Enable(enable_required)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   222
           
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   223
        languages = ["", "en-US", "fr-FR", "zh-CN"]
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   224
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   225
        for language in languages:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   226
            self.Language.Append(language)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   227
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   228
    def RefreshView(self):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   229
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   230
            self.SetValues(self.Controller.GetProjectProperties())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   231
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   232
    def SetValues(self, values):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   233
        self.Values = values
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   234
        for item, value in values.items():
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   235
            if item == "language":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   236
                self.Language.SetStringSelection(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   237
            elif item == "contentDescription":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   238
                self.ContentDescription.SetValue(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   239
            elif item == "pageSize":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   240
                self.PageWidth.SetValue(value[0])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   241
                self.PageHeight.SetValue(value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   242
            elif item == "scaling":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   243
                for language, (x, y) in value.items():
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   244
                    if language in self.Scalings:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   245
                        self.Scalings[language][0].SetValue(x)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   246
                        self.Scalings[language][1].SetValue(y)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   247
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   248
                tc = getattr(self, item, None)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   249
                if tc is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   250
                    tc.SetValue(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   251
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   252
    def GetValues(self):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   253
        values = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   254
        for param in ["projectName", "projectVersion",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   255
                      "productName", "productVersion",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   256
                      "productRelease", "companyName",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   257
                      "companyURL", "authorName", 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   258
                      "organization"]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   259
            value = getattr(self, param).GetValue()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   260
            if param in REQUIRED_PARAMS or value != "":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   261
                values[param] = value
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   262
            else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   263
                values[param] = None
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   264
        language = self.Language.GetStringSelection()
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   265
        if language != "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   266
            values["language"] = language
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   267
        else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   268
            values["language"] = None
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   269
        content_description = self.ContentDescription.GetValue()
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   270
        if content_description != "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   271
            values["contentDescription"] = content_description
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   272
        else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   273
            values["contentDescription"] = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   274
        values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   275
        values["scaling"] = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   276
        for language in ["FBD", "LD", "SFC"]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   277
            values["scaling"][language] = (self.Scalings[language][0].GetValue(),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   278
                                           self.Scalings[language][1].GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   279
        return values
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   280
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   281
    def GetTextCtrlChangedFunction(self, textctrl, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   282
        def TextCtrlChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   283
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   284
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   285
                    old_value = self.Values.get(name)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   286
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   287
                    old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   288
                new_value = textctrl.GetValue()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   289
                if name not in REQUIRED_PARAMS and new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   290
                    new_value = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   291
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   292
                    self.Controller.SetProjectProperties(properties={name: new_value})
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   293
                    self.ParentWindow.RefreshTitle()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   294
                    self.ParentWindow.RefreshFileMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   295
                    self.ParentWindow.RefreshEditMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   296
                    self.ParentWindow.RefreshProjectTree()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   297
                    self.ParentWindow.RefreshPageTitles()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   298
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   299
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   300
        return TextCtrlChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   301
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   302
    def GetPageSizeChangedFunction(self, spinctrl, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   303
        def PageSizeChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   304
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   305
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   306
                    old_value = self.Values.get("pageSize")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   307
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   308
                    old_value = (0, 0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   309
                if name == 'PageWidth':
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   310
                    new_value = (spinctrl.GetValue(), old_value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   311
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   312
                    new_value = (old_value[0], spinctrl.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   313
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   314
                    self.Controller.SetProjectProperties(properties={"pageSize": new_value})
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   315
                    self.ParentWindow.RefreshTitle()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   316
                    self.ParentWindow.RefreshFileMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   317
                    self.ParentWindow.RefreshEditMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   318
                    self.ParentWindow.RefreshPageTitles()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   319
                    self.ParentWindow.RefreshScaling()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   320
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   321
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   322
        return PageSizeChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   323
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   324
    def GetScalingChangedFunction(self, spinctrl, language, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   325
        def ScalingChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   326
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   327
                old_value = (0, 0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   328
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   329
                    scaling = self.Values.get("scaling")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   330
                    if scaling is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   331
                        old_value = scaling.get(language)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   332
                if name == 'XScale':
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   333
                    new_value = (spinctrl.GetValue(), old_value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   334
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   335
                    new_value = (old_value[0], spinctrl.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   336
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   337
                    self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}})
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   338
                    self.ParentWindow.RefreshTitle()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   339
                    self.ParentWindow.RefreshFileMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   340
                    self.ParentWindow.RefreshEditMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   341
                    self.ParentWindow.RefreshPageTitles()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   342
                    self.ParentWindow.RefreshScaling()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   343
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   344
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   345
        return ScalingChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   346
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   347
    def OnLanguageChanged(self, event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   348
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   349
            if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   350
                old_value = self.Values.get("language")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   351
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   352
                old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   353
            new_value = self.Language.GetStringSelection()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   354
            if new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   355
                new_value = None
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   356
            print old_value, new_value
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   357
            if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   358
                self.Controller.SetProjectProperties(properties={"language": new_value})
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   359
                self.ParentWindow.RefreshTitle()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   360
                self.ParentWindow.RefreshFileMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   361
                self.ParentWindow.RefreshEditMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   362
                self.ParentWindow.RefreshPageTitles()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   363
                wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   364
        event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   365
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   366
    def OnContentDescriptionChanged(self, event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   367
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   368
            if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   369
                old_value = self.Values.get("contentDescription")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   370
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   371
                old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   372
            new_value = self.ContentDescription.GetValue()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   373
            if new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   374
                new_value = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   375
            if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   376
                self.Controller.SetProjectProperties(properties={"contentDescription": new_value})
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   377
                self.ParentWindow.RefreshTitle()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   378
                self.ParentWindow.RefreshFileMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   379
                self.ParentWindow.RefreshEditMenu()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   380
                self.ParentWindow.RefreshPageTitles()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   381
                wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   382
        event.Skip()