379 |
379 |
380 def OnAddSDOServerMenu(self, event): |
380 def OnAddSDOServerMenu(self, event): |
381 self.Manager.AddSDOServerToCurrent() |
381 self.Manager.AddSDOServerToCurrent() |
382 self.RefreshBufferState() |
382 self.RefreshBufferState() |
383 self.RefreshCurrentIndexList() |
383 self.RefreshCurrentIndexList() |
384 event.Skip() |
384 |
385 |
|
386 def OnAddSDOClientMenu(self, event): |
385 def OnAddSDOClientMenu(self, event): |
387 self.Manager.AddSDOClientToCurrent() |
386 self.Manager.AddSDOClientToCurrent() |
388 self.RefreshBufferState() |
387 self.RefreshBufferState() |
389 self.RefreshCurrentIndexList() |
388 self.RefreshCurrentIndexList() |
390 event.Skip() |
389 |
391 |
|
392 def OnAddPDOTransmitMenu(self, event): |
390 def OnAddPDOTransmitMenu(self, event): |
393 self.Manager.AddPDOTransmitToCurrent() |
391 self.Manager.AddPDOTransmitToCurrent() |
394 self.RefreshBufferState() |
392 self.RefreshBufferState() |
395 self.RefreshCurrentIndexList() |
393 self.RefreshCurrentIndexList() |
396 event.Skip() |
394 |
397 |
|
398 def OnAddPDOReceiveMenu(self, event): |
395 def OnAddPDOReceiveMenu(self, event): |
399 self.Manager.AddPDOReceiveToCurrent() |
396 self.Manager.AddPDOReceiveToCurrent() |
400 self.RefreshBufferState() |
397 self.RefreshBufferState() |
401 self.RefreshCurrentIndexList() |
398 self.RefreshCurrentIndexList() |
402 event.Skip() |
399 |
403 |
|
404 def OnAddMapVariableMenu(self, event): |
400 def OnAddMapVariableMenu(self, event): |
405 self.AddMapVariable() |
401 self.AddMapVariable() |
406 event.Skip() |
402 |
407 |
|
408 def OnAddUserTypeMenu(self, event): |
403 def OnAddUserTypeMenu(self, event): |
409 self.AddUserType() |
404 self.AddUserType() |
410 event.Skip() |
405 |
411 |
|
412 def OnFileSelectedChanged(self, event): |
406 def OnFileSelectedChanged(self, event): |
413 if not self.Closing: |
407 if not self.Closing: |
414 selected = event.GetSelection() |
408 selected = event.GetSelection() |
415 # At init selected = -1 |
409 # At init selected = -1 |
416 if selected >= 0: |
410 if selected >= 0: |
440 result = OpenPDFDocIndex(None, ScriptDirectory) |
434 result = OpenPDFDocIndex(None, ScriptDirectory) |
441 if isinstance(result, (StringType, UnicodeType)): |
435 if isinstance(result, (StringType, UnicodeType)): |
442 message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR) |
436 message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR) |
443 message.ShowModal() |
437 message.ShowModal() |
444 message.Destroy() |
438 message.Destroy() |
445 event.Skip() |
|
446 |
439 |
447 def OnHelpCANFestivalMenu(self, event): |
440 def OnHelpCANFestivalMenu(self, event): |
448 #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600)) |
441 #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600)) |
449 if wx.Platform == '__WXMSW__': |
442 if wx.Platform == '__WXMSW__': |
450 readerpath = get_acroversion() |
443 readerpath = get_acroversion() |
460 os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16)) |
453 os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16)) |
461 except: |
454 except: |
462 message = wx.MessageDialog(self, _("Check if xpdf is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
455 message = wx.MessageDialog(self, _("Check if xpdf is correctly installed on your computer"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
463 message.ShowModal() |
456 message.ShowModal() |
464 message.Destroy() |
457 message.Destroy() |
465 event.Skip() |
458 |
466 |
|
467 def OnAboutMenu(self, event): |
459 def OnAboutMenu(self, event): |
468 self.OpenHtmlFrame(_("About CAN Festival"), os.path.join(ScriptDirectory, "doc/about.html"), wx.Size(500, 450)) |
460 self.OpenHtmlFrame(_("About CAN Festival"), os.path.join(ScriptDirectory, "doc/about.html"), wx.Size(500, 450)) |
469 event.Skip() |
461 |
470 |
|
471 def OpenHtmlFrame(self, title, file, size): |
462 def OpenHtmlFrame(self, title, file, size): |
472 if title not in self.HtmlFrameOpened: |
463 if title not in self.HtmlFrameOpened: |
473 self.HtmlFrameOpened.append(title) |
464 self.HtmlFrameOpened.append(title) |
474 window = HtmlFrame(self, self.HtmlFrameOpened) |
465 window = HtmlFrame(self, self.HtmlFrameOpened) |
475 window.SetTitle(title) |
466 window.SetTitle(title) |
477 window.SetClientSize(size) |
468 window.SetClientSize(size) |
478 window.Show() |
469 window.Show() |
479 |
470 |
480 def OnQuitMenu(self, event): |
471 def OnQuitMenu(self, event): |
481 self.Close() |
472 self.Close() |
482 event.Skip() |
473 |
483 |
|
484 def OnCloseFrame(self, event): |
474 def OnCloseFrame(self, event): |
485 self.Closing = True |
475 self.Closing = True |
486 if not self.ModeSolo: |
476 if not self.ModeSolo: |
487 if getattr(self, "_onclose", None) != None: |
477 if getattr(self, "_onclose", None) != None: |
488 self._onclose() |
478 self._onclose() |
516 else: |
506 else: |
517 self.SetTitle(_("Objdictedit")) |
507 self.SetTitle(_("Objdictedit")) |
518 |
508 |
519 def OnRefreshMenu(self, event): |
509 def OnRefreshMenu(self, event): |
520 self.RefreshCurrentIndexList() |
510 self.RefreshCurrentIndexList() |
521 event.Skip() |
511 |
522 |
|
523 def RefreshCurrentIndexList(self): |
512 def RefreshCurrentIndexList(self): |
524 selected = self.FileOpened.GetSelection() |
513 selected = self.FileOpened.GetSelection() |
525 window = self.FileOpened.GetPage(selected) |
514 window = self.FileOpened.GetPage(selected) |
526 window.RefreshIndexList() |
515 window.RefreshIndexList() |
527 |
516 |
626 |
615 |
627 def OnUndoMenu(self, event): |
616 def OnUndoMenu(self, event): |
628 self.Manager.LoadCurrentPrevious() |
617 self.Manager.LoadCurrentPrevious() |
629 self.RefreshCurrentIndexList() |
618 self.RefreshCurrentIndexList() |
630 self.RefreshBufferState() |
619 self.RefreshBufferState() |
631 event.Skip() |
620 |
632 |
|
633 def OnRedoMenu(self, event): |
621 def OnRedoMenu(self, event): |
634 self.Manager.LoadCurrentNext() |
622 self.Manager.LoadCurrentNext() |
635 self.RefreshCurrentIndexList() |
623 self.RefreshCurrentIndexList() |
636 self.RefreshBufferState() |
624 self.RefreshBufferState() |
637 event.Skip() |
625 |
638 |
|
639 |
626 |
640 #------------------------------------------------------------------------------- |
627 #------------------------------------------------------------------------------- |
641 # Load and Save Funtions |
628 # Load and Save Funtions |
642 #------------------------------------------------------------------------------- |
629 #------------------------------------------------------------------------------- |
643 |
630 |
664 else: |
651 else: |
665 message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR) |
652 message = wx.MessageDialog(self, result, _("ERROR"), wx.OK|wx.ICON_ERROR) |
666 message.ShowModal() |
653 message.ShowModal() |
667 message.Destroy() |
654 message.Destroy() |
668 dialog.Destroy() |
655 dialog.Destroy() |
669 event.Skip() |
656 |
670 |
|
671 def OnOpenMenu(self, event): |
657 def OnOpenMenu(self, event): |
672 filepath = self.Manager.GetCurrentFilePath() |
658 filepath = self.Manager.GetCurrentFilePath() |
673 if filepath != "": |
659 if filepath != "": |
674 directory = os.path.dirname(filepath) |
660 directory = os.path.dirname(filepath) |
675 else: |
661 else: |
695 else: |
681 else: |
696 message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
682 message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
697 message.ShowModal() |
683 message.ShowModal() |
698 message.Destroy() |
684 message.Destroy() |
699 dialog.Destroy() |
685 dialog.Destroy() |
700 event.Skip() |
686 |
701 |
|
702 def OnSaveMenu(self, event): |
687 def OnSaveMenu(self, event): |
703 if not self.ModeSolo and getattr(self, "_onsave", None) != None: |
688 if not self.ModeSolo and getattr(self, "_onsave", None) != None: |
704 self._onsave() |
689 self._onsave() |
705 self.RefreshBufferState() |
690 self.RefreshBufferState() |
706 else: |
691 else: |
707 self.Save() |
692 self.Save() |
708 event.Skip() |
693 |
709 |
|
710 def OnSaveAsMenu(self, event): |
694 def OnSaveAsMenu(self, event): |
711 self.SaveAs() |
695 self.SaveAs() |
712 event.Skip() |
|
713 |
696 |
714 def Save(self): |
697 def Save(self): |
715 result = self.Manager.SaveCurrentInFile() |
698 result = self.Manager.SaveCurrentInFile() |
716 if not result: |
699 if not result: |
717 self.SaveAs() |
700 self.SaveAs() |
763 self.FileOpened.DeletePage(current) |
746 self.FileOpened.DeletePage(current) |
764 if self.FileOpened.GetPageCount() > 0: |
747 if self.FileOpened.GetPageCount() > 0: |
765 self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1)) |
748 self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1)) |
766 self.RefreshBufferState() |
749 self.RefreshBufferState() |
767 self.RefreshMainMenu() |
750 self.RefreshMainMenu() |
768 event.Skip() |
|
769 |
751 |
770 |
752 |
771 #------------------------------------------------------------------------------- |
753 #------------------------------------------------------------------------------- |
772 # Import and Export Functions |
754 # Import and Export Functions |
773 #------------------------------------------------------------------------------- |
755 #------------------------------------------------------------------------------- |
797 else: |
779 else: |
798 message = wx.MessageDialog(self, _("\"%s\" is not a valid file!")%filepath, _("Error"), wx.OK|wx.ICON_ERROR) |
780 message = wx.MessageDialog(self, _("\"%s\" is not a valid file!")%filepath, _("Error"), wx.OK|wx.ICON_ERROR) |
799 message.ShowModal() |
781 message.ShowModal() |
800 message.Destroy() |
782 message.Destroy() |
801 dialog.Destroy() |
783 dialog.Destroy() |
802 event.Skip() |
|
803 |
784 |
804 def OnExportEDSMenu(self, event): |
785 def OnExportEDSMenu(self, event): |
805 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) |
786 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) |
806 if dialog.ShowModal() == wx.ID_OK: |
787 if dialog.ShowModal() == wx.ID_OK: |
807 filepath = dialog.GetPath() |
788 filepath = dialog.GetPath() |
821 else: |
802 else: |
822 message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR) |
803 message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR) |
823 message.ShowModal() |
804 message.ShowModal() |
824 message.Destroy() |
805 message.Destroy() |
825 dialog.Destroy() |
806 dialog.Destroy() |
826 event.Skip() |
|
827 |
807 |
828 def OnExportCMenu(self, event): |
808 def OnExportCMenu(self, event): |
829 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) |
809 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) |
830 if dialog.ShowModal() == wx.ID_OK: |
810 if dialog.ShowModal() == wx.ID_OK: |
831 filepath = dialog.GetPath() |
811 filepath = dialog.GetPath() |
845 else: |
825 else: |
846 message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR) |
826 message = wx.MessageDialog(self, _("\"%s\" is not a valid folder!")%os.path.dirname(filepath), _("Error"), wx.OK|wx.ICON_ERROR) |
847 message.ShowModal() |
827 message.ShowModal() |
848 message.Destroy() |
828 message.Destroy() |
849 dialog.Destroy() |
829 dialog.Destroy() |
850 event.Skip() |
|
851 |
830 |
852 #------------------------------------------------------------------------------- |
831 #------------------------------------------------------------------------------- |
853 # Editing Profiles functions |
832 # Editing Profiles functions |
854 #------------------------------------------------------------------------------- |
833 #------------------------------------------------------------------------------- |
855 |
834 |
856 def OnCommunicationMenu(self, event): |
835 def OnCommunicationMenu(self, event): |
857 dictionary,current = self.Manager.GetCurrentCommunicationLists() |
836 dictionary,current = self.Manager.GetCurrentCommunicationLists() |
858 self.EditProfile(_("Edit DS-301 Profile"), dictionary, current) |
837 self.EditProfile(_("Edit DS-301 Profile"), dictionary, current) |
859 event.Skip() |
|
860 |
838 |
861 def OnOtherCommunicationMenu(self, event): |
839 def OnOtherCommunicationMenu(self, event): |
862 dictionary,current = self.Manager.GetCurrentDS302Lists() |
840 dictionary,current = self.Manager.GetCurrentDS302Lists() |
863 self.EditProfile(_("Edit DS-302 Profile"), dictionary, current) |
841 self.EditProfile(_("Edit DS-302 Profile"), dictionary, current) |
864 event.Skip() |
|
865 |
842 |
866 def OnEditProfileMenu(self, event): |
843 def OnEditProfileMenu(self, event): |
867 title = _("Edit %s Profile")%self.Manager.GetCurrentProfileName() |
844 title = _("Edit %s Profile")%self.Manager.GetCurrentProfileName() |
868 dictionary,current = self.Manager.GetCurrentProfileLists() |
845 dictionary,current = self.Manager.GetCurrentProfileLists() |
869 self.EditProfile(title, dictionary, current) |
846 self.EditProfile(title, dictionary, current) |
870 event.Skip() |
|
871 |
847 |
872 def EditProfile(self, title, dictionary, current): |
848 def EditProfile(self, title, dictionary, current): |
873 dialog = CommunicationDialog(self) |
849 dialog = CommunicationDialog(self) |
874 dialog.SetTitle(title) |
850 dialog.SetTitle(title) |
875 dialog.SetIndexDictionary(dictionary) |
851 dialog.SetIndexDictionary(dictionary) |
894 def GetProfileCallBack(self, text): |
870 def GetProfileCallBack(self, text): |
895 def ProfileCallBack(event): |
871 def ProfileCallBack(event): |
896 self.Manager.AddSpecificEntryToCurrent(text) |
872 self.Manager.AddSpecificEntryToCurrent(text) |
897 self.RefreshBufferState() |
873 self.RefreshBufferState() |
898 self.RefreshCurrentIndexList() |
874 self.RefreshCurrentIndexList() |
899 event.Skip() |
|
900 return ProfileCallBack |
875 return ProfileCallBack |
901 |
876 |
902 #------------------------------------------------------------------------------- |
877 #------------------------------------------------------------------------------- |
903 # Edit Node informations function |
878 # Edit Node informations function |
904 #------------------------------------------------------------------------------- |
879 #------------------------------------------------------------------------------- |
916 self.RefreshProfileMenu() |
891 self.RefreshProfileMenu() |
917 selected = self.FileOpened.GetSelection() |
892 selected = self.FileOpened.GetSelection() |
918 if selected >= 0: |
893 if selected >= 0: |
919 window = self.FileOpened.GetPage(selected) |
894 window = self.FileOpened.GetPage(selected) |
920 window.RefreshTable() |
895 window.RefreshTable() |
921 event.Skip() |
|
922 |
896 |
923 |
897 |
924 #------------------------------------------------------------------------------- |
898 #------------------------------------------------------------------------------- |
925 # Add User Types and Variables |
899 # Add User Types and Variables |
926 #------------------------------------------------------------------------------- |
900 #------------------------------------------------------------------------------- |