objdictgen/commondialogs.py
author greg
Wed, 30 Jan 2008 17:23:32 +0100
changeset 374 b74f7ec412fc
parent 359 346435b94063
child 418 64a8c24b61a5
permissions -rw-r--r--
add cancfg.h dependency to rebuild can_peak_win32 driver
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     1
#!/usr/bin/env python
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     3
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     4
#This file is part of CanFestival, a library implementing CanOpen Stack. 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     5
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     6
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     7
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     8
#See COPYING file for copyrights details.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
     9
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    11
#modify it under the terms of the GNU Lesser General Public
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    14
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    18
#Lesser General Public License for more details.
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    19
#
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    20
#You should have received a copy of the GNU Lesser General Public
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    23
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    24
import wx
359
346435b94063 Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents: 328
diff changeset
    25
import wx.grid
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    26
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    27
import os
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    28
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
    29
from node import BE_to_LE, LE_to_BE
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
    30
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
    31
ScriptDirectory = os.path.split(__file__)[0]
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
    32
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    33
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    34
#                          Editing Communication Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    35
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    36
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    37
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    38
[ID_COMMUNICATIONDIALOG, ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    39
 ID_COMMUNICATIONDIALOGCURRENTINDEXES, ID_COMMUNICATIONDIALOGSELECT, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    40
 ID_COMMUNICATIONDIALOGUNSELECT, ID_COMMUNICATIONDIALOGSTATICTEXT1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    41
 ID_COMMUNICATIONDIALOGSTATICTEXT2
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    42
] = [wx.NewId() for _init_ctrls in range(7)]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    43
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    44
class CommunicationDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    45
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    46
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    47
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    48
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    49
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    50
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    51
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    52
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    53
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    54
        parent.AddSizer(self.LeftGridSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    55
        parent.AddSizer(self.MiddleGridSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    56
        parent.AddSizer(self.RightGridSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    57
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    58
    def _init_coll_MainSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    59
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    60
        parent.AddGrowableCol(2)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    61
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    62
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    63
    def _init_coll_LeftGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    64
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    65
        parent.AddWindow(self.PossibleIndexes, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    66
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    67
    def _init_coll_LeftGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    68
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    69
        parent.AddGrowableRow(1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    70
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    71
    def _init_coll_MiddleGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    72
        parent.AddWindow(self.Select, 0, border=0, flag=wx.ALIGN_BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    73
        parent.AddWindow(self.Unselect, 0, border=0, flag=wx.ALIGN_TOP)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    74
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    75
    def _init_coll_MiddleGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    76
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    77
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    78
        parent.AddGrowableRow(1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    79
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    80
    def _init_coll_RightGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    81
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    82
        parent.AddWindow(self.CurrentIndexes, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    83
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    84
    def _init_coll_RightGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    85
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    86
        parent.AddGrowableRow(1)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    87
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    88
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    89
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    90
        self.MainSizer = wx.FlexGridSizer(cols=3, hgap=15, rows=1, vgap=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    91
        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    92
        self.MiddleGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=40)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    93
        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    94
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    95
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    96
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    97
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    98
        self._init_coll_MainSizer_Growables(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
    99
        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   100
        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   101
        self._init_coll_MiddleGridSizer_Items(self.MiddleGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   102
        self._init_coll_MiddleGridSizer_Growables(self.MiddleGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   103
        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   104
        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   105
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   106
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   107
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   108
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   109
        wx.Dialog.__init__(self, id=ID_COMMUNICATIONDIALOG,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   110
              name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   111
              size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   112
              title='Edit Communication Profile')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   113
        self.SetClientSize(wx.Size(726, 437))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   114
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   115
        self.staticText1 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   116
              label='Possible Profile Indexes:', name='staticText1',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   117
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   118
              17), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   119
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   120
        self.PossibleIndexes = wx.ListBox(choices=[],
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   121
              id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   122
              name='PossibleIndexes', parent=self, pos=wx.Point(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   123
              size=wx.Size(0, 0), style=wx.LB_EXTENDED)
266
8678a3cf7fe7 Code corrections
lbessard
parents: 259
diff changeset
   124
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnPossibleIndexesDClick,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   125
              id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   126
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   127
        self.Select = wx.Button(id=ID_COMMUNICATIONDIALOGSELECT, label='>>',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   128
              name='Select', parent=self, pos=wx.Point(0, 0),
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   129
              size=wx.Size(32, 32), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   130
        self.Select.Bind(wx.EVT_BUTTON, self.OnSelectButton,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   131
              id=ID_COMMUNICATIONDIALOGSELECT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   132
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   133
        self.Unselect = wx.Button(id=ID_COMMUNICATIONDIALOGUNSELECT,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   134
              label='<<', name='Unselect', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   135
              pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   136
        self.Unselect.Bind(wx.EVT_BUTTON, self.OnUnselectButton,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   137
              id=ID_COMMUNICATIONDIALOGUNSELECT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   138
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   139
        self.staticText2 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   140
              label='Current Profile Indexes:', name='staticText2',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   141
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   142
              17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   143
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   144
        self.CurrentIndexes = wx.ListBox(choices=[],
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   145
              id=ID_COMMUNICATIONDIALOGCURRENTINDEXES, name='CurrentIndexes',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   146
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   147
              style=wx.LB_EXTENDED)
266
8678a3cf7fe7 Code corrections
lbessard
parents: 259
diff changeset
   148
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnCurrentIndexesDClick,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   149
              id=ID_COMMUNICATIONDIALOGCURRENTINDEXES)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   150
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   151
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   152
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   153
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   154
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   155
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   156
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   157
        self.AllList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   158
        self.CurrentList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   159
        self.IndexDictionary = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   160
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   161
    def SetIndexDictionary(self, dictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   162
        self.IndexDictionary = dictionary
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   163
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   164
    def SetCurrentList(self, list):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   165
        self.CurrentList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   166
        self.CurrentList.extend(list)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   167
        self.CurrentList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   168
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   169
    def GetCurrentList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   170
        return self.CurrentList
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   171
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   172
    def RefreshLists(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   173
        self.PossibleIndexes.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   174
        self.CurrentIndexes.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   175
        self.AllList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   176
        for index in self.IndexDictionary.iterkeys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   177
            if index not in self.CurrentList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   178
                self.AllList.append(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   179
        self.AllList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   180
        for index in self.AllList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   181
            self.PossibleIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   182
        for index in self.CurrentList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   183
            if index in self.IndexDictionary:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   184
                self.CurrentIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   185
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   186
    def OnPossibleIndexesDClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   187
        self.SelectPossible()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   188
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   189
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   190
    def OnCurrentIndexesDClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   191
        self.UnselectCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   192
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   193
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   194
    def OnSelectButton(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   195
        self.SelectPossible()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   196
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   197
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   198
    def OnUnselectButton(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   199
        self.UnselectCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   200
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   201
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   202
    def SelectPossible(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   203
        selected = self.PossibleIndexes.GetSelections()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   204
        for i in selected:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   205
            self.CurrentList.append(self.AllList[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   206
        self.CurrentList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   207
        self.RefreshLists()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   208
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   209
    def UnselectCurrent(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   210
        selected = self.CurrentIndexes.GetSelections()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   211
        for i in selected:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   212
            if not self.IndexDictionary[self.CurrentList[i]][1]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   213
                self.CurrentList.pop(i)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   214
        self.CurrentList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   215
        self.RefreshLists()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   216
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   217
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   218
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   219
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   220
#                          Create Map Variable Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   221
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   222
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   223
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   224
[ID_MAPVARIABLEDIALOG, ID_MAPVARIABLEDIALOGINDEX, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   225
 ID_MAPVARIABLEDIALOGINDEXNAME, ID_MAPVARIABLEDIALOGSPACER, 
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   226
 ID_MAPVARIABLEDIALOGSPACER2, ID_MAPVARIABLEDIALOGNUMBER, 
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   227
 ID_MAPVARIABLEDIALOGRADIOBUTTON1, ID_MAPVARIABLEDIALOGRADIOBUTTON2, 
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   228
 ID_MAPVARIABLEDIALOGRADIOBUTTON3, ID_MAPVARIABLEDIALOGSTATICTEXT1, 
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   229
 ID_MAPVARIABLEDIALOGSTATICTEXT2, ID_MAPVARIABLEDIALOGSTATICTEXT3, 
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   230
 ID_MAPVARIABLEDIALOGSTATICTEXT4, 
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   231
] = [wx.NewId() for _init_ctrls in range(13)]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   232
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   233
class MapVariableDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   234
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   235
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   236
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   237
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   238
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   239
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   240
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   241
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   242
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   243
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   244
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   245
        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   246
        parent.AddWindow(self.Index, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   247
        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   248
        parent.AddWindow(self.Spacer2, 0, border=0, flag=wx.GROW)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   249
        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   250
        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   251
        parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   252
        parent.AddWindow(self.IndexName, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   253
        parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   254
        parent.AddWindow(self.Number, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   255
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   256
    def _init_coll_MainSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   257
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   258
        parent.AddGrowableCol(2)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   259
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   260
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   261
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   262
        self.MainSizer = wx.FlexGridSizer(cols=3, hgap=30, rows=4, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   263
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   264
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   265
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   266
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   267
        self._init_coll_MainSizer_Growables(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   268
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   269
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   270
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   271
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   272
        wx.Dialog.__init__(self, id=ID_MAPVARIABLEDIALOG,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   273
              name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   274
              size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   275
              title='Add Map Variable')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   276
        self.SetClientSize(wx.Size(444, 186))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   277
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   278
        self.staticText1 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   279
              label='Index:', name='staticText1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   280
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   281
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   282
        self.staticText2 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   283
              label='Type:', name='staticText2', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   284
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   285
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   286
        self.staticText3 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT3,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   287
              label='Name:', name='staticText3', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   288
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   289
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   290
        self.staticText4 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT4,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   291
              label='Number:', name='staticText4', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   292
              pos=wx.Point(0, 0), size=wx.Size(0, 16), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   293
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   294
        self.radioButton1 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   295
              label='VAR', name='radioButton1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   296
              pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_GROUP)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   297
        self.radioButton1.SetValue(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   298
        self.radioButton1.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton1Click,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   299
              id=ID_MAPVARIABLEDIALOGRADIOBUTTON1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   300
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   301
        self.radioButton2 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   302
              label='ARRAY', name='radioButton2', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   303
              pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   304
        self.radioButton2.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   305
        self.radioButton2.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton2Click,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   306
              id=ID_MAPVARIABLEDIALOGRADIOBUTTON2)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   307
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   308
        self.radioButton3 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON3,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   309
              label='REC', name='radioButton3', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   310
              pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   311
        self.radioButton3.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   312
        self.radioButton3.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton3Click,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   313
              id=ID_MAPVARIABLEDIALOGRADIOBUTTON3)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   314
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   315
        self.Index = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGINDEX, name='Index',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   316
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   317
              style=0, value='0x2000')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   318
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   319
        self.IndexName = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGINDEXNAME,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   320
              name='IndexName', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   321
              size=wx.Size(0, 24), style=0, value='Undefined')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   322
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   323
        self.Number = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGNUMBER,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   324
              name='Number', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   325
              size=wx.Size(0, 24), style=wx.TE_RIGHT, value='0')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   326
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   327
        self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   328
              name='Spacer', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   329
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   330
        
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   331
        self.Spacer2 = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER2,
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   332
              name='Spacer2', parent=self, pos=wx.Point(0, 0),
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   333
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   334
        
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   335
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   336
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   337
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   338
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   339
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   340
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   341
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   342
        self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   343
        self.Number.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   344
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   345
    def SetIndex(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   346
        self.Index.SetValue("0x%04X"%index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   347
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   348
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   349
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   350
        try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   351
            int(self.Index.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   352
        except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   353
            error.append("Index")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   354
        if self.radioButton2.GetValue() or self.radioButton3.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   355
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   356
                int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   357
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   358
                error.append("Number")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   359
        if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   360
            text = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   361
            if len(error) > 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   362
                suffix = "s"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   363
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   364
                suffix = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   365
            for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   366
                if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   367
                    text += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   368
                elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   369
                    text += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   370
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   371
                    text += ", %s"%item
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   372
            message = wx.MessageDialog(self, "Form isn't valid. %s must be integer%s!"%(text,suffix), "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   373
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   374
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   375
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   376
            self.EndModal(wx.ID_OK)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   377
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   378
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   379
        name = self.IndexName.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   380
        index = int(self.Index.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   381
        if self.radioButton1.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   382
            struct = 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   383
            number = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   384
        elif self.radioButton2.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   385
            struct = 3
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   386
            number = int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   387
        elif self.radioButton3.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   388
            struct = 7
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   389
            number = int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   390
        return index, name, struct, number
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   391
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   392
    def OnRadioButton1Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   393
        self.EnableNumberTyping(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   394
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   395
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   396
    def OnRadioButton2Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   397
        self.EnableNumberTyping(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   398
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   399
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   400
    def OnRadioButton3Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   401
        self.EnableNumberTyping(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   402
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   403
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   404
    def EnableNumberTyping(self, enable):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   405
        self.staticText4.Enable(enable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   406
        self.Number.Enable(enable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   407
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   408
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   409
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   410
#                          Create User Type Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   411
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   412
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   413
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   414
[ID_USERTYPEDIALOG, ID_USERTYPEDIALOGSPACER, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   415
 ID_USERTYPEDIALOGTYPE, ID_USERTYPEDIALOGMAX, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   416
 ID_USERTYPEDIALOGMIN, ID_USERTYPEDIALOGLENGTH, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   417
 ID_USERTYPEDIALOGSTATICBOX1, ID_USERTYPEDIALOGSTATICTEXT1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   418
 ID_USERTYPEDIALOGSTATICTEXT2, ID_USERTYPEDIALOGSTATICTEXT3, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   419
 ID_USERTYPEDIALOGSTATICTEXT4,  
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   420
] = [wx.NewId() for _init_ctrls in range(11)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   421
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   422
class UserTypeDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   423
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   424
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   425
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   426
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   427
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   428
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   429
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   430
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   431
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   432
        parent.AddSizer(self.LeftGridSizer, 2, border=5, flag=wx.GROW|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   433
        parent.AddSizer(self.RightBoxSizer, 3, border=5, flag=wx.GROW|wx.LEFT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   434
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   435
    def _init_coll_LeftGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   436
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   437
        parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   438
        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   439
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   440
    def _init_coll_LeftGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   441
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   442
        parent.AddGrowableRow(2)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   443
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   444
    def _init_coll_RightBoxSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   445
        parent.AddSizer(self.RightBoxGridSizer, 0, border=10, flag=wx.GROW|wx.ALL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   446
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   447
    def _init_coll_RightBoxGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   448
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   449
        parent.AddWindow(self.Min, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   450
        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   451
        parent.AddWindow(self.Max, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   452
        parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   453
        parent.AddWindow(self.Length, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   454
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   455
    def _init_coll_RightBoxGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   456
        parent.AddGrowableCol(1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   457
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   458
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   459
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   460
        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   461
        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   462
        self.RightBoxSizer = wx.StaticBoxSizer(self.staticBox1, wx.VERTICAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   463
        self.RightBoxGridSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   464
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   465
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   466
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   467
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   468
        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   469
        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   470
        self._init_coll_RightBoxSizer_Items(self.RightBoxSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   471
        self._init_coll_RightBoxGridSizer_Items(self.RightBoxGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   472
        self._init_coll_RightBoxGridSizer_Growables(self.RightBoxGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   473
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   474
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   475
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   476
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   477
        wx.Dialog.__init__(self, id=ID_USERTYPEDIALOG, name='UserTypeDialog',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   478
              parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210),
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   479
              style=wx.DEFAULT_DIALOG_STYLE, title='Add User Type')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   480
        self.SetClientSize(wx.Size(444, 210))
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   481
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   482
        self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   483
              label='Type:', name='staticText1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   484
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   485
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   486
        self.Type = wx.Choice(choices=[], id=ID_USERTYPEDIALOGTYPE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   487
              name='Type', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   488
              size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   489
        self.Type.Bind(wx.EVT_CHOICE, self.OnTypeChoice,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   490
              id=ID_USERTYPEDIALOGTYPE)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   491
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   492
        self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   493
              name='Spacer', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   494
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   495
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   496
        self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   497
              label='Values', name='staticBox1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   498
              pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   499
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   500
        self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   501
              label='Minimum:', name='staticText2', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   502
              pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   503
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   504
        self.Min = wx.TextCtrl(id=ID_USERTYPEDIALOGMIN, name='Min',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   505
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   506
              style=wx.TE_RIGHT, value='0')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   507
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   508
        self.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   509
              label='Maximum:', name='staticText3', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   510
              pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   511
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   512
        self.Max = wx.TextCtrl(id=ID_USERTYPEDIALOGMAX, name='Max',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   513
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   514
              style=wx.TE_RIGHT, value='0')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   515
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   516
        self.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   517
              label='Length:', name='staticText4', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   518
              pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   519
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   520
        self.Length = wx.TextCtrl(id=ID_USERTYPEDIALOGLENGTH, name='Length',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   521
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   522
              style=wx.TE_RIGHT, value='0')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   523
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   524
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   525
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   526
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   527
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   528
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   529
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   530
        self._init_ctrls(parent)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   531
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   532
        self.TypeDictionary = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   533
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   534
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   535
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   536
        good = True
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   537
        firstmessage = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   538
        secondmessage = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   539
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   540
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   541
            valuetype = self.TypeDictionary[name][1]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   542
            if valuetype == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   543
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   544
                    int(self.Min.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   545
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   546
                    error.append("Minimum")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   547
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   548
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   549
                    int(self.Max.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   550
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   551
                    error.append("Maximum")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   552
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   553
            elif valuetype == 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   554
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   555
                    int(self.Length.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   556
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   557
                    error.append("Length")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   558
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   559
            if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   560
                secondmessage = ". "
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   561
                for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   562
                    if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   563
                        secondmessage += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   564
                    elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   565
                        secondmessage += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   566
                    else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   567
                        secondmessage += ", %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   568
                secondmessage += " must be integer"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   569
                if len(error) > 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   570
                    secondmessage += "s"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   571
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   572
            firstmessage = ". A type must be selected"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   573
            good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   574
        if not good:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   575
            message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   576
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   577
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   578
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   579
            self.EndModal(wx.ID_OK)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   580
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   581
    def SetValues(self, min = None, max = None, length = None):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   582
        if min != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   583
            self.Min.SetValue(str(min))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   584
        if max != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   585
            self.Max.SetValue(str(max))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   586
        if length != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   587
            self.Length.SetValue(str(length))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   588
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   589
    def SetTypeList(self, typedic, type = None):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   590
        self.Type.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   591
        list = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   592
        for index, (name, valuetype) in typedic.iteritems():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   593
            self.TypeDictionary[name] = (index, valuetype)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   594
            list.append((index, name))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   595
        list.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   596
        for index, name in list:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   597
            self.Type.Append(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   598
        if type != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   599
            self.Type.SetStringSelection(typedic[type][0])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   600
        self.RefreshValues()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   601
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   602
    def OnTypeChoice(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   603
        self.RefreshValues()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   604
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   605
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   606
    def RefreshValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   607
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   608
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   609
            valuetype = self.TypeDictionary[name][1]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   610
            if valuetype == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   611
                self.staticText2.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   612
                self.staticText3.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   613
                self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   614
                self.Min.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   615
                self.Max.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   616
                self.Length.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   617
            elif valuetype == 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   618
                self.staticText2.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   619
                self.staticText3.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   620
                self.staticText4.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   621
                self.Min.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   622
                self.Max.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   623
                self.Length.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   624
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   625
            self.staticText2.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   626
            self.staticText3.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   627
            self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   628
            self.Min.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   629
            self.Max.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   630
            self.Length.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   631
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   632
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   633
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   634
        type = self.TypeDictionary[name][0]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   635
        min = int(self.Min.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   636
        max = int(self.Max.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   637
        length = int(self.Length.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   638
        return type, min, max, length
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   639
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   640
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   641
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   642
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   643
#                          Editing Node Infos Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   644
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   645
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   646
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   647
[ID_NODEINFOSDIALOG, ID_NODEINFOSDIALOGNAME, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   648
 ID_NODEINFOSDIALOGNODEID, ID_NODEINFOSDIALOGDESCRIPTION, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   649
 ID_NODEINFOSDIALOGTYPE, ID_NODEINFOSDIALOGSTATICTEXT1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   650
 ID_NODEINFOSDIALOGSTATICTEXT2, ID_NODEINFOSDIALOGSTATICTEXT3, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   651
 ID_NODEINFOSDIALOGSTATICTEXT4,  
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   652
] = [wx.NewId() for _init_ctrls in range(9)]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   653
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   654
class NodeInfosDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   655
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   656
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   657
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   658
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   659
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   660
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   661
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   662
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   663
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   664
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   665
        parent.AddWindow(self.NodeName, 0, border=0, flag=wx.GROW)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   666
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   667
        parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   668
        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   669
        parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   670
        parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   671
        parent.AddWindow(self.Description, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   672
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   673
    def _init_coll_MainSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   674
        parent.AddGrowableCol(0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   675
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   676
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   677
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   678
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   679
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   680
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   681
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   682
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   683
        self._init_coll_MainSizer_Growables(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   684
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   685
        self.SetSizer(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   686
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   687
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   688
        wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   689
              name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   690
              size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   691
              title='Node Infos')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   692
        self.SetClientSize(wx.Size(300, 280))
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   693
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   694
        self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   695
              label='Name:', name='staticText1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   696
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   697
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   698
        self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName',
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   699
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   700
              style=0, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   701
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   702
        self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   703
              label='Node ID:', name='staticText2', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   704
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   705
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   706
        self.NodeID = wx.TextCtrl(id=ID_NODEINFOSDIALOGNODEID, name='NodeID',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   707
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   708
              style=wx.TE_RIGHT, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   709
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   710
        self.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   711
              label='Type:', name='staticText3', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   712
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   713
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   714
        self.Type = wx.Choice(choices=[], id=ID_NODEINFOSDIALOGTYPE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   715
              name='Type', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   716
              size=wx.Size(0, 25), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   717
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   718
        self.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   719
              label='Description:', name='staticText4', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   720
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   721
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   722
        self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   723
              name='Description', parent=self, pos=wx.Point(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   724
              size=wx.Size(0, 24), style=0, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   725
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   726
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   727
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   728
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   729
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   730
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   731
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   732
        self._init_ctrls(parent)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   733
        
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   734
        self.staticText2.Hide()
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   735
        self.NodeID.Hide()
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   736
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   737
        self.Type.Append("master")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   738
        self.Type.Append("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   739
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   740
    def OnOK(self, event):
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   741
        name = self.NodeName.GetValue()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   742
        message = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   743
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   744
            good = not name[0].isdigit()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   745
            for item in name.split("_"):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   746
                good &= item.isalnum()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   747
            if not good:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   748
                message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   749
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   750
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   751
                nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   752
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   753
                message = "Node ID must be integer!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   754
        if message != "":
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   755
            message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   756
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   757
            message.Destroy()
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   758
            self.NodeName.SetFocus()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   759
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   760
            self.EndModal(wx.ID_OK)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   761
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   762
    def SetValues(self, name, id, type, description):
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   763
        self.NodeName.SetValue(name)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   764
        self.NodeID.SetValue("0x%02X"%id)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   765
        self.Type.SetStringSelection(type)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   766
        self.Description.SetValue(description)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   767
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   768
    def GetValues(self):
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   769
        name = self.NodeName.GetValue()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   770
        nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   771
        type = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   772
        description = self.Description.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   773
        return name, nodeid, type, description
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   774
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   775
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   776
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   777
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   778
#                          Create New Node Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   779
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   780
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   781
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   782
[ID_CREATENODEDIALOG, ID_CREATENODEDIALOGEMERGENCY, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   783
 ID_CREATENODEDIALOGGENSYNC, ID_CREATENODEDIALOGSPACER, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   784
 ID_CREATENODEDIALOGNAME, ID_CREATENODEDIALOGNMT_HEARTBEAT, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   785
 ID_CREATENODEDIALOGNMT_NODEGUARDING, ID_CREATENODEDIALOGNMT_NONE, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   786
 ID_CREATENODEDIALOGNODEID, ID_CREATENODEDIALOGPROFILE, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   787
 ID_CREATENODEDIALOGSAVECONFIG, ID_CREATENODEDIALOGSTATICTEXT1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   788
 ID_CREATENODEDIALOGSTATICTEXT2, ID_CREATENODEDIALOGSTATICTEXT3, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   789
 ID_CREATENODEDIALOGSTATICTEXT4, ID_CREATENODEDIALOGSTATICTEXT5, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   790
 ID_CREATENODEDIALOGSTATICTEXT6, ID_CREATENODEDIALOGSTATICTEXT7,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   791
 ID_CREATENODEDIALOGSTOREEDS, ID_CREATENODEDIALOGDESCRIPTION,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   792
 ID_CREATENODEDIALOGTYPE, 
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   793
] = [wx.NewId() for _init_ctrls in range(21)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   794
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   795
class CreateNodeDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   796
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   797
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   798
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   799
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   800
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   801
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   802
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   803
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   804
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   805
        parent.AddSizer(self.TopBoxSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   806
        parent.AddWindow(self.staticText7, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   807
        parent.AddWindow(self.Description, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   808
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   809
    def _init_coll_MainSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   810
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   811
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   812
    
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   813
    def _init_coll_TopBoxSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   814
        parent.AddSizer(self.LeftBoxSizer, 1, border=10, flag=wx.GROW|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   815
        parent.AddSizer(self.RightGridSizer, 1, border=10, flag=wx.GROW|wx.LEFT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   816
    
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   817
    def _init_coll_LeftBoxSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   818
        parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   819
        parent.AddWindow(self.Type, 0, border=10, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   820
        parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM)
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   821
        parent.AddWindow(self.NodeName, 0, border=10, flag=wx.GROW|wx.BOTTOM)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   822
        parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   823
        parent.AddWindow(self.NodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   824
        parent.AddWindow(self.staticText4, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   825
        parent.AddWindow(self.Profile, 0, border=20, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   826
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   827
    def _init_coll_RightGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   828
        parent.AddSizer(self.RightTopGridSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   829
        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   830
        parent.AddSizer(self.RightBottomGridSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   831
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   832
    def _init_coll_RightGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   833
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   834
        parent.AddGrowableRow(1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   835
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   836
    def _init_coll_RightTopGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   837
        parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   838
        parent.AddWindow(self.NMT_None, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   839
        parent.AddWindow(self.NMT_NodeGuarding, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   840
        parent.AddWindow(self.NMT_Heartbeat, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   841
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   842
    def _init_coll_RightTopGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   843
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   844
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   845
    def _init_coll_RightBottomGridSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   846
        parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   847
        parent.AddWindow(self.DS302, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   848
        parent.AddWindow(self.GenSYNC, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   849
        parent.AddWindow(self.Emergency, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   850
        parent.AddWindow(self.SaveConfig, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   851
        parent.AddWindow(self.StoreEDS, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   852
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   853
    def _init_coll_RightBottomGridSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   854
        parent.AddGrowableCol(0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   855
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   856
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   857
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   858
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=5, rows=3, vgap=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   859
        self.TopBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   860
        self.LeftBoxSizer = wx.BoxSizer(wx.VERTICAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   861
        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   862
        self.RightTopGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   863
        self.RightBottomGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   864
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   865
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   866
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   867
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   868
        self._init_coll_MainSizer_Growables(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   869
        self._init_coll_TopBoxSizer_Items(self.TopBoxSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   870
        self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   871
        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   872
        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   873
        self._init_coll_RightTopGridSizer_Items(self.RightTopGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   874
        self._init_coll_RightTopGridSizer_Growables(self.RightTopGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   875
        self._init_coll_RightBottomGridSizer_Items(self.RightBottomGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   876
        self._init_coll_RightBottomGridSizer_Growables(self.RightBottomGridSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   877
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   878
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   879
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   880
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   881
        wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   882
              name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   883
              size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   884
              title='Create a new Node')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   885
        self.SetClientSize(wx.Size(450, 350))
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   886
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   887
        self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1,
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   888
              label='Type:', name='staticText1', parent=self,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   889
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   890
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   891
        self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2,
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   892
              label='Name:', name='staticText2', parent=self,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   893
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   894
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   895
        self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3,
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   896
              label='Node ID:', name='staticText3', parent=self,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   897
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   898
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   899
        self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   900
              label='Profile:', name='staticText4', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   901
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   902
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   903
        self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   904
              name='Type', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   905
              size=wx.Size(0, 25), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   906
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
   907
        self.NodeName = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='NodeName',
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   908
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   909
              style=0, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   910
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   911
        self.NodeID = wx.TextCtrl(id=ID_CREATENODEDIALOGNODEID, name='NodeID',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   912
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   913
              style=wx.TE_RIGHT, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   914
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   915
        self.Profile = wx.Choice(choices=[], id=ID_CREATENODEDIALOGPROFILE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   916
              name='Profile', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   917
              size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   918
        self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   919
              id=ID_CREATENODEDIALOGPROFILE)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   920
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   921
        self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   922
              label='Network Management:', name='staticText5',
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   923
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   924
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   925
        self.NMT_None = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NONE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   926
              label='None', name='NMT_None', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   927
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   928
        self.NMT_None.SetValue(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   929
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   930
        self.NMT_NodeGuarding = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NODEGUARDING,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   931
              label='Node Guarding', name='NMT_NodeGuarding', parent=self, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   932
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   933
        self.NMT_NodeGuarding.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   934
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   935
        self.NMT_Heartbeat = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_HEARTBEAT,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   936
              label='Heartbeat', name='NMT_Heartbeat', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   937
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   938
        self.NMT_Heartbeat.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   939
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   940
        self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   941
              label='Options:', name='staticText6', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   942
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   943
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   944
        self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   945
              label='DS-302 Profile', name='DS302', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   946
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   947
        self.DS302.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   948
        #self.DS302.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   949
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   950
        self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   951
              label='Generate SYNC', name='GenSYNC', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   952
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   953
        self.GenSYNC.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   954
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   955
        self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   956
              label='Emergency support', name='Emergency',
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   957
              parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   958
        self.Emergency.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   959
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   960
        self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   961
              label='Save Configuration', name='SaveConfig', parent=self, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   962
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   963
        self.SaveConfig.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   964
        self.SaveConfig.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   965
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   966
        self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   967
              label='Store EDS', name='StoreEDS', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   968
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   969
        self.StoreEDS.SetValue(False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   970
        self.StoreEDS.Hide()
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   971
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   972
        self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   973
              label='Description:', name='staticText7', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   974
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   975
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   976
        self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   977
              name='Description', parent=self, pos=wx.Point(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   978
              size=wx.Size(0, 24), style=0, value='')
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   979
259
fefaeb965850 Bugs fixed on objdictedit dialogs
lbessard
parents: 258
diff changeset
   980
        self.Spacer = wx.Panel(id=ID_CREATENODEDIALOGSPACER,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   981
              name='Spacer', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   982
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   983
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   984
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   985
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   986
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   987
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   988
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   989
    def __init__(self, parent):
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   990
        self._init_ctrls(parent)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
   991
        
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   992
        self.staticText3.Hide()
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   993
        self.NodeID.Hide()
506f9700b9fb Allowing user to type formulas
lbessard
parents: 276
diff changeset
   994
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   995
        self.NodeID.SetValue("0x00")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   996
        self.Type.Append("master")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   997
        self.Type.Append("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   998
        self.Type.SetStringSelection("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   999
        self.Description.SetValue("")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1000
        self.ListProfile = {"None" : ""}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1001
        self.Profile.Append("None")
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
  1002
        self.Directory = os.path.join(ScriptDirectory, "config")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1003
        listfiles = os.listdir(self.Directory)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1004
        listfiles.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1005
        for item in listfiles:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1006
            name, extend = os.path.splitext(item)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1007
            if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1008
                self.ListProfile[name] = os.path.join(self.Directory, item)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1009
                self.Profile.Append(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1010
        self.Profile.Append("Other")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1011
        self.Profile.SetStringSelection("None")
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
  1012
        self.NodeName.SetFocus()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1013
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1014
    def OnOK(self, event):
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
  1015
        name = self.NodeName.GetValue()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1016
        message = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1017
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1018
            good = not name[0].isdigit()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1019
            for item in name.split("_"):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1020
                good &= item.isalnum()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1021
            if not good:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1022
                message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1023
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1024
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1025
                nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1026
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1027
                message = "Node ID must be an integer!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1028
        if message != "":
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1029
            message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1030
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1031
            message.Destroy()
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
  1032
            self.NodeName.SetFocus()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1033
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1034
            self.EndModal(wx.ID_OK)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1035
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1036
    def GetValues(self):
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 266
diff changeset
  1037
        name = self.NodeName.GetValue()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1038
        nodeid = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1039
        if self.NodeID.GetValue() != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1040
            nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1041
        type = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1042
        description = self.Description.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1043
        return name, nodeid, type, description
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1044
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1045
    def GetProfile(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1046
        name = self.Profile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1047
        return name, self.ListProfile[name]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1048
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1049
    def GetNMTManagement(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1050
        if self.NMT_None.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1051
            return "None"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1052
        elif self.NMT_NodeGuarding.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1053
            return "NodeGuarding"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1054
        elif self.NMT_Heartbeat.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1055
            return "Heartbeat"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1056
        return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1057
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1058
    def GetOptions(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1059
        options = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1060
        if self.DS302.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1061
            options.append("DS302")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1062
        if self.GenSYNC.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1063
            options.append("GenSYNC")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1064
        if self.Emergency.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1065
            options.append("Emergency")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1066
        if self.SaveConfig.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1067
            options.append("SaveConfig")
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1068
        if self.StoreEDS.GetValue():
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1069
            options.append("StoreEDS")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1070
        return options
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1071
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1072
    def OnProfileChoice(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1073
        if self.Profile.GetStringSelection() == "Other":
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1074
            dialog = wx.FileDialog(self, "Choose a file", self.Directory, "",  "OD Profile files (*.prf)|*.prf|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1075
            dialog.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1076
            filepath = dialog.GetPath()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1077
            dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1078
            if os.path.isfile(filepath):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1079
                name = os.path.splitext(os.path.basename(filepath))[0]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1080
                self.ListProfile[name] = filepath
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1081
                length = self.Profile.GetCount()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1082
                self.Profile.Insert(name, length - 2)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1083
                self.Profile.SetStringSelection(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1084
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1085
                self.Profile.SetStringSelection("None")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1086
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1087
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1088
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1089
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1090
#                            ADD Slave to NodeList Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1091
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1092
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1093
[ID_ADDSLAVEDIALOG, ID_ADDSLAVEDIALOGSLAVENAME, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1094
 ID_ADDSLAVEDIALOGSLAVENODEID, ID_ADDSLAVEDIALOGEDSFILE, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1095
 ID_ADDSLAVEDIALOGIMPORTEDS, ID_ADDSLAVEDIALOGSTATICTEXT1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1096
 ID_ADDSLAVEDIALOGSTATICTEXT2, ID_ADDSLAVEDIALOGSTATICTEXT3, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1097
] = [wx.NewId() for _init_ctrls in range(8)]
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1098
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1099
class AddSlaveDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1100
    def _init_coll_flexGridSizer1_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1101
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1102
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1103
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1104
    def _init_coll_flexGridSizer1_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1105
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1106
        parent.AddGrowableRow(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1107
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1108
    def _init_coll_MainSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1109
        parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1110
        parent.AddWindow(self.SlaveName, 0, border=10, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1111
        parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1112
        parent.AddWindow(self.SlaveNodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1113
        parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1114
        parent.AddSizer(self.BottomSizer, 0, border=0, flag=wx.GROW)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1115
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1116
    def _init_coll_BottomSizer_Items(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1117
        parent.AddWindow(self.EDSFile, 0, border=4, flag=wx.GROW|wx.TOP|wx.BOTTOM)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1118
        parent.AddWindow(self.ImportEDS, 0, border=0, flag=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1119
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1120
    def _init_coll_BottomSizer_Growables(self, parent):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1121
        parent.AddGrowableCol(0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1122
        parent.AddGrowableRow(0)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1123
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1124
    def _init_sizers(self):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1125
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1126
        self.MainSizer = wx.BoxSizer(wx.VERTICAL)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1127
        self.BottomSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1128
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1129
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1130
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1131
        self._init_coll_MainSizer_Items(self.MainSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1132
        self._init_coll_BottomSizer_Items(self.BottomSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1133
        self._init_coll_BottomSizer_Growables(self.BottomSizer)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1134
        
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1135
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1136
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1137
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1138
        wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1139
              name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1140
              size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1141
              title='Add a slave to nodelist')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1142
        self.SetClientSize(wx.Size(300, 250))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1143
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1144
        self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1145
              label='Slave Name:', name='staticText1', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1146
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1147
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1148
        self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1149
              name='SlaveName', parent=self, pos=wx.Point(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1150
              size=wx.Size(0, 24), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1151
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1152
        self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1153
              label='Slave Node ID:', name='staticText2', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1154
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1155
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1156
        self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1157
              name='SlaveName', parent=self, pos=wx.Point(0, 0), 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1158
              size=wx.Size(0, 24), style=wx.ALIGN_RIGHT)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1159
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1160
        self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1161
              label='EDS File:', name='staticText3', parent=self,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1162
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1163
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1164
        self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1165
              name='EDSFile', parent=self, pos=wx.Point(0, 0),
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1166
              size=wx.Size(0, 24), style=0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1167
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1168
        self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label='Import EDS',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1169
              name='ImportEDS', parent=self, pos=wx.Point(0, 0),
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1170
              size=wx.Size(100, 32), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1171
        self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1172
              id=ID_ADDSLAVEDIALOGIMPORTEDS)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1173
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1174
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1175
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1176
    
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1177
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1178
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1179
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1180
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1181
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1182
        self.SlaveNodeID.SetValue("0x00")
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1183
            
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1184
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1185
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1186
        if self.SlaveName.GetValue() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1187
            error.append("Slave Name")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1188
        if self.SlaveNodeID.GetValue() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1189
            error.append("Slave Node ID")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1190
        if self.EDSFile.GetStringSelection() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1191
            error.append("EDS File")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1192
        if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1193
            text = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1194
            for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1195
                if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1196
                    text += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1197
                elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1198
                    text += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1199
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1200
                    text += ", %s"%item 
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1201
            message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1202
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1203
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1204
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1205
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1206
                nodeid = self.SlaveNodeID.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1207
                if nodeid.find("x") != -1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1208
                    nodeid = int(nodeid, 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1209
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1210
                    nodeid = int(nodeid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1211
            except:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1212
                message = wx.MessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1213
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1214
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1215
                return
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1216
            if not 0 <= nodeid <= 127:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1217
                message = wx.MessageDialog(self, "Slave Node ID must be between 0 and 127!", "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1218
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1219
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1220
            elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys():
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1221
                message = wx.MessageDialog(self, "A Node with this ID already exist in the network!", "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1222
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1223
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1224
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1225
                self.EndModal(wx.ID_OK)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1226
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1227
    def OnImportEDSButton(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1228
        dialog = wx.FileDialog(self, "Choose an EDS file", os.getcwd(), "",  "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1229
        if dialog.ShowModal() == wx.ID_OK:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1230
            filepath = dialog.GetPath()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1231
            if os.path.isfile(filepath):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1232
                result = self.NodeList.ImportEDSFile(filepath)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1233
                if result:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1234
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1235
                    message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1236
                    message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1237
        dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1238
        self.RefreshEDSFile()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1239
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1240
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1241
    def RefreshEDSFile(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1242
        selection = self.EDSFile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1243
        self.EDSFile.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1244
        for option in self.NodeList.EDSNodes.keys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1245
            self.EDSFile.Append(option)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 206
diff changeset
  1246
        if self.EDSFile.FindString(selection) != wx.NOT_FOUND:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1247
            self.EDSFile.SetStringSelection(selection)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1248
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1249
    def SetNodeList(self, nodelist):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1250
        self.NodeList = nodelist
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1251
        self.RefreshEDSFile()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1252
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1253
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1254
        values = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1255
        values["slaveName"] = self.SlaveName.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1256
        nodeid = self.SlaveNodeID.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1257
        if nodeid.find("x") != -1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1258
            values["slaveNodeID"] = int(nodeid, 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1259
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1260
            values["slaveNodeID"] = int(nodeid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1261
        values["edsFile"] = self.EDSFile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1262
        return values
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1263
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1264
#-------------------------------------------------------------------------------
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1265
#                            Editing DCF Entry Dialog
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1266
#-------------------------------------------------------------------------------
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1267
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1268
class DCFEntryValuesTable(wx.grid.PyGridTableBase):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1269
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1270
    """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1271
    A custom wxGrid Table using user supplied data
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1272
    """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1273
    def __init__(self, parent, data, colnames):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1274
        # The base class must be initialized *first*
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1275
        wx.grid.PyGridTableBase.__init__(self)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1276
        self.data = data
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1277
        self.colnames = colnames
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1278
        self.Parent = parent
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1279
        # XXX
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1280
        # we need to store the row length and collength to
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1281
        # see if the table has changed size
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1282
        self._rows = self.GetNumberRows()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1283
        self._cols = self.GetNumberCols()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1284
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1285
    def GetNumberCols(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1286
        return len(self.colnames)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1287
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1288
    def GetNumberRows(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1289
        return len(self.data)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1290
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1291
    def GetColLabelValue(self, col):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1292
        if col < len(self.colnames):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1293
            return self.colnames[col]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1294
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1295
    def GetRowLabelValues(self, row):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1296
        return row
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1297
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1298
    def GetValue(self, row, col):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1299
        if row < self.GetNumberRows():
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1300
            return str(self.data[row].get(self.GetColLabelValue(col), ""))
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1301
            
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1302
    def GetEditor(self, row, col):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1303
        if row < self.GetNumberRows():
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1304
            return self.editors[row].get(self.GetColLabelValue(col), "")
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1305
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1306
    def GetValueByName(self, row, colname):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1307
        return self.data[row].get(colname)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1308
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1309
    def SetValue(self, row, col, value):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1310
        if col < len(self.colnames):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1311
            self.data[row][self.GetColLabelValue(col)] = value
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1312
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1313
    def ResetView(self, grid):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1314
        """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1315
        (wx.grid.Grid) -> Reset the grid view.   Call this to
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1316
        update the grid if rows and columns have been added or deleted
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1317
        """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1318
        grid.BeginBatch()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1319
        for current, new, delmsg, addmsg in [
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1320
            (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1321
            (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1322
        ]:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1323
            if new < current:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1324
                msg = wx.grid.GridTableMessage(self,delmsg,new,current-new)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1325
                grid.ProcessTableMessage(msg)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1326
            elif new > current:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1327
                msg = wx.grid.GridTableMessage(self,addmsg,new-current)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1328
                grid.ProcessTableMessage(msg)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1329
                self.UpdateValues(grid)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1330
        grid.EndBatch()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1331
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1332
        self._rows = self.GetNumberRows()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1333
        self._cols = self.GetNumberCols()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1334
        # update the column rendering scheme
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1335
        self._updateColAttrs(grid)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1336
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1337
        # update the scrollbars and the displayed part of the grid
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1338
        grid.AdjustScrollbars()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1339
        grid.ForceRefresh()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1340
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1341
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1342
    def UpdateValues(self, grid):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1343
        """Update all displayed values"""
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1344
        # This sends an event to the grid table to update all of the values
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1345
        msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1346
        grid.ProcessTableMessage(msg)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1347
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1348
    def _updateColAttrs(self, grid):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1349
        """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1350
        wx.grid.Grid -> update the column attributes to add the
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1351
        appropriate renderer given the column name.
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1352
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1353
        Otherwise default to the default renderer.
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1354
        """
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1355
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1356
        for row in range(self.GetNumberRows()):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1357
            for col in range(self.GetNumberCols()):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1358
                editor = wx.grid.GridCellTextEditor()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1359
                renderer = wx.grid.GridCellStringRenderer()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1360
                    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1361
                grid.SetCellEditor(row, col, editor)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1362
                grid.SetCellRenderer(row, col, renderer)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1363
                
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1364
                grid.SetCellBackgroundColour(row, col, wx.WHITE)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1365
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1366
    def SetData(self, data):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1367
        self.data = data
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1368
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1369
    def AppendRow(self, row_content):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1370
        self.data.append(row_content)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1371
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1372
    def Empty(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1373
        self.data = []
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1374
        self.editors = []
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1375
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1376
[ID_DCFENTRYVALUESDIALOG, ID_DCFENTRYVALUESDIALOGVALUESGRID, 
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1377
 ID_DCFENTRYVALUESDIALOGADDBUTTON, ID_DCFENTRYVALUESDIALOGDELETEBUTTON, 
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1378
 ID_DCFENTRYVALUESDIALOGUPBUTTON, ID_DCFENTRYVALUESDIALOGDOWNBUTTON, 
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1379
 ID_VARIABLEEDITORPANELSTATICTEXT1, 
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1380
] = [wx.NewId() for _init_ctrls in range(7)]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1381
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1382
class DCFEntryValuesDialog(wx.Dialog):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1383
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1384
    if wx.VERSION < (2, 6, 0):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1385
        def Bind(self, event, function, id = None):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1386
            if id is not None:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1387
                event(self, id, function)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1388
            else:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1389
                event(self, function)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1390
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1391
    def _init_coll_MainSizer_Items(self, parent):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1392
        parent.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1393
        parent.AddWindow(self.ValuesGrid, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1394
        parent.AddSizer(self.ButtonPanelSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1395
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1396
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1397
    def _init_coll_MainSizer_Growables(self, parent):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1398
        parent.AddGrowableCol(0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1399
        parent.AddGrowableRow(1)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1400
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1401
    def _init_coll_ButtonPanelSizer_Items(self, parent):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1402
        parent.AddWindow(self.UpButton, 0, border=5, flag=wx.ALL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1403
        parent.AddWindow(self.AddButton, 0, border=5, flag=wx.ALL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1404
        parent.AddWindow(self.DownButton, 0, border=5, flag=wx.ALL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1405
        parent.AddWindow(self.DeleteButton, 0, border=5, flag=wx.ALL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1406
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1407
    def _init_sizers(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1408
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1409
        self.ButtonPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1410
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1411
        self._init_coll_MainSizer_Items(self.MainSizer)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1412
        self._init_coll_MainSizer_Growables(self.MainSizer)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1413
        self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1414
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1415
        self.SetSizer(self.MainSizer)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1416
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1417
    def _init_ctrls(self, prnt):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1418
        wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1419
              name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1420
              size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1421
              title='Edit DCF Entry Values')
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1422
        self.SetClientSize(wx.Size(400, 300))
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1423
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1424
        self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1425
              label='Entry Values:', name='staticText1', parent=self,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1426
              pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1427
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1428
        self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1429
              name='ValuesGrid', parent=self, pos=wx.Point(0, 0), 
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1430
              size=wx.Size(0, 150), style=wx.VSCROLL)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1431
        self.ValuesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1432
              'Sans'))
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1433
        self.ValuesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1434
              False, 'Sans'))
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1435
        self.ValuesGrid.SetRowLabelSize(0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1436
        self.ValuesGrid.SetSelectionBackground(wx.WHITE)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1437
        self.ValuesGrid.SetSelectionForeground(wx.BLACK)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1438
        if wx.VERSION >= (2, 6, 0):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1439
            self.ValuesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnValuesGridCellChange)
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1440
            self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell)
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1441
        else:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1442
            wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange)
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1443
            wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell)
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1444
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1445
        self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label='Add',
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1446
              name='AddButton', parent=self, pos=wx.Point(0, 0),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1447
              size=wx.Size(72, 32), style=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1448
        self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1449
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1450
        self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label='Delete',
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1451
              name='DeleteButton', parent=self, pos=wx.Point(0, 0),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1452
              size=wx.Size(72, 32), style=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1453
        self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1454
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1455
        self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^',
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1456
              name='UpButton', parent=self, pos=wx.Point(0, 0),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1457
              size=wx.Size(32, 32), style=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1458
        self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_DCFENTRYVALUESDIALOGUPBUTTON)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1459
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1460
        self.DownButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON, label='v',
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1461
              name='DownButton', parent=self, pos=wx.Point(0, 0),
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1462
              size=wx.Size(32, 32), style=0)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1463
        self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1464
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1465
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1466
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1467
        self._init_sizers()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1468
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1469
    def __init__(self, parent):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1470
        self._init_ctrls(parent)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1471
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1472
        self.Values = []
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1473
        self.DefaultValue = {"Index" : 0, "Subindex" : 0, "Size" : 1, "Value" : 0}
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1474
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1475
        self.Table = DCFEntryValuesTable(self, [], ["Index", "Subindex", "Size", "Value"])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1476
        self.ValuesGrid.SetTable(self.Table)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1477
        
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1478
    def OnValuesGridCellChange(self, event):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1479
        row, col = event.GetRow(), event.GetCol()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1480
        colname = self.Table.GetColLabelValue(col)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1481
        value = self.Table.GetValue(row, col)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1482
        try:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1483
            self.Values[row][colname] = int(value, 16)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1484
        except:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1485
            message = wx.MessageDialog(self, "\"%s\" is not a valid value!"%value, "Error", wx.OK|wx.ICON_ERROR)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1486
            message.ShowModal()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1487
            message.Destroy()
359
346435b94063 Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents: 328
diff changeset
  1488
        wx.CallAfter(self.RefreshValues)
346435b94063 Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents: 328
diff changeset
  1489
        event.Skip()
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1490
    
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1491
    def OnValuesGridSelectCell(self, event):
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1492
        wx.CallAfter(self.RefreshButtons)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1493
        event.Skip()
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1494
    
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1495
    def RefreshButtons(self):
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1496
        row = self.ValuesGrid.GetGridCursorRow()
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1497
        length = len(self.Table.data)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1498
        self.DeleteButton.Enable(length > 0)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1499
        self.UpButton.Enable(row > 0)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1500
        self.DownButton.Enable(row < length - 1)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1501
    
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1502
    def OnAddButton(self, event):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1503
        new_row = self.DefaultValue.copy()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1504
        self.Values.append(new_row)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1505
        self.RefreshValues()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1506
        event.Skip()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1507
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1508
    def OnDeleteButton(self, event):
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1509
        row = self.ValuesGrid.GetGridCursorRow()
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1510
        self.Values.pop(row)
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1511
        self.RefreshValues()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1512
        event.Skip()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1513
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1514
    def OnUpButton(self, event):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1515
        self.MoveValue(self.ValuesGrid.GetGridCursorRow(), -1)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1516
        event.Skip()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1517
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1518
    def OnDownButton(self, event):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1519
        self.MoveValue(self.ValuesGrid.GetGridCursorRow(), 1)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1520
        event.Skip()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1521
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1522
    def MoveValue(self, value_index, move):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1523
        new_index = max(0, min(value_index + move, len(self.Values) - 1))
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1524
        if new_index != value_index:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1525
            self.Values.insert(new_index, self.Values.pop(value_index))
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1526
            col = self.ValuesGrid.GetGridCursorCol()
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1527
            self.RefreshValues()
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1528
            self.ValuesGrid.SetGridCursor(new_index, col)
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1529
            self.RefreshButtons()
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1530
        else:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1531
            self.RefreshValues()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1532
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1533
    def SetValues(self, values):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1534
        self.Values = []
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1535
        if values != "":
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1536
            data = values[4:]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1537
            current = 0
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1538
            for i in xrange(BE_to_LE(values[:4])):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1539
                value = {}
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1540
                value["Index"] = BE_to_LE(data[current:current+2])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1541
                value["Subindex"] = BE_to_LE(data[current+2:current+3])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1542
                size = BE_to_LE(data[current+3:current+7])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1543
                value["Size"] = size
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1544
                value["Value"] = BE_to_LE(data[current+7:current+7+size])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1545
                current += 7 + size
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1546
                self.Values.append(value)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1547
        self.RefreshValues()
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1548
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1549
    def GetValues(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1550
        value = LE_to_BE(len(self.Values), 4)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1551
        for row in self.Values:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1552
            value += LE_to_BE(row["Index"], 2)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1553
            value += LE_to_BE(row["Subindex"], 1)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1554
            value += LE_to_BE(row["Size"], 4)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1555
            value += LE_to_BE(row["Value"], row["Size"])
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1556
        return value
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1557
    
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1558
    def RefreshValues(self):
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1559
        if len(self.Table.data) > 0:
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1560
            self.ValuesGrid.SetGridCursor(0, 0)
327
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1561
        data = []
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1562
        for value in self.Values:
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1563
            row = {}
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1564
            row["Index"] = "%04X"%value["Index"]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1565
            row["Subindex"] = "%02X"%value["Subindex"]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1566
            row["Size"] = "%08X"%value["Size"]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1567
            row["Value"] = ("%0"+"%d"%(value["Size"] * 2)+"X")%value["Value"]
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1568
            data.append(row)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1569
        self.Table.SetData(data)
b904d9a99e28 Adding DCFEditor Dialog to networkedit
lbessard
parents: 314
diff changeset
  1570
        self.Table.ResetView(self.ValuesGrid)
328
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1571
        self.RefreshButtons()
474aa35daa95 Bug on DCFEditor Dialog fixed
lbessard
parents: 327
diff changeset
  1572