objdictgen/objdictedit.py
author groke6
Mon, 11 Feb 2008 11:00:12 +0100
changeset 387 6efc85c5493e
parent 386 0f56a144ba5f
child 408 f85552acc2bf
permissions -rwxr-xr-x
fixed TextMasterSlaveLSS
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
import wx
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
from types import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
import os, re, platform, sys, time, traceback, getopt
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
__version__ = "$Revision$"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
206
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
    31
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
6787754b251b Bugs corrected on objdictedit and networkdict
greg
parents: 205
diff changeset
    32
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
from nodemanager import *
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
    34
from subindextable import *
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
    35
from commondialogs import *
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
from doc_index.DS301_index import *
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    38
try:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    39
    import wx.html
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    40
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    41
    EVT_HTML_URL_CLICK = wx.NewId()
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    42
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    43
    class HtmlWindowUrlClick(wx.PyEvent):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    44
        def __init__(self, linkinfo):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    45
            wx.PyEvent.__init__(self)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    46
            self.SetEventType(EVT_HTML_URL_CLICK)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    47
            self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget())
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    48
            
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    49
    class UrlClickHtmlWindow(wx.html.HtmlWindow):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    50
        """ HTML window that generates and OnLinkClicked event.
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    51
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    52
        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
    53
        """
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    54
        def OnLinkClicked(self, linkinfo):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    55
            wx.PostEvent(self, HtmlWindowUrlClick(linkinfo))
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    56
        
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    57
        def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    58
            if event == HtmlWindowUrlClick:
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    59
                self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    60
            else:
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    61
                wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    62
    
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
#                                Html Frame
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    65
#-------------------------------------------------------------------------------
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    66
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    67
    [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    68
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    69
    class HtmlFrame(wx.Frame):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    70
        def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    71
            wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    72
                  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
    73
                  style=wx.DEFAULT_FRAME_STYLE, title='')
273
58b39f97e352 Some bugs fixed
lbessard
parents: 258
diff changeset
    74
            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    75
            
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    76
            self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    77
                  name='HtmlContent', parent=self, pos=wx.Point(0, 0),
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    78
                  size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO|wx.html.HW_NO_SELECTION)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
    79
            self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    80
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    81
        def __init__(self, parent, opened):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    82
            self._init_ctrls(parent)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    83
            self.HtmlFrameOpened = opened
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    84
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    85
        def SetHtmlCode(self, htmlcode):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    86
            self.HtmlContent.SetPage(htmlcode)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    87
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    88
        def SetHtmlPage(self, htmlpage):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    89
            self.HtmlContent.LoadPage(htmlpage)
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    90
            
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    91
        def OnCloseFrame(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    92
            self.HtmlFrameOpened.remove(self.GetTitle())
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    93
            event.Skip()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    94
        
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    95
        def OnLinkClick(self, event):
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    96
            url = event.linkinfo[0]
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    97
            try:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    98
                import webbrowser
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
    99
            except ImportError:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   100
                wx.MessageBox('Please point your browser at: %s' % url)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   101
            else:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   102
                webbrowser.open(url)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   103
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   104
    Html_Window = True
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   105
except:
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   106
    Html_Window = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
318
cef08361bab1 Fix problem with symbolic link ( --> os.path.realpath() )
greg
parents: 300
diff changeset
   108
ScriptDirectory = os.path.split(os.path.realpath(__file__))[0]
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   110
[ID_OBJDICTEDIT, ID_OBJDICTEDITFILEOPENED, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   111
 ID_OBJDICTEDITHELPBAR,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
] = [wx.NewId() for _init_ctrls in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   114
[ID_OBJDICTEDITADDMENUITEMS0, ID_OBJDICTEDITADDMENUITEMS1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   115
 ID_OBJDICTEDITADDMENUITEMS2, ID_OBJDICTEDITADDMENUITEMS3, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   116
 ID_OBJDICTEDITADDMENUITEMS4, ID_OBJDICTEDITADDMENUITEMS5, 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   119
[ID_OBJDICTEDITFILEMENUITEMS0, ID_OBJDICTEDITFILEMENUITEMS1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   120
 ID_OBJDICTEDITFILEMENUITEMS2, ID_OBJDICTEDITFILEMENUITEMS4, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   121
 ID_OBJDICTEDITFILEMENUITEMS5, ID_OBJDICTEDITFILEMENUITEMS6, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   122
 ID_OBJDICTEDITFILEMENUITEMS7, ID_OBJDICTEDITFILEMENUITEMS8,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   123
 ID_OBJDICTEDITFILEMENUITEMS9,
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   124
] = [wx.NewId() for _init_coll_FileMenu_Items in range(9)]
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   126
[ID_OBJDICTEDITEDITMENUITEMS0, ID_OBJDICTEDITEDITMENUITEMS1, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   127
 ID_OBJDICTEDITEDITMENUITEMS2, ID_OBJDICTEDITEDITMENUITEMS4, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   128
 ID_OBJDICTEDITEDITMENUITEMS6, ID_OBJDICTEDITEDITMENUITEMS7, 
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   129
 ID_OBJDICTEDITEDITMENUITEMS8, 
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
] = [wx.NewId() for _init_coll_EditMenu_Items in range(7)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   132
[ID_OBJDICTEDITHELPMENUITEMS0, ID_OBJDICTEDITHELPMENUITEMS1,
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   133
 ID_OBJDICTEDITHELPMENUITEMS2,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
] = [wx.NewId() for _init_coll_HelpMenu_Items in range(3)]
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
class objdictedit(wx.Frame):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
    def _init_coll_menuBar1_Menus(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
        parent.Append(menu=self.FileMenu, title='File')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
        parent.Append(menu=self.EditMenu, title='Edit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
        parent.Append(menu=self.AddMenu, title='Add')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
        parent.Append(menu=self.HelpMenu, title='Help')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
    def _init_coll_EditMenu_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   144
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS4,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
              kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
        parent.AppendSeparator()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   147
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS1,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
              kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   149
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS0,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
              kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
        parent.AppendSeparator()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   152
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS6,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
              kind=wx.ITEM_NORMAL, text='Node infos')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   154
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS2,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
              kind=wx.ITEM_NORMAL, text='DS-301 Profile')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   156
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS8,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
              kind=wx.ITEM_NORMAL, text='DS-302 Profile')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   158
        parent.Append(help='', id=ID_OBJDICTEDITEDITMENUITEMS7,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
              kind=wx.ITEM_NORMAL, text='Other Profile')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
        self.Bind(wx.EVT_MENU, self.OnUndoMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   161
              id=ID_OBJDICTEDITEDITMENUITEMS1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
        self.Bind(wx.EVT_MENU, self.OnRedoMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   163
              id=ID_OBJDICTEDITEDITMENUITEMS0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
        self.Bind(wx.EVT_MENU, self.OnCommunicationMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   165
              id=ID_OBJDICTEDITEDITMENUITEMS2)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
        self.Bind(wx.EVT_MENU, self.OnRefreshMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   167
              id=ID_OBJDICTEDITEDITMENUITEMS4)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
        self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   169
              id=ID_OBJDICTEDITEDITMENUITEMS6)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
        self.Bind(wx.EVT_MENU, self.OnEditProfileMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   171
              id=ID_OBJDICTEDITEDITMENUITEMS7)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
        self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   173
              id=ID_OBJDICTEDITEDITMENUITEMS8)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
    def _init_coll_HelpMenu_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   176
        parent.Append(help='', id=ID_OBJDICTEDITHELPMENUITEMS0,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
              kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
        self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   179
              id=ID_OBJDICTEDITHELPMENUITEMS0)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   180
        parent.Append(help='', id=ID_OBJDICTEDITHELPMENUITEMS1,
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   181
              kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2')
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   182
        self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   183
              id=ID_OBJDICTEDITHELPMENUITEMS1)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   184
        if Html_Window:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   185
            parent.Append(help='', id=ID_OBJDICTEDITHELPMENUITEMS2,
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   186
                  kind=wx.ITEM_NORMAL, text='About')
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   187
            self.Bind(wx.EVT_MENU, self.OnAboutMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   188
                  id=ID_OBJDICTEDITHELPMENUITEMS2)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
    def _init_coll_FileMenu_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   191
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS5,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
              kind=wx.ITEM_NORMAL, text='New\tCTRL+N')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   193
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS0,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
              kind=wx.ITEM_NORMAL, text='Open\tCTRL+O')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   195
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS1,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
              kind=wx.ITEM_NORMAL, text='Save\tCTRL+S')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   197
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS6,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
              kind=wx.ITEM_NORMAL, text='Save As...\tALT+S')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   199
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS2,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
              kind=wx.ITEM_NORMAL, text='Close\tCTRL+W')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
        parent.AppendSeparator()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   202
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS7,
171
db7a030babb2 EDS import
etisserant
parents: 158
diff changeset
   203
              kind=wx.ITEM_NORMAL, text='Import EDS file')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   204
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS9,
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   205
              kind=wx.ITEM_NORMAL, text='Export to EDS file')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   206
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS8,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
              kind=wx.ITEM_NORMAL, text='Build Dictionary\tCTRL+B')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
        parent.AppendSeparator()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   209
        parent.Append(help='', id=ID_OBJDICTEDITFILEMENUITEMS4,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
              kind=wx.ITEM_NORMAL, text='Exit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
        self.Bind(wx.EVT_MENU, self.OnOpenMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   212
              id=ID_OBJDICTEDITFILEMENUITEMS0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
        self.Bind(wx.EVT_MENU, self.OnSaveMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   214
              id=ID_OBJDICTEDITFILEMENUITEMS1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
        self.Bind(wx.EVT_MENU, self.OnCloseMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   216
              id=ID_OBJDICTEDITFILEMENUITEMS2)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
        self.Bind(wx.EVT_MENU, self.OnQuitMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   218
              id=ID_OBJDICTEDITFILEMENUITEMS4)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
        self.Bind(wx.EVT_MENU, self.OnNewMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   220
              id=ID_OBJDICTEDITFILEMENUITEMS5)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
        self.Bind(wx.EVT_MENU, self.OnSaveAsMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   222
              id=ID_OBJDICTEDITFILEMENUITEMS6)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   223
        self.Bind(wx.EVT_MENU, self.OnImportEDSMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   224
              id=ID_OBJDICTEDITFILEMENUITEMS7)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   225
        self.Bind(wx.EVT_MENU, self.OnExportCMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   226
              id=ID_OBJDICTEDITFILEMENUITEMS8)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   227
        self.Bind(wx.EVT_MENU, self.OnExportEDSMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   228
              id=ID_OBJDICTEDITFILEMENUITEMS9)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
    def _init_coll_AddMenu_Items(self, parent):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   231
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS0,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
              kind=wx.ITEM_NORMAL, text='SDO Server')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   233
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS1,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
              kind=wx.ITEM_NORMAL, text='SDO Client')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   235
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS2,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
              kind=wx.ITEM_NORMAL, text='PDO Transmit')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   237
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS3,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
              kind=wx.ITEM_NORMAL, text='PDO Receive')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   239
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS4,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
              kind=wx.ITEM_NORMAL, text='Map Variable')
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   241
        parent.Append(help='', id=ID_OBJDICTEDITADDMENUITEMS5,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
              kind=wx.ITEM_NORMAL, text='User Type')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   243
        self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   244
              id=ID_OBJDICTEDITADDMENUITEMS0)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
        self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   246
              id=ID_OBJDICTEDITADDMENUITEMS1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
        self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   248
              id=ID_OBJDICTEDITADDMENUITEMS2)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
        self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   250
              id=ID_OBJDICTEDITADDMENUITEMS3)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
        self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   252
              id=ID_OBJDICTEDITADDMENUITEMS4)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
        self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   254
              id=ID_OBJDICTEDITADDMENUITEMS5)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
    def _init_coll_HelpBar_Fields(self, parent):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
        parent.SetFieldsCount(3)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
        parent.SetStatusText(number=0, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
        parent.SetStatusText(number=1, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
        parent.SetStatusText(number=2, text='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
        parent.SetStatusWidths([100, 110, -1])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
    def _init_utils(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
        self.menuBar1 = wx.MenuBar()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
        self.menuBar1.SetEvtHandlerEnabled(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
        self.FileMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
        self.EditMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
        self.AddMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
        self.HelpMenu = wx.Menu(title='')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   273
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   274
        self._init_coll_menuBar1_Menus(self.menuBar1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   275
        self._init_coll_FileMenu_Items(self.FileMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
        self._init_coll_EditMenu_Items(self.EditMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   277
        self._init_coll_AddMenu_Items(self.AddMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   278
        self._init_coll_HelpMenu_Items(self.HelpMenu)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   279
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
    def _init_ctrls(self, prnt):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   281
        wx.Frame.__init__(self, id=ID_OBJDICTEDIT, name='objdictedit',
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
              parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
              style=wx.DEFAULT_FRAME_STYLE, title='Objdictedit')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
        self._init_utils()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
        self.SetClientSize(wx.Size(1000, 700))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
        self.SetMenuBar(self.menuBar1)
273
58b39f97e352 Some bugs fixed
lbessard
parents: 258
diff changeset
   287
        self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   288
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   289
        self.FileOpened = wx.Notebook(id=ID_OBJDICTEDITFILEOPENED,
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
              name='FileOpened', parent=self, pos=wx.Point(0, 0),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
              size=wx.Size(0, 0), style=0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
        self.FileOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   293
              self.OnFileSelectedChanged, id=ID_OBJDICTEDITFILEOPENED)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   294
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   295
        self.HelpBar = wx.StatusBar(id=ID_OBJDICTEDITHELPBAR, name='HelpBar',
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   296
              parent=self, style=wx.ST_SIZEGRIP)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   297
        self._init_coll_HelpBar_Fields(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   298
        self.SetStatusBar(self.HelpBar)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   299
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   300
    def __init__(self, parent, filesOpen = []):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   301
        self._init_ctrls(parent)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
        self.HtmlFrameOpened = []
245
d43ebbed895f Modifying gen_cfile.py for generating C file from a node as data rather than a manager
lbessard
parents: 232
diff changeset
   303
        self.ModeSolo = True
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   304
        
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   305
        self.Manager = NodeManager()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   306
        for filepath in filesOpen:
232
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   307
            result = self.Manager.OpenFileInCurrent(filepath)
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   308
            if type(result) == IntType:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   309
                new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
232
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   310
                new_editingpanel.SetIndex(result)
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   311
                self.FileOpened.AddPage(new_editingpanel, "")
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   312
            window = self.FileOpened.GetPage(0)
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   313
            if window:
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   314
                self.Manager.ChangeCurrentNode(window.GetIndex())
e435bbec1759 Bug on file loading from shell command fixed
lbessard
parents: 227
diff changeset
   315
                self.FileOpened.SetSelection(0)
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   316
        if self.Manager.CurrentDS302Defined():
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   317
            self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   319
            self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   321
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   322
        self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   323
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   324
        self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   325
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   326
    def OnAddSDOServerMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   327
        self.Manager.AddSDOServerToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   328
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   329
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   330
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   331
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   332
    def OnAddSDOClientMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   333
        self.Manager.AddSDOClientToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   334
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   335
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   336
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   337
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   338
    def OnAddPDOTransmitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   339
        self.Manager.AddPDOTransmitToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   340
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   341
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   342
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   343
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   344
    def OnAddPDOReceiveMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   345
        self.Manager.AddPDOReceiveToCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   346
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   347
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   348
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   349
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   350
    def OnAddMapVariableMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   351
        self.AddMapVariable()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   352
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   353
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   354
    def OnAddUserTypeMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   355
        self.AddUserType()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   356
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   357
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   358
    def OnFileSelectedChanged(self, event):
43
56ab4f38075e Bug on NoteBook in Windows corrected
lbessard
parents: 39
diff changeset
   359
        selected = event.GetSelection()
37
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
   360
        # At init selected = -1
c6ff23a48232 Some fixes for GUI running Windows
etisserant
parents: 30
diff changeset
   361
        if selected >= 0:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   362
            window = self.FileOpened.GetPage(selected)
223
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   363
            if window:
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   364
                self.Manager.ChangeCurrentNode(window.GetIndex())
300
b83d063c4dc4 Bug on new file and open file with wxPython 2.8.4.2 on GTK fixed
lbessard
parents: 299
diff changeset
   365
                wx.CallAfter(self.RefreshBufferState)
223
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   366
                self.RefreshStatusBar()
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   367
                self.RefreshProfileMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   368
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   369
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   370
    def OnHelpDS301Menu(self, event):
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   371
        find_index = False
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   372
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   373
        if selected >= 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   374
            window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   375
            result = window.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   376
            if result:
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   377
                find_index = True
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   378
                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
   379
                result = OpenPDFDocIndex(index, ScriptDirectory)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   380
                if type(result) == StringType:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   381
                    message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   382
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   383
                    message.Destroy()
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   384
        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
   385
            result = OpenPDFDocIndex(None, ScriptDirectory)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   386
            if type(result) == StringType:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   387
                message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
72
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   388
                message.ShowModal()
68524f7c58b5 Code for avoiding possible problem on Window while importing html module
lbessard
parents: 68
diff changeset
   389
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   390
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   391
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   392
    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
   393
        #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
341
7ff01f109bbc Windows related enhancements
etisserant
parents: 334
diff changeset
   394
        if wx.Platform == '__WXMSW__':
386
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   395
            readerpath = get_acroversion()
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   396
            readerexepath = os.path.join(readerpath,"AcroRd32.exe")
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   397
            if(os.path.isfile(readerexepath)):
0f56a144ba5f Now, PDF doc of objdictgen can be opened with acrobat reader on windows
etisserant
parents: 348
diff changeset
   398
                os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
341
7ff01f109bbc Windows related enhancements
etisserant
parents: 334
diff changeset
   399
        else:
7ff01f109bbc Windows related enhancements
etisserant
parents: 334
diff changeset
   400
            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
   401
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   402
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   403
    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
   404
        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
   405
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   406
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   407
    def OpenHtmlFrame(self, title, file, size):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   408
        if title not in self.HtmlFrameOpened:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   409
            self.HtmlFrameOpened.append(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   410
            window = HtmlFrame(self, self.HtmlFrameOpened)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   411
            window.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   412
            window.SetHtmlPage(file)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   413
            window.SetClientSize(size)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   414
            window.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   415
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   416
    def OnQuitMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   417
        self.Close()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   418
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   419
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   420
    def OnCloseFrame(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   421
        if self.Manager.OneFileHasChanged():
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   422
            dialog = wx.MessageDialog(self, "There are changes, do you want to save?",  "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   423
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   424
            dialog.Destroy()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   425
            if answer == wx.ID_YES:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   426
                self.Manager.ChangeCurrentNode(0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   427
                for i in xrange(self.FileOpened.GetPageCount()):
223
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   428
                    window = self.FileOpened.GetPage(i)
461f5516176b Bug on Domain data writing in gen_cfile fixed
lbessard
parents: 219
diff changeset
   429
                    self.Manager.ChangeCurrentNode(window.GetIndex())
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   430
                    if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   431
                        self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   432
                    else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   433
                        self.Save()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   434
                        self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   435
                event.Skip()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   436
            elif answer == wx.ID_NO:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   437
                for i in xrange(self.FileOpened.GetPageCount()):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   438
                    self.Manager.CloseCurrent(True)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   439
                wx.CallAfter(self.Close)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   440
                event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   441
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   442
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   443
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   444
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   445
#                             Refresh Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   446
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   447
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   448
    def RefreshTitle(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   449
        if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   450
            self.SetTitle("Objdictedit - %s"%self.Manager.GetCurrentFilename())
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   451
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   452
            self.SetTitle("Objdictedit")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   453
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   454
    def OnRefreshMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   455
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   456
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   457
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   458
    def RefreshCurrentIndexList(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   459
        selected = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   460
        window = self.FileOpened.GetPage(selected)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   461
        window.RefreshIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   462
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   463
    def RefreshStatusBar(self):
348
c50feb2bb590 Bug when close objdictedit fixed
lbessard
parents: 341
diff changeset
   464
        if self and self.HelpBar:
209
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   465
            selected = self.FileOpened.GetSelection()
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   466
            if selected >= 0:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   467
                window = self.FileOpened.GetPage(selected)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   468
                selection = window.GetSelection()
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   469
                if selection:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   470
                    index, subIndex = selection
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   471
                    if self.Manager.IsCurrentEntry(index):
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   472
                        self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   473
                        self.HelpBar.SetStatusText("Subindex: 0x%02X"%subIndex, 1)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   474
                        entryinfos = self.Manager.GetEntryInfos(index)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   475
                        name = entryinfos["name"]
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   476
                        category = "Optional"
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   477
                        if entryinfos["need"]:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   478
                            category = "Mandatory"
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   479
                        struct = "VAR"
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   480
                        number = ""
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   481
                        if entryinfos["struct"] & OD_IdenticalIndexes:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   482
                            number = " possibly defined %d times"%entryinfos["nbmax"]
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   483
                        if entryinfos["struct"] & OD_IdenticalSubindexes:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   484
                            struct = "REC"
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   485
                        elif entryinfos["struct"] & OD_MultipleSubindexes:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   486
                            struct = "ARRAY"
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   487
                        text = "%s: %s entry of struct %s%s."%(name,category,struct,number)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   488
                        self.HelpBar.SetStatusText(text, 2)
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   489
                    else:
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   490
                        for i in xrange(3):
2cb34a4ac65a Bug on RefreshStatusBar corrected
lbessard
parents: 206
diff changeset
   491
                            self.HelpBar.SetStatusText("", i)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   492
                else:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   493
                    for i in xrange(3):
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   494
                        self.HelpBar.SetStatusText("", i)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   495
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   496
    def RefreshMainMenu(self):
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   497
        if self.FileMenu:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   498
            if self.FileOpened.GetPageCount() > 0:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   499
                self.menuBar1.EnableTop(1, True)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   500
                self.menuBar1.EnableTop(2, True)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   501
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS1, True)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   502
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS2, True)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   503
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS6, True)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   504
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS8, True)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   505
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS9, True)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   506
            else:
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   507
                self.menuBar1.EnableTop(1, False)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   508
                self.menuBar1.EnableTop(2, False)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   509
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS1, False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   510
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS2, False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   511
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS6, False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   512
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS8, False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   513
                self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUITEMS9, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   514
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   515
    def RefreshEditMenu(self):
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   516
        if self.FileMenu:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   517
            if self.FileOpened.GetPageCount() > 0:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   518
                undo, redo = self.Manager.GetCurrentBufferState()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   519
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS1, undo)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   520
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS0, redo)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   521
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   522
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS1, False)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   523
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS0, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   524
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   525
    def RefreshProfileMenu(self):
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   526
        if self.EditMenu:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   527
            profile = self.Manager.GetCurrentProfileName()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   528
            edititem = self.EditMenu.FindItemById(ID_OBJDICTEDITEDITMENUITEMS7)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   529
            if edititem:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   530
                length = self.AddMenu.GetMenuItemCount()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   531
                for i in xrange(length-6):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   532
                    additem = self.AddMenu.FindItemByPosition(6)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   533
                    self.AddMenu.Delete(additem.GetId())
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   534
                if profile not in ("None", "DS-301"):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   535
                    edititem.SetText("%s Profile"%profile)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   536
                    edititem.Enable(True)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   537
                    self.AddMenu.AppendSeparator()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   538
                    for text, indexes in self.Manager.GetCurrentSpecificMenu():
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   539
                        new_id = wx.NewId()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   540
                        self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   541
                        self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   542
                else:
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   543
                    edititem.SetText("Other Profile")
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   544
                    edititem.Enable(False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   545
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   546
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   547
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   548
#                            Buffer Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   549
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   550
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   551
    def RefreshBufferState(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   552
        fileopened = self.Manager.GetAllFilenames()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   553
        for idx, filename in enumerate(fileopened):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   554
            self.FileOpened.SetPageText(idx, filename)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   555
        self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   556
        self.RefreshTitle()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   557
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   558
    def OnUndoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   559
        self.Manager.LoadCurrentPrevious()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   560
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   561
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   562
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   563
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   564
    def OnRedoMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   565
        self.Manager.LoadCurrentNext()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   566
        self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   567
        self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   568
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   569
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   570
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   571
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   572
#                         Load and Save Funtions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   573
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   574
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   575
    def OnNewMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   576
        self.FilePath = ""
258
8f7725451453 Some bugs fixed:
lbessard
parents: 254
diff changeset
   577
        dialog = CreateNodeDialog(self)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   578
        if dialog.ShowModal() == wx.ID_OK:
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   579
            name, id, nodetype, description = dialog.GetValues()
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   580
            profile, filepath = dialog.GetProfile()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   581
            NMT = dialog.GetNMTManagement()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   582
            options = dialog.GetOptions()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   583
            result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   584
            if type(result) == IntType:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   585
                new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   586
                new_editingpanel.SetIndex(result)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   587
                self.FileOpened.AddPage(new_editingpanel, "")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   588
                self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   589
                self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, False)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   590
                if "DS302" in options:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   591
                    self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, True)
59
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   592
                self.RefreshBufferState()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   593
                self.RefreshProfileMenu()
3a553c789116 Some bugs reported by Francis Dupin corrected.
lbessard
parents: 44
diff changeset
   594
                self.RefreshMainMenu()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   595
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   596
                message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   597
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   598
                message.Destroy()
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   599
        dialog.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   600
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   601
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   602
    def OnOpenMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   603
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   604
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   605
            directory = os.path.dirname(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   606
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   607
            directory = os.getcwd()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   608
        dialog = wx.FileDialog(self, "Choose a file", directory, "",  "OD files (*.od)|*.od|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   609
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   610
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   611
            if os.path.isfile(filepath):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   612
                result = self.Manager.OpenFileInCurrent(filepath)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   613
                if type(result) == IntType:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   614
                    new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   615
                    new_editingpanel.SetIndex(result)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   616
                    self.FileOpened.AddPage(new_editingpanel, "")
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   617
                    self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   618
                    if self.Manager.CurrentDS302Defined(): 
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   619
                        self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, True)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   620
                    else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   621
                        self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUITEMS8, False)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   622
                    self.RefreshEditMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   623
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   624
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   625
                    self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   626
                else:
280
d9b232ec7057 Bug on MessageDialog popup when unable to load a file fixed
lbessard
parents: 276
diff changeset
   627
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   628
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   629
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   630
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   631
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   632
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   633
    def OnSaveMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   634
        self.Save()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   635
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   636
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   637
    def OnSaveAsMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   638
        self.SaveAs()
30
a5dd050b28cb Some bugs found corrected
lbessard
parents: 0
diff changeset
   639
        event.Skip()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   640
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   641
    def Save(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   642
        result = self.Manager.SaveCurrentInFile()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   643
        if not result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   644
            self.SaveAs()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   645
        elif type(result) != StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   646
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   647
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   648
            message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   649
            message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   650
            message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   651
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   652
    def SaveAs(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   653
        filepath = self.Manager.GetCurrentFilePath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   654
        if filepath != "":
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   655
            directory, filename = os.path.split(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   656
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   657
            directory, filename = os.getcwd(), "%s.od"%self.Manager.GetCurrentNodeInfos()[0]
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   658
        dialog = wx.FileDialog(self, "Choose a file", directory, filename,  "OD files (*.od)|*.od|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   659
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   660
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   661
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   662
                result = self.Manager.SaveCurrentInFile(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   663
                if type(result) != StringType:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   664
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   665
                else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   666
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   667
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   668
                    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   669
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   670
                message = wx.MessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   671
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   672
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   673
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   674
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   675
    def OnCloseMenu(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   676
        answer = wx.ID_YES
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   677
        result = self.Manager.CloseCurrent()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   678
        if not result:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   679
            dialog = wx.MessageDialog(self, "There are changes, do you want to save?",  "Close File", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   680
            answer = dialog.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   681
            dialog.Destroy()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   682
            if answer == wx.ID_YES:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   683
                self.OnSaveMenu(event)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   684
                if self.Manager.CurrentIsSaved():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   685
                    self.Manager.CloseCurrent()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   686
            elif answer == wx.ID_NO:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   687
                self.Manager.CloseCurrent(True)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   688
        if self.FileOpened.GetPageCount() > self.Manager.GetBufferNumber():
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   689
            current = self.FileOpened.GetSelection()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   690
            self.FileOpened.DeletePage(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   691
            if self.FileOpened.GetPageCount() > 0:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   692
                self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   693
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   694
            self.RefreshMainMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   695
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   696
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   697
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   698
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   699
#                         Import and Export Functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   700
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   701
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   702
    def OnImportEDSMenu(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   703
        dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "",  "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   704
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   705
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   706
            if os.path.isfile(filepath):
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   707
                result = self.Manager.ImportCurrentFromEDSFile(filepath)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   708
                if type(result) == IntType:
299
506f9700b9fb Allowing user to type formulas
lbessard
parents: 280
diff changeset
   709
                    new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   710
                    new_editingpanel.SetIndex(result)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   711
                    self.FileOpened.AddPage(new_editingpanel, "")
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   712
                    self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   713
                    self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   714
                    self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   715
                    self.RefreshProfileMenu()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   716
                    self.RefreshMainMenu()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   717
                    message = wx.MessageDialog(self, "Import successful", "Information", wx.OK|wx.ICON_INFORMATION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   718
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   719
                    message.Destroy()
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   720
                else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   721
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   722
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   723
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   724
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   725
                message = wx.MessageDialog(self, "\"%s\" is not a valid file!"%filepath, "Error", wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   726
                message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   727
                message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   728
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   729
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   730
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   731
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   732
    def OnExportEDSMenu(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   733
        dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "EDS files (*.eds)|*.eds|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   734
        if dialog.ShowModal() == wx.ID_OK:
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   735
            filepath = dialog.GetPath()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   736
            if os.path.isdir(os.path.dirname(filepath)):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   737
                path, extend = os.path.splitext(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   738
                if extend in ("", "."):
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   739
                    filepath = path + ".eds"
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   740
                result = self.Manager.ExportCurrentToEDSFile(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   741
                if not result:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   742
                    message = wx.MessageDialog(self, "Export successful", "Information", wx.OK|wx.ICON_INFORMATION)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   743
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   744
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   745
                else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   746
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   747
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   748
                    message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   749
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   750
                message = wx.MessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   751
                message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   752
                message.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   753
        dialog.Destroy()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   754
        event.Skip()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   755
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   756
    def OnExportCMenu(self, event):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   757
        dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0],  "CANFestival C files (*.c)|*.c|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   758
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   759
            filepath = dialog.GetPath()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   760
            if os.path.isdir(os.path.dirname(filepath)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   761
                path, extend = os.path.splitext(filepath)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   762
                if extend in ("", "."):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   763
                    filepath = path + ".c"
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   764
                result = self.Manager.ExportCurrentToCFile(filepath)
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   765
                if not result:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   766
                    message = wx.MessageDialog(self, "Export successful", "Information", wx.OK|wx.ICON_INFORMATION)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   767
                    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   768
                    message.Destroy()
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   769
                else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   770
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   771
                    message.ShowModal()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   772
                    message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   773
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   774
                message = wx.MessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   775
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   776
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   777
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   778
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   779
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   780
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   781
#                          Editing Profiles functions
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   782
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   783
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   784
    def OnCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   785
        dictionary,current = self.Manager.GetCurrentCommunicationLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   786
        self.EditProfile("Edit DS-301 Profile", dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   787
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   788
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   789
    def OnOtherCommunicationMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   790
        dictionary,current = self.Manager.GetCurrentDS302Lists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   791
        self.EditProfile("Edit DS-301 Profile", dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   792
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   793
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   794
    def OnEditProfileMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   795
        title = "Edit %s Profile"%self.Manager.GetCurrentProfileName()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   796
        dictionary,current = self.Manager.GetCurrentProfileLists()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   797
        self.EditProfile(title, dictionary, current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   798
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   799
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   800
    def EditProfile(self, title, dictionary, current):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   801
        dialog = CommunicationDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   802
        dialog.SetTitle(title)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   803
        dialog.SetIndexDictionary(dictionary)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   804
        dialog.SetCurrentList(current)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   805
        dialog.RefreshLists()
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   806
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   807
            new_profile = dialog.GetCurrentList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   808
            addinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   809
            removinglist = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   810
            for index in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   811
                if index not in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   812
                    addinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   813
            for index in current:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   814
                if index not in new_profile:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   815
                    removinglist.append(index)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   816
            self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   817
            self.Manager.BufferCurrentNode()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   818
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   819
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   820
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   821
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   822
    def GetProfileCallBack(self, text):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   823
        def ProfileCallBack(event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   824
            self.Manager.AddSpecificEntryToCurrent(text)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   825
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   826
            self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   827
            event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   828
        return ProfileCallBack
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   829
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   830
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   831
#                         Edit Node informations function
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   832
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   833
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   834
    def OnNodeInfosMenu(self, event):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   835
        dialog = NodeInfosDialog(self)
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   836
        name, id, type, description = self.Manager.GetCurrentNodeInfos()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   837
        dialog.SetValues(name, id, type, description)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   838
        if dialog.ShowModal() == wx.ID_OK:
182
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   839
            name, id, type, description = dialog.GetValues()
988f2b302aa6 Adding support for importing and exporting EDS files
lbessard
parents: 176
diff changeset
   840
            self.Manager.SetCurrentNodeInfos(name, id, type, description)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   841
            self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   842
            self.RefreshProfileMenu()
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   843
            selected = self.FileOpened.GetSelection()
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   844
            if selected >= 0:
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   845
                window = self.FileOpened.GetPage(selected)
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   846
                window.RefreshTable()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   847
        event.Skip()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   848
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   849
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   850
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   851
#                           Add User Types and Variables
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   852
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   853
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   854
    def AddMapVariable(self):
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   855
        index = self.Manager.GetCurrentNextMapIndex()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   856
        if index:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   857
            dialog = MapVariableDialog(self)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   858
            dialog.SetIndex(index)
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   859
            if dialog.ShowModal() == wx.ID_OK:
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   860
                index, name, struct, number = dialog.GetValues()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   861
                result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   862
                if type(result) != StringType:
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   863
                    self.RefreshBufferState()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   864
                    self.RefreshCurrentIndexList()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   865
                else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   866
                    message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   867
                    message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   868
                    message.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   869
            dialog.Destroy()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   870
        else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   871
            message = wx.MessageDialog(self, result, "No map variable index left!", wx.OK|wx.ICON_ERROR)
39
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   872
            message.ShowModal()
3e94ee906bc6 Add incremented index in Add Map Variable
lbessard
parents: 37
diff changeset
   873
            message.Destroy()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   874
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   875
    def AddUserType(self):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   876
        dialog = UserTypeDialog(self)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   877
        dialog.SetTypeList(self.Manager.GetCustomisableTypes())
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   878
        if dialog.ShowModal() == wx.ID_OK:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   879
            type, min, max, length = dialog.GetValues()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   880
            result = self.Manager.AddUserTypeToCurrent(type, min, max, length)
205
dac0f9b4e3f8 Adding program for network management
lbessard
parents: 182
diff changeset
   881
            if not result:
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   882
                self.RefreshBufferState()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   883
                self.RefreshCurrentIndexList()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   884
            else:
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   885
                message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   886
                message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   887
                message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   888
        dialog.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   889
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   890
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   891
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   892
#                               Exception Handler
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   893
#-------------------------------------------------------------------------------
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   894
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   895
Max_Traceback_List_Size = 20
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   896
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   897
def Display_Exception_Dialog(e_type,e_value,e_tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   898
    trcbck_lst = []
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   899
    for i,line in enumerate(traceback.extract_tb(e_tb)):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   900
        trcbck = " " + str(i+1) + ". "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   901
        if line[0].find(os.getcwd()) == -1:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   902
            trcbck += "file : " + str(line[0]) + ",   "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   903
        else:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   904
            trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ",   "
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   905
        trcbck += "line : " + str(line[1]) + ",   " + "function : " + str(line[2])
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   906
        trcbck_lst.append(trcbck)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   907
        
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   908
    # Allow clicking....
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   909
    cap = wx.Window_GetCapture()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   910
    if cap:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   911
        cap.ReleaseMouse()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   912
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   913
    dlg = wx.SingleChoiceDialog(None, 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   914
        """
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   915
An error happens.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   916
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   917
Click on OK for saving an error report.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   918
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   919
Please contact LOLITech at:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   920
+33 (0)3 29 52 95 67
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   921
bugs_objdictedit@lolitech.fr
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   922
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   923
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   924
Error:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   925
""" +
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   926
        str(e_type) + " : " + str(e_value), 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   927
        "Error",
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   928
        trcbck_lst)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   929
    try:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   930
        res = (dlg.ShowModal() == wx.ID_OK)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   931
    finally:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   932
        dlg.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   933
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   934
    return res
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   935
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   936
def Display_Error_Dialog(e_value):
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   937
    message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   938
    message.ShowModal()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   939
    message.Destroy()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   940
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   941
def get_last_traceback(tb):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   942
    while tb.tb_next:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   943
        tb = tb.tb_next
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   944
    return tb
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   945
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   946
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   947
def format_namespace(d, indent='    '):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   948
    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
   949
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   950
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   951
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
   952
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
   953
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   954
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   955
    def handle_exception(e_type, e_value, e_traceback):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   956
        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
   957
        last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   958
        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
   959
        if str(e_value).startswith("!!!"):
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   960
            Display_Error_Dialog(e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   961
        elif ex not in ignored_exceptions:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   962
            ignored_exceptions.append(ex)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   963
            result = Display_Exception_Dialog(e_type,e_value,e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   964
            if result:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   965
                info = {
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   966
                    'app-title' : wx.GetApp().GetAppName(), # app_title
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   967
                    'app-version' : app_version,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   968
                    'wx-version' : wx.VERSION_STRING,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   969
                    'wx-platform' : wx.Platform,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   970
                    'python-version' : platform.python_version(), #sys.version.split()[0],
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   971
                    'platform' : platform.platform(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   972
                    'e-type' : e_type,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   973
                    'e-value' : e_value,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   974
                    'date' : time.ctime(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   975
                    'cwd' : os.getcwd(),
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   976
                    }
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   977
                if e_traceback:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   978
                    info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   979
                    last_tb = get_last_traceback(e_traceback)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   980
                    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
   981
                    info['locals'] = format_namespace(exception_locals)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   982
                    if 'self' in exception_locals:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   983
                        info['self'] = format_namespace(exception_locals['self'].__dict__)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   984
                
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   985
                output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   986
                lst = info.keys()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   987
                lst.sort()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   988
                for a in lst:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   989
                    output.write(a+":\n"+str(info[a])+"\n\n")
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   990
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   991
    #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   992
    sys.excepthook = handle_exception
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   993
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   994
if __name__ == '__main__':
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   995
    def usage():
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   996
        print "\nUsage of objdictedit.py :"
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   997
        print "\n   %s [Filepath, ...]\n"%sys.argv[0]
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   998
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
   999
    try:
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1000
        opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1001
    except getopt.GetoptError:
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1002
        # print help information and exit:
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1003
        usage()
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1004
        sys.exit(2)
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1005
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1006
    for o, a in opts:
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1007
        if o in ("-h", "--help"):
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1008
            usage()
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1009
            sys.exit()
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1010
    
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1011
    app = wx.PySimpleApp()
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1012
    wx.InitAllImageHandlers()
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1013
    
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1014
    # Install a exception handle for bug reports
254
f2b0acb54e65 Cleaning code for using only wxPython 2.6 class naming
lbessard
parents: 245
diff changeset
  1015
    AddExceptHook(os.getcwd(),__version__)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1016
    
276
eada6c6c2e87 Corrections for wx version 2.8.4
lbessard
parents: 273
diff changeset
  1017
    frame = objdictedit(None, args)
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1018
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1019
    frame.Show()
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
  1020
    app.MainLoop()