#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from wxPython.wx import *
-from wxPython.grid import *
import wx
-import wx.grid
from types import *
import os, re, platform, sys, time, traceback, getopt
-__version__ = "$Revision: 1.20 $"
+__version__ = "$Revision: 1.47 $"
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
from doc_index.DS301_index import *
try:
- from wxPython.html import *
+ import wx.html
- wxEVT_HTML_URL_CLICK = wxNewId()
+ EVT_HTML_URL_CLICK = wx.NewId()
- def EVT_HTML_URL_CLICK(win, func):
- win.Connect(-1, -1, wxEVT_HTML_URL_CLICK, func)
-
- class wxHtmlWindowUrlClick(wxPyEvent):
+ class HtmlWindowUrlClick(wx.PyEvent):
def __init__(self, linkinfo):
- wxPyEvent.__init__(self)
- self.SetEventType(wxEVT_HTML_URL_CLICK)
+ wx.PyEvent.__init__(self)
+ self.SetEventType(EVT_HTML_URL_CLICK)
self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget())
-
- class wxUrlClickHtmlWindow(wxHtmlWindow):
+
+ class UrlClickHtmlWindow(wx.html.HtmlWindow):
""" HTML window that generates and OnLinkClicked event.
Use this to avoid having to override HTMLWindow
"""
def OnLinkClicked(self, linkinfo):
- wxPostEvent(self, wxHtmlWindowUrlClick(linkinfo))
+ wx.PostEvent(self, HtmlWindowUrlClick(linkinfo))
+
+ def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
+ if event == HtmlWindowUrlClick:
+ self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler)
+ else:
+ wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2)
#-------------------------------------------------------------------------------
# Html Frame
#-------------------------------------------------------------------------------
- [wxID_HTMLFRAME, wxID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
+ [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
class HtmlFrame(wx.Frame):
def _init_ctrls(self, prnt):
- # generated method, don't edit
- wx.Frame.__init__(self, id=wxID_HTMLFRAME, name='HtmlFrame',
+ wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
style=wx.DEFAULT_FRAME_STYLE, title='')
- self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_HTMLFRAME)
+ self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
- self.HtmlContent = wxUrlClickHtmlWindow(id=wxID_HTMLFRAMEHTMLCONTENT,
+ self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
name='HtmlContent', parent=self, pos=wx.Point(0, 0),
- size=wx.Size(-1, -1), style=wxHW_SCROLLBAR_AUTO|wxHW_NO_SELECTION)
- EVT_HTML_URL_CLICK(self.HtmlContent, self.OnLinkClick)
+ size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO|wx.html.HW_NO_SELECTION)
+ self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
def __init__(self, parent, opened):
self._init_ctrls(parent)
try:
import webbrowser
except ImportError:
- wxMessageBox('Please point your browser at: %s' % url)
+ wx.MessageBox('Please point your browser at: %s' % url)
else:
webbrowser.open(url)
-
+
Html_Window = True
except:
Html_Window = False
-def create(parent):
- return objdictedit(parent)
-
-def usage():
- print "\nUsage of objdictedit.py :"
- print "\n %s [Filepath, ...]\n"%sys.argv[0]
+ScriptDirectory = os.path.split(os.path.realpath(__file__))[0]
-try:
- opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
-except getopt.GetoptError:
- # print help information and exit:
- usage()
- sys.exit(2)
-
-for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
-
-filesOpen = args
-ScriptDirectory = sys.path[0]
-
-
-[wxID_OBJDICTEDIT, wxID_OBJDICTEDITFILEOPENED,
- wxID_OBJDICTEDITHELPBAR,
+[ID_OBJDICTEDIT, ID_OBJDICTEDITFILEOPENED,
+ ID_OBJDICTEDITHELPBAR,
] = [wx.NewId() for _init_ctrls in range(3)]
-[wxID_OBJDICTEDITADDMENUITEMS0, wxID_OBJDICTEDITADDMENUITEMS1,
- wxID_OBJDICTEDITADDMENUITEMS2, wxID_OBJDICTEDITADDMENUITEMS3,
- wxID_OBJDICTEDITADDMENUITEMS4, wxID_OBJDICTEDITADDMENUITEMS5,
-] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
-
-[wxID_OBJDICTEDITFILEMENUITEMS0, wxID_OBJDICTEDITFILEMENUITEMS1,
- wxID_OBJDICTEDITFILEMENUITEMS2, wxID_OBJDICTEDITFILEMENUITEMS4,
- wxID_OBJDICTEDITFILEMENUITEMS5, wxID_OBJDICTEDITFILEMENUITEMS6,
- wxID_OBJDICTEDITFILEMENUITEMS7, wxID_OBJDICTEDITFILEMENUITEMS8,
- wxID_OBJDICTEDITFILEMENUITEMS9,
-] = [wx.NewId() for _init_coll_FileMenu_Items in range(9)]
+[ID_OBJDICTEDITFILEMENUIMPORTEDS, ID_OBJDICTEDITFILEMENUEXPORTEDS,
+ ID_OBJDICTEDITFILEMENUEXPORTC,
+] = [wx.NewId() for _init_coll_FileMenu_Items in range(3)]
-[wxID_OBJDICTEDITEDITMENUITEMS0, wxID_OBJDICTEDITEDITMENUITEMS1,
- wxID_OBJDICTEDITEDITMENUITEMS2, wxID_OBJDICTEDITEDITMENUITEMS4,
- wxID_OBJDICTEDITEDITMENUITEMS6, wxID_OBJDICTEDITEDITMENUITEMS7,
- wxID_OBJDICTEDITEDITMENUITEMS8,
-] = [wx.NewId() for _init_coll_EditMenu_Items in range(7)]
+[ID_OBJDICTEDITEDITMENUNODEINFOS, ID_OBJDICTEDITEDITMENUDS301PROFILE,
+ ID_OBJDICTEDITEDITMENUDS302PROFILE, ID_OBJDICTEDITEDITMENUOTHERPROFILE,
+] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)]
-[wxID_OBJDICTEDITHELPMENUITEMS0, wxID_OBJDICTEDITHELPMENUITEMS1,
- wxID_OBJDICTEDITHELPMENUITEMS2,
-] = [wx.NewId() for _init_coll_HelpMenu_Items in range(3)]
+[ID_OBJDICTEDITADDMENUSDOSERVER, ID_OBJDICTEDITADDMENUSDOCLIENT,
+ ID_OBJDICTEDITADDMENUPDOTRANSMIT, ID_OBJDICTEDITADDMENUPDORECEIVE,
+ ID_OBJDICTEDITADDMENUMAPVARIABLE, ID_OBJDICTEDITADDMENUUSERTYPE,
+] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
class objdictedit(wx.Frame):
- def _init_coll_menuBar1_Menus(self, parent):
- # generated method, don't edit
-
- parent.Append(menu=self.FileMenu, title='File')
+ def _init_coll_MenuBar_Menus(self, parent):
+ if self.ModeSolo:
+ parent.Append(menu=self.FileMenu, title='File')
parent.Append(menu=self.EditMenu, title='Edit')
parent.Append(menu=self.AddMenu, title='Add')
parent.Append(menu=self.HelpMenu, title='Help')
- def _init_coll_EditMenu_Items(self, parent):
- # generated method, don't edit
-
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS4,
- kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R')
- parent.AppendSeparator()
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS1,
- kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z')
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS0,
- kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y')
- parent.AppendSeparator()
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS6,
- kind=wx.ITEM_NORMAL, text='Node infos')
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS2,
- kind=wx.ITEM_NORMAL, text='DS-301 Profile')
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS8,
- kind=wx.ITEM_NORMAL, text='DS-302 Profile')
- parent.Append(help='', id=wxID_OBJDICTEDITEDITMENUITEMS7,
- kind=wx.ITEM_NORMAL, text='Other Profile')
- self.Bind(wx.EVT_MENU, self.OnUndoMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS1)
- self.Bind(wx.EVT_MENU, self.OnRedoMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS0)
- self.Bind(wx.EVT_MENU, self.OnCommunicationMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS2)
- self.Bind(wx.EVT_MENU, self.OnRefreshMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS4)
- self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS6)
- self.Bind(wx.EVT_MENU, self.OnEditProfileMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS7)
- self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu,
- id=wxID_OBJDICTEDITEDITMENUITEMS8)
-
- def _init_coll_HelpMenu_Items(self, parent):
- # generated method, don't edit
-
- parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS0,
- kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1')
- self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu,
- id=wxID_OBJDICTEDITHELPMENUITEMS0)
- parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS1,
- kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2')
- self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu,
- id=wxID_OBJDICTEDITHELPMENUITEMS1)
- if Html_Window:
- parent.Append(help='', id=wxID_OBJDICTEDITHELPMENUITEMS2,
- kind=wx.ITEM_NORMAL, text='About')
- self.Bind(wx.EVT_MENU, self.OnAboutMenu,
- id=wxID_OBJDICTEDITHELPMENUITEMS2)
-
def _init_coll_FileMenu_Items(self, parent):
- # generated method, don't edit
-
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS5,
+ parent.Append(help='', id=wx.ID_NEW,
kind=wx.ITEM_NORMAL, text='New\tCTRL+N')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS0,
+ parent.Append(help='', id=wx.ID_OPEN,
kind=wx.ITEM_NORMAL, text='Open\tCTRL+O')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS1,
+ parent.Append(help='', id=wx.ID_CLOSE,
+ kind=wx.ITEM_NORMAL, text='Close\tCTRL+W')
+ parent.AppendSeparator()
+ parent.Append(help='', id=wx.ID_SAVE,
kind=wx.ITEM_NORMAL, text='Save\tCTRL+S')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS6,
+ parent.Append(help='', id=wx.ID_SAVEAS,
kind=wx.ITEM_NORMAL, text='Save As...\tALT+S')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS2,
- kind=wx.ITEM_NORMAL, text='Close\tCTRL+W')
parent.AppendSeparator()
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS7,
+ parent.Append(help='', id=ID_OBJDICTEDITFILEMENUIMPORTEDS,
kind=wx.ITEM_NORMAL, text='Import EDS file')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS9,
+ parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTEDS,
kind=wx.ITEM_NORMAL, text='Export to EDS file')
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS8,
+ parent.Append(help='', id=ID_OBJDICTEDITFILEMENUEXPORTC,
kind=wx.ITEM_NORMAL, text='Build Dictionary\tCTRL+B')
parent.AppendSeparator()
- parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS4,
+ parent.Append(help='', id=wx.ID_EXIT,
kind=wx.ITEM_NORMAL, text='Exit')
- self.Bind(wx.EVT_MENU, self.OnOpenMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS0)
- self.Bind(wx.EVT_MENU, self.OnSaveMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS1)
- self.Bind(wx.EVT_MENU, self.OnCloseMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS2)
- self.Bind(wx.EVT_MENU, self.OnQuitMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS4)
- self.Bind(wx.EVT_MENU, self.OnNewMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS5)
- self.Bind(wx.EVT_MENU, self.OnSaveAsMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS6)
+ self.Bind(wx.EVT_MENU, self.OnNewMenu, id=wx.ID_NEW)
+ self.Bind(wx.EVT_MENU, self.OnOpenMenu, id=wx.ID_OPEN)
+ self.Bind(wx.EVT_MENU, self.OnCloseMenu, id=wx.ID_CLOSE)
+ self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE)
+ self.Bind(wx.EVT_MENU, self.OnSaveAsMenu, id=wx.ID_SAVEAS)
self.Bind(wx.EVT_MENU, self.OnImportEDSMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS7)
- self.Bind(wx.EVT_MENU, self.OnExportCMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS8)
+ id=ID_OBJDICTEDITFILEMENUIMPORTEDS)
self.Bind(wx.EVT_MENU, self.OnExportEDSMenu,
- id=wxID_OBJDICTEDITFILEMENUITEMS9)
+ id=ID_OBJDICTEDITFILEMENUEXPORTEDS)
+ self.Bind(wx.EVT_MENU, self.OnExportCMenu,
+ id=ID_OBJDICTEDITFILEMENUEXPORTC)
+ self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
- def _init_coll_AddMenu_Items(self, parent):
- # generated method, don't edit
+ def _init_coll_EditMenu_Items(self, parent):
+ parent.Append(help='', id=wx.ID_REFRESH,
+ kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R')
+ parent.AppendSeparator()
+ parent.Append(help='', id=wx.ID_UNDO,
+ kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z')
+ parent.Append(help='', id=wx.ID_REDO,
+ kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y')
+ parent.AppendSeparator()
+ parent.Append(help='', id=ID_OBJDICTEDITEDITMENUNODEINFOS,
+ kind=wx.ITEM_NORMAL, text='Node infos')
+ parent.Append(help='', id=ID_OBJDICTEDITEDITMENUDS301PROFILE,
+ kind=wx.ITEM_NORMAL, text='DS-301 Profile')
+ parent.Append(help='', id=ID_OBJDICTEDITEDITMENUDS302PROFILE,
+ kind=wx.ITEM_NORMAL, text='DS-302 Profile')
+ parent.Append(help='', id=ID_OBJDICTEDITEDITMENUOTHERPROFILE,
+ kind=wx.ITEM_NORMAL, text='Other Profile')
+ self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH)
+ self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO)
+ self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO)
+ self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu,
+ id=ID_OBJDICTEDITEDITMENUNODEINFOS)
+ self.Bind(wx.EVT_MENU, self.OnCommunicationMenu,
+ id=ID_OBJDICTEDITEDITMENUDS301PROFILE)
+ self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu,
+ id=ID_OBJDICTEDITEDITMENUDS302PROFILE)
+ self.Bind(wx.EVT_MENU, self.OnEditProfileMenu,
+ id=ID_OBJDICTEDITEDITMENUOTHERPROFILE)
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS0,
+ def _init_coll_AddMenu_Items(self, parent):
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUSDOSERVER,
kind=wx.ITEM_NORMAL, text='SDO Server')
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS1,
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUSDOCLIENT,
kind=wx.ITEM_NORMAL, text='SDO Client')
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS2,
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUPDOTRANSMIT,
kind=wx.ITEM_NORMAL, text='PDO Transmit')
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS3,
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUPDORECEIVE,
kind=wx.ITEM_NORMAL, text='PDO Receive')
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS4,
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUMAPVARIABLE,
kind=wx.ITEM_NORMAL, text='Map Variable')
- parent.Append(help='', id=wxID_OBJDICTEDITADDMENUITEMS5,
+ parent.Append(help='', id=ID_OBJDICTEDITADDMENUUSERTYPE,
kind=wx.ITEM_NORMAL, text='User Type')
self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS0)
+ id=ID_OBJDICTEDITADDMENUSDOSERVER)
self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS1)
+ id=ID_OBJDICTEDITADDMENUSDOCLIENT)
self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS2)
+ id=ID_OBJDICTEDITADDMENUPDOTRANSMIT)
self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS3)
+ id=ID_OBJDICTEDITADDMENUPDORECEIVE)
self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS4)
+ id=ID_OBJDICTEDITADDMENUMAPVARIABLE)
self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu,
- id=wxID_OBJDICTEDITADDMENUITEMS5)
+ id=ID_OBJDICTEDITADDMENUUSERTYPE)
+
+ def _init_coll_HelpMenu_Items(self, parent):
+ parent.Append(help='', id=wx.ID_HELP,
+ kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1')
+ self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, id=wx.ID_HELP)
+ parent.Append(help='', id=wx.ID_HELP_CONTEXT,
+ kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2')
+ self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, id=wx.ID_HELP_CONTEXT)
+ if Html_Window and self.ModeSolo:
+ parent.Append(help='', id=wx.ID_ABOUT,
+ kind=wx.ITEM_NORMAL, text='About')
+ self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
def _init_coll_HelpBar_Fields(self, parent):
- # generated method, don't edit
parent.SetFieldsCount(3)
parent.SetStatusText(number=0, text='')
parent.SetStatusWidths([100, 110, -1])
def _init_utils(self):
- # generated method, don't edit
- self.menuBar1 = wx.MenuBar()
- self.menuBar1.SetEvtHandlerEnabled(True)
-
- self.FileMenu = wx.Menu(title='')
+ self.MenuBar = wx.MenuBar()
+ self.MenuBar.SetEvtHandlerEnabled(True)
+ if self.ModeSolo:
+ self.FileMenu = wx.Menu(title='')
self.EditMenu = wx.Menu(title='')
-
self.AddMenu = wx.Menu(title='')
-
self.HelpMenu = wx.Menu(title='')
- self._init_coll_menuBar1_Menus(self.menuBar1)
- self._init_coll_FileMenu_Items(self.FileMenu)
+ self._init_coll_MenuBar_Menus(self.MenuBar)
+ if self.ModeSolo:
+ self._init_coll_FileMenu_Items(self.FileMenu)
self._init_coll_EditMenu_Items(self.EditMenu)
self._init_coll_AddMenu_Items(self.AddMenu)
self._init_coll_HelpMenu_Items(self.HelpMenu)
def _init_ctrls(self, prnt):
- # generated method, don't edit
- wx.Frame.__init__(self, id=wxID_OBJDICTEDIT, name='objdictedit',
+ wx.Frame.__init__(self, id=ID_OBJDICTEDIT, name='objdictedit',
parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700),
style=wx.DEFAULT_FRAME_STYLE, title='Objdictedit')
self._init_utils()
self.SetClientSize(wx.Size(1000, 700))
- self.SetMenuBar(self.menuBar1)
- self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_OBJDICTEDIT)
-
- self.FileOpened = wx.Notebook(id=wxID_OBJDICTEDITFILEOPENED,
+ self.SetMenuBar(self.MenuBar)
+ self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
+ if not self.ModeSolo:
+ self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE)
+ accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, wx.ID_SAVE)])
+ self.SetAcceleratorTable(accel)
+
+ self.FileOpened = wx.Notebook(id=ID_OBJDICTEDITFILEOPENED,
name='FileOpened', parent=self, pos=wx.Point(0, 0),
size=wx.Size(0, 0), style=0)
self.FileOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
- self.OnFileSelectedChanged, id=wxID_OBJDICTEDITFILEOPENED)
+ self.OnFileSelectedChanged, id=ID_OBJDICTEDITFILEOPENED)
- self.HelpBar = wx.StatusBar(id=wxID_OBJDICTEDITHELPBAR, name='HelpBar',
- parent=self, style=wxST_SIZEGRIP)
+ self.HelpBar = wx.StatusBar(id=ID_OBJDICTEDITHELPBAR, name='HelpBar',
+ parent=self, style=wx.ST_SIZEGRIP)
self._init_coll_HelpBar_Fields(self.HelpBar)
self.SetStatusBar(self.HelpBar)
- def __init__(self, parent):
+ def __init__(self, parent, manager = None, filesOpen = []):
+ self.ModeSolo = manager == None
self._init_ctrls(parent)
self.HtmlFrameOpened = []
+ self.BusId = None
+ self.Closing = False
+
+ icon = wx.Icon(os.path.join(ScriptDirectory,"networkedit.ico"),wx.BITMAP_TYPE_ICO)
+ self.SetIcon(icon)
- self.Manager = NodeManager(ScriptDirectory)
- for filepath in filesOpen:
- self.Manager.OpenFileInCurrent(filepath)
- new_editingpanel = EditingPanel(self, self.Manager)
- self.FileOpened.AddPage(new_editingpanel, "")
- self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex())
- if self.Manager.CurrentDS302Defined():
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
+ if self.ModeSolo:
+ self.Manager = NodeManager()
+ for filepath in filesOpen:
+ result = self.Manager.OpenFileInCurrent(os.path.abspath(filepath))
+ if isinstance(result, (IntType, LongType)):
+ new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
+ new_editingpanel.SetIndex(result)
+ self.FileOpened.AddPage(new_editingpanel, "")
else:
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
+ self.Manager = manager
+ for index in self.Manager.GetBufferIndexes():
+ new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
+ new_editingpanel.SetIndex(index)
+ self.FileOpened.AddPage(new_editingpanel, "")
+
+ if self.Manager.GetBufferNumber() > 0:
+ window = self.FileOpened.GetPage(0)
+ if window:
+ self.Manager.ChangeCurrentNode(window.GetIndex())
+ self.FileOpened.SetSelection(0)
+
+ if self.Manager.CurrentDS302Defined():
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
+ else:
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
self.RefreshEditMenu()
self.RefreshBufferState()
self.RefreshProfileMenu()
self.RefreshTitle()
self.RefreshMainMenu()
- def GetNoteBook(self):
- return self.FileOpened
+ def SetBusId(self, bus_id):
+ self.BusId = bus_id
+
+ def GetBusId(self):
+ return self.BusId
+
+ def IsClosing(self):
+ return self.Closing
def OnAddSDOServerMenu(self, event):
self.Manager.AddSDOServerToCurrent()
event.Skip()
def OnFileSelectedChanged(self, event):
- selected = event.GetSelection()
- # At init selected = -1
- if selected >= 0:
- window = self.FileOpened.GetPage(selected)
- self.Manager.ChangeCurrentNode(window.GetIndex())
- self.RefreshBufferState()
- self.RefreshStatusBar()
- self.RefreshProfileMenu()
+ if not self.Closing:
+ selected = event.GetSelection()
+ # At init selected = -1
+ if selected >= 0:
+ window = self.FileOpened.GetPage(selected)
+ if window:
+ self.Manager.ChangeCurrentNode(window.GetIndex())
+ wx.CallAfter(self.RefreshBufferState)
+ self.RefreshStatusBar()
+ self.RefreshProfileMenu()
event.Skip()
def OnHelpDS301Menu(self, event):
find_index = True
index, subIndex = result
result = OpenPDFDocIndex(index, ScriptDirectory)
- if type(result) == StringType:
- message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
+ if isinstance(result, (StringType, UnicodeType)):
+ message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
if not find_index:
result = OpenPDFDocIndex(None, ScriptDirectory)
- if type(result) == StringType:
- message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
+ if isinstance(result, (StringType, UnicodeType)):
+ message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
event.Skip()
def OnHelpCANFestivalMenu(self, event):
#self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
- os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
+ if wx.Platform == '__WXMSW__':
+ readerpath = get_acroversion()
+ readerexepath = os.path.join(readerpath,"AcroRd32.exe")
+ if(os.path.isfile(readerexepath)):
+ os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", '"%s"'%os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
+ else:
+ os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
event.Skip()
def OnAboutMenu(self, event):
event.Skip()
def OnCloseFrame(self, event):
- if self.Manager.OneFileHasChanged():
- dialog = wxMessageDialog(self, "There are changes, do you want to save?", "Close Application", wxYES_NO|wxCANCEL|wxICON_QUESTION)
+ self.Closing = True
+ if not self.ModeSolo:
+ if getattr(self, "_onclose", None) != None:
+ self._onclose()
+ event.Skip()
+ elif self.Manager.OneFileHasChanged():
+ dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
- if answer == wxID_YES:
- self.Manager.ChangeCurrentNode(0)
- for i in xrange(self.FileOpened.GetPageCount()):
+ if answer == wx.ID_YES:
+ for i in xrange(self.Manager.GetBufferNumber()):
if self.Manager.CurrentIsSaved():
self.Manager.CloseCurrent()
else:
self.Save()
self.Manager.CloseCurrent(True)
event.Skip()
- elif answer == wxID_NO:
- for i in xrange(self.FileOpened.GetPageCount()):
- self.Manager.CloseCurrent(True)
- wxCallAfter(self.Close)
+ elif answer == wx.ID_NO:
event.Skip()
+ else:
+ event.Veto()
else:
event.Skip()
window.RefreshIndexList()
def RefreshStatusBar(self):
- if self.HelpBar:
- selected = self.FileOpened.GetSelection()
- if selected >= 0:
- window = self.FileOpened.GetPage(selected)
- selection = window.GetSelection()
- if selection:
- index, subIndex = selection
- if self.Manager.IsCurrentEntry(index):
- self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
- self.HelpBar.SetStatusText("Subindex: 0x%02X"%subIndex, 1)
- entryinfos = self.Manager.GetEntryInfos(index)
- name = entryinfos["name"]
- category = "Optional"
- if entryinfos["need"]:
- category = "Mandatory"
- struct = "VAR"
- number = ""
- if entryinfos["struct"] & OD_IdenticalIndexes:
- number = " possibly defined %d times"%entryinfos["nbmax"]
- if entryinfos["struct"] & OD_IdenticalSubindexes:
- struct = "REC"
- elif entryinfos["struct"] & OD_MultipleSubindexes:
- struct = "ARRAY"
- text = "%s: %s entry of struct %s%s."%(name,category,struct,number)
- self.HelpBar.SetStatusText(text, 2)
- else:
- for i in xrange(3):
- self.HelpBar.SetStatusText("", i)
+ selected = self.FileOpened.GetSelection()
+ if selected >= 0:
+ window = self.FileOpened.GetPage(selected)
+ selection = window.GetSelection()
+ if selection:
+ index, subIndex = selection
+ if self.Manager.IsCurrentEntry(index):
+ self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
+ self.HelpBar.SetStatusText("Subindex: 0x%02X"%subIndex, 1)
+ entryinfos = self.Manager.GetEntryInfos(index)
+ name = entryinfos["name"]
+ category = "Optional"
+ if entryinfos["need"]:
+ category = "Mandatory"
+ struct = "VAR"
+ number = ""
+ if entryinfos["struct"] & OD_IdenticalIndexes:
+ number = " possibly defined %d times"%entryinfos["nbmax"]
+ if entryinfos["struct"] & OD_IdenticalSubindexes:
+ struct = "REC"
+ elif entryinfos["struct"] & OD_MultipleSubindexes:
+ struct = "ARRAY"
+ text = "%s: %s entry of struct %s%s."%(name,category,struct,number)
+ self.HelpBar.SetStatusText(text, 2)
else:
for i in xrange(3):
self.HelpBar.SetStatusText("", i)
+ else:
+ for i in xrange(3):
+ self.HelpBar.SetStatusText("", i)
def RefreshMainMenu(self):
- if self.FileMenu:
- if self.FileOpened.GetPageCount() > 0:
- self.menuBar1.EnableTop(1, True)
- self.menuBar1.EnableTop(2, True)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS1, True)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS2, True)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS6, True)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS8, True)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS9, True)
+ if self.FileOpened.GetPageCount() > 0:
+ if self.ModeSolo:
+ self.MenuBar.EnableTop(1, True)
+ self.MenuBar.EnableTop(2, True)
+ self.FileMenu.Enable(wx.ID_CLOSE, True)
+ self.FileMenu.Enable(wx.ID_SAVE, True)
+ self.FileMenu.Enable(wx.ID_SAVEAS, True)
+ self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, True)
+ self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, True)
else:
- self.menuBar1.EnableTop(1, False)
- self.menuBar1.EnableTop(2, False)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS1, False)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS2, False)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS6, False)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS8, False)
- self.FileMenu.Enable(wxID_OBJDICTEDITFILEMENUITEMS9, False)
+ self.MenuBar.EnableTop(0, True)
+ self.MenuBar.EnableTop(1, True)
+ else:
+ if self.ModeSolo:
+ self.MenuBar.EnableTop(1, False)
+ self.MenuBar.EnableTop(2, False)
+ self.FileMenu.Enable(wx.ID_CLOSE, False)
+ self.FileMenu.Enable(wx.ID_SAVE, False)
+ self.FileMenu.Enable(wx.ID_SAVEAS, False)
+ self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTEDS, False)
+ self.FileMenu.Enable(ID_OBJDICTEDITFILEMENUEXPORTC, False)
+ else:
+ self.MenuBar.EnableTop(0, False)
+ self.MenuBar.EnableTop(1, False)
def RefreshEditMenu(self):
- if self.FileMenu:
- if self.FileOpened.GetPageCount() > 0:
- undo, redo = self.Manager.GetCurrentBufferState()
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS1, undo)
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS0, redo)
- else:
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS1, False)
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS0, False)
+ if self.FileOpened.GetPageCount() > 0:
+ undo, redo = self.Manager.GetCurrentBufferState()
+ self.EditMenu.Enable(wx.ID_UNDO, undo)
+ self.EditMenu.Enable(wx.ID_REDO, redo)
+ else:
+ self.EditMenu.Enable(wx.ID_UNDO, False)
+ self.EditMenu.Enable(wx.ID_REDO, False)
def RefreshProfileMenu(self):
- if self.EditMenu:
- profile = self.Manager.GetCurrentProfileName()
- edititem = self.EditMenu.FindItemById(wxID_OBJDICTEDITEDITMENUITEMS7)
- if edititem:
- length = self.AddMenu.GetMenuItemCount()
- for i in xrange(length-6):
- additem = self.AddMenu.FindItemByPosition(6)
- self.AddMenu.Delete(additem.GetId())
- if profile not in ("None", "DS-301"):
- edititem.SetText("%s Profile"%profile)
- edititem.Enable(True)
- self.AddMenu.AppendSeparator()
- for text, indexes in self.Manager.GetCurrentSpecificMenu():
- new_id = wx.NewId()
- self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
- self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
- else:
- edititem.SetText("Other Profile")
- edititem.Enable(False)
+ profile = self.Manager.GetCurrentProfileName()
+ edititem = self.EditMenu.FindItemById(ID_OBJDICTEDITEDITMENUOTHERPROFILE)
+ if edititem:
+ length = self.AddMenu.GetMenuItemCount()
+ for i in xrange(length-6):
+ additem = self.AddMenu.FindItemByPosition(6)
+ self.AddMenu.Delete(additem.GetId())
+ if profile not in ("None", "DS-301"):
+ edititem.SetText("%s Profile"%profile)
+ edititem.Enable(True)
+ self.AddMenu.AppendSeparator()
+ for text, indexes in self.Manager.GetCurrentSpecificMenu():
+ new_id = wx.NewId()
+ self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text)
+ self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id)
+ else:
+ edititem.SetText("Other Profile")
+ edititem.Enable(False)
#-------------------------------------------------------------------------------
def OnNewMenu(self, event):
self.FilePath = ""
- dialog = CreateNodeDialog(self, ScriptDirectory)
- if dialog.ShowModal() == wxID_OK:
+ dialog = CreateNodeDialog(self)
+ if dialog.ShowModal() == wx.ID_OK:
name, id, nodetype, description = dialog.GetValues()
profile, filepath = dialog.GetProfile()
NMT = dialog.GetNMTManagement()
options = dialog.GetOptions()
result = self.Manager.CreateNewNode(name, id, nodetype, description, profile, filepath, NMT, options)
- if type(result) == IntType:
- new_editingpanel = EditingPanel(self, self.Manager)
+ if isinstance(result, (IntType, LongType)):
+ new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
new_editingpanel.SetIndex(result)
self.FileOpened.AddPage(new_editingpanel, "")
self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
if "DS302" in options:
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
self.RefreshBufferState()
self.RefreshProfileMenu()
self.RefreshMainMenu()
else:
- message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
+ dialog.Destroy()
event.Skip()
def OnOpenMenu(self, event):
directory = os.path.dirname(filepath)
else:
directory = os.getcwd()
- dialog = wxFileDialog(self, "Choose a file", directory, "", "OD files (*.od)|*.od|All files|*.*", wxOPEN|wxCHANGE_DIR)
- if dialog.ShowModal() == wxID_OK:
+ dialog = wx.FileDialog(self, "Choose a file", directory, "", "OD files (*.od)|*.od|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
+ if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isfile(filepath):
result = self.Manager.OpenFileInCurrent(filepath)
- if type(result) == IntType:
- new_editingpanel = EditingPanel(self, self.Manager)
+ if isinstance(result, (IntType, LongType)):
+ new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
new_editingpanel.SetIndex(result)
self.FileOpened.AddPage(new_editingpanel, "")
self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
if self.Manager.CurrentDS302Defined():
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True)
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, True)
else:
- self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False)
+ self.EditMenu.Enable(ID_OBJDICTEDITEDITMENUDS302PROFILE, False)
self.RefreshEditMenu()
self.RefreshBufferState()
self.RefreshProfileMenu()
self.RefreshMainMenu()
else:
- message = wxMessageDialog(self, e.args[0], "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
event.Skip()
def OnSaveMenu(self, event):
- self.Save()
+ if not self.ModeSolo and getattr(self, "_onsave", None) != None:
+ self._onsave()
+ self.RefreshBufferState()
+ else:
+ self.Save()
event.Skip()
def OnSaveAsMenu(self, event):
result = self.Manager.SaveCurrentInFile()
if not result:
self.SaveAs()
- elif type(result) != StringType:
+ elif not isinstance(result, (StringType, UnicodeType)):
self.RefreshBufferState()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
directory, filename = os.path.split(filepath)
else:
directory, filename = os.getcwd(), "%s.od"%self.Manager.GetCurrentNodeInfos()[0]
- dialog = wxFileDialog(self, "Choose a file", directory, filename, "OD files (*.od)|*.od|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
- if dialog.ShowModal() == wxID_OK:
+ dialog = wx.FileDialog(self, "Choose a file", directory, filename, "OD files (*.od)|*.od|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
+ if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):
result = self.Manager.SaveCurrentInFile(filepath)
- if type(result) != StringType:
+ if not isinstance(result, (StringType, UnicodeType)):
self.RefreshBufferState()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
def OnCloseMenu(self, event):
- answer = wxID_YES
+ answer = wx.ID_YES
result = self.Manager.CloseCurrent()
if not result:
- dialog = wxMessageDialog(self, "There are changes, do you want to save?", "Close File", wxYES_NO|wxCANCEL|wxICON_QUESTION)
+ dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close File", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
- if answer == wxID_YES:
+ if answer == wx.ID_YES:
self.OnSaveMenu(event)
if self.Manager.CurrentIsSaved():
self.Manager.CloseCurrent()
- elif answer == wxID_NO:
+ elif answer == wx.ID_NO:
self.Manager.CloseCurrent(True)
if self.FileOpened.GetPageCount() > self.Manager.GetBufferNumber():
current = self.FileOpened.GetSelection()
#-------------------------------------------------------------------------------
def OnImportEDSMenu(self, event):
- dialog = wxFileDialog(self, "Choose a file", os.getcwd(), "", "EDS files (*.eds)|*.eds|All files|*.*", wxOPEN|wxCHANGE_DIR)
- if dialog.ShowModal() == wxID_OK:
+ dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR)
+ if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isfile(filepath):
result = self.Manager.ImportCurrentFromEDSFile(filepath)
- if type(result) == IntType:
- new_editingpanel = EditingPanel(self, self.Manager)
+ if isinstance(result, (IntType, LongType)):
+ new_editingpanel = EditingPanel(self.FileOpened, self, self.Manager)
new_editingpanel.SetIndex(result)
self.FileOpened.AddPage(new_editingpanel, "")
self.FileOpened.SetSelection(self.FileOpened.GetPageCount() - 1)
self.RefreshCurrentIndexList()
self.RefreshProfileMenu()
self.RefreshMainMenu()
- message = wxMessageDialog(self, "Import successful", "Information", wxOK|wxICON_INFORMATION)
+ message = wx.MessageDialog(self, "Import successful", "Information", wx.OK|wx.ICON_INFORMATION)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, "\"%s\" is not a valid file!"%filepath, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "\"%s\" is not a valid file!"%filepath, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
event.Skip()
-
def OnExportEDSMenu(self, event):
- dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "EDS files (*.eds)|*.eds|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
- if dialog.ShowModal() == wxID_OK:
+ 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)
+ if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):
path, extend = os.path.splitext(filepath)
filepath = path + ".eds"
result = self.Manager.ExportCurrentToEDSFile(filepath)
if not result:
- message = wxMessageDialog(self, "Export successful", "Information", wxOK|wxICON_INFORMATION)
+ message = wx.MessageDialog(self, "Export successful", "Information", wx.OK|wx.ICON_INFORMATION)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
event.Skip()
def OnExportCMenu(self, event):
- dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "CANFestival OD files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR)
- if dialog.ShowModal() == wxID_OK:
+ 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)
+ if dialog.ShowModal() == wx.ID_OK:
filepath = dialog.GetPath()
if os.path.isdir(os.path.dirname(filepath)):
path, extend = os.path.splitext(filepath)
filepath = path + ".c"
result = self.Manager.ExportCurrentToCFile(filepath)
if not result:
- message = wxMessageDialog(self, "Export successful", "Information", wxOK|wxICON_INFORMATION)
+ message = wx.MessageDialog(self, "Export successful", "Information", wx.OK|wx.ICON_INFORMATION)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
else:
- message = wxMessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, "\"%s\" is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
def OnOtherCommunicationMenu(self, event):
dictionary,current = self.Manager.GetCurrentDS302Lists()
- self.EditProfile("Edit DS-301 Profile", dictionary, current)
+ self.EditProfile("Edit DS-302 Profile", dictionary, current)
event.Skip()
def OnEditProfileMenu(self, event):
dialog.SetIndexDictionary(dictionary)
dialog.SetCurrentList(current)
dialog.RefreshLists()
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
new_profile = dialog.GetCurrentList()
addinglist = []
removinglist = []
if index not in new_profile:
removinglist.append(index)
self.Manager.ManageEntriesOfCurrent(addinglist, removinglist)
- self.Manager.GenerateMapList()
self.Manager.BufferCurrentNode()
self.RefreshBufferState()
self.RefreshCurrentIndexList()
def OnNodeInfosMenu(self, event):
dialog = NodeInfosDialog(self)
name, id, type, description = self.Manager.GetCurrentNodeInfos()
- dialog.SetValues(name, id, type, description)
- if dialog.ShowModal() == wxID_OK:
- name, id, type, description = dialog.GetValues()
+ defaultstringsize = self.Manager.GetCurrentNodeDefaultStringSize()
+ dialog.SetValues(name, id, type, description, defaultstringsize)
+ if dialog.ShowModal() == wx.ID_OK:
+ name, id, type, description, defaultstringsize = dialog.GetValues()
self.Manager.SetCurrentNodeInfos(name, id, type, description)
+ self.Manager.SetCurrentNodeDefaultStringSize(defaultstringsize)
self.RefreshBufferState()
self.RefreshProfileMenu()
selected = self.FileOpened.GetSelection()
if index:
dialog = MapVariableDialog(self)
dialog.SetIndex(index)
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
index, name, struct, number = dialog.GetValues()
result = self.Manager.AddMapVariableToCurrent(index, name, struct, number)
- if type(result) != StringType:
+ if not isinstance(result, (StringType, UnicodeType)):
self.RefreshBufferState()
self.RefreshCurrentIndexList()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
else:
- message = wxMessageDialog(self, result, "No map variable index left!", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "No map variable index left!", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
def AddUserType(self):
dialog = UserTypeDialog(self)
dialog.SetTypeList(self.Manager.GetCustomisableTypes())
- if dialog.ShowModal() == wxID_OK:
+ if dialog.ShowModal() == wx.ID_OK:
type, min, max, length = dialog.GetValues()
result = self.Manager.AddUserTypeToCurrent(type, min, max, length)
if not result:
self.RefreshBufferState()
self.RefreshCurrentIndexList()
else:
- message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
dialog.Destroy()
return res
def Display_Error_Dialog(e_value):
- message = wxMessageDialog(None, str(e_value), "Error", wxOK|wxICON_ERROR)
+ message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR)
message.ShowModal()
message.Destroy()
ignored_exceptions = [] # a problem with a line in a module is only reported once per session
-def wxAddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
+def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]):
def handle_exception(e_type, e_value, e_traceback):
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func
sys.excepthook = handle_exception
if __name__ == '__main__':
- app = wxPySimpleApp()
- wxInitAllImageHandlers()
+ def usage():
+ print "\nUsage of objdictedit.py :"
+ print "\n %s [Filepath, ...]\n"%sys.argv[0]
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
+ except getopt.GetoptError:
+ # print help information and exit:
+ usage()
+ sys.exit(2)
+
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+
+ app = wx.PySimpleApp()
+ wx.InitAllImageHandlers()
# Install a exception handle for bug reports
- wxAddExceptHook(os.getcwd(),__version__)
+ AddExceptHook(os.getcwd(),__version__)
- frame = objdictedit(None)
+ frame = objdictedit(None, filesOpen = args)
frame.Show()
app.MainLoop()