dialogs/FBDVariableDialog.py
author laurent
Thu, 24 Sep 2009 18:18:04 +0200
changeset 436 f3bb091f803f
parent 409 34c9f624c2fe
child 488 93bf600bae11
permissions -rw-r--r--
Fix BrowseVariableDialog to be used in PLCOpenEditor without Beremiz plugins
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     1
#!/usr/bin/env python
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     3
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     5
#based on the plcopen standard. 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     6
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     7
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     8
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     9
#See COPYING file for copyrights details.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    10
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    15
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    19
#General Public License for more details.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    20
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    24
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    25
import wx
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    26
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    27
from graphics import *
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    28
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    29
#-------------------------------------------------------------------------------
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    30
#                          Create New Variable Dialog
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    31
#-------------------------------------------------------------------------------
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    32
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    33
[ID_FBDVARIABLEDIALOG, ID_FBDVARIABLEDIALOGSPACER, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    34
 ID_FBDVARIABLEDIALOGNAME, ID_FBDVARIABLEDIALOGCLASS, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    35
 ID_FBDVARIABLEDIALOGPREVIEW, ID_FBDVARIABLEDIALOGEXPRESSION,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    36
 ID_FBDVARIABLEDIALOGEXECUTIONORDER, ID_FBDVARIABLEDIALOGSTATICTEXT1, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    37
 ID_FBDVARIABLEDIALOGSTATICTEXT2, ID_FBDVARIABLEDIALOGSTATICTEXT3, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    38
 ID_FBDVARIABLEDIALOGSTATICTEXT4, ID_FBDVARIABLEDIALOGSTATICTEXT5
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    39
] = [wx.NewId() for _init_ctrls in range(12)]
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    40
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    41
VARIABLE_CLASSES_DICT = {INPUT : _("Input"),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    42
                         INOUT : _("InOut"),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    43
                         OUTPUT : _("Output")}
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    44
VARIABLE_CLASSES_DICT_REVERSE = dict([(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    45
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    46
class FBDVariableDialog(wx.Dialog):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    47
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    48
    if wx.VERSION < (2, 6, 0):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    49
        def Bind(self, event, function, id = None):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    50
            if id is not None:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    51
                event(self, id, function)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    52
            else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    53
                event(self, function)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    54
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    55
    def _init_coll_flexGridSizer1_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    56
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    57
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    58
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    59
    def _init_coll_flexGridSizer1_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    60
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    61
        parent.AddGrowableRow(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    62
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    63
    def _init_coll_MainSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    64
        parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    65
        parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    66
        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    67
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    68
    def _init_coll_MainSizer_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    69
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    70
        parent.AddGrowableRow(2)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    71
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    72
    def _init_coll_TopSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    73
        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    74
        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    75
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    76
    def _init_coll_LeftGridSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    77
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    78
        parent.AddWindow(self.Class, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    79
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    80
        parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    81
        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    82
        parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    83
        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    84
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    85
    def _init_coll_LeftGridSizer_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    86
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    87
        parent.AddGrowableRow(2)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    88
            
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    89
    def _init_coll_RightGridSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    90
        parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    91
        parent.AddWindow(self.VariableName, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    92
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    93
    def _init_coll_RightGridSizer_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    94
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    95
        parent.AddGrowableRow(1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    96
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    97
    def _init_sizers(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    98
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    99
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   100
        self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   101
        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   102
        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   103
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   104
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   105
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   106
        self._init_coll_MainSizer_Items(self.MainSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   107
        self._init_coll_MainSizer_Growables(self.MainSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   108
        self._init_coll_TopSizer_Items(self.TopSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   109
        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   110
        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   111
        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   112
        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   113
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   114
        self.SetSizer(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   115
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   116
    def _init_ctrls(self, prnt, ctrler):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   117
        wx.Dialog.__init__(self, id=ID_FBDVARIABLEDIALOG,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   118
              name='FBDVariableDialog', parent=prnt, pos=wx.Point(376, 223),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   119
              size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   120
              title=_('Variable Properties'))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   121
        self.SetClientSize(wx.Size(400, 380))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   122
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   123
        self.staticText1 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT1,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   124
              label=_('Class:'), name='staticText1', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   125
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   126
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   127
        self.staticText2 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT2,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   128
              label=_('Expression:'), name='staticText2', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   129
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   130
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   131
        self.staticText3 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT3,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   132
              label=_('Execution Order:'), name='staticText3', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   133
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   134
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   135
        self.staticText4 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT4,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   136
              label=_('Name:'), name='staticText4', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   137
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   138
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   139
        self.staticText5 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT5,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   140
              label=_('Preview:'), name='staticText5', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   141
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   142
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   143
        self.Class = wx.ComboBox(id=ID_FBDVARIABLEDIALOGCLASS,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   144
              name='Class', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   145
              size=wx.Size(0, 28), style=wx.CB_READONLY)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   146
        self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, id=ID_FBDVARIABLEDIALOGCLASS)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   147
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   148
        self.VariableName = wx.ListBox(id=ID_FBDVARIABLEDIALOGNAME,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   149
              name='Name', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   150
              size=wx.Size(0, 90), style=wx.LB_SINGLE|wx.LB_SORT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   151
        self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_FBDVARIABLEDIALOGNAME)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   152
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   153
        self.Expression = wx.TextCtrl(id=ID_FBDVARIABLEDIALOGEXPRESSION,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   154
              name='Expression', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   155
              size=wx.Size(0, 24), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   156
        self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_FBDVARIABLEDIALOGEXPRESSION)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   157
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   158
        self.ExecutionOrder = wx.SpinCtrl(id=ID_FBDVARIABLEDIALOGEXECUTIONORDER,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   159
              name='ExecutionOrder', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   160
              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   161
        self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_FBDVARIABLEDIALOGEXECUTIONORDER)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   162
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   163
        self.Spacer = wx.Panel(id=ID_FBDVARIABLEDIALOGSPACER,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   164
              name='Spacer', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   165
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   166
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   167
        self.Preview = wx.Panel(id=ID_FBDVARIABLEDIALOGPREVIEW,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   168
              name='Preview', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   169
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   170
        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   171
        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   172
        setattr(self.Preview, "GetScaling", lambda:None)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   173
        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   174
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   175
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   176
        if wx.VERSION >= (2, 5, 0):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   177
            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   178
            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   179
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   180
            self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   181
            wx.EVT_PAINT(self.Preview, self.OnPaint)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   182
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   183
        self._init_sizers()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   184
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   185
    def __init__(self, parent, controler, transition = ""):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   186
        self._init_ctrls(parent, controler)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   187
        self.Transition = transition
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   188
        self.Variable = None
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   189
        self.VarList = []
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   190
        self.MinVariableSize = None
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   191
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   192
        for choice in VARIABLE_CLASSES_DICT.itervalues():
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   193
            self.Class.Append(choice)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   194
        self.Class.SetStringSelection(VARIABLE_CLASSES_DICT[INPUT])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   195
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   196
        self.RefreshNameList()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   197
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   198
    def SetPreviewFont(self, font):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   199
        self.Preview.SetFont(font)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   200
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   201
    def RefreshNameList(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   202
        selected = self.VariableName.GetStringSelection()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   203
        var_class = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   204
        self.VariableName.Clear()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   205
        self.VariableName.Append("")
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   206
        for name, var_type, value_type in self.VarList:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   207
            if var_type != "Input" or var_class == INPUT:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   208
                self.VariableName.Append(name)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   209
        if selected != "" and self.VariableName.FindString(selected) != wx.NOT_FOUND:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   210
            self.VariableName.SetStringSelection(selected)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   211
            self.Expression.Enable(False)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   212
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   213
            self.VariableName.SetStringSelection("")
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   214
            self.Expression.Enable(var_class == INPUT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   215
        self.VariableName.Enable(self.VariableName.GetCount() > 0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   216
            
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   217
    def SetMinVariableSize(self, size):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   218
        self.MinVariableSize = size
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   219
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   220
    def SetVariables(self, vars):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   221
        self.VarList = vars
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   222
        self.RefreshNameList()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   223
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   224
    def SetValues(self, values):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   225
        value_type = values.get("type", None)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   226
        value_name = values.get("name", None)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   227
        if value_type:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   228
            self.Class.SetStringSelection(VARIABLE_CLASSES_DICT[value_type])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   229
            self.RefreshNameList()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   230
        if value_name:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   231
            if self.VariableName.FindString(value_name) != wx.NOT_FOUND:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   232
                self.VariableName.SetStringSelection(value_name)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   233
                self.Expression.Enable(False)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   234
            else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   235
                self.Expression.SetValue(value_name)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   236
                self.VariableName.Enable(False)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   237
        if "executionOrder" in values:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   238
            self.ExecutionOrder.SetValue(values["executionOrder"])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   239
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   240
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   241
    def GetValues(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   242
        values = {}
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   243
        values["type"] = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   244
        expression = self.Expression.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   245
        if self.Expression.IsEnabled() and expression != "":
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   246
            values["name"] = expression
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   247
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   248
            values["name"] = self.VariableName.GetStringSelection()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   249
        values["value_type"] = None
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   250
        for var_name, var_type, value_type in self.VarList:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   251
            if var_name == values["name"]:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   252
                values["value_type"] = value_type
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   253
        values["width"], values["height"] = self.Variable.GetSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   254
        values["executionOrder"] = self.ExecutionOrder.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   255
        return values
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   256
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   257
    def OnOK(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   258
        expression = self.Expression.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   259
        if self.Expression.IsEnabled():
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   260
            value = expression
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   261
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   262
            value = self.VariableName.GetStringSelection()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   263
        if value == "":
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   264
            message = wx.MessageDialog(self, _("At least a variable or an expression must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   265
            message.ShowModal()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   266
            message.Destroy()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   267
        elif value.upper() in IEC_KEYWORDS:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   268
            message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   269
            message.ShowModal()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   270
            message.Destroy()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   271
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   272
            self.EndModal(wx.ID_OK)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   273
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   274
    def OnClassChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   275
        self.RefreshNameList()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   276
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   277
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   278
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   279
    def OnNameChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   280
        if self.VariableName.GetStringSelection() != "":
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   281
            self.Expression.Enable(False)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   282
        elif VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()] == INPUT:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   283
            self.Expression.Enable(True)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   284
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   285
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   286
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   287
    def OnExpressionChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   288
        if self.Expression.GetValue() != "":
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   289
            self.VariableName.Enable(False)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   290
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   291
            self.VariableName.Enable(True)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   292
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   293
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   294
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   295
    def OnExecutionOrderChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   296
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   297
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   298
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   299
    def RefreshPreview(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   300
        dc = wx.ClientDC(self.Preview)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   301
        dc.SetFont(self.Preview.GetFont())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   302
        dc.Clear()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   303
        expression = self.Expression.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   304
        if self.Expression.IsEnabled() and expression != "":
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   305
            name = expression
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   306
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   307
            name = self.VariableName.GetStringSelection()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   308
        type = ""
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   309
        for var_name, var_type, value_type in self.VarList:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   310
            if var_name == name:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   311
                type = value_type
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   312
        classtype = VARIABLE_CLASSES_DICT_REVERSE[self.Class.GetStringSelection()]
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   313
        self.Variable = FBD_Variable(self.Preview, classtype, name, type, executionOrder = self.ExecutionOrder.GetValue())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   314
        width, height = self.MinVariableSize
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   315
        min_width, min_height = self.Variable.GetMinSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   316
        width, height = max(min_width, width), max(min_height, height)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   317
        self.Variable.SetSize(width, height)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   318
        clientsize = self.Preview.GetClientSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   319
        x = (clientsize.width - width) / 2
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   320
        y = (clientsize.height - height) / 2
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   321
        self.Variable.SetPosition(x, y)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   322
        self.Variable.Draw(dc)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   323
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   324
    def OnPaint(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   325
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   326
        event.Skip()