objdictgen/objdictedit.py
author greg
Mon, 30 Apr 2007 16:56:21 +0200
changeset 176 5d57fe1e3a5b
parent 171 db7a030babb2
child 182 988f2b302aa6
permissions -rwxr-xr-x
Support for DCF (DS-302)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
#!/usr/bin/env python
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
#This file is part of CanFestival, a library implementing CanOpen Stack. 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
#See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
#modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
#Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
#
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
#You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
from wxPython.wx import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
from wxPython.grid import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
import wx
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
from wx.lib.anchors import LayoutAnchors
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
import wx.grid
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
from types import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
import os, re, platform, sys, time, traceback, getopt
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
__version__ = "$Revision$"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
from nodemanager import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
from node import OD_Subindex,OD_MultipleSubindexes,OD_IdenticalSubindexes,OD_IdenticalIndexes
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
from doc_index.DS301_index import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    39
try:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    40
    from wxPython.html import *
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    41
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    42
    wxEVT_HTML_URL_CLICK = wxNewId()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    43
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    44
    def EVT_HTML_URL_CLICK(win, func):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    45
        win.Connect(-1, -1, wxEVT_HTML_URL_CLICK, func)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    46
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    47
    class wxHtmlWindowUrlClick(wxPyEvent):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    48
        def __init__(self, linkinfo):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    49
            wxPyEvent.__init__(self)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    50
            self.SetEventType(wxEVT_HTML_URL_CLICK)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    51
            self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget())
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    52
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    53
    class wxUrlClickHtmlWindow(wxHtmlWindow):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    54
        """ HTML window that generates and OnLinkClicked event.
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    55
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    56
        Use this to avoid having to override HTMLWindow
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    57
        """
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    58
        def OnLinkClicked(self, linkinfo):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    59
            wxPostEvent(self, wxHtmlWindowUrlClick(linkinfo))
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    60
    
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    61
#-------------------------------------------------------------------------------
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    62
#                                Html Frame
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    63
#-------------------------------------------------------------------------------
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    64
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    65
    [wxID_HTMLFRAME, wxID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    66
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    67
    class HtmlFrame(wx.Frame):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    68
        def _init_ctrls(self, prnt):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    69
            # generated method, don't edit
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    70
            wx.Frame.__init__(self, id=wxID_HTMLFRAME, name='HtmlFrame',
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    71
                  parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    72
                  style=wx.DEFAULT_FRAME_STYLE, title='')
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    73
            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_HTMLFRAME)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    74
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    75
            self.HtmlContent = wxUrlClickHtmlWindow(id=wxID_HTMLFRAMEHTMLCONTENT,
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    76
                  name='HtmlContent', parent=self, pos=wx.Point(0, 0),
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    77
                  size=wx.Size(-1, -1), style=wxHW_SCROLLBAR_AUTO|wxHW_NO_SELECTION)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    78
            EVT_HTML_URL_CLICK(self.HtmlContent, self.OnLinkClick)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    79
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    80
        def __init__(self, parent, opened):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    81
            self._init_ctrls(parent)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    82
            self.HtmlFrameOpened = opened
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    83
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    84
        def SetHtmlCode(self, htmlcode):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    85
            self.HtmlContent.SetPage(htmlcode)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    86
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    87
        def SetHtmlPage(self, htmlpage):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    88
            self.HtmlContent.LoadPage(htmlpage)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    89
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    90
        def OnCloseFrame(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    91
            self.HtmlFrameOpened.remove(self.GetTitle())
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    92
            event.Skip()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    93
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    94
        def OnLinkClick(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    95
            url = event.linkinfo[0]
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    96
            try:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    97
                import webbrowser
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    98
            except ImportError:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    99
                wxMessageBox('Please point your browser at: %s' % url)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   100
            else:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   101
                webbrowser.open(url)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   102
    
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   103
    Html_Window = True
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   104
except:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   105
    Html_Window = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   106
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
def create(parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
    return objdictedit(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
def usage():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
    print "\nUsage of objectdict.py :"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
    print "\n   %s [Filepath, ...]\n"%sys.argv[0]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
try:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
    opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
except getopt.GetoptError:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
    # print help information and exit:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
    usage()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
    sys.exit(2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
for o, a in opts:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
    if o in ("-h", "--help"):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
        usage()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
        sys.exit()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
filesOpen = args
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
   127
ScriptDirectory = sys.path[0]
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
ColSizes = [75, 250, 150, 125, 100, 60, 250]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_RIGHT, wxALIGN_CENTER, wxALIGN_CENTER, wxALIGN_LEFT]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
AccessList = "Read Only,Write Only,Read/Write"
68
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   132
RAccessList = "Read Only,Read/Write"
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
BoolList = "True,False"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
OptionList = "Yes,No"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
DictionaryOrganisation = [
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
    {"minIndex" : 0x0001, "maxIndex" : 0x0FFF, "name" : "Data Type Definitions"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
    {"minIndex" : 0x1000, "maxIndex" : 0x1029, "name" : "Communication Parameters"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
    {"minIndex" : 0x1200, "maxIndex" : 0x12FF, "name" : "SDO Parameters"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
    {"minIndex" : 0x1400, "maxIndex" : 0x15FF, "name" : "Receive PDO Parameters"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
    {"minIndex" : 0x1600, "maxIndex" : 0x17FF, "name" : "Receive PDO Mapping"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
    {"minIndex" : 0x1800, "maxIndex" : 0x19FF, "name" : "Transmit PDO Parameters"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
    {"minIndex" : 0x1A00, "maxIndex" : 0x1BFF, "name" : "Transmit PDO Mapping"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
    {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
    {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
    {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
    {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
class SubindexTable(wxPyGridTableBase):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
    A custom wxGrid Table using user supplied data
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
    """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
    def __init__(self, parent, data, editors, colnames):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
        # The base class must be initialized *first*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
        wxPyGridTableBase.__init__(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
        self.data = data
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
        self.editors = editors
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
        self.CurrentIndex = 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
        self.colnames = colnames
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
        self.Parent = parent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
        # XXX
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
        # we need to store the row length and collength to
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
        # see if the table has changed size
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
        self._rows = self.GetNumberRows()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
        self._cols = self.GetNumberCols()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
    def GetNumberCols(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
        return len(self.colnames)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
    def GetNumberRows(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
        return len(self.data)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
    def GetColLabelValue(self, col):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
        if col < len(self.colnames):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
            return self.colnames[col]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
    def GetRowLabelValues(self, row):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
        return row
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   181
    def GetValue(self, row, col):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
        if row < self.GetNumberRows():
63
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 59
diff changeset
   183
            value = self.data[row].get(self.GetColLabelValue(col), "")
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 59
diff changeset
   184
            if (type(value) == UnicodeType):
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 59
diff changeset
   185
                return value
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 59
diff changeset
   186
            else: 
2be18e405e40 Bug on map variable type changing and on comments with special characters corrected
lbessard
parents: 59
diff changeset
   187
                return str(value)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
    def GetEditor(self, row, col):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
        if row < self.GetNumberRows():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
            return self.editors[row].get(self.GetColLabelValue(col), "")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
    def GetValueByName(self, row, colname):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
        return self.data[row].get(colname)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
    def SetValue(self, row, col, value):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
        if col < len(self.colnames):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
            self.data[row][self.GetColLabelValue(col)] = value
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
    def ResetView(self, grid):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
        (wxGrid) -> Reset the grid view.   Call this to
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
        update the grid if rows and columns have been added or deleted
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
        grid.BeginBatch()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
        for current, new, delmsg, addmsg in [
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
            (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
            (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
        ]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
            if new < current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
                msg = wxGridTableMessage(self,delmsg,new,current-new)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
                grid.ProcessTableMessage(msg)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
            elif new > current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
                msg = wxGridTableMessage(self,addmsg,new-current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
                grid.ProcessTableMessage(msg)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
                self.UpdateValues(grid)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
        grid.EndBatch()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
        self._rows = self.GetNumberRows()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
        self._cols = self.GetNumberCols()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
        # update the column rendering scheme
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
        self._updateColAttrs(grid)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
        # update the scrollbars and the displayed part of the grid
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
        grid.AdjustScrollbars()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
        grid.ForceRefresh()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
    def UpdateValues(self, grid):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
        """Update all displayed values"""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
        # This sends an event to the grid table to update all of the values
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
        msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   233
        grid.ProcessTableMessage(msg)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
    def _updateColAttrs(self, grid):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
        wxGrid -> update the column attributes to add the
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
        appropriate renderer given the column name.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
        Otherwise default to the default renderer.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   243
        for col in range(self.GetNumberCols()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   244
            attr = wxGridCellAttr()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
            attr.SetAlignment(ColAlignements[col], wxALIGN_CENTRE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   246
            grid.SetColAttr(col, attr)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
            grid.SetColSize(col, ColSizes[col])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   248
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
        typelist = None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
        accesslist = None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
        for row in range(self.GetNumberRows()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
            editors = self.editors[row]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
            for col in range(self.GetNumberCols()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
                editor = None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
                renderer = None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
                
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
                colname = self.GetColLabelValue(col)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
                editortype = editors[colname]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
                if editortype:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
                    grid.SetReadOnly(row, col, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
                    if editortype == "string":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
                        editor = wxGridCellTextEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
                        renderer = wxGridCellStringRenderer()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
                        if colname == "value" and "length" in editors:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
                            editor.SetParameters(editors["length"]) 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
                    elif editortype == "number":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
                        editor = wxGridCellNumberEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
                        renderer = wxGridCellNumberRenderer()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
                        if colname == "value" and "min" in editors and "max" in editors:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
                    elif editortype == "real":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
                        editor = wxGridCellFloatEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   273
                        renderer = wxGridCellFloatRenderer()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   274
                        if colname == "value" and "min" in editors and "max" in editors:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   275
                            editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
                    elif editortype == "bool":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   277
                        editor = wxGridCellChoiceEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   278
                        editor.SetParameters(BoolList)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   279
                    elif editortype == "access":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
                        editor = wxGridCellChoiceEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
                        editor.SetParameters(AccessList)
68
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   282
                    elif editortype == "raccess":
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   283
                        editor = wxGridCellChoiceEditor()
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   284
                        editor.SetParameters(RAccessList)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
                    elif editortype == "option":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
                        editor = wxGridCellChoiceEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
                        editor.SetParameters(OptionList)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
                    elif editortype == "type":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   289
                        editor = wxGridCellChoiceEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
                        editor.SetParameters(self.Parent.Manager.GetCurrentTypeList())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
                    elif editortype == "map":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
                        editor = wxGridCellChoiceEditor()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   293
                        editor.SetParameters(self.Parent.Manager.GetCurrentMapList())
68
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   294
                    elif editortype == "time":
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   295
                        editor = wxGridCellTextEditor()
234dad27b398 Adding the possibility for users to choose between Dynamic Mapping and Static Mapping
lbessard
parents: 63
diff changeset
   296
                        renderer = wxGridCellStringRenderer()
176
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 171
diff changeset
   297
                    elif editortype == "domain":
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 171
diff changeset
   298
                        editor = wxGridCellTextEditor()
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 171
diff changeset
   299
                        renderer = wxGridCellStringRenderer()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   300
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   301
                    grid.SetReadOnly(row, col, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
                    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
                grid.SetCellEditor(row, col, editor)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   304
                grid.SetCellRenderer(row, col, renderer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   305
                
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   306
                grid.SetCellBackgroundColour(row, col, wxWHITE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   307
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
    def SetData(self, data):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   309
        self.data = data
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
    def SetEditors(self, editors):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   312
        self.editors = editors
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   313
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   314
    def GetCurrentIndex(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   315
        return self.CurrentIndex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   316
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   317
    def SetCurrentIndex(self, index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
        self.CurrentIndex = index
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   319
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320
    def AppendRow(self, row_content):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   321
        self.data.append(row_content)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   322
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   323
    def Empty(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   324
        self.data = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   325
        self.editors = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   326
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   327
[wxID_EDITINGPANEL, wxID_EDITINGPANELADDBUTTON, wxID_EDITINGPANELINDEXCHOICE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   328
 wxID_EDITINGPANELINDEXLIST, wxID_EDITINGPANELINDEXLISTPANEL, wxID_EDITINGPANELPARTLIST, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   329
 wxID_EDITINGPANELSECONDSPLITTER, wxID_EDITINGPANELSUBINDEXGRID,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   330
 wxID_EDITINGPANELSUBINDEXGRIDPANEL, wxID_EDITINGPANELCALLBACKCHECK,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   331
] = [wx.NewId() for _init_ctrls in range(10)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   332
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   333
[wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   334
 wxID_EDITINGPANELINDEXLISTMENUITEMS2, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   335
] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   336
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   337
[wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   338
] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   340
class EditingPanel(wx.SplitterWindow):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   341
    def _init_coll_AddToListSizer_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   342
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   343
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   344
        parent.AddWindow(self.AddButton, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   345
        parent.AddWindow(self.IndexChoice, 0, border=0, flag=wxGROW)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   346
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   347
    def _init_coll_SubindexGridSizer_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   348
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   349
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   350
        parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   351
        parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wxGROW)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   352
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   353
    def _init_coll_IndexListSizer_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   354
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   355
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   356
        parent.AddWindow(self.IndexList, 0, border=0, flag=wxGROW)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   357
        parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wxGROW)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   358
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   359
    def _init_coll_AddToListSizer_Growables(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   360
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   361
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   362
        parent.AddGrowableCol(1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   363
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   364
    def _init_coll_SubindexGridSizer_Growables(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   365
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   366
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   367
        parent.AddGrowableCol(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   368
        parent.AddGrowableRow(1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   369
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   370
    def _init_coll_IndexListSizer_Growables(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   371
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   372
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   373
        parent.AddGrowableCol(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   374
        parent.AddGrowableRow(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   375
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   376
    def _init_coll_SubindexGridMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   377
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   378
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   379
        parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   380
              kind=wx.ITEM_NORMAL, text='Add')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   381
        parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   382
              kind=wx.ITEM_NORMAL, text='Delete')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   383
        self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   384
              id=wxID_EDITINGPANELMENU1ITEMS0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   385
        self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   386
              id=wxID_EDITINGPANELMENU1ITEMS1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   387
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   388
    def _init_coll_IndexListMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   389
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
              kind=wx.ITEM_NORMAL, text='Rename')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   393
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS2,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   394
              kind=wx.ITEM_NORMAL, text='Modify')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   395
        parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   396
              kind=wx.ITEM_NORMAL, text='Delete')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   397
        self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   398
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   399
        self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   400
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   401
        self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
              id=wxID_EDITINGPANELINDEXLISTMENUITEMS2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   404
    def _init_utils(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   405
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   406
        self.IndexListMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   407
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   408
        self.SubindexGridMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   409
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   410
        self._init_coll_IndexListMenu_Items(self.IndexListMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   411
        self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   412
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   413
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   414
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   415
        self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
        self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   419
        self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   420
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   421
        self._init_coll_IndexListSizer_Growables(self.IndexListSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   422
        self._init_coll_IndexListSizer_Items(self.IndexListSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
        self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
        self._init_coll_SubindexGridSizer_Items(self.SubindexGridSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   425
        self._init_coll_AddToListSizer_Growables(self.AddToListSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   426
        self._init_coll_AddToListSizer_Items(self.AddToListSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   428
        self.SubindexGridPanel.SetSizer(self.SubindexGridSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   429
        self.IndexListPanel.SetSizer(self.IndexListSizer)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   431
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   432
        wx.SplitterWindow.__init__(self, id=wxID_EDITINGPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   433
              name='MainSplitter', parent=prnt, point=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   434
              size=wx.Size(-1, -1), style=wx.SP_3D)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   435
        self._init_utils()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   436
        self.SetNeedUpdating(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   437
        self.SetMinimumPaneSize(1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   438
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   439
        self.PartList = wx.ListBox(choices=[], id=wxID_EDITINGPANELPARTLIST,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   440
              name='PartList', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   441
              size=wx.Size(-1, -1), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   442
        self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   443
              id=wxID_EDITINGPANELPARTLIST)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   444
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
        self.SecondSplitter = wx.SplitterWindow(id=wxID_EDITINGPANELSECONDSPLITTER,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   446
              name='SecondSplitter', parent=self, point=wx.Point(0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   447
              0), size=wx.Size(-1, -1), style=wx.SP_3D)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   448
        self.SecondSplitter.SetMinimumPaneSize(1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   449
        self.SplitHorizontally(self.PartList, self.SecondSplitter,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   450
              110)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   451
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   452
        self.SubindexGridPanel = wx.Panel(id=wxID_EDITINGPANELSUBINDEXGRIDPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   453
              name='SubindexGridPanel', parent=self.SecondSplitter, pos=wx.Point(0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   454
              0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   455
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   456
        self.IndexListPanel = wx.Panel(id=wxID_EDITINGPANELINDEXLISTPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   457
              name='IndexListPanel', parent=self.SecondSplitter, pos=wx.Point(0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   458
              0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   459
        self.SecondSplitter.SplitVertically(self.IndexListPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   460
              self.SubindexGridPanel, 280)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   461
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   462
        self.SubindexGrid = wx.grid.Grid(id=wxID_EDITINGPANELSUBINDEXGRID,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   463
              name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   464
              0), size=wx.Size(-1, -1), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   465
        self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   466
              'Sans'))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   467
        self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   468
              False, 'Sans'))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   469
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   470
              self.OnSubindexGridCellChange)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   471
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   472
              self.OnSubindexGridRightClick)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   473
        self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   474
              self.OnSubindexGridSelectCell)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   475
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   476
        self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   477
              label='Have Callbacks', name='CallbackCheck',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   478
              parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   479
              24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   480
        self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   481
              id=wxID_EDITINGPANELCALLBACKCHECK)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   482
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   483
        self.IndexList = wx.ListBox(choices=[], id=wxID_EDITINGPANELINDEXLIST,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   484
              name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   485
              size=wx.Size(-1, -1), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   486
        self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   487
              id=wxID_EDITINGPANELINDEXLIST)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   488
        self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   489
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   490
        self.AddButton = wx.Button(id=wxID_EDITINGPANELADDBUTTON, label='Add',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   491
              name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   492
              size=wx.Size(50, 30), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   493
        self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   494
              id=wxID_EDITINGPANELADDBUTTON)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   495
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   496
        self.IndexChoice = wx.Choice(choices=[], id=wxID_EDITINGPANELINDEXCHOICE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   497
              name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   498
              0), size=wx.Size(-1, 30), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   499
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   500
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   501
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   502
    def __init__(self, parent, manager):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   503
        self._init_ctrls(parent.GetNoteBook())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   504
        self.Parent = parent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   505
        self.Manager = manager
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   506
        self.ListIndex = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   507
        self.ChoiceIndex = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   508
        self.FirstCall = False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   509
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   510
        for values in DictionaryOrganisation:
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
   511
            text = "   0x%04X-0x%04X      %s"%(values["minIndex"],values["maxIndex"],values["name"])
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   512
            self.PartList.Append(text)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   513
        self.Table = SubindexTable(self, [], [], ["subindex", "name", "type", "value", "access", "save", "comment"])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
        self.SubindexGrid.SetTable(self.Table)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   515
        self.SubindexGrid.SetRowLabelSize(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   516
        self.CallbackCheck.Disable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   517
        self.Table.ResetView(self.SubindexGrid)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   518
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   519
    def GetSelection(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   520
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   521
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   522
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   523
            subIndex = self.SubindexGrid.GetGridCursorRow()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
            return index, subIndex
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   525
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   526
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   527
    def OnAddButtonClick(self, event):
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   528
        self.SubindexGrid.SetGridCursor(0, 0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   529
        selected = self.IndexChoice.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   530
        if selected != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   531
            if selected == "User Type":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   532
                self.Parent.AddUserType()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   533
            elif selected == "SDO Server":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   534
                self.Manager.AddSDOServerToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   535
            elif selected == "SDO Client":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   536
                self.Manager.AddSDOClientToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   537
            elif selected == "PDO Receive":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   538
                self.Manager.AddPDOReceiveToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   539
            elif selected == "PDO Transmit":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   540
                self.Manager.AddPDOTransmitToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   541
            elif selected == "Map Variable":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   542
                self.Parent.AddMapVariable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   543
            elif selected in [menu for menu, indexes in self.Manager.GetCurrentSpecificMenu()]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   544
                self.Manager.AddSpecificEntryToCurrent(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   545
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   546
                index = self.ChoiceIndex[self.IndexChoice.GetSelection()]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   547
                self.Manager.ManageEntriesOfCurrent([index], [])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   548
            self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   549
            self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   550
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   551
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   552
    def OnPartListBoxClick(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   553
        self.SubindexGrid.SetGridCursor(0, 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   554
        self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   555
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   556
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   557
    def OnIndexListClick(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   558
        self.SubindexGrid.SetGridCursor(0, 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
        self.RefreshTable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   560
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   561
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   562
    def OnSubindexGridSelectCell(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   563
        wxCallAfter(self.Parent.RefreshStatusBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   564
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   565
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   566
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   567
#                             Refresh Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   568
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   569
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   570
    def RefreshIndexList(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   571
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   572
        choice = self.IndexChoice.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   573
        choiceindex = self.IndexChoice.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   574
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   575
            selectedindex = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   576
        self.IndexList.Clear()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   577
        self.IndexChoice.Clear()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   578
        i = self.PartList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   579
        if i < len(DictionaryOrganisation):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   580
            values = DictionaryOrganisation[i]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   581
            self.ListIndex = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   582
            for name, index in self.Manager.GetCurrentValidIndexes(values["minIndex"], values["maxIndex"]):
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
   583
                self.IndexList.Append("0x%04X   %s"%(index, name))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   584
                self.ListIndex.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   585
            self.ChoiceIndex = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   586
            if i == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   587
                self.IndexChoice.Append("User Type")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   588
                self.IndexChoice.SetStringSelection("User Type")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   589
            elif i == 2:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   590
                self.IndexChoice.Append("SDO Server")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   591
                self.IndexChoice.Append("SDO Client")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   592
                if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   593
                     self.IndexChoice.SetStringSelection(choice)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   594
            elif i in (3, 4):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   595
                self.IndexChoice.Append("PDO Receive")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   596
                self.IndexChoice.SetStringSelection("PDO Receive")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   597
            elif i in (5, 6):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   598
                self.IndexChoice.Append("PDO Transmit")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   599
                self.IndexChoice.SetStringSelection("PDO Transmit")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   600
            elif i == 8:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   601
                self.IndexChoice.Append("Map Variable")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   602
                self.IndexChoice.SetStringSelection("Map Variable")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   603
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   604
                for name, index in self.Manager.GetCurrentValidChoices(values["minIndex"], values["maxIndex"]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   605
                    if index:
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
   606
                        self.IndexChoice.Append("0x%04X   %s"%(index, name))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   607
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   608
                        self.IndexChoice.Append(name)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   609
                    self.ChoiceIndex.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   610
            if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   611
                self.IndexChoice.SetStringSelection(choice)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   612
        self.IndexChoice.Enable(self.IndexChoice.GetCount() != 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   613
        self.AddButton.Enable(self.IndexChoice.GetCount() != 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   614
        if selected == wxNOT_FOUND or selected >= len(self.ListIndex) or selectedindex != self.ListIndex[selected]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   615
            self.Table.Empty()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   616
            self.CallbackCheck.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   617
            self.CallbackCheck.Disable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   618
            self.Table.ResetView(self.SubindexGrid)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   619
            self.Parent.RefreshStatusBar()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   621
            self.IndexList.SetSelection(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   622
            self.RefreshTable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   623
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   624
    def RefreshTable(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   625
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   626
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   627
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
            if index > 0x260:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   629
                self.CallbackCheck.Enable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   630
                self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
            result = self.Manager.GetCurrentEntryValues(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
            if result != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   633
                self.Table.SetCurrentIndex(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
                data, editors = result
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
                self.Table.SetData(data)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
                self.Table.SetEditors(editors)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
                self.Table.ResetView(self.SubindexGrid)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   638
        self.Parent.RefreshStatusBar()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   639
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   640
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
#                        Editing Table value function
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   642
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   643
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   644
    def OnSubindexGridCellChange(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   645
        index = self.Table.GetCurrentIndex()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   646
        subIndex = event.GetRow()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   647
        col = event.GetCol()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   648
        name = self.Table.GetColLabelValue(col)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   649
        value = self.Table.GetValue(subIndex, col)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   650
        editor = self.Table.GetEditor(subIndex, col)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   651
        self.Manager.SetCurrentEntry(index, subIndex, value, name, editor)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   652
        self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   653
        wxCallAfter(self.RefreshTable)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   654
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   655
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   656
    def OnCallbackCheck(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   657
        index = self.Table.GetCurrentIndex()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   658
        self.Manager.SetCurrentEntryCallbacks(index, self.CallbackCheck.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   659
        self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   660
        wxCallAfter(self.RefreshTable)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   661
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   662
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   663
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   664
#                          Contextual Menu functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   665
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   666
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   667
    def OnIndexListRightUp(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   668
        if not self.FirstCall:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   669
            self.FirstCall = True
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   670
            selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   671
            if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   672
                index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   673
                if index < 0x260:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   674
                    self.IndexListMenu.FindItemByPosition(0).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   675
                    self.IndexListMenu.FindItemByPosition(1).Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   676
                    self.PopupMenu(self.IndexListMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   677
                elif 0x1000 <= index <= 0x1BFF:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   678
                    self.IndexListMenu.FindItemByPosition(0).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   679
                    self.IndexListMenu.FindItemByPosition(1).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   680
                    self.PopupMenu(self.IndexListMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   681
                elif 0x2000 <= index <= 0x5FFF:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   682
                    self.IndexListMenu.FindItemByPosition(0).Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   683
                    self.IndexListMenu.FindItemByPosition(1).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   684
                    self.PopupMenu(self.IndexListMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   685
                elif index >= 0x6000:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   686
                    self.IndexListMenu.FindItemByPosition(0).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   687
                    self.IndexListMenu.FindItemByPosition(1).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   688
                    self.PopupMenu(self.IndexListMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   689
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   690
            self.FirstCall = False
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   691
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   692
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   693
    def OnSubindexGridRightClick(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   694
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   695
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   696
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   697
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   698
                infos = self.Manager.GetEntryInfos(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   699
                if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   700
                    self.PopupMenu(self.SubindexGridMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   701
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   702
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   703
    def OnRenameIndexMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   704
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   705
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   706
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   707
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   708
                infos = self.Manager.GetEntryInfos(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   709
                dialog = wxTextEntryDialog(self, "Give a new name for index 0x%04X"%index,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   710
                             "Rename an index", infos["name"], wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   711
                if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   712
                    self.Manager.SetCurrentEntryName(index, dialog.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   713
                    self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   714
                    self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   715
                dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   716
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   717
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   718
    def OnModifyIndexMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   719
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   720
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   721
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   722
            if self.Manager.IsCurrentEntry(index) and index < 0x260:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   723
                values, valuetype = self.Manager.GetCustomisedTypeValues(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   724
                dialog = UserTypeDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   725
                dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   726
                if valuetype == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   727
                    dialog.SetValues(min = values[2], max = values[3])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   728
                elif valuetype == 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   729
                    dialog.SetValues(length = values[2])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   730
                if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   731
                    type, min, max, length = dialog.GetValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   732
                    self.Manager.SetCurrentUserType(index, type, min, max, length)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   733
                    self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   734
                    self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   735
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   736
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   737
    def OnDeleteIndexMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   738
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   739
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   740
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   741
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   742
                self.Manager.ManageEntriesOfCurrent([],[index])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   743
                self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   744
                self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   745
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   746
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   747
    def OnAddSubindexMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   748
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   749
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   750
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   751
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   752
                dialog = wxTextEntryDialog(self, "Number of subindexes to add:",
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   753
                             "Add subindexes", "1", wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   754
                if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   755
                    number = eval(dialog.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   756
                    if type(number) == IntType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   757
                        self.Manager.AddSubentriesToCurrent(index, number)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   758
                        self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   759
                        self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   760
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   761
                        message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   762
                        message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   763
                        message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   764
                dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   765
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   766
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   767
    def OnDeleteSubindexMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   768
        selected = self.IndexList.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   769
        if selected != wxNOT_FOUND:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   770
            index = self.ListIndex[selected]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   771
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   772
                dialog = wxTextEntryDialog(self, "Number of subindexes to delete:",
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   773
                             "Delete subindexes", "1", wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   774
                if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   775
                    number = eval(dialog.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   776
                    if type(number) == IntType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   777
                        self.Manager.RemoveSubentriesFromCurrent(index, number)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   778
                        self.Parent.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   779
                        self.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   780
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   781
                        message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   782
                        message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   783
                        message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   784
                dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   785
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   786
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   787
[wxID_OBJDICTEDIT, wxID_OBJDICTEDITFILEOPENED, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   788
 wxID_OBJDICTEDITHELPBAR,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   789
] = [wx.NewId() for _init_ctrls in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   790
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   791
[wxID_OBJDICTEDITADDMENUITEMS0, wxID_OBJDICTEDITADDMENUITEMS1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   792
 wxID_OBJDICTEDITADDMENUITEMS2, wxID_OBJDICTEDITADDMENUITEMS3, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   793
 wxID_OBJDICTEDITADDMENUITEMS4, wxID_OBJDICTEDITADDMENUITEMS5, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   794
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   795
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   796
[wxID_OBJDICTEDITFILEMENUITEMS0, wxID_OBJDICTEDITFILEMENUITEMS1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   797
 wxID_OBJDICTEDITFILEMENUITEMS2, wxID_OBJDICTEDITFILEMENUITEMS4, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   798
 wxID_OBJDICTEDITFILEMENUITEMS5, wxID_OBJDICTEDITFILEMENUITEMS6, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   799
 wxID_OBJDICTEDITFILEMENUITEMS7, wxID_OBJDICTEDITFILEMENUITEMS8,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   800
] = [wx.NewId() for _init_coll_FileMenu_Items in range(8)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   801
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   802
[wxID_OBJDICTEDITEDITMENUITEMS0, wxID_OBJDICTEDITEDITMENUITEMS1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   803
 wxID_OBJDICTEDITEDITMENUITEMS2, wxID_OBJDICTEDITEDITMENUITEMS4, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   804
 wxID_OBJDICTEDITEDITMENUITEMS6, wxID_OBJDICTEDITEDITMENUITEMS7, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   805
 wxID_OBJDICTEDITEDITMENUITEMS8, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   806
] = [wx.NewId() for _init_coll_EditMenu_Items in range(7)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   807
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   808
[wxID_OBJDICTEDITHELPMENUITEMS0, wxID_OBJDICTEDITHELPMENUITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   809
 wxID_OBJDICTEDITHELPMENUITEMS2,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   810
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   811
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   812
class objdictedit(wx.Frame):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   813
    def _init_coll_menuBar1_Menus(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   814
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   815
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   816
        parent.Append(menu=self.FileMenu, title='File')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   817
        parent.Append(menu=self.EditMenu, title='Edit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   818
        parent.Append(menu=self.AddMenu, title='Add')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   819
        parent.Append(menu=self.HelpMenu, title='Help')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   820
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   821
    def _init_coll_EditMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   822
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   823
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   824
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS4,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   825
              kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   826
        parent.AppendSeparator()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   827
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   828
              kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   829
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   830
              kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   831
        parent.AppendSeparator()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   832
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS6,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   833
              kind=wx.ITEM_NORMAL, text='Node infos')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   834
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS2,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   835
              kind=wx.ITEM_NORMAL, text='DS-301 Profile')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   836
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS8,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   837
              kind=wx.ITEM_NORMAL, text='DS-302 Profile')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   838
        parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS7,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   839
              kind=wx.ITEM_NORMAL, text='Other Profile')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   840
        self.Bind(wx.EVT_MENU, self.OnUndoMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   841
              id=wxID_OBJDICTEDITEDITMENUITEMS1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   842
        self.Bind(wx.EVT_MENU, self.OnRedoMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   843
              id=wxID_OBJDICTEDITEDITMENUITEMS0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   844
        self.Bind(wx.EVT_MENU, self.OnCommunicationMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   845
              id=wxID_OBJDICTEDITEDITMENUITEMS2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   846
        self.Bind(wx.EVT_MENU, self.OnRefreshMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   847
              id=wxID_OBJDICTEDITEDITMENUITEMS4)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   848
        self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   849
              id=wxID_OBJDICTEDITEDITMENUITEMS6)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   850
        self.Bind(wx.EVT_MENU, self.OnEditProfileMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   851
              id=wxID_OBJDICTEDITEDITMENUITEMS7)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   852
        self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   853
              id=wxID_OBJDICTEDITEDITMENUITEMS8)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   854
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   855
    def _init_coll_HelpMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   856
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   857
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   858
        parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   859
              kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   860
        self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   861
              id=wxID_OBJDICTEDITHELPMENUITEMS0)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   862
        if Html_Window:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   863
            parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS1,
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   864
                  kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2')
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   865
            parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS2,
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   866
                  kind=wx.ITEM_NORMAL, text='About')
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   867
            self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu,
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   868
                  id=wxID_OBJDICTEDITHELPMENUITEMS1)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   869
            self.Bind(wx.EVT_MENU, self.OnAboutMenu,
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   870
                  id=wxID_OBJDICTEDITHELPMENUITEMS2)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   871
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   872
    def _init_coll_FileMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   873
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   874
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   875
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS5,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   876
              kind=wx.ITEM_NORMAL, text='New\tCTRL+N')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   877
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   878
              kind=wx.ITEM_NORMAL, text='Open\tCTRL+O')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   879
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   880
              kind=wx.ITEM_NORMAL, text='Save\tCTRL+S')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   881
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS6,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   882
              kind=wx.ITEM_NORMAL, text='Save As...\tALT+S')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   883
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS2,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   884
              kind=wx.ITEM_NORMAL, text='Close\tCTRL+W')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   885
        parent.AppendSeparator()
171
db7a030babb2 EDS import
etisserant
parents: 158
diff changeset
   886
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS7,
db7a030babb2 EDS import
etisserant
parents: 158
diff changeset
   887
              kind=wx.ITEM_NORMAL, text='Import EDS file')
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   888
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS8,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   889
              kind=wx.ITEM_NORMAL, text='Build Dictionary\tCTRL+B')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   890
        parent.AppendSeparator()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   891
        parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS4,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   892
              kind=wx.ITEM_NORMAL, text='Exit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   893
        self.Bind(wx.EVT_MENU, self.OnOpenMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   894
              id=wxID_OBJDICTEDITFILEMENUITEMS0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   895
        self.Bind(wx.EVT_MENU, self.OnSaveMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   896
              id=wxID_OBJDICTEDITFILEMENUITEMS1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   897
        self.Bind(wx.EVT_MENU, self.OnCloseMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   898
              id=wxID_OBJDICTEDITFILEMENUITEMS2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   899
        self.Bind(wx.EVT_MENU, self.OnQuitMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   900
              id=wxID_OBJDICTEDITFILEMENUITEMS4)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   901
        self.Bind(wx.EVT_MENU, self.OnNewMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   902
              id=wxID_OBJDICTEDITFILEMENUITEMS5)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   903
        self.Bind(wx.EVT_MENU, self.OnSaveAsMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   904
              id=wxID_OBJDICTEDITFILEMENUITEMS6)
171
db7a030babb2 EDS import
etisserant
parents: 158
diff changeset
   905
        self.Bind(wx.EVT_MENU, self.OnImportMenu,
db7a030babb2 EDS import
etisserant
parents: 158
diff changeset
   906
              id=wxID_OBJDICTEDITFILEMENUITEMS7)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   907
        self.Bind(wx.EVT_MENU, self.OnExportMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   908
              id=wxID_OBJDICTEDITFILEMENUITEMS8)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   909
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   910
    def _init_coll_AddMenu_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   911
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   912
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   913
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS0,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   914
              kind=wx.ITEM_NORMAL, text='SDO Server')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   915
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   916
              kind=wx.ITEM_NORMAL, text='SDO Client')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   917
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS2,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   918
              kind=wx.ITEM_NORMAL, text='PDO Transmit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   919
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS3,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   920
              kind=wx.ITEM_NORMAL, text='PDO Receive')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   921
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS4,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   922
              kind=wx.ITEM_NORMAL, text='Map Variable')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   923
        parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS5,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   924
              kind=wx.ITEM_NORMAL, text='User Type')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   925
        self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   926
              id=wxID_OBJDICTEDITADDMENUITEMS0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   927
        self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   928
              id=wxID_OBJDICTEDITADDMENUITEMS1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   929
        self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   930
              id=wxID_OBJDICTEDITADDMENUITEMS2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   931
        self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   932
              id=wxID_OBJDICTEDITADDMENUITEMS3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   933
        self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   934
              id=wxID_OBJDICTEDITADDMENUITEMS4)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   935
        self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   936
              id=wxID_OBJDICTEDITADDMENUITEMS5)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   937
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   938
    def _init_coll_HelpBar_Fields(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   939
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   940
        parent.SetFieldsCount(3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   941
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   942
        parent.SetStatusText(number=0, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   943
        parent.SetStatusText(number=1, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   944
        parent.SetStatusText(number=2, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   945
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   946
        parent.SetStatusWidths([100, 110, -1])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   947
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   948
    def _init_utils(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   949
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   950
        self.menuBar1 = wx.MenuBar()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   951
        self.menuBar1.SetEvtHandlerEnabled(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   952
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   953
        self.FileMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   954
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   955
        self.EditMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   956
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   957
        self.AddMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   958
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   959
        self.HelpMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   960
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   961
        self._init_coll_menuBar1_Menus(self.menuBar1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   962
        self._init_coll_FileMenu_Items(self.FileMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   963
        self._init_coll_EditMenu_Items(self.EditMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   964
        self._init_coll_AddMenu_Items(self.AddMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   965
        self._init_coll_HelpMenu_Items(self.HelpMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   966
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   967
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   968
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   969
        wx.Frame.__init__(self, id=wxID_OBJDICTEDIT, name='objdictedit',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   970
              parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   971
              style=wx.DEFAULT_FRAME_STYLE, title='Objdictedit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   972
        self._init_utils()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   973
        self.SetClientSize(wx.Size(1000, 700))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   974
        self.SetMenuBar(self.menuBar1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   975
        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_OBJDICTEDIT)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   976
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   977
        self.FileOpened = wx.Notebook(id=wxID_OBJDICTEDITFILEOPENED,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   978
              name='FileOpened', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   979
              size=wx.Size(0, 0), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   980
        self.FileOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   981
              self.OnFileSelectedChanged, id=wxID_OBJDICTEDITFILEOPENED)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   982
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   983
        self.HelpBar = wx.StatusBar(id=wxID_OBJDICTEDITHELPBAR, name='HelpBar',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   984
              parent=self, style=wxST_SIZEGRIP)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   985
        self._init_coll_HelpBar_Fields(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   986
        self.SetStatusBar(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   987
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   988
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   989
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   990
        self.HtmlFrameOpened = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   991
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   992
        self.Manager = NodeManager()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   993
        for filepath in filesOpen:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   994
            self.Manager.OpenFileInCurrent(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   995
            new_editingpanel = EditingPanel(self, self.Manager)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   996
            self.FileOpened.AddPage(new_editingpanel, "")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   997
            self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   998
        if self.Manager.CurrentDS302Defined(): 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   999
            self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1000
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1001
            self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1002
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1003
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1004
        self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1005
        self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1006
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1007
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1008
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1009
        self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1010
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1011
    def GetNoteBook(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1012
        return self.FileOpened
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1013
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1014
    def OnAddSDOServerMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1015
        self.Manager.AddSDOServerToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1016
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1017
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1018
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1019
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1020
    def OnAddSDOClientMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1021
        self.Manager.AddSDOClientToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1022
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1023
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1024
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1025
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1026
    def OnAddPDOTransmitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1027
        self.Manager.AddPDOTransmitToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1028
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1029
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1030
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1031
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1032
    def OnAddPDOReceiveMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1033
        self.Manager.AddPDOReceiveToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1034
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1035
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1036
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1037
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1038
    def OnAddMapVariableMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1039
        self.AddMapVariable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1040
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1041
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1042
    def OnAddUserTypeMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1043
        self.AddUserType()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1044
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1045
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1046
    def OnFileSelectedChanged(self, event):
43
56ab4f38075e Bug on NoteBook in Windows corrected
lbessard
parents: 39
diff changeset
  1047
        selected = event.GetSelection()
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1048
        # At init selected = -1
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1049
        if selected >= 0:
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1050
        	self.Manager.ChangeCurrentNode(selected)
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1051
        	self.RefreshBufferState()
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1052
        	self.RefreshProfileMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1053
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1054
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1055
    def OnHelpDS301Menu(self, event):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1056
        find_index = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1057
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1058
        if selected >= 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1059
            window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1060
            result = window.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1061
            if result:
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1062
                find_index = True
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1063
                index, subIndex = result
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  1064
                result = OpenPDFDocIndex(index, ScriptDirectory)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1065
                if type(result) == StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1066
                    message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1067
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1068
                    message.Destroy()
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1069
        if not find_index:
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  1070
            result = OpenPDFDocIndex(None, ScriptDirectory)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1071
            if type(result) == StringType:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1072
                message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1073
                message.ShowModal()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
  1074
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1075
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1076
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1077
    def OnHelpCANFestivalMenu(self, event):
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  1078
        #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  1079
        os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1080
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1081
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1082
    def OnAboutMenu(self, event):
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  1083
        self.OpenHtmlFrame("About CAN Festival", os.path.join(ScriptDirectory, "doc/about.html"), wx.Size(500, 450))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1084
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1085
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1086
    def OpenHtmlFrame(self, title, file, size):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1087
        if title not in self.HtmlFrameOpened:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1088
            self.HtmlFrameOpened.append(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1089
            window = HtmlFrame(self, self.HtmlFrameOpened)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1090
            window.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1091
            window.SetHtmlPage(file)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1092
            window.SetClientSize(size)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1093
            window.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1094
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1095
    def OnQuitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1096
        self.Close()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1097
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1098
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1099
    def OnCloseFrame(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1100
        if self.Manager.OneFileHasChanged():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1101
            dialog = wxMessageDialog(self, "There are changes, do you want to save?",  "Close Application", wxYES_NO|wxCANCEL|wxICON_QUESTION)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1102
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1103
            dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1104
            if answer == wxID_YES:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1105
                self.Manager.ChangeCurrentNode(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1106
                for i in xrange(self.FileOpened.GetPageCount()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1107
                    if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1108
                        self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1109
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1110
                        self.Save()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1111
                        self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1112
                event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1113
            elif answer == wxID_NO:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1114
                for i in xrange(self.FileOpened.GetPageCount()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1115
                    self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1116
                wxCallAfter(self.Close)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1117
                event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1118
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1119
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1120
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1121
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1122
#                             Refresh Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1123
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1124
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1125
    def RefreshTitle(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1126
        if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1127
            self.SetTitle("Objdictedit - %s"%self.Manager.GetCurrentFilename())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1128
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1129
            self.SetTitle("Objdictedit")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1130
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1131
    def OnRefreshMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1132
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1133
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1134
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1135
    def RefreshCurrentIndexList(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1136
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1137
        window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1138
        window.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1139
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1140
    def RefreshStatusBar(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1141
        window = self.FileOpened.GetPage(self.FileOpened.GetSelection())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1142
        selection = window.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1143
        if selection:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1144
            index, subIndex = selection
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1145
            if self.Manager.IsCurrentEntry(index):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1146
                self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1147
                self.HelpBar.SetStatusText("Subindex: 0x%02X"%subIndex, 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1148
                entryinfos = self.Manager.GetEntryInfos(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1149
                name = entryinfos["name"]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1150
                category = "Optional"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1151
                if entryinfos["need"]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1152
                    category = "Mandatory"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1153
                struct = "VAR"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1154
                number = ""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1155
                if entryinfos["struct"] & OD_IdenticalIndexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1156
                    number = " possibly defined %d times"%entryinfos["nbmax"]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1157
                if entryinfos["struct"] & OD_IdenticalSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1158
                    struct = "REC"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1159
                elif entryinfos["struct"] & OD_MultipleSubindexes:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1160
                    struct = "ARRAY"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1161
                text = "%s: %s entry of struct %s%s."%(name,category,struct,number)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1162
                self.HelpBar.SetStatusText(text, 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1163
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1164
                for i in xrange(3):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1165
                    self.HelpBar.SetStatusText("", i)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1166
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1167
            for i in xrange(3):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1168
                self.HelpBar.SetStatusText("", i)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1169
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1170
    def RefreshMainMenu(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1171
        if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1172
            self.menuBar1.EnableTop(1, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1173
            self.menuBar1.EnableTop(2, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1174
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS1, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1175
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS2, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1176
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS6, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1177
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS8, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1178
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1179
            self.menuBar1.EnableTop(1, False)      
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1180
            self.menuBar1.EnableTop(2, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1181
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS1, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1182
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS2, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1183
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS6, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1184
            self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS8, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1185
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1186
    def RefreshEditMenu(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1187
        if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1188
            undo, redo = self.Manager.GetCurrentBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1189
            self.EditMenu.FindItemByPosition(2).Enable(undo)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1190
            self.EditMenu.FindItemByPosition(3).Enable(redo)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1191
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1192
            self.EditMenu.FindItemByPosition(2).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1193
            self.EditMenu.FindItemByPosition(3).Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1194
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1195
    def RefreshProfileMenu(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1196
        profile = self.Manager.GetCurrentProfileName()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1197
        edititem = self.EditMenu.FindItemByPosition(8)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1198
        length = self.AddMenu.GetMenuItemCount()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1199
        for i in xrange(length-6):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1200
            additem = self.AddMenu.FindItemByPosition(6)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1201
            self.AddMenu.Delete(additem.GetId())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1202
        if profile not in ("None", "DS-301"):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1203
            edititem.SetText("%s Profile"%profile)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1204
            edititem.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1205
            self.AddMenu.AppendSeparator()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1206
            for text, indexes in self.Manager.GetCurrentSpecificMenu():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1207
                new_id = wx.NewId()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1208
                self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1209
                self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1210
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1211
            edititem.SetText("Other Profile")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1212
            edititem.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1213
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1214
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1215
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1216
#                            Buffer Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1217
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1218
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1219
    def RefreshBufferState(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1220
        fileopened = self.Manager.GetAllFilenames()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1221
        for idx, filename in enumerate(fileopened):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1222
            self.FileOpened.SetPageText(idx, filename)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1223
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1224
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1225
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1226
    def OnUndoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1227
        self.Manager.LoadCurrentPrevious()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1228
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1229
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1230
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1231
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1232
    def OnRedoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1233
        self.Manager.LoadCurrentNext()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1234
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1235
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1236
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1237
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1238
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1239
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1240
#                         Load and Save Funtions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1241
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1242
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1243
    def OnNewMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1244
        self.FilePath = ""
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1245
        dialog = CreateNodeDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1246
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1247
            name, id, type = dialog.GetValues()
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1248
            profile, filepath = dialog.GetProfile()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1249
            NMT = dialog.GetNMTManagement()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1250
            options = dialog.GetOptions()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1251
            result = self.Manager.CreateNewNode(name, id, type, profile, filepath, NMT, options)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1252
            if not IsOfType(result, StringType):
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1253
                new_editingpanel = EditingPanel(self, self.Manager)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1254
                self.FileOpened.AddPage(new_editingpanel, "")
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1255
                self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex())
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1256
                self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1257
                if "DS302" in options:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1258
                    self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1259
                self.RefreshBufferState()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1260
                self.RefreshProfileMenu()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1261
                self.RefreshMainMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1262
            else:
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1263
                message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1264
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1265
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1266
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1267
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1268
    def OnOpenMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1269
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1270
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1271
            directory = os.path.dirname(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1272
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1273
            directory = os.getcwd()
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1274
        dialog = wxFileDialog(self, "Choose a file", directory, "",  "OD files (*.od)|*.od|All files|*.*", wxOPEN|wxCHANGE_DIR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1275
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1276
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1277
            if os.path.isfile(filepath):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1278
                result = self.Manager.OpenFileInCurrent(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1279
                if type(result) != StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1280
                    new_editingpanel = EditingPanel(self, self.Manager)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1281
                    self.FileOpened.AddPage(new_editingpanel, "")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1282
                    self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1283
                    if self.Manager.CurrentDS302Defined(): 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1284
                        self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1285
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1286
                        self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1287
                    self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1288
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1289
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1290
                    self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1291
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1292
                    message = wxMessageDialog(self, e.args[0], "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1293
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1294
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1295
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1296
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1297
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1298
    def OnSaveMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1299
        self.Save()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1300
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1301
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1302
    def OnSaveAsMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1303
        self.SaveAs()
30
a5dd050b28cb Some bugs found corrected
lbessard
parents: 0
diff changeset
  1304
        event.Skip()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1305
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1306
    def Save(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1307
        result = self.Manager.SaveCurrentInFile()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1308
        if not result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1309
            self.SaveAs()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1310
        elif type(result) != StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1311
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1312
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1313
            message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1314
            message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1315
            message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1316
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1317
    def SaveAs(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1318
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1319
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1320
            directory, filename = os.path.split(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1321
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1322
            directory, filename = os.getcwd(), "%s.od"%self.Manager.GetCurrentNodeInfos()[0]
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1323
        dialog = wxFileDialog(self, "Choose a file", directory, filename,  "OD files (*.od)|*.od|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1324
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1325
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1326
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1327
                result = self.Manager.SaveCurrentInFile(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1328
                if type(result) != StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1329
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1330
                else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1331
                    message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1332
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1333
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1334
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1335
                message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1336
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1337
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1338
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1339
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1340
    def OnCloseMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1341
        answer = wxID_YES
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1342
        result = self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1343
        if not result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1344
            dialog = wxMessageDialog(self, "There are changes, do you want to save?",  "Close File", wxYES_NO|wxCANCEL|wxICON_QUESTION)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1345
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1346
            dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1347
            if answer == wxID_YES:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1348
                self.OnSaveMenu(event)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1349
                if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1350
                    self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1351
            elif answer == wxID_NO:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1352
                self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1353
        if self.FileOpened.GetPageCount() > self.Manager.GetBufferNumber():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1354
            current = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1355
            self.FileOpened.DeletePage(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1356
            if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1357
                self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1358
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1359
            self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1360
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1361
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1362
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1363
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1364
#                         Import and Export Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1365
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1366
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1367
    def OnImportMenu(self, event):
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1368
        dialog = wxFileDialog(self, "Choose a file", os.getcwd(), "",  "XML OD files (*.xml)|*.xml|All files|*.*", wxOPEN|wxCHANGE_DIR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1369
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1370
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1371
            if os.path.isfile(filepath):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1372
                result = self.Manager.ImportCurrentFromFile(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1373
                if result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1374
                    if self.FileOpened.GetPageCount() == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1375
                        new_editingpanel = EditingPanel(self, self.Manager)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1376
                        self.FileOpened.AddPage(new_editingpanel, "")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1377
                        self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1378
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1379
                    self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1380
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1381
                    self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1382
                    message = wxMessageDialog(self, "Import successful", "Information", wxOK|wxICON_INFORMATION)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1383
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1384
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1385
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1386
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1387
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1388
    def OnExportMenu(self, event):
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1389
        dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0],  "CANFestival OD files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1390
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1391
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1392
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1393
                path, extend = os.path.splitext(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1394
                if extend in ("", "."):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1395
                    filepath = path + ".c"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1396
                result = self.Manager.ExportCurrentToFile(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1397
                if result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1398
                    message = wxMessageDialog(self, "Export successful", "Information", wxOK|wxICON_INFORMATION)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1399
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1400
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1401
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1402
                message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1403
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1404
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1405
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1406
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1407
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1408
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1409
#                          Editing Profiles functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1410
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1411
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1412
    def OnCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1413
        dictionary,current = self.Manager.GetCurrentCommunicationLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1414
        self.EditProfile("Edit DS-301 Profile", dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1415
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1416
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1417
    def OnOtherCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1418
        dictionary,current = self.Manager.GetCurrentDS302Lists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1419
        self.EditProfile("Edit DS-301 Profile", dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1420
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1421
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1422
    def OnEditProfileMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1423
        title = "Edit %s Profile"%self.Manager.GetCurrentProfileName()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1424
        dictionary,current = self.Manager.GetCurrentProfileLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1425
        self.EditProfile(title, dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1426
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1427
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1428
    def EditProfile(self, title, dictionary, current):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1429
        dialog = CommunicationDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1430
        dialog.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1431
        dialog.SetIndexDictionary(dictionary)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1432
        dialog.SetCurrentList(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1433
        dialog.RefreshLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1434
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1435
            new_profile = dialog.GetCurrentList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1436
            addinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1437
            removinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1438
            for index in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1439
                if index not in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1440
                    addinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1441
            for index in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1442
                if index not in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1443
                    removinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1444
            self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1445
            self.Manager.GenerateMapList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1446
            self.Manager.BufferCurrentNode()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1447
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1448
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1449
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1450
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1451
    def GetProfileCallBack(self, text):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1452
        def ProfileCallBack(event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1453
            self.Manager.AddSpecificEntryToCurrent(text)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1454
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1455
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1456
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1457
        return ProfileCallBack
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1458
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1459
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1460
#                         Edit Node informations function
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1461
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1462
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1463
    def OnNodeInfosMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1464
        dialog = NodeInfosDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1465
        name,id,type = self.Manager.GetCurrentNodeInfos()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1466
        profile = self.Manager.GetCurrentProfileName()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1467
        dialog.SetProfiles([profile])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1468
        dialog.SetValues(name, id, type, profile)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1469
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1470
            name,id,type,profile = dialog.GetValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1471
            self.Manager.SetCurrentNodeInfos(name, id, type)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1472
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1473
            self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1474
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1475
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1476
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1477
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1478
#                           Add User Types and Variables
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1479
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1480
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1481
    def AddMapVariable(self):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1482
        index = self.Manager.GetCurrentNextMapIndex()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1483
        if index:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1484
            dialog = MapVariableDialog(self)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1485
            dialog.SetIndex(index)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1486
            if dialog.ShowModal() == wxID_OK:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1487
                index, name, struct, number = dialog.GetValues()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1488
                result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1489
                if type(result) != StringType:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1490
                    self.RefreshBufferState()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1491
                    self.RefreshCurrentIndexList()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1492
                else:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1493
                    message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1494
                    message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1495
                    message.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1496
            dialog.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1497
        else:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1498
            message = wxMessageDialog(self, result, "No map variable index left!", wxOK|wxICON_ERROR)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1499
            message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1500
            message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1501
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1502
    def AddUserType(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1503
        dialog = UserTypeDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1504
        dialog.SetTypeList(self.Manager.GetCustomisableTypes())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1505
        if dialog.ShowModal() == wxID_OK:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1506
            type, min, max, length = dialog.GetValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1507
            result = self.Manager.AddUserTypeToCurrent(type, min, max, length)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1508
            if not IsOfType(result, StringType):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1509
                self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1510
                self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1511
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1512
                message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1513
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1514
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1515
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1516
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1517
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1518
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1519
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1520
#                          Editing Communication Dialog
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1521
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1522
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1523
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1524
[wxID_COMMUNICATIONDIALOG, wxID_COMMUNICATIONDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1525
 wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, wxID_COMMUNICATIONDIALOGCURRENTINDEXES,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1526
 wxID_COMMUNICATIONDIALOGSELECT, wxID_COMMUNICATIONDIALOGUNSELECT, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1527
 wxID_COMMUNICATIONDIALOGSTATICTEXT1, wxID_COMMUNICATIONDIALOGSTATICTEXT2
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1528
] = [wx.NewId() for _init_ctrls in range(8)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1529
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1530
class CommunicationDialog(wx.Dialog):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1531
    def _init_coll_flexGridSizer1_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1532
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1533
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1534
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1535
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1536
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1537
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1538
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1539
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1540
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1541
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1542
        self.SetSizer(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1543
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1544
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1545
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1546
        wx.Dialog.__init__(self, id=wxID_COMMUNICATIONDIALOG,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1547
              name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1548
              size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1549
              title='Edit Communication Profile')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1550
        self.SetClientSize(wx.Size(726, 437))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1551
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1552
        self.MainPanel = wx.Panel(id=wxID_COMMUNICATIONDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1553
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1554
              size=wx.Size(688, 382), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1555
        self.MainPanel.SetAutoLayout(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1556
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1557
        self.PossibleIndexes = wx.ListBox(choices=[],
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1558
              id=wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1559
              name='PossibleIndexes', parent=self.MainPanel, pos=wx.Point(40,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1560
              48), size=wx.Size(280, 320), style=wxLB_EXTENDED)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1561
        self.PossibleIndexes.Bind(wx.EVT_LEFT_DCLICK, self.OnPossibleIndexesDClick,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1562
              id=wxID_COMMUNICATIONDIALOGPOSSIBLEINDEXES)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1563
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1564
        self.CurrentIndexes = wx.ListBox(choices=[],
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1565
              id=wxID_COMMUNICATIONDIALOGCURRENTINDEXES, name='CurrentIndexes',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1566
              parent=self.MainPanel, pos=wx.Point(400, 48), size=wx.Size(280,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1567
              320), style=wxLB_EXTENDED)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1568
        self.CurrentIndexes.Bind(wx.EVT_LEFT_DCLICK, self.OnCurrentIndexesDClick,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1569
              id=wxID_COMMUNICATIONDIALOGCURRENTINDEXES)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1570
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1571
        self.Select = wx.Button(id=wxID_COMMUNICATIONDIALOGSELECT, label='>>',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1572
              name='Select', parent=self.MainPanel, pos=wx.Point(345, 136),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1573
              size=wx.Size(32, 32), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1574
        self.Select.Bind(wx.EVT_BUTTON, self.OnSelectButton,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1575
              id=wxID_COMMUNICATIONDIALOGSELECT)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1576
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1577
        self.Unselect = wx.Button(id=wxID_COMMUNICATIONDIALOGUNSELECT,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1578
              label='<<', name='Unselect', parent=self.MainPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1579
              pos=wx.Point(345, 216), size=wx.Size(32, 30), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1580
        self.Unselect.Bind(wx.EVT_BUTTON, self.OnUnselectButton,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1581
              id=wxID_COMMUNICATIONDIALOGUNSELECT)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1582
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1583
        self.staticText1 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT1,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1584
              label='Possible Profile Indexes:', name='staticText1',
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1585
              parent=self.MainPanel, pos=wx.Point(40, 24), size=wx.Size(156,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1586
              17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1587
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1588
        self.staticText2 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT2,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1589
              label='Current Profile Indexes:', name='staticText2',
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1590
              parent=self.MainPanel, pos=wx.Point(400, 24), size=wx.Size(152,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1591
              17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1592
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1593
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1594
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1595
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1596
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1597
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1598
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1599
        self.AllList = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1600
        self.CurrentList = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1601
        self.IndexDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1602
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1603
    def SetIndexDictionary(self, dictionary):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1604
        self.IndexDictionary = dictionary
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1605
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1606
    def SetCurrentList(self, list):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1607
        self.CurrentList = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1608
        self.CurrentList.extend(list)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1609
        self.CurrentList.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1610
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1611
    def GetCurrentList(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1612
        return self.CurrentList
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1613
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1614
    def RefreshLists(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1615
        self.PossibleIndexes.Clear()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1616
        self.CurrentIndexes.Clear()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1617
        self.AllList = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1618
        for index in self.IndexDictionary.iterkeys():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1619
            if index not in self.CurrentList:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1620
                self.AllList.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1621
        self.AllList.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1622
        for index in self.AllList:
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1623
            self.PossibleIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1624
        for index in self.CurrentList:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1625
            if index in self.IndexDictionary:
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
  1626
                self.CurrentIndexes.Append("0x%04X   %s"%(index, self.IndexDictionary[index][0]))
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1627
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1628
    def OnPossibleIndexesDClick(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1629
        self.SelectPossible()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1630
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1631
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1632
    def OnCurrentIndexesDClick(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1633
        self.UnselectCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1634
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1635
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1636
    def OnSelectButton(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1637
        self.SelectPossible()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1638
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1639
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1640
    def OnUnselectButton(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1641
        self.UnselectCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1642
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1643
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1644
    def SelectPossible(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1645
        selected = self.PossibleIndexes.GetSelections()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1646
        for i in selected:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1647
            self.CurrentList.append(self.AllList[i])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1648
        self.CurrentList.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1649
        self.RefreshLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1650
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1651
    def UnselectCurrent(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1652
        selected = self.CurrentIndexes.GetSelections()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1653
        for i in selected:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1654
            if not self.IndexDictionary[self.CurrentList[i]][1]:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1655
                self.CurrentList.pop(i)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1656
        self.CurrentList.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1657
        self.RefreshLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1658
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1659
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1660
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1661
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1662
#                          Create Map Variable Dialog
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1663
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1664
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1665
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1666
[wxID_MAPVARIABLEDIALOG, wxID_MAPVARIABLEDIALOGINDEX, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1667
 wxID_MAPVARIABLEDIALOGINDEXNAME, wxID_MAPVARIABLEDIALOGMAINPANEL, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1668
 wxID_MAPVARIABLEDIALOGNUMBER, wxID_MAPVARIABLEDIALOGRADIOBUTTON1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1669
 wxID_MAPVARIABLEDIALOGRADIOBUTTON2, wxID_MAPVARIABLEDIALOGRADIOBUTTON3, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1670
 wxID_MAPVARIABLEDIALOGSTATICTEXT1, wxID_MAPVARIABLEDIALOGSTATICTEXT2, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1671
 wxID_MAPVARIABLEDIALOGSTATICTEXT3, wxID_MAPVARIABLEDIALOGSTATICTEXT4, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1672
] = [wx.NewId() for _init_ctrls in range(12)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1673
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1674
class MapVariableDialog(wx.Dialog):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1675
    def _init_coll_flexGridSizer1_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1676
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1677
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1678
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1679
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1680
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1681
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1682
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1683
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1684
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1685
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1686
        self.SetSizer(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1687
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1688
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1689
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1690
        wx.Dialog.__init__(self, id=wxID_MAPVARIABLEDIALOG,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1691
              name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1692
              size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1693
              title='Add Map Variable')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1694
        self.SetClientSize(wx.Size(444, 186))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1695
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1696
        self.MainPanel = wx.Panel(id=wxID_MAPVARIABLEDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1697
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1698
              size=wx.Size(431, 142), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1699
        self.MainPanel.SetAutoLayout(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1700
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1701
        self.staticText1 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT1,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1702
              label='Index:', name='staticText1', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1703
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1704
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1705
        self.Index = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEX, name='Index',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1706
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(152,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1707
              25), style=0, value='0x2000')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1708
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1709
        self.staticText3 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT3,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1710
              label='Name:', name='staticText3', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1711
              pos=wx.Point(24, 80), size=wx.Size(47, 17), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1712
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1713
        self.IndexName = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEXNAME,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1714
              name='IndexName', parent=self.MainPanel, pos=wx.Point(24, 104),
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1715
              size=wx.Size(152, 24), style=0, value='Undefined')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1716
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1717
        self.staticText2 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT2,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1718
              label='Type:', name='staticText2', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1719
              pos=wx.Point(208, 24), size=wx.Size(38, 17), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1720
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1721
        self.radioButton1 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON1,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1722
              label='VAR', name='radioButton1', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1723
              pos=wx.Point(208, 48), size=wx.Size(72, 24), style=wxRB_GROUP)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1724
        self.radioButton1.SetValue(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1725
        self.radioButton1.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton1Click,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1726
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1727
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1728
        self.radioButton2 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON2,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1729
              label='ARRAY', name='radioButton2', parent=self.MainPanel,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1730
              pos=wx.Point(208, 72), size=wx.Size(80, 24), style=wxRB_SINGLE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1731
        self.radioButton2.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1732
        self.radioButton2.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton2Click,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1733
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1734
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1735
        self.radioButton3 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON3,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1736
              label='REC', name='radioButton3', parent=self.MainPanel,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1737
              pos=wx.Point(208, 96), size=wx.Size(96, 24), style=wxRB_SINGLE)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1738
        self.radioButton3.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1739
        self.radioButton3.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton3Click,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1740
              id=wxID_MAPVARIABLEDIALOGRADIOBUTTON3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1741
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1742
        self.staticText4 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT4,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1743
              label='Number:', name='staticText4', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1744
              pos=wx.Point(312, 80), size=wx.Size(88, 16), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1745
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1746
        self.Number = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGNUMBER,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1747
              name='Number', parent=self.MainPanel, pos=wx.Point(312, 104),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1748
              size=wx.Size(112, 24), style=wx.TE_RIGHT, value='0')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1749
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1750
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1751
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1752
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1753
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1754
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1755
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1756
        self.staticText4.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1757
        self.Number.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1758
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1759
    def SetIndex(self, index):
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1760
        self.Index.SetValue("0x%04X"%index)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1761
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1762
    def GetValues(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1763
        if self.radioButton1.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1764
            struct = 1
43
56ab4f38075e Bug on NoteBook in Windows corrected
lbessard
parents: 39
diff changeset
  1765
        elif self.radioButton2.GetValue():
56ab4f38075e Bug on NoteBook in Windows corrected
lbessard
parents: 39
diff changeset
  1766
            struct = 3
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1767
        elif self.radioButton3.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1768
            struct = 7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1769
        name = self.IndexName.GetValue()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1770
        index = eval(self.Index.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1771
        number = eval(self.Number.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1772
        return index, name, struct, number
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1773
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1774
    def OnRadioButton1Click(self, event):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1775
        self.EnableNumberTyping(False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1776
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1777
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1778
    def OnRadioButton2Click(self, event):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1779
        self.EnableNumberTyping(True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1780
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1781
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1782
    def OnRadioButton3Click(self, event):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1783
        self.EnableNumberTyping(True)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1784
        event.Skip()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1785
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1786
    def EnableNumberTyping(self, enable):
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1787
        self.staticText4.Enable(enable)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1788
        self.Number.Enable(enable)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1789
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1790
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1791
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1792
#                          Create User Type Dialog
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1793
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1794
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1795
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1796
[wxID_USERTYPEDIALOG, wxID_USERTYPEDIALOGLENGTH, wxID_USERTYPEDIALOGMAINPANEL, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1797
 wxID_USERTYPEDIALOGMAX, wxID_USERTYPEDIALOGMIN, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1798
 wxID_USERTYPEDIALOGSTATICBOX1, wxID_USERTYPEDIALOGSTATICTEXT1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1799
 wxID_USERTYPEDIALOGSTATICTEXT2, wxID_USERTYPEDIALOGSTATICTEXT3, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1800
 wxID_USERTYPEDIALOGSTATICTEXT4, wxID_USERTYPEDIALOGTYPE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1801
] = [wx.NewId() for _init_ctrls in range(11)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1802
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1803
class UserTypeDialog(wx.Dialog):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1804
    def _init_coll_flexGridSizer1_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1805
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1806
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1807
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1808
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1809
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1810
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1811
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1812
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1813
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1814
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1815
        self.SetSizer(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1816
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1817
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1818
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1819
        wx.Dialog.__init__(self, id=wxID_USERTYPEDIALOG, name='UserTypeDialog',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1820
              parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 228),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1821
              style=wx.DEFAULT_DIALOG_STYLE, title='Add User Type')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1822
        self.SetClientSize(wx.Size(444, 228))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1823
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1824
        self.MainPanel = wx.Panel(id=wxID_USERTYPEDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1825
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1826
              size=wx.Size(431, 182), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1827
        self.MainPanel.SetAutoLayout(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1828
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1829
        self.staticText1 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT1,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1830
              label='Type:', name='staticText1', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1831
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1832
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1833
        self.Type = wx.Choice(choices=[], id=wxID_USERTYPEDIALOGTYPE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1834
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 48),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1835
              size=wx.Size(160, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1836
        self.Type.Bind(wx.EVT_CHOICE, self.OnTypeChoice,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1837
              id=wxID_USERTYPEDIALOGTYPE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1838
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1839
        self.staticBox1 = wx.StaticBox(id=wxID_USERTYPEDIALOGSTATICBOX1,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1840
              label='Values', name='staticBox1', parent=self.MainPanel,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1841
              pos=wx.Point(200, 24), size=wx.Size(224, 144), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1842
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1843
        self.staticText2 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT2,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1844
              label='Minimum:', name='staticText2', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1845
              pos=wx.Point(216, 48), size=wx.Size(67, 17), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1846
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1847
        self.Min = wx.TextCtrl(id=wxID_USERTYPEDIALOGMIN, name='Min',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1848
              parent=self.MainPanel, pos=wx.Point(296, 48), size=wx.Size(112,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1849
              24), style=wx.TE_RIGHT, value='0')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1850
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1851
        self.staticText3 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT3,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1852
              label='Maximum:', name='staticText3', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1853
              pos=wx.Point(216, 88), size=wx.Size(71, 17), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1854
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1855
        self.Max = wx.TextCtrl(id=wxID_USERTYPEDIALOGMAX, name='Max',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1856
              parent=self.MainPanel, pos=wx.Point(296, 88), size=wx.Size(112,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1857
              25), style=wx.TE_RIGHT, value='0')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1858
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1859
        self.staticText4 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT4,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1860
              label='Length:', name='staticText4', parent=self.MainPanel,
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1861
              pos=wx.Point(216, 128), size=wx.Size(52, 17), style=0)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1862
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1863
        self.Length = wx.TextCtrl(id=wxID_USERTYPEDIALOGLENGTH, name='Length',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1864
              parent=self.MainPanel, pos=wx.Point(296, 128), size=wx.Size(112,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1865
              25), style=wx.TE_RIGHT, value='0')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1866
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1867
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1868
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1869
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1870
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1871
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1872
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1873
        self.TypeDictionary = {}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1874
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1875
    def SetValues(self, min = None, max = None, length = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1876
        if min != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1877
            self.Min.SetValue(str(min))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1878
        if max != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1879
            self.Max.SetValue(str(max))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1880
        if length != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1881
            self.Length.SetValue(str(length))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1882
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1883
    def SetTypeList(self, typedic, type = None):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1884
        self.Type.Clear()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1885
        list = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1886
        for index, (name, valuetype) in typedic.iteritems():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1887
            self.TypeDictionary[name] = (index, valuetype)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1888
            list.append((index, name))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1889
        list.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1890
        for index, name in list:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1891
            self.Type.Append(name)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1892
        if type != None:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1893
            self.Type.SetStringSelection(typedic[type][0])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1894
        self.RefreshValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1895
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1896
    def OnTypeChoice(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1897
        self.RefreshValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1898
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1899
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1900
    def RefreshValues(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1901
        name = self.Type.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1902
        if name != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1903
            valuetype = self.TypeDictionary[name][1]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1904
            if valuetype == 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1905
                self.staticText2.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1906
                self.staticText3.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1907
                self.staticText4.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1908
                self.Min.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1909
                self.Max.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1910
                self.Length.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1911
            elif valuetype == 1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1912
                self.staticText2.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1913
                self.staticText3.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1914
                self.staticText4.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1915
                self.Min.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1916
                self.Max.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1917
                self.Length.Enable(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1918
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1919
            self.staticText2.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1920
            self.staticText3.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1921
            self.staticText4.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1922
            self.Min.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1923
            self.Max.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1924
            self.Length.Enable(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1925
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1926
    def GetValues(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1927
        name = self.Type.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1928
        type = self.TypeDictionary[name][0]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1929
        min = eval(self.Min.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1930
        max = eval(self.Max.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1931
        length = eval(self.Length.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1932
        return type, min, max, length
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1933
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1934
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1935
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1936
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1937
#                          Editing Node Infos Dialog
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1938
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1939
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1940
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1941
[wxID_NODEINFOSDIALOG, wxID_NODEINFOSDIALOGMAINPANEL, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1942
 wxID_NODEINFOSDIALOGNAME, wxID_NODEINFOSDIALOGNODEID, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1943
 wxID_NODEINFOSDIALOGPROFILE, wxID_NODEINFOSDIALOGSTATICTEXT1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1944
 wxID_NODEINFOSDIALOGSTATICTEXT2, wxID_NODEINFOSDIALOGSTATICTEXT3, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1945
 wxID_NODEINFOSDIALOGSTATICTEXT4, wxID_NODEINFOSDIALOGTYPE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1946
] = [wx.NewId() for _init_ctrls in range(10)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1947
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1948
class NodeInfosDialog(wx.Dialog):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1949
    def _init_coll_flexGridSizer1_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1950
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1951
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1952
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1953
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1954
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1955
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1956
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1957
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1958
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1959
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1960
        self.SetSizer(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1961
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1962
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1963
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1964
        wx.Dialog.__init__(self, id=wxID_NODEINFOSDIALOG,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1965
              name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1966
              size=wx.Size(249, 250), style=wx.DEFAULT_DIALOG_STYLE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1967
              title='Node Infos')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1968
        self.SetClientSize(wx.Size(249, 250))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1969
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1970
        self.MainPanel = wx.Panel(id=wxID_NODEINFOSDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1971
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1972
              size=wx.Size(231, 264), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1973
        self.MainPanel.SetAutoLayout(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1974
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1975
        self.staticText1 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT1,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1976
              label='Name:', 
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1977
              name='staticText1', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1978
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1979
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1980
        self.Name = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNAME, name='Name',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1981
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(200,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1982
              25), style=0, value='')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1983
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1984
        self.staticText2 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT2,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1985
              label='Node ID:', name='staticText2', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1986
              pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1987
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1988
        self.NodeID = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNODEID, name='NodeID',
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1989
              parent=self.MainPanel, pos=wx.Point(24, 104), size=wx.Size(200,
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1990
              25), style=wx.TE_RIGHT, value='')
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1991
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1992
        self.staticText3 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT3,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  1993
              label='Type:', name='staticText3', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1994
              pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1995
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1996
        self.Type = wx.Choice(choices=[], id=wxID_NODEINFOSDIALOGTYPE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1997
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 160),
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  1998
              size=wx.Size(200, 25), style=0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1999
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2000
        self.staticText4 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT4,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2001
              label='Profile:', name='staticText4', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2002
              pos=wx.Point(24, 192), size=wx.Size(47, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2003
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2004
        self.Profile = wx.Choice(choices=[], id=wxID_NODEINFOSDIALOGPROFILE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2005
              name='Profile', parent=self.MainPanel, pos=wx.Point(24, 216),
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
  2006
              size=wx.Size(200, 25), style=0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2007
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2008
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2009
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2010
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2011
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2012
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2013
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2014
        self.Type.Append("master")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2015
        self.Type.Append("slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2016
        self.staticText4.Hide()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2017
        self.Profile.Hide()
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2018
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2019
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2020
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2021
    def OnOK(self, event):
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2022
        name = self.Name.GetValue()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2023
        if name != "":
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2024
            good = not name[0].isdigit()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2025
            for item in name.split("_"):
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2026
                good &= item.isalnum()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2027
        else:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2028
            good = False
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2029
        if not good:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2030
            message = wxMessageDialog(self, "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!", "ERROR", wxOK|wxICON_ERROR)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2031
            message.ShowModal()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2032
            message.Destroy()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2033
            self.Name.SetFocus()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2034
        else:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2035
            self.EndModal(wxID_OK)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2036
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2037
    def SetProfiles(self, profiles):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2038
        for profile in profiles:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2039
            self.Profile.Append(profile)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2040
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2041
    def SetValues(self, name, id, type, profile):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2042
        self.Name.SetValue(name)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2043
        self.NodeID.SetValue("0x%02X"%id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2044
        self.Type.SetStringSelection(type)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2045
        self.Profile.SetStringSelection(profile)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2046
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2047
    def GetValues(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2048
        name = self.Name.GetValue()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2049
        nodeid = eval(self.NodeID.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2050
        type = self.Type.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2051
        profile = self.Profile.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2052
        return name, nodeid, type, profile
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2053
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2054
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2055
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2056
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2057
#                          Create New Node Dialog
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2058
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2059
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2060
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2061
[wxID_CREATENODEDIALOG, wxID_CREATENODEDIALOGEMERGENCY, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2062
 wxID_CREATENODEDIALOGGENSYNC, wxID_CREATENODEDIALOGMAINPANEL, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2063
 wxID_CREATENODEDIALOGNAME, wxID_CREATENODEDIALOGNMT_HEARTBEAT, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2064
 wxID_CREATENODEDIALOGNMT_NODEGUARDING, wxID_CREATENODEDIALOGNMT_NONE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2065
 wxID_CREATENODEDIALOGNODEID, wxID_CREATENODEDIALOGPROFILE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2066
 wxID_CREATENODEDIALOGSAVECONFIG, wxID_CREATENODEDIALOGSTATICTEXT1, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2067
 wxID_CREATENODEDIALOGSTATICTEXT2, wxID_CREATENODEDIALOGSTATICTEXT3, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2068
 wxID_CREATENODEDIALOGSTATICTEXT4, wxID_CREATENODEDIALOGSTATICTEXT5, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2069
 wxID_CREATENODEDIALOGSTATICTEXT6, wxID_CREATENODEDIALOGSTOREEDS, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2070
 wxID_CREATENODEDIALOGTYPE, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2071
] = [wx.NewId() for _init_ctrls in range(19)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2072
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2073
class CreateNodeDialog(wx.Dialog):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2074
    def _init_coll_flexGridSizer1_Items(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2075
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2076
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2077
        parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2078
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2079
    def _init_sizers(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2080
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2081
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2082
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2083
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2084
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2085
        self.SetSizer(self.flexGridSizer1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2086
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2087
    def _init_ctrls(self, prnt):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2088
        # generated method, don't edit
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2089
        wx.Dialog.__init__(self, id=wxID_CREATENODEDIALOG,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2090
              name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2091
              size=wx.Size(451, 316), style=wx.DEFAULT_DIALOG_STYLE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2092
              title='Create a new Node')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2093
        self.SetClientSize(wx.Size(451, 316))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2094
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2095
        self.MainPanel = wx.Panel(id=wxID_CREATENODEDIALOGMAINPANEL,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2096
              name='MainPanel', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2097
              size=wx.Size(440, 278), style=wx.TAB_TRAVERSAL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2098
        self.MainPanel.SetAutoLayout(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2099
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2100
        self.staticText1 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT1,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2101
              label='Name:', name='staticText1', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2102
              pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2103
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2104
        self.staticText2 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT2,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2105
              label='Node ID:', name='staticText2', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2106
              pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2107
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2108
        self.staticText3 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT3,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2109
              label='Type:', name='staticText3', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2110
              pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2111
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2112
        self.Type = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGTYPE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2113
              name='Type', parent=self.MainPanel, pos=wx.Point(24, 160),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2114
              size=wx.Size(200, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2115
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2116
        self.Name = wx.TextCtrl(id=wxID_CREATENODEDIALOGNAME, name='Name',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2117
              parent=self.MainPanel, pos=wx.Point(24, 48), size=wx.Size(200,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2118
              25), style=0, value='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2119
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2120
        self.NodeID = wx.TextCtrl(id=wxID_CREATENODEDIALOGNODEID, name='NodeID',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2121
              parent=self.MainPanel, pos=wx.Point(24, 104), size=wx.Size(200,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2122
              25), style=wx.TE_RIGHT, value='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2123
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2124
        self.staticText4 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT4,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2125
              label='Profile:', name='staticText4', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2126
              pos=wx.Point(24, 192), size=wx.Size(47, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2127
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2128
        self.Profile = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGPROFILE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2129
              name='Profile', parent=self.MainPanel, pos=wx.Point(24, 216),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2130
              size=wx.Size(200, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2131
        self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2132
              id=wxID_CREATENODEDIALOGPROFILE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2133
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2134
        self.staticText5 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT5,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2135
              label='Network Management:', name='staticText5',
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2136
              parent=self.MainPanel, pos=wx.Point(256, 24), size=wx.Size(152,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2137
              16), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2138
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2139
        self.NMT_None = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_NONE,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2140
              label='None', name='NMT_None', parent=self.MainPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2141
              pos=wx.Point(256, 40), size=wx.Size(114, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2142
        self.NMT_None.SetValue(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2143
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2144
        self.NMT_NodeGuarding = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_NODEGUARDING,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2145
              label='Node Guarding', name='NMT_NodeGuarding',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2146
              parent=self.MainPanel, pos=wx.Point(256, 64), size=wx.Size(128,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2147
              24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2148
        self.NMT_NodeGuarding.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2149
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2150
        self.NMT_Heartbeat = wx.RadioButton(id=wxID_CREATENODEDIALOGNMT_HEARTBEAT,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2151
              label='Heartbeat', name='NMT_Heartbeat', parent=self.MainPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2152
              pos=wx.Point(256, 88), size=wx.Size(114, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2153
        self.NMT_Heartbeat.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2154
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2155
        self.staticText6 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT6,
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2156
              label='Options:', name='staticText6', parent=self.MainPanel,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2157
              pos=wx.Point(256, 128), size=wx.Size(72, 17), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2158
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2159
        self.DS302 = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2160
              label='DS-302 Profile', name='DS302', parent=self.MainPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2161
              pos=wx.Point(256, 144), size=wx.Size(128, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2162
        self.DS302.SetValue(False)
176
5d57fe1e3a5b Support for DCF (DS-302)
greg
parents: 171
diff changeset
  2163
        #self.DS302.Enable(False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2164
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2165
        self.GenSYNC = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2166
              label='Generate SYNC', name='GenSYNC', parent=self.MainPanel,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2167
              pos=wx.Point(256, 168), size=wx.Size(128, 24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2168
        self.GenSYNC.SetValue(False)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2169
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2170
        self.Emergency = wx.CheckBox(id=wxID_CREATENODEDIALOGEMERGENCY,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2171
              label='Emergency support', name='Emergency',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2172
              parent=self.MainPanel, pos=wx.Point(256, 192), size=wx.Size(152,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2173
              24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2174
        self.Emergency.SetValue(False)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2175
        self.Emergency.Enable(False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2176
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2177
        self.SaveConfig = wx.CheckBox(id=wxID_CREATENODEDIALOGSAVECONFIG,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2178
              label='Save Configuration', name='SaveConfig',
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2179
              parent=self.MainPanel, pos=wx.Point(256, 216), size=wx.Size(152,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2180
              24), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2181
        self.SaveConfig.SetValue(False)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2182
        self.SaveConfig.Enable(False)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2183
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2184
#        self.StoreEDS = wx.CheckBox(id=wxID_CREATENODEDIALOGSTOREEDS,
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2185
#              label='Store EDS', name='StoreEDS', parent=self.MainPanel,
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2186
#              pos=wx.Point(256, 240), size=wx.Size(144, 24), style=0)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2187
#        self.StoreEDS.SetValue(False)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2188
 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2189
        self._init_sizers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2190
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2191
    def __init__(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2192
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2193
        self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2194
        self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2195
        self.NodeID.SetValue("0x00")
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2196
        self.Type.Append("master")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2197
        self.Type.Append("slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2198
        self.Type.SetStringSelection("slave")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2199
        self.ListProfile = {"None" : ""}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2200
        self.Profile.Append("None")
158
b505f7116a1c Moved DS-301 PDF into objdictgen. Fixed installation on linux. Now TestMasterSlave is also installed in $PREFIX/bin.
etisserant
parents: 149
diff changeset
  2201
        self.Directory = os.path.join(ScriptDirectory, "config")
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2202
        listfiles = os.listdir(self.Directory)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2203
        listfiles.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2204
        for item in listfiles:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2205
            name, extend = os.path.splitext(item)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2206
            if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2207
                self.ListProfile[name] = os.path.join(self.Directory, item)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2208
                self.Profile.Append(name)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2209
        self.Profile.Append("Other")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2210
        self.Profile.SetStringSelection("None")
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2211
        self.Name.SetFocus()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2212
        
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2213
        EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2214
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2215
    def OnOK(self, event):
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2216
        name = self.Name.GetValue()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2217
        if name != "":
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2218
            good = not name[0].isdigit()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2219
            for item in name.split("_"):
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2220
                good &= item.isalnum()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2221
        else:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2222
            good = False
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2223
        if not good:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2224
            message = wxMessageDialog(self, "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!", "ERROR", wxOK|wxICON_ERROR)
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2225
            message.ShowModal()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2226
            message.Destroy()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2227
            self.Name.SetFocus()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2228
        else:
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2229
            self.EndModal(wxID_OK)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2230
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2231
    def GetValues(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2232
        name = self.Name.GetValue()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2233
        nodeid = 0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2234
        if self.NodeID.GetValue() != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2235
            nodeid = eval(self.NodeID.GetValue())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2236
        type = self.Type.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2237
        return name, nodeid, type
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2238
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2239
    def GetProfile(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2240
        name = self.Profile.GetStringSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2241
        return name, self.ListProfile[name]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2242
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2243
    def GetNMTManagement(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2244
        if self.NMT_None.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2245
            return "None"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2246
        elif self.NMT_NodeGuarding.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2247
            return "NodeGuarding"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2248
        elif self.NMT_Heartbeat.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2249
            return "Heartbeat"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2250
        return None
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2251
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2252
    def GetOptions(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2253
        options = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2254
        if self.DS302.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2255
            options.append("DS302")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2256
        if self.GenSYNC.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2257
            options.append("GenSYNC")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2258
        if self.Emergency.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2259
            options.append("Emergency")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2260
        if self.SaveConfig.GetValue():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2261
            options.append("SaveConfig")
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2262
#        if self.StoreEDS.GetValue():
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2263
#            options.append("StoreEDS")
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2264
        return options
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2265
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2266
    def OnProfileChoice(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2267
        if self.Profile.GetStringSelection() == "Other":
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
  2268
            dialog = wxFileDialog(self, "Choose a file", self.Directory, "",  "OD Profile files (*.prf)|*.prf|All files|*.*", wxOPEN|wxCHANGE_DIR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2269
            dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2270
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2271
            dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2272
            if os.path.isfile(filepath):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2273
                name = os.path.splitext(os.path.basename(filepath))[0]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2274
                self.ListProfile[name] = filepath
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2275
                length = self.Profile.GetCount()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2276
                self.Profile.Insert(name, length - 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2277
                self.Profile.SetStringSelection(name)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2278
            else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2279
                self.Profile.SetStringSelection("None")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2280
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2281
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2282
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2283
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2284
#                               Exception Handler
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2285
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2286
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2287
Max_Traceback_List_Size = 20
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2288
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2289
def Display_Exception_Dialog(e_type,e_value,e_tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2290
    trcbck_lst = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2291
    for i,line in enumerate(traceback.extract_tb(e_tb)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2292
        trcbck = " " + str(i+1) + ". "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2293
        if line[0].find(os.getcwd()) == -1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2294
            trcbck += "file : " + str(line[0]) + ",   "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2295
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2296
            trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ",   "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2297
        trcbck += "line : " + str(line[1]) + ",   " + "function : " + str(line[2])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2298
        trcbck_lst.append(trcbck)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2299
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2300
    # Allow clicking....
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2301
    cap = wx.Window_GetCapture()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2302
    if cap:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2303
        cap.ReleaseMouse()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2304
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2305
    dlg = wx.SingleChoiceDialog(None, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2306
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2307
An error happens.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2308
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2309
Click on OK for saving an error report.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2310
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2311
Please contact LOLITech at:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2312
+33 (0)3 29 52 95 67
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2313
bugs_objdictedit@lolitech.fr
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2314
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2315
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2316
Error:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2317
""" +
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2318
        str(e_type) + " : " + str(e_value), 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2319
        "Error",
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2320
        trcbck_lst)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2321
    try:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2322
        res = (dlg.ShowModal() == wx.ID_OK)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2323
    finally:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2324
        dlg.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2325
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2326
    return res
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2327
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2328
def Display_Error_Dialog(e_value):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2329
    message = wxMessageDialog(None, str(e_value), "Error", wxOK|wxICON_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2330
    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2331
    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2332
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2333
def get_last_traceback(tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2334
    while tb.tb_next:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2335
        tb = tb.tb_next
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2336
    return tb
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2337
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2338
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2339
def format_namespace(d, indent='    '):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2340
    return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2341
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2342
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2343
ignored_exceptions = [] # a problem with a line in a module is only reported once per session
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2344
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2345
def wxAddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2346
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2347
    def handle_exception(e_type, e_value, e_traceback):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2348
        traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2349
        last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2350
        ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2351
        if str(e_value).startswith("!!!"):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2352
            Display_Error_Dialog(e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2353
        elif ex not in ignored_exceptions:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2354
            ignored_exceptions.append(ex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2355
            result = Display_Exception_Dialog(e_type,e_value,e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2356
            if result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2357
                info = {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2358
                    'app-title' : wx.GetApp().GetAppName(), # app_title
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2359
                    'app-version' : app_version,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2360
                    'wx-version' : wx.VERSION_STRING,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2361
                    'wx-platform' : wx.Platform,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2362
                    'python-version' : platform.python_version(), #sys.version.split()[0],
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2363
                    'platform' : platform.platform(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2364
                    'e-type' : e_type,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2365
                    'e-value' : e_value,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2366
                    'date' : time.ctime(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2367
                    'cwd' : os.getcwd(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2368
                    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2369
                if e_traceback:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2370
                    info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2371
                    last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2372
                    exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2373
                    info['locals'] = format_namespace(exception_locals)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2374
                    if 'self' in exception_locals:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2375
                        info['self'] = format_namespace(exception_locals['self'].__dict__)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2376
                
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2377
                output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2378
                lst = info.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2379
                lst.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2380
                for a in lst:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2381
                    output.write(a+":\n"+str(info[a])+"\n\n")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2382
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2383
    #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2384
    sys.excepthook = handle_exception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2385
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2386
if __name__ == '__main__':
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2387
    app = wxPySimpleApp()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2388
    wxInitAllImageHandlers()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2389
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2390
    # Install a exception handle for bug reports
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2391
    wxAddExceptHook(os.getcwd(),__version__)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2392
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2393
    frame = objdictedit(None)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2394
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2395
    frame.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  2396
    app.MainLoop()