objdictgen/networkedit.py
changeset 276 eada6c6c2e87
parent 273 58b39f97e352
child 299 506f9700b9fb
equal deleted inserted replaced
275:7d5130f2f8ab 276:eada6c6c2e87
    33 from nodemanager import *
    33 from nodemanager import *
    34 from subindextable import *
    34 from subindextable import *
    35 from commondialogs import *
    35 from commondialogs import *
    36 from doc_index.DS301_index import *
    36 from doc_index.DS301_index import *
    37 
    37 
    38 def create(parent):
       
    39     return networkedit(parent)
       
    40 
       
    41 def usage():
       
    42     print "\nUsage of networkedit.py :"
       
    43     print "\n   %s [Projectpath]\n"%sys.argv[0]
       
    44 
       
    45 try:
       
    46     opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
       
    47 except getopt.GetoptError:
       
    48     # print help information and exit:
       
    49     usage()
       
    50     sys.exit(2)
       
    51 
       
    52 for o, a in opts:
       
    53     if o in ("-h", "--help"):
       
    54         usage()
       
    55         sys.exit()
       
    56 
       
    57 if len(args) == 0:
       
    58     projectOpen = None 
       
    59 elif len(args) == 1:
       
    60     projectOpen = args[0]
       
    61 else:
       
    62     usage()
       
    63     sys.exit(2)
       
    64 ScriptDirectory = os.path.split(__file__)[0]
    38 ScriptDirectory = os.path.split(__file__)[0]
    65 
    39 
    66 try:
    40 try:
    67     import wx.html
    41     import wx.html
    68 
    42 
   334         self.HelpBar = wx.StatusBar(id=ID_NETWORKEDITHELPBAR, name='HelpBar',
   308         self.HelpBar = wx.StatusBar(id=ID_NETWORKEDITHELPBAR, name='HelpBar',
   335               parent=self, style=wx.ST_SIZEGRIP)
   309               parent=self, style=wx.ST_SIZEGRIP)
   336         self._init_coll_HelpBar_Fields(self.HelpBar)
   310         self._init_coll_HelpBar_Fields(self.HelpBar)
   337         self.SetStatusBar(self.HelpBar)
   311         self.SetStatusBar(self.HelpBar)
   338 
   312 
   339     def __init__(self, parent, nodelist = None):
   313     def __init__(self, parent, nodelist = None, projectOpen = None):
   340         self.ModeSolo = nodelist == None
   314         self.ModeSolo = nodelist == None
   341         self._init_ctrls(parent)
   315         self._init_ctrls(parent)
   342         self.HtmlFrameOpened = []
   316         self.HtmlFrameOpened = []
   343         self.BusId = None
   317         self.BusId = None
   344         
   318         
   428         event.Skip()
   402         event.Skip()
   429 
   403 
   430     def OnNodeSelectedChanged(self, event):
   404     def OnNodeSelectedChanged(self, event):
   431         selected = event.GetSelection()
   405         selected = event.GetSelection()
   432         # At init selected = -1
   406         # At init selected = -1
   433         if selected > 0:
   407         if selected >= 0:
   434             window = self.NetworkNodes.GetPage(selected)
   408             window = self.NetworkNodes.GetPage(selected)
   435             self.NodeList.SetCurrentSelected(window.GetIndex())
   409             self.NodeList.SetCurrentSelected(window.GetIndex())
   436         self.RefreshMainMenu()
   410         self.RefreshMainMenu()
   437         self.RefreshStatusBar()
   411         self.RefreshStatusBar()
   438         event.Skip()
   412         event.Skip()
   612                 new_editingpanel = EditingPanel(self, self.NodeList, False)
   586                 new_editingpanel = EditingPanel(self, self.NodeList, False)
   613                 new_editingpanel.SetIndex(idx)
   587                 new_editingpanel.SetIndex(idx)
   614                 self.NetworkNodes.AddPage(new_editingpanel, "")
   588                 self.NetworkNodes.AddPage(new_editingpanel, "")
   615 
   589 
   616     def RefreshStatusBar(self):
   590     def RefreshStatusBar(self):
   617         if self.HelpBar:
   591         selected = self.NetworkNodes.GetSelection()
   618             window = self.NetworkNodes.GetPage(self.NetworkNodes.GetSelection())
   592         if self.HelpBar and selected >= 0:
       
   593             window = self.NetworkNodes.GetPage(selected)
   619             selection = window.GetSelection()
   594             selection = window.GetSelection()
   620             if selection:
   595             if selection:
   621                 index, subIndex = selection
   596                 index, subIndex = selection
   622                 if self.NodeList.IsCurrentEntry(index):
   597                 if self.NodeList.IsCurrentEntry(index):
   623                     self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
   598                     self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0)
   985 
   960 
   986     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
   961     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
   987     sys.excepthook = handle_exception
   962     sys.excepthook = handle_exception
   988 
   963 
   989 if __name__ == '__main__':
   964 if __name__ == '__main__':
       
   965     def usage():
       
   966         print "\nUsage of networkedit.py :"
       
   967         print "\n   %s [Projectpath]\n"%sys.argv[0]
       
   968 
       
   969     try:
       
   970         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
       
   971     except getopt.GetoptError:
       
   972         # print help information and exit:
       
   973         usage()
       
   974         sys.exit(2)
       
   975 
       
   976     for o, a in opts:
       
   977         if o in ("-h", "--help"):
       
   978             usage()
       
   979             sys.exit()
       
   980 
       
   981     if len(args) == 0:
       
   982         projectOpen = None 
       
   983     elif len(args) == 1:
       
   984         projectOpen = args[0]
       
   985     else:
       
   986         usage()
       
   987         sys.exit(2)
       
   988     
   990     app = wx.PySimpleApp()
   989     app = wx.PySimpleApp()
   991     wx.InitAllImageHandlers()
   990     wx.InitAllImageHandlers()
   992     
   991     
   993     # Install a exception handle for bug reports
   992     # Install a exception handle for bug reports
   994     AddExceptHook(os.getcwd(),__version__)
   993     AddExceptHook(os.getcwd(),__version__)
   995     
   994     
   996     frame = networkedit(None)
   995     frame = networkedit(None, projectOpen=projectOpen)
   997 
   996 
   998     frame.Show()
   997     frame.Show()
   999     app.MainLoop()
   998     app.MainLoop()