objdictgen/commondialogs.py
author nico
Mon, 04 Jun 2007 17:59:50 +0200
changeset 207 b6572d0336c3
parent 206 6787754b251b
child 254 f2b0acb54e65
permissions -rw-r--r--
First doxygen implementation
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
from wxPython.wx import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    25
from wxPython.grid import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    26
import wx
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    27
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    28
import os
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    29
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    30
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    31
#                          Editing Communication Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    32
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    33
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    34
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    35
[wxID_COMMUNICATIONDIALOG, wxID_COMMUNICATIONDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    36
 wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, wxID_COMMUNICATIONDIALOGCURRENTINDEXES,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    37
 wxID_COMMUNICATIONDIALOGSELECT, wxID_COMMUNICATIONDIALOGUNSELECT, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    38
 wxID_COMMUNICATIONDIALOGSTATICTEXT1, wxID_COMMUNICATIONDIALOGSTATICTEXT2
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    39
] = [wx.NewId() for _init_ctrls in range(8)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    40
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    41
class CommunicationDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    42
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    43
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    44
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    45
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    46
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    47
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    48
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    49
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    50
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    51
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    52
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    53
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    54
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    55
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    56
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    57
        wx.Dialog.__init__(self, id=wxID_COMMUNICATIONDIALOG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    58
              name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    59
              size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    60
              title='Edit Communication Profile')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    61
        self.SetClientSize(wx.Size(726, 437))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    62
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    63
        self.MainPanel = wx.Panel(id=wxID_COMMUNICATIONDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    64
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    65
              size=wx.Size(688, 382), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    66
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    67
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    68
        self.PossibleIndexes = wx.ListBox(choices=[],
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    69
              id=wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    70
              name='PossibleIndexes', parent=self.MainPanel, pos=wx.Point(40,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    71
              48), size=wx.Size(280, 320), style=wxLB_EXTENDED)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    72
        self.PossibleIndexes.Bind(wx.EVT_LEFT_DCLICK, self.OnPossibleIndexesDClick,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    73
              id=wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    74
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    75
        self.CurrentIndexes = wx.ListBox(choices=[],
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    76
              id=wxID_COMMUNICATIONDIALOGCURRENTINDEXES, name='CurrentIndexes',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    77
              parent=self.MainPanel, pos=wx.Point(400, 48), size=wx.Size(280,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    78
              320), style=wxLB_EXTENDED)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    79
        self.CurrentIndexes.Bind(wx.EVT_LEFT_DCLICK, self.OnCurrentIndexesDClick,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    80
              id=wxID_COMMUNICATIONDIALOGCURRENTINDEXES)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    81
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    82
        self.Select = wx.Button(id=wxID_COMMUNICATIONDIALOGSELECT, label='>>',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    83
              name='Select', parent=self.MainPanel, pos=wx.Point(345, 136),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    84
              size=wx.Size(32, 32), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    85
        self.Select.Bind(wx.EVT_BUTTON, self.OnSelectButton,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    86
              id=wxID_COMMUNICATIONDIALOGSELECT)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    87
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    88
        self.Unselect = wx.Button(id=wxID_COMMUNICATIONDIALOGUNSELECT,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    89
              label='<<', name='Unselect', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    90
              pos=wx.Point(345, 216), size=wx.Size(32, 30), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    91
        self.Unselect.Bind(wx.EVT_BUTTON, self.OnUnselectButton,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    92
              id=wxID_COMMUNICATIONDIALOGUNSELECT)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    93
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    94
        self.staticText1 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    95
              label='Possible Profile Indexes:', name='staticText1',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    96
              parent=self.MainPanel, pos=wx.Point(40, 24), size=wx.Size(156,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    97
              17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    98
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
    99
        self.staticText2 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   100
              label='Current Profile Indexes:', name='staticText2',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   101
              parent=self.MainPanel, pos=wx.Point(400, 24), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   102
              17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   103
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   104
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   105
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   106
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   107
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   108
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   109
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   110
        self.AllList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   111
        self.CurrentList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   112
        self.IndexDictionary = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   113
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   114
    def SetIndexDictionary(self, dictionary):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   115
        self.IndexDictionary = dictionary
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   116
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   117
    def SetCurrentList(self, list):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   118
        self.CurrentList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   119
        self.CurrentList.extend(list)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   120
        self.CurrentList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   121
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   122
    def GetCurrentList(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   123
        return self.CurrentList
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   124
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   125
    def RefreshLists(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   126
        self.PossibleIndexes.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   127
        self.CurrentIndexes.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   128
        self.AllList = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   129
        for index in self.IndexDictionary.iterkeys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   130
            if index not in self.CurrentList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   131
                self.AllList.append(index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   132
        self.AllList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   133
        for index in self.AllList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   134
            self.PossibleIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   135
        for index in self.CurrentList:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   136
            if index in self.IndexDictionary:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   137
                self.CurrentIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   138
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   139
    def OnPossibleIndexesDClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   140
        self.SelectPossible()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   141
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   142
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   143
    def OnCurrentIndexesDClick(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   144
        self.UnselectCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   145
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   146
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   147
    def OnSelectButton(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   148
        self.SelectPossible()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   149
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   150
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   151
    def OnUnselectButton(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   152
        self.UnselectCurrent()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   153
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   154
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   155
    def SelectPossible(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   156
        selected = self.PossibleIndexes.GetSelections()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   157
        for i in selected:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   158
            self.CurrentList.append(self.AllList[i])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   159
        self.CurrentList.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   160
        self.RefreshLists()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   161
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   162
    def UnselectCurrent(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   163
        selected = self.CurrentIndexes.GetSelections()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   164
        for i in selected:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   165
            if not self.IndexDictionary[self.CurrentList[i]][1]:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   166
                self.CurrentList.pop(i)
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
        self.RefreshLists()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   169
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   170
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   171
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   172
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   173
#                          Create Map Variable Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   174
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   175
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   176
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   177
[wxID_MAPVARIABLEDIALOG, wxID_MAPVARIABLEDIALOGINDEX, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   178
 wxID_MAPVARIABLEDIALOGINDEXNAME, wxID_MAPVARIABLEDIALOGMAINPANEL, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   179
 wxID_MAPVARIABLEDIALOGNUMBER, wxID_MAPVARIABLEDIALOGRADIOBUTTON1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   180
 wxID_MAPVARIABLEDIALOGRADIOBUTTON2, wxID_MAPVARIABLEDIALOGRADIOBUTTON3, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   181
 wxID_MAPVARIABLEDIALOGSTATICTEXT1, wxID_MAPVARIABLEDIALOGSTATICTEXT2, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   182
 wxID_MAPVARIABLEDIALOGSTATICTEXT3, wxID_MAPVARIABLEDIALOGSTATICTEXT4, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   183
] = [wx.NewId() for _init_ctrls in range(12)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   184
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   185
class MapVariableDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   186
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   187
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   188
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   189
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   190
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   191
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   192
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   193
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   194
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   195
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   196
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   197
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   198
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   199
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   200
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   201
        wx.Dialog.__init__(self, id=wxID_MAPVARIABLEDIALOG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   202
              name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   203
              size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   204
              title='Add Map Variable')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   205
        self.SetClientSize(wx.Size(444, 186))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   206
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   207
        self.MainPanel = wx.Panel(id=wxID_MAPVARIABLEDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   208
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   209
              size=wx.Size(431, 142), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   210
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   211
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   212
        self.staticText1 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   213
              label='Index:', name='staticText1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   214
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   215
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   216
        self.Index = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEX, name='Index',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   217
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   218
              25), style=0, value='0x2000')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   219
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   220
        self.staticText3 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   221
              label='Name:', name='staticText3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   222
              pos=wx.Point(24, 80), size=wx.Size(47, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   223
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   224
        self.IndexName = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEXNAME,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   225
              name='IndexName', parent=self.MainPanel, pos=wx.Point(24, 104),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   226
              size=wx.Size(152, 24), style=0, value='Undefined')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   227
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   228
        self.staticText2 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   229
              label='Type:', name='staticText2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   230
              pos=wx.Point(208, 24), size=wx.Size(38, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   231
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   232
        self.radioButton1 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   233
              label='VAR', name='radioButton1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   234
              pos=wx.Point(208, 48), size=wx.Size(72, 24), style=wxRB_GROUP)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   235
        self.radioButton1.SetValue(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   236
        self.radioButton1.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton1Click,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   237
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   238
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   239
        self.radioButton2 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   240
              label='ARRAY', name='radioButton2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   241
              pos=wx.Point(208, 72), size=wx.Size(80, 24), style=wxRB_SINGLE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   242
        self.radioButton2.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   243
        self.radioButton2.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton2Click,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   244
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON2)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   245
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   246
        self.radioButton3 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   247
              label='REC', name='radioButton3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   248
              pos=wx.Point(208, 96), size=wx.Size(96, 24), style=wxRB_SINGLE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   249
        self.radioButton3.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   250
        self.radioButton3.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton3Click,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   251
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON3)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   252
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   253
        self.staticText4 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT4,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   254
              label='Number:', name='staticText4', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   255
              pos=wx.Point(312, 80), size=wx.Size(88, 16), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   256
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   257
        self.Number = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGNUMBER,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   258
              name='Number', parent=self.MainPanel, pos=wx.Point(312, 104),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   259
              size=wx.Size(112, 24), style=wx.TE_RIGHT, value='0')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   260
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   261
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   262
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   263
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   264
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   265
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   266
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   267
        self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   268
        self.Number.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   269
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   270
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   271
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   272
    def SetIndex(self, index):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   273
        self.Index.SetValue("0x%04X"%index)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   274
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   275
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   276
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   277
        try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   278
            int(self.Index.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   279
        except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   280
            error.append("Index")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   281
        if self.radioButton2.GetValue() or self.radioButton3.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   282
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   283
                int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   284
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   285
                error.append("Number")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   286
        if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   287
            text = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   288
            if len(error) > 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   289
                suffix = "s"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   290
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   291
                suffix = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   292
            for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   293
                if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   294
                    text += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   295
                elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   296
                    text += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   297
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   298
                    text += ", %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   299
            message = wxMessageDialog(self, "Form isn't valid. %s must be integer%s!"%(text,suffix), "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   300
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   301
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   302
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   303
            self.EndModal(wxID_OK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   304
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   305
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   306
        name = self.IndexName.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   307
        index = int(self.Index.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   308
        if self.radioButton1.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   309
            struct = 1
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   310
            number = None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   311
        elif self.radioButton2.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   312
            struct = 3
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   313
            number = int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   314
        elif self.radioButton3.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   315
            struct = 7
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   316
            number = int(self.Number.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   317
        return index, name, struct, number
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   318
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   319
    def OnRadioButton1Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   320
        self.EnableNumberTyping(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   321
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   322
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   323
    def OnRadioButton2Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   324
        self.EnableNumberTyping(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   325
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   326
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   327
    def OnRadioButton3Click(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   328
        self.EnableNumberTyping(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   329
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   330
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   331
    def EnableNumberTyping(self, enable):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   332
        self.staticText4.Enable(enable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   333
        self.Number.Enable(enable)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   334
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   335
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   336
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   337
#                          Create User Type Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   338
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   339
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   340
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   341
[wxID_USERTYPEDIALOG, wxID_USERTYPEDIALOGLENGTH, wxID_USERTYPEDIALOGMAINPANEL, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   342
 wxID_USERTYPEDIALOGMAX, wxID_USERTYPEDIALOGMIN, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   343
 wxID_USERTYPEDIALOGSTATICBOX1, wxID_USERTYPEDIALOGSTATICTEXT1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   344
 wxID_USERTYPEDIALOGSTATICTEXT2, wxID_USERTYPEDIALOGSTATICTEXT3, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   345
 wxID_USERTYPEDIALOGSTATICTEXT4, wxID_USERTYPEDIALOGTYPE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   346
] = [wx.NewId() for _init_ctrls in range(11)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   347
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   348
class UserTypeDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   349
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   350
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   351
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   352
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   353
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   354
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   355
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   356
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   357
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   358
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   359
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   360
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   361
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   362
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   363
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   364
        wx.Dialog.__init__(self, id=wxID_USERTYPEDIALOG, name='UserTypeDialog',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   365
              parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 228),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   366
              style=wx.DEFAULT_DIALOG_STYLE, title='Add User Type')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   367
        self.SetClientSize(wx.Size(444, 228))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   368
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   369
        self.MainPanel = wx.Panel(id=wxID_USERTYPEDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   370
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   371
              size=wx.Size(431, 182), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   372
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   373
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   374
        self.staticText1 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   375
              label='Type:', name='staticText1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   376
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   377
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   378
        self.Type = wx.Choice(choices=[], id=wxID_USERTYPEDIALOGTYPE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   379
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 48),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   380
              size=wx.Size(160, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   381
        self.Type.Bind(wx.EVT_CHOICE, self.OnTypeChoice,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   382
              id=wxID_USERTYPEDIALOGTYPE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   383
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   384
        self.staticBox1 = wx.StaticBox(id=wxID_USERTYPEDIALOGSTATICBOX1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   385
              label='Values', name='staticBox1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   386
              pos=wx.Point(200, 24), size=wx.Size(224, 144), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   387
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   388
        self.staticText2 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   389
              label='Minimum:', name='staticText2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   390
              pos=wx.Point(216, 48), size=wx.Size(67, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   391
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   392
        self.Min = wx.TextCtrl(id=wxID_USERTYPEDIALOGMIN, name='Min',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   393
              parent=self.MainPanel, pos=wx.Point(296, 48), size=wx.Size(112,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   394
              24), style=wx.TE_RIGHT, value='0')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   395
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   396
        self.staticText3 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   397
              label='Maximum:', name='staticText3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   398
              pos=wx.Point(216, 88), size=wx.Size(71, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   399
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   400
        self.Max = wx.TextCtrl(id=wxID_USERTYPEDIALOGMAX, name='Max',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   401
              parent=self.MainPanel, pos=wx.Point(296, 88), size=wx.Size(112,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   402
              25), style=wx.TE_RIGHT, value='0')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   403
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   404
        self.staticText4 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT4,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   405
              label='Length:', name='staticText4', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   406
              pos=wx.Point(216, 128), size=wx.Size(52, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   407
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   408
        self.Length = wx.TextCtrl(id=wxID_USERTYPEDIALOGLENGTH, name='Length',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   409
              parent=self.MainPanel, pos=wx.Point(296, 128), size=wx.Size(112,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   410
              25), style=wx.TE_RIGHT, value='0')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   411
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   412
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   413
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   414
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   415
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   416
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   417
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   418
        self.TypeDictionary = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   419
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   420
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   421
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   422
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   423
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   424
        good = True
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   425
        firstmessage = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   426
        secondmessage = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   427
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   428
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   429
            valuetype = self.TypeDictionary[name][1]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   430
            if valuetype == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   431
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   432
                    int(self.Min.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   433
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   434
                    error.append("Minimum")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   435
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   436
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   437
                    int(self.Max.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   438
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   439
                    error.append("Maximum")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   440
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   441
            elif valuetype == 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   442
                try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   443
                    int(self.Length.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   444
                except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   445
                    error.append("Length")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   446
                    good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   447
            if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   448
                secondmessage = ". "
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   449
                for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   450
                    if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   451
                        secondmessage += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   452
                    elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   453
                        secondmessage += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   454
                    else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   455
                        secondmessage += ", %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   456
                secondmessage += " must be integer"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   457
                if len(error) > 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   458
                    secondmessage += "s"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   459
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   460
            firstmessage = ". A type must be selected"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   461
            good = False
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   462
        if not good:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   463
            message = wxMessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   464
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   465
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   466
            self.Name.SetFocus()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   467
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   468
            self.EndModal(wxID_OK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   469
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   470
    def SetValues(self, min = None, max = None, length = None):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   471
        if min != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   472
            self.Min.SetValue(str(min))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   473
        if max != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   474
            self.Max.SetValue(str(max))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   475
        if length != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   476
            self.Length.SetValue(str(length))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   477
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   478
    def SetTypeList(self, typedic, type = None):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   479
        self.Type.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   480
        list = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   481
        for index, (name, valuetype) in typedic.iteritems():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   482
            self.TypeDictionary[name] = (index, valuetype)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   483
            list.append((index, name))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   484
        list.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   485
        for index, name in list:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   486
            self.Type.Append(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   487
        if type != None:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   488
            self.Type.SetStringSelection(typedic[type][0])
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   489
        self.RefreshValues()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   490
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   491
    def OnTypeChoice(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   492
        self.RefreshValues()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   493
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   494
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   495
    def RefreshValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   496
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   497
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   498
            valuetype = self.TypeDictionary[name][1]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   499
            if valuetype == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   500
                self.staticText2.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   501
                self.staticText3.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   502
                self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   503
                self.Min.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   504
                self.Max.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   505
                self.Length.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   506
            elif valuetype == 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   507
                self.staticText2.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   508
                self.staticText3.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   509
                self.staticText4.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   510
                self.Min.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   511
                self.Max.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   512
                self.Length.Enable(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   513
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   514
            self.staticText2.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   515
            self.staticText3.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   516
            self.staticText4.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   517
            self.Min.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   518
            self.Max.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   519
            self.Length.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   520
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   521
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   522
        name = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   523
        type = self.TypeDictionary[name][0]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   524
        min = int(self.Min.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   525
        max = int(self.Max.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   526
        length = int(self.Length.GetValue())
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   527
        return type, min, max, length
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   528
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   529
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   530
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   531
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   532
#                          Editing Node Infos Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   533
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   534
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   535
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   536
[wxID_NODEINFOSDIALOG, wxID_NODEINFOSDIALOGMAINPANEL, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   537
 wxID_NODEINFOSDIALOGNAME, wxID_NODEINFOSDIALOGNODEID, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   538
 wxID_NODEINFOSDIALOGDESCRIPTION, wxID_NODEINFOSDIALOGSTATICTEXT1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   539
 wxID_NODEINFOSDIALOGSTATICTEXT2, wxID_NODEINFOSDIALOGSTATICTEXT3, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   540
 wxID_NODEINFOSDIALOGSTATICTEXT4, wxID_NODEINFOSDIALOGTYPE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   541
] = [wx.NewId() for _init_ctrls in range(10)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   542
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   543
class NodeInfosDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   544
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   545
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   546
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   547
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   548
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   549
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   550
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   551
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   552
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   553
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   554
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   555
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   556
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   557
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   558
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   559
        wx.Dialog.__init__(self, id=wxID_NODEINFOSDIALOG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   560
              name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   561
              size=wx.Size(300, 300), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   562
              title='Node Infos')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   563
        self.SetClientSize(wx.Size(300, 300))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   564
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   565
        self.MainPanel = wx.Panel(id=wxID_NODEINFOSDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   566
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   567
              size=wx.Size(280, 264), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   568
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   569
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   570
        self.staticText1 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   571
              label='Name:', 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   572
              name='staticText1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   573
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   574
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   575
        self.Name = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNAME, name='Name',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   576
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(250,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   577
              25), style=0, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   578
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   579
        self.staticText2 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   580
              label='Node ID:', name='staticText2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   581
              pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   582
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   583
        self.NodeID = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNODEID, name='NodeID',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   584
              parent=self.MainPanel, pos=wx.Point(24, 104), size=wx.Size(250,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   585
              25), style=wx.TE_RIGHT, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   586
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   587
        self.staticText3 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   588
              label='Type:', name='staticText3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   589
              pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   590
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   591
        self.Type = wx.Choice(choices=[], id=wxID_NODEINFOSDIALOGTYPE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   592
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 160),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   593
              size=wx.Size(250, 25), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   594
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   595
        self.staticText4 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT4,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   596
              label='Description:', name='staticText4', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   597
              pos=wx.Point(24, 192), size=wx.Size(71, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   598
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   599
        self.Description = wx.TextCtrl(id=wxID_NODEINFOSDIALOGDESCRIPTION, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   600
              name='Description', parent=self.MainPanel, pos=wx.Point(24, 216), 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   601
              size=wx.Size(250, 25), style=0, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   602
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   603
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   604
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   605
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   606
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   607
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   608
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   609
        self.Type.Append("master")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   610
        self.Type.Append("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   611
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   612
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   613
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   614
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   615
        name = self.Name.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   616
        message = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   617
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   618
            good = not name[0].isdigit()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   619
            for item in name.split("_"):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   620
                good &= item.isalnum()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   621
            if not good:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   622
                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
   623
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   624
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   625
                nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   626
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   627
                message = "Node ID must be integer!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   628
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   629
            message = wxMessageDialog(self, message, "ERROR", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   630
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   631
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   632
            self.Name.SetFocus()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   633
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   634
            self.EndModal(wxID_OK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   635
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   636
    def SetValues(self, name, id, type, description):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   637
        self.Name.SetValue(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   638
        self.NodeID.SetValue("0x%02X"%id)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   639
        self.Type.SetStringSelection(type)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   640
        self.Description.SetValue(description)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   641
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   642
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   643
        name = self.Name.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   644
        nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   645
        type = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   646
        description = self.Description.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   647
        return name, nodeid, type, description
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   648
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   649
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   650
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   651
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   652
#                          Create New Node Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   653
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   654
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   655
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   656
[wxID_CREATENODEDIALOG, wxID_CREATENODEDIALOGEMERGENCY, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   657
 wxID_CREATENODEDIALOGGENSYNC, wxID_CREATENODEDIALOGMAINPANEL, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   658
 wxID_CREATENODEDIALOGNAME, wxID_CREATENODEDIALOGNMT_HEARTBEAT, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   659
 wxID_CREATENODEDIALOGNMT_NODEGUARDING, wxID_CREATENODEDIALOGNMT_NONE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   660
 wxID_CREATENODEDIALOGNODEID, wxID_CREATENODEDIALOGPROFILE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   661
 wxID_CREATENODEDIALOGSAVECONFIG, wxID_CREATENODEDIALOGSTATICTEXT1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   662
 wxID_CREATENODEDIALOGSTATICTEXT2, wxID_CREATENODEDIALOGSTATICTEXT3, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   663
 wxID_CREATENODEDIALOGSTATICTEXT4, wxID_CREATENODEDIALOGSTATICTEXT5, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   664
 wxID_CREATENODEDIALOGSTATICTEXT6, wxID_CREATENODEDIALOGSTATICTEXT7,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   665
 wxID_CREATENODEDIALOGSTOREEDS, wxID_CREATENODEDIALOGDESCRIPTION,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   666
 wxID_CREATENODEDIALOGTYPE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   667
] = [wx.NewId() for _init_ctrls in range(21)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   668
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   669
class CreateNodeDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   670
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   671
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   672
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   673
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   674
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   675
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   676
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   677
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   678
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   679
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   680
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   681
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   682
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   683
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   684
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   685
        wx.Dialog.__init__(self, id=wxID_CREATENODEDIALOG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   686
              name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   687
              size=wx.Size(451, 376), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   688
              title='Create a new Node')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   689
        self.SetClientSize(wx.Size(451, 376))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   690
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   691
        self.MainPanel = wx.Panel(id=wxID_CREATENODEDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   692
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   693
              size=wx.Size(440, 278), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   694
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   695
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   696
        self.staticText1 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   697
              label='Name:', name='staticText1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   698
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   699
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   700
        self.staticText2 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   701
              label='Node ID:', name='staticText2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   702
              pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   703
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   704
        self.staticText3 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   705
              label='Type:', name='staticText3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   706
              pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   707
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   708
        self.Type = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGTYPE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   709
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 160),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   710
              size=wx.Size(200, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   711
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   712
        self.Name = wx.TextCtrl(id=wxID_CREATENODEDIALOGNAME, name='Name',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   713
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(200,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   714
              25), style=0, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   715
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   716
        self.NodeID = wx.TextCtrl(id=wxID_CREATENODEDIALOGNODEID, name='NodeID',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   717
              parent=self.MainPanel, pos=wx.Point(24, 104), size=wx.Size(200,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   718
              25), style=wx.TE_RIGHT, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   719
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   720
        self.staticText4 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT4,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   721
              label='Profile:', name='staticText4', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   722
              pos=wx.Point(24, 192), size=wx.Size(47, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   723
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   724
        self.Profile = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGPROFILE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   725
              name='Profile', parent=self.MainPanel, pos=wx.Point(24, 216),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   726
              size=wx.Size(200, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   727
        self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   728
              id=wxID_CREATENODEDIALOGPROFILE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   729
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   730
        self.staticText5 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT5,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   731
              label='Network Management:', name='staticText5',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   732
              parent=self.MainPanel, pos=wx.Point(256, 24), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   733
              16), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   734
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   735
        self.NMT_None = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_NONE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   736
              label='None', name='NMT_None', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   737
              pos=wx.Point(256, 40), size=wx.Size(114, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   738
        self.NMT_None.SetValue(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   739
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   740
        self.NMT_NodeGuarding = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_NODEGUARDING,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   741
              label='Node Guarding', name='NMT_NodeGuarding',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   742
              parent=self.MainPanel, pos=wx.Point(256, 64), size=wx.Size(128,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   743
              24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   744
        self.NMT_NodeGuarding.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   745
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   746
        self.NMT_Heartbeat = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_HEARTBEAT,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   747
              label='Heartbeat', name='NMT_Heartbeat', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   748
              pos=wx.Point(256, 88), size=wx.Size(114, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   749
        self.NMT_Heartbeat.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   750
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   751
        self.staticText6 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT6,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   752
              label='Options:', name='staticText6', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   753
              pos=wx.Point(256, 128), size=wx.Size(72, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   754
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   755
        self.DS302 = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   756
              label='DS-302 Profile', name='DS302', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   757
              pos=wx.Point(256, 144), size=wx.Size(128, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   758
        self.DS302.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   759
        #self.DS302.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   760
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   761
        self.GenSYNC = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   762
              label='Generate SYNC', name='GenSYNC', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   763
              pos=wx.Point(256, 168), size=wx.Size(128, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   764
        self.GenSYNC.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   765
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   766
        self.Emergency = wx.CheckBox(id=wxID_CREATENODEDIALOGEMERGENCY,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   767
              label='Emergency support', name='Emergency',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   768
              parent=self.MainPanel, pos=wx.Point(256, 192), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   769
              24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   770
        self.Emergency.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   771
        self.Emergency.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   772
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   773
        self.SaveConfig = wx.CheckBox(id=wxID_CREATENODEDIALOGSAVECONFIG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   774
              label='Save Configuration', name='SaveConfig',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   775
              parent=self.MainPanel, pos=wx.Point(256, 216), size=wx.Size(152,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   776
              24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   777
        self.SaveConfig.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   778
        self.SaveConfig.Enable(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   779
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   780
#        self.StoreEDS = wx.CheckBox(id=wxID_CREATENODEDIALOGSTOREEDS,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   781
#              label='Store EDS', name='StoreEDS', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   782
#              pos=wx.Point(256, 240), size=wx.Size(144, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   783
#        self.StoreEDS.SetValue(False)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   784
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   785
        self.staticText7 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT7,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   786
              label='Description:', name='staticText7', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   787
              pos=wx.Point(24, 248), size=wx.Size(71, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   788
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   789
        self.Description = wx.TextCtrl(id=wxID_CREATENODEDIALOGDESCRIPTION, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   790
              name='Description', parent=self.MainPanel, pos=wx.Point(24, 272), 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   791
              size=wx.Size(400, 25), style=0, value='')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   792
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   793
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   794
206
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
   795
    def __init__(self, parent, cwd):
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   796
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   797
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   798
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   799
        self.NodeID.SetValue("0x00")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   800
        self.Type.Append("master")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   801
        self.Type.Append("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   802
        self.Type.SetStringSelection("slave")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   803
        self.Description.SetValue("")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   804
        self.ListProfile = {"None" : ""}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   805
        self.Profile.Append("None")
206
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
   806
        self.Directory = os.path.join(cwd, "config")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   807
        listfiles = os.listdir(self.Directory)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   808
        listfiles.sort()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   809
        for item in listfiles:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   810
            name, extend = os.path.splitext(item)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   811
            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
   812
                self.ListProfile[name] = os.path.join(self.Directory, item)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   813
                self.Profile.Append(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   814
        self.Profile.Append("Other")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   815
        self.Profile.SetStringSelection("None")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   816
        self.Name.SetFocus()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   817
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   818
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   819
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   820
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   821
        name = self.Name.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   822
        message = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   823
        if name != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   824
            good = not name[0].isdigit()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   825
            for item in name.split("_"):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   826
                good &= item.isalnum()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   827
            if not good:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   828
                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
   829
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   830
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   831
                nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   832
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   833
                message = "Node ID must be an integer!"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   834
        if message != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   835
            message = wxMessageDialog(self, message, "ERROR", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   836
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   837
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   838
            self.Name.SetFocus()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   839
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   840
            self.EndModal(wxID_OK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   841
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   842
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   843
        name = self.Name.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   844
        nodeid = 0
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   845
        if self.NodeID.GetValue() != "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   846
            nodeid = int(self.NodeID.GetValue(), 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   847
        type = self.Type.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   848
        description = self.Description.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   849
        return name, nodeid, type, description
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   850
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   851
    def GetProfile(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   852
        name = self.Profile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   853
        return name, self.ListProfile[name]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   854
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   855
    def GetNMTManagement(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   856
        if self.NMT_None.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   857
            return "None"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   858
        elif self.NMT_NodeGuarding.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   859
            return "NodeGuarding"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   860
        elif self.NMT_Heartbeat.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   861
            return "Heartbeat"
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   862
        return None
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   863
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   864
    def GetOptions(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   865
        options = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   866
        if self.DS302.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   867
            options.append("DS302")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   868
        if self.GenSYNC.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   869
            options.append("GenSYNC")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   870
        if self.Emergency.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   871
            options.append("Emergency")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   872
        if self.SaveConfig.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   873
            options.append("SaveConfig")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   874
#        if self.StoreEDS.GetValue():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   875
#            options.append("StoreEDS")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   876
        return options
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   877
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   878
    def OnProfileChoice(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   879
        if self.Profile.GetStringSelection() == "Other":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   880
            dialog = wxFileDialog(self, "Choose a file", self.Directory, "",  "OD Profile files (*.prf)|*.prf|All files|*.*", wxOPEN|wxCHANGE_DIR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   881
            dialog.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   882
            filepath = dialog.GetPath()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   883
            dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   884
            if os.path.isfile(filepath):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   885
                name = os.path.splitext(os.path.basename(filepath))[0]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   886
                self.ListProfile[name] = filepath
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   887
                length = self.Profile.GetCount()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   888
                self.Profile.Insert(name, length - 2)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   889
                self.Profile.SetStringSelection(name)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   890
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   891
                self.Profile.SetStringSelection("None")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   892
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   893
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   894
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   895
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   896
#                            ADD Slave to NodeList Dialog
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   897
#-------------------------------------------------------------------------------
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   898
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   899
[wxID_ADDSLAVEDIALOG, wxID_ADDSLAVEDIALOGMAINPANEL, wxID_ADDSLAVEDIALOGSLAVENAME, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   900
 wxID_ADDSLAVEDIALOGSLAVENODEID, wxID_ADDSLAVEDIALOGEDSFILE, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   901
 wxID_ADDSLAVEDIALOGIMPORTEDS, wxID_ADDSLAVEDIALOGSTATICTEXT1, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   902
 wxID_ADDSLAVEDIALOGSTATICTEXT2, wxID_ADDSLAVEDIALOGSTATICTEXT3, 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   903
] = [wx.NewId() for _init_ctrls in range(9)]
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   904
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   905
class AddSlaveDialog(wx.Dialog):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   906
    def _init_coll_flexGridSizer1_Items(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   907
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   908
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   909
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   910
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   911
    def _init_sizers(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   912
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   913
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   914
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   915
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   916
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   917
        self.SetSizer(self.flexGridSizer1)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   918
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   919
    def _init_ctrls(self, prnt):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   920
        # generated method, don't edit
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   921
        wx.Dialog.__init__(self, id=wxID_ADDSLAVEDIALOG,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   922
              name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   923
              size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   924
              title='Add a slave to nodelist')
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   925
        self.SetClientSize(wx.Size(300, 250))
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   926
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   927
        self.MainPanel = wx.Panel(id=wxID_ADDSLAVEDIALOGMAINPANEL,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   928
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   929
              size=wx.Size(350, 250), style=wx.TAB_TRAVERSAL)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   930
        self.MainPanel.SetAutoLayout(True)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   931
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   932
        self.staticText1 = wx.StaticText(id=wxID_ADDSLAVEDIALOGSTATICTEXT1,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   933
              label='Slave Name:', name='staticText1', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   934
              pos=wx.Point(24, 24), size=wx.Size(150, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   935
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   936
        self.SlaveName = wx.TextCtrl(id=wxID_ADDSLAVEDIALOGSLAVENAME,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   937
              name='SlaveName', parent=self.MainPanel, pos=wx.Point(24, 48), 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   938
              size=wx.Size(250, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   939
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   940
        self.staticText2 = wx.StaticText(id=wxID_ADDSLAVEDIALOGSTATICTEXT2,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   941
              label='Slave Node ID:', name='staticText2', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   942
              pos=wx.Point(24, 80), size=wx.Size(150, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   943
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   944
        self.SlaveNodeID = wx.TextCtrl(id=wxID_ADDSLAVEDIALOGSLAVENODEID,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   945
              name='SlaveName', parent=self.MainPanel, pos=wx.Point(24, 104), 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   946
              size=wx.Size(250, 24), style=wxALIGN_RIGHT)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   947
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   948
        self.staticText3 = wx.StaticText(id=wxID_ADDSLAVEDIALOGSTATICTEXT3,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   949
              label='EDS File:', name='staticText3', parent=self.MainPanel,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   950
              pos=wx.Point(24, 136), size=wx.Size(155, 17), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   951
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   952
        self.EDSFile = wx.Choice(id=wxID_ADDSLAVEDIALOGEDSFILE,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   953
              name='EDSFile', parent=self.MainPanel, pos=wx.Point(24, 160),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   954
              size=wx.Size(145, 24), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   955
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   956
        self.ImportEDS = wxButton(id=wxID_ADDSLAVEDIALOGIMPORTEDS, label='Import EDS',
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   957
              name='ImportEDS', parent=self.MainPanel, pos=wx.Point(174, 160),
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   958
              size=wx.Size(100, 32), style=0)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   959
        self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton,
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   960
              id=wxID_ADDSLAVEDIALOGIMPORTEDS)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   961
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   962
        self._init_sizers()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   963
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   964
    def __init__(self, parent):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   965
        self._init_ctrls(parent)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   966
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   967
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   968
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   969
        self.SlaveNodeID.SetValue("0x00")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   970
        
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   971
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   972
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   973
    def OnOK(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   974
        error = []
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   975
        if self.SlaveName.GetValue() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   976
            error.append("Slave Name")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   977
        if self.SlaveNodeID.GetValue() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   978
            error.append("Slave Node ID")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   979
        if self.EDSFile.GetStringSelection() == "":
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   980
            error.append("EDS File")
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   981
        if len(error) > 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   982
            text = ""
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   983
            for i, item in enumerate(error):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   984
                if i == 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   985
                    text += item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   986
                elif i == len(error) - 1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   987
                    text += " and %s"%item
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   988
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   989
                    text += ", %s"%item 
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   990
            message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   991
            message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   992
            message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   993
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   994
            try:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   995
                nodeid = self.SlaveNodeID.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   996
                if nodeid.find("x") != -1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   997
                    nodeid = int(nodeid, 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   998
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
   999
                    nodeid = int(nodeid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1000
            except:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1001
                message = wxMessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1002
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1003
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1004
                return
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1005
            if not 0 <= nodeid <= 127:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1006
                message = wxMessageDialog(self, "Slave Node ID must be between 0 and 127!", "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1007
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1008
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1009
            elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1010
                message = wxMessageDialog(self, "A Node with this ID already exist in the network!", "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1011
                message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1012
                message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1013
            else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1014
                self.EndModal(wxID_OK)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1015
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1016
    def OnImportEDSButton(self, event):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1017
        dialog = wxFileDialog(self, "Choose an EDS file", os.getcwd(), "",  "EDS files (*.eds)|*.eds|All files|*.*", wxOPEN|wxCHANGE_DIR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1018
        if dialog.ShowModal() == wxID_OK:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1019
            filepath = dialog.GetPath()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1020
            if os.path.isfile(filepath):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1021
                result = self.NodeList.ImportEDSFile(filepath)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1022
                if result:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1023
                    message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1024
                    message.ShowModal()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1025
                    message.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1026
        dialog.Destroy()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1027
        self.RefreshEDSFile()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1028
        event.Skip()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1029
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1030
    def RefreshEDSFile(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1031
        selection = self.EDSFile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1032
        self.EDSFile.Clear()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1033
        for option in self.NodeList.EDSNodes.keys():
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1034
            self.EDSFile.Append(option)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1035
        if self.EDSFile.FindString(selection) != wxNOT_FOUND:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1036
            self.EDSFile.SetStringSelection(selection)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1037
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1038
    def SetNodeList(self, nodelist):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1039
        self.NodeList = nodelist
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1040
        self.RefreshEDSFile()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1041
    
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1042
    def GetValues(self):
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1043
        values = {}
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1044
        values["slaveName"] = self.SlaveName.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1045
        nodeid = self.SlaveNodeID.GetValue()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1046
        if nodeid.find("x") != -1:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1047
            values["slaveNodeID"] = int(nodeid, 16)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1048
        else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1049
            values["slaveNodeID"] = int(nodeid)
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1050
        values["edsFile"] = self.EDSFile.GetStringSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents:
diff changeset
  1051
        return values