107 |
107 |
108 def _init_ctrls(self, prnt): |
108 def _init_ctrls(self, prnt): |
109 wx.Dialog.__init__(self, id=ID_COMMUNICATIONDIALOG, |
109 wx.Dialog.__init__(self, id=ID_COMMUNICATIONDIALOG, |
110 name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216), |
110 name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216), |
111 size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
111 size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
112 title='Edit Communication Profile') |
112 title=_('Edit Communication Profile')) |
113 self.SetClientSize(wx.Size(726, 437)) |
113 self.SetClientSize(wx.Size(726, 437)) |
114 |
114 |
115 self.staticText1 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT1, |
115 self.staticText1 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT1, |
116 label='Possible Profile Indexes:', name='staticText1', |
116 label=_('Possible Profile Indexes:'), name='staticText1', |
117 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, |
117 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, |
118 17), style=0) |
118 17), style=0) |
119 |
119 |
120 self.PossibleIndexes = wx.ListBox(choices=[], |
120 self.PossibleIndexes = wx.ListBox(choices=[], |
121 id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
121 id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
270 |
270 |
271 def _init_ctrls(self, prnt): |
271 def _init_ctrls(self, prnt): |
272 wx.Dialog.__init__(self, id=ID_MAPVARIABLEDIALOG, |
272 wx.Dialog.__init__(self, id=ID_MAPVARIABLEDIALOG, |
273 name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223), |
273 name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223), |
274 size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE, |
274 size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE, |
275 title='Add Map Variable') |
275 title=_('Add Map Variable')) |
276 self.SetClientSize(wx.Size(444, 186)) |
276 self.SetClientSize(wx.Size(444, 186)) |
277 |
277 |
278 self.staticText1 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT1, |
278 self.staticText1 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT1, |
279 label='Index:', name='staticText1', parent=self, |
279 label=_('Index:'), name='staticText1', parent=self, |
280 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
280 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
281 |
281 |
282 self.staticText2 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT2, |
282 self.staticText2 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT2, |
283 label='Type:', name='staticText2', parent=self, |
283 label=_('Type:'), name='staticText2', parent=self, |
284 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
284 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
285 |
285 |
286 self.staticText3 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT3, |
286 self.staticText3 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT3, |
287 label='Name:', name='staticText3', parent=self, |
287 label=_('Name:'), name='staticText3', parent=self, |
288 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
288 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
289 |
289 |
290 self.staticText4 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT4, |
290 self.staticText4 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT4, |
291 label='Number:', name='staticText4', parent=self, |
291 label=_('Number:'), name='staticText4', parent=self, |
292 pos=wx.Point(0, 0), size=wx.Size(0, 16), style=0) |
292 pos=wx.Point(0, 0), size=wx.Size(0, 16), style=0) |
293 |
293 |
294 self.radioButton1 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON1, |
294 self.radioButton1 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON1, |
295 label='VAR', name='radioButton1', parent=self, |
295 label='VAR', name='radioButton1', parent=self, |
296 pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_GROUP) |
296 pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_GROUP) |
474 self.SetSizer(self.flexGridSizer1) |
470 self.SetSizer(self.flexGridSizer1) |
475 |
471 |
476 def _init_ctrls(self, prnt): |
472 def _init_ctrls(self, prnt): |
477 wx.Dialog.__init__(self, id=ID_USERTYPEDIALOG, name='UserTypeDialog', |
473 wx.Dialog.__init__(self, id=ID_USERTYPEDIALOG, name='UserTypeDialog', |
478 parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210), |
474 parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210), |
479 style=wx.DEFAULT_DIALOG_STYLE, title='Add User Type') |
475 style=wx.DEFAULT_DIALOG_STYLE, title=_('Add User Type')) |
480 self.SetClientSize(wx.Size(444, 210)) |
476 self.SetClientSize(wx.Size(444, 210)) |
481 |
477 |
482 self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1, |
478 self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1, |
483 label='Type:', name='staticText1', parent=self, |
479 label=_('Type:'), name='staticText1', parent=self, |
484 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
480 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
485 |
481 |
486 self.Type = wx.Choice(choices=[], id=ID_USERTYPEDIALOGTYPE, |
482 self.Type = wx.Choice(choices=[], id=ID_USERTYPEDIALOGTYPE, |
487 name='Type', parent=self, pos=wx.Point(0, 0), |
483 name='Type', parent=self, pos=wx.Point(0, 0), |
488 size=wx.Size(0, 24), style=0) |
484 size=wx.Size(0, 24), style=0) |
492 self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
488 self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
493 name='Spacer', parent=self, pos=wx.Point(0, 0), |
489 name='Spacer', parent=self, pos=wx.Point(0, 0), |
494 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
490 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
495 |
491 |
496 self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1, |
492 self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1, |
497 label='Values', name='staticBox1', parent=self, |
493 label=_('Values'), name='staticBox1', parent=self, |
498 pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
494 pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
499 |
495 |
500 self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2, |
496 self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2, |
501 label='Minimum:', name='staticText2', parent=self, |
497 label=_('Minimum:'), name='staticText2', parent=self, |
502 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
498 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
503 |
499 |
504 self.Min = wx.TextCtrl(id=ID_USERTYPEDIALOGMIN, name='Min', |
500 self.Min = wx.TextCtrl(id=ID_USERTYPEDIALOGMIN, name='Min', |
505 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
501 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
506 style=wx.TE_RIGHT, value='0') |
502 style=wx.TE_RIGHT, value='0') |
507 |
503 |
508 self.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3, |
504 self.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3, |
509 label='Maximum:', name='staticText3', parent=self, |
505 label=_('Maximum:'), name='staticText3', parent=self, |
510 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
506 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
511 |
507 |
512 self.Max = wx.TextCtrl(id=ID_USERTYPEDIALOGMAX, name='Max', |
508 self.Max = wx.TextCtrl(id=ID_USERTYPEDIALOGMAX, name='Max', |
513 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
509 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
514 style=wx.TE_RIGHT, value='0') |
510 style=wx.TE_RIGHT, value='0') |
515 |
511 |
516 self.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4, |
512 self.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4, |
517 label='Length:', name='staticText4', parent=self, |
513 label=_('Length:'), name='staticText4', parent=self, |
518 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
514 pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
519 |
515 |
520 self.Length = wx.TextCtrl(id=ID_USERTYPEDIALOGLENGTH, name='Length', |
516 self.Length = wx.TextCtrl(id=ID_USERTYPEDIALOGLENGTH, name='Length', |
521 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
517 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
522 style=wx.TE_RIGHT, value='0') |
518 style=wx.TE_RIGHT, value='0') |
532 self.TypeDictionary = {} |
528 self.TypeDictionary = {} |
533 |
529 |
534 def OnOK(self, event): |
530 def OnOK(self, event): |
535 error = [] |
531 error = [] |
536 good = True |
532 good = True |
537 firstmessage = "" |
533 message = None |
538 secondmessage = "" |
|
539 name = self.Type.GetStringSelection() |
534 name = self.Type.GetStringSelection() |
540 if name != "": |
535 if name != "": |
541 valuetype = self.TypeDictionary[name][1] |
536 valuetype = self.TypeDictionary[name][1] |
542 if valuetype == 0: |
537 if valuetype == 0: |
543 try: |
538 try: |
544 int(self.Min.GetValue(), 16) |
539 int(self.Min.GetValue(), 16) |
545 except: |
540 except: |
546 error.append("Minimum") |
541 error.append(_("Minimum")) |
547 good = False |
542 good = False |
548 try: |
543 try: |
549 int(self.Max.GetValue(), 16) |
544 int(self.Max.GetValue(), 16) |
550 except: |
545 except: |
551 error.append("Maximum") |
546 error.append(_("Maximum")) |
552 good = False |
547 good = False |
553 elif valuetype == 1: |
548 elif valuetype == 1: |
554 try: |
549 try: |
555 int(self.Length.GetValue(), 16) |
550 int(self.Length.GetValue(), 16) |
556 except: |
551 except: |
557 error.append("Length") |
552 error.append(_("Length")) |
558 good = False |
553 good = False |
559 if len(error) > 0: |
554 if len(error) > 0: |
560 secondmessage = ". " |
555 message = "" |
561 for i, item in enumerate(error): |
556 for i, item in enumerate(error): |
562 if i == 0: |
557 if i == 0: |
563 secondmessage += item |
558 message += item |
564 elif i == len(error) - 1: |
559 elif i == len(error) - 1: |
565 secondmessage += " and %s"%item |
560 message += _(" and %s")%item + _(" must be integers!") |
566 else: |
561 else: |
567 secondmessage += ", %s"%item |
562 message += _(", %s")%item + _(" must be integer!") |
568 secondmessage += " must be integer" |
|
569 if len(error) > 1: |
|
570 secondmessage += "s" |
|
571 else: |
563 else: |
572 firstmessage = ". A type must be selected" |
564 message = _("A type must be selected!") |
573 good = False |
565 if message is not None: |
574 if not good: |
566 message = wx.MessageDialog(self, _("Form isn't valid. %s")%(firstmessage,secondmessage), _("Error"), wx.OK|wx.ICON_ERROR) |
575 message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR) |
|
576 message.ShowModal() |
567 message.ShowModal() |
577 message.Destroy() |
568 message.Destroy() |
578 else: |
569 else: |
579 self.EndModal(wx.ID_OK) |
570 self.EndModal(wx.ID_OK) |
580 |
571 |
689 |
685 |
690 def _init_ctrls(self, prnt): |
686 def _init_ctrls(self, prnt): |
691 wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG, |
687 wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG, |
692 name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223), |
688 name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223), |
693 size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE, |
689 size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE, |
694 title='Node Infos') |
690 title=_('Node infos')) |
695 self.SetClientSize(wx.Size(300, 280)) |
691 self.SetClientSize(wx.Size(300, 280)) |
696 |
692 |
697 self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
693 self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
698 label='Name:', name='staticText1', parent=self, |
694 label=_('Name:'), name='staticText1', parent=self, |
699 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
695 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
700 |
696 |
701 self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName', |
697 self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName', |
702 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
698 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
703 style=0, value='') |
699 style=0, value='') |
704 |
700 |
705 self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
701 self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
706 label='Node ID:', name='staticText2', parent=self, |
702 label=_('Node ID:'), name='staticText2', parent=self, |
707 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
703 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
708 |
704 |
709 self.NodeID = wx.TextCtrl(id=ID_NODEINFOSDIALOGNODEID, name='NodeID', |
705 self.NodeID = wx.TextCtrl(id=ID_NODEINFOSDIALOGNODEID, name='NodeID', |
710 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), |
706 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), |
711 style=wx.TE_RIGHT, value='') |
707 style=wx.TE_RIGHT, value='') |
712 |
708 |
713 self.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3, |
709 self.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3, |
714 label='Type:', name='staticText3', parent=self, |
710 label=_('Type:'), name='staticText3', parent=self, |
715 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
711 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
716 |
712 |
717 self.Type = wx.Choice(choices=[], id=ID_NODEINFOSDIALOGTYPE, |
713 self.Type = wx.Choice(choices=[], id=ID_NODEINFOSDIALOGTYPE, |
718 name='Type', parent=self, pos=wx.Point(0, 0), |
714 name='Type', parent=self, pos=wx.Point(0, 0), |
719 size=wx.Size(0, 25), style=0) |
715 size=wx.Size(0, 25), style=0) |
720 |
716 |
721 self.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4, |
717 self.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4, |
722 label='Default String Size:', name='staticText4', parent=self, |
718 label=_('Default String Size:'), name='staticText4', parent=self, |
723 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
719 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
724 |
720 |
725 self.DefaultStringSize = wx.SpinCtrl(id=ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, |
721 self.DefaultStringSize = wx.SpinCtrl(id=ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, |
726 name='DefaultStringSize', parent=self, pos=wx.Point(0, 0), |
722 name='DefaultStringSize', parent=self, pos=wx.Point(0, 0), |
727 size=wx.Size(0, 25), style=wx.TE_RIGHT) |
723 size=wx.Size(0, 25), style=wx.TE_RIGHT) |
728 |
724 |
729 self.staticText5 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT5, |
725 self.staticText5 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT5, |
730 label='Description:', name='staticText5', parent=self, |
726 label=_('Description:'), name='staticText5', parent=self, |
731 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
727 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
732 |
728 |
733 self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, |
729 self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, |
734 name='Description', parent=self, pos=wx.Point(0, 0), |
730 name='Description', parent=self, pos=wx.Point(0, 0), |
735 size=wx.Size(0, 24), style=0, value='') |
731 size=wx.Size(0, 24), style=0, value='') |
743 self._init_ctrls(parent) |
739 self._init_ctrls(parent) |
744 |
740 |
745 self.staticText2.Hide() |
741 self.staticText2.Hide() |
746 self.NodeID.Hide() |
742 self.NodeID.Hide() |
747 |
743 |
748 self.Type.Append("master") |
744 for node_type in GetNodeTypes(): |
749 self.Type.Append("slave") |
745 self.Type.Append(_(node_type)) |
750 |
746 |
751 def OnOK(self, event): |
747 def OnOK(self, event): |
752 name = self.NodeName.GetValue() |
748 name = self.NodeName.GetValue() |
753 message = "" |
749 message = "" |
754 if name != "": |
750 if name != "": |
755 good = not name[0].isdigit() |
751 good = not name[0].isdigit() |
756 for item in name.split("_"): |
752 for item in name.split("_"): |
757 good &= item.isalnum() |
753 good &= item.isalnum() |
758 if not good: |
754 if not good: |
759 message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
755 message = _("Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!") |
760 if message != "": |
756 if message != "": |
761 try: |
757 try: |
762 nodeid = int(self.NodeID.GetValue(), 16) |
758 nodeid = int(self.NodeID.GetValue(), 16) |
763 except: |
759 except: |
764 message = "Node ID must be integer!" |
760 message = _("Node ID must be integer!") |
765 if message != "": |
761 if message != "": |
766 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
762 message = wx.MessageDialog(self, message, _("ERROR"), wx.OK|wx.ICON_ERROR) |
767 message.ShowModal() |
763 message.ShowModal() |
768 message.Destroy() |
764 message.Destroy() |
769 self.NodeName.SetFocus() |
765 self.NodeName.SetFocus() |
770 else: |
766 else: |
771 self.EndModal(wx.ID_OK) |
767 self.EndModal(wx.ID_OK) |
772 |
768 |
773 def SetValues(self, name, id, type, description, defaultstringsize): |
769 def SetValues(self, name, id, type, description, defaultstringsize): |
774 self.NodeName.SetValue(name) |
770 self.NodeName.SetValue(name) |
775 self.NodeID.SetValue("0x%02X"%id) |
771 self.NodeID.SetValue("0x%02X"%id) |
776 self.Type.SetStringSelection(type) |
772 self.Type.SetStringSelection(_(type)) |
777 self.Description.SetValue(description) |
773 self.Description.SetValue(description) |
778 self.DefaultStringSize.SetValue(defaultstringsize) |
774 self.DefaultStringSize.SetValue(defaultstringsize) |
779 |
775 |
780 def GetValues(self): |
776 def GetValues(self): |
781 name = self.NodeName.GetValue() |
777 name = self.NodeName.GetValue() |
782 nodeid = int(self.NodeID.GetValue(), 16) |
778 nodeid = int(self.NodeID.GetValue(), 16) |
783 type = self.Type.GetStringSelection() |
779 type = NODE_TYPES_DICT[self.Type.GetStringSelection()] |
784 description = self.Description.GetValue() |
780 description = self.Description.GetValue() |
785 defaultstringsize = self.DefaultStringSize.GetValue() |
781 defaultstringsize = self.DefaultStringSize.GetValue() |
786 return name, nodeid, type, description, defaultstringsize |
782 return name, nodeid, type, description, defaultstringsize |
787 |
783 |
788 |
784 |
892 |
888 |
893 def _init_ctrls(self, prnt, buttons): |
889 def _init_ctrls(self, prnt, buttons): |
894 wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
890 wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
895 name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223), |
891 name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223), |
896 size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
892 size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
897 title='Create a new Node') |
893 title=_('Create a new Node')) |
898 self.SetClientSize(wx.Size(450, 350)) |
894 self.SetClientSize(wx.Size(450, 350)) |
899 |
895 |
900 self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
896 self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
901 label='Type:', name='staticText1', parent=self, |
897 label=_('Type:'), name='staticText1', parent=self, |
902 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
898 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
903 |
899 |
904 self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
900 self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
905 label='Name:', name='staticText2', parent=self, |
901 label=_('Name:'), name='staticText2', parent=self, |
906 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
902 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
907 |
903 |
908 self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
904 self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
909 label='Node ID:', name='staticText3', parent=self, |
905 label=_('Node ID:'), name='staticText3', parent=self, |
910 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
906 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
911 |
907 |
912 self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
908 self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
913 label='Profile:', name='staticText4', parent=self, |
909 label=_('Profile:'), name='staticText4', parent=self, |
914 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
910 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
915 |
911 |
916 self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
912 self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
917 name='Type', parent=self, pos=wx.Point(0, 0), |
913 name='Type', parent=self, pos=wx.Point(0, 0), |
918 size=wx.Size(0, 25), style=0) |
914 size=wx.Size(0, 25), style=0) |
930 size=wx.Size(0, 24), style=0) |
926 size=wx.Size(0, 24), style=0) |
931 self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice, |
927 self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice, |
932 id=ID_CREATENODEDIALOGPROFILE) |
928 id=ID_CREATENODEDIALOGPROFILE) |
933 |
929 |
934 self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
930 self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
935 label='Network Management:', name='staticText5', |
931 label=_('Network Management:'), name='staticText5', |
936 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
932 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
937 |
933 |
938 self.NMT_None = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NONE, |
934 self.NMT_None = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NONE, |
939 label='None', name='NMT_None', parent=self, |
935 label=_('None'), name='NMT_None', parent=self, |
940 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) |
936 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) |
941 self.NMT_None.SetValue(True) |
937 self.NMT_None.SetValue(True) |
942 |
938 |
943 self.NMT_NodeGuarding = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NODEGUARDING, |
939 self.NMT_NodeGuarding = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NODEGUARDING, |
944 label='Node Guarding', name='NMT_NodeGuarding', parent=self, |
940 label=_('Node Guarding'), name='NMT_NodeGuarding', parent=self, |
945 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
941 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
946 self.NMT_NodeGuarding.SetValue(False) |
942 self.NMT_NodeGuarding.SetValue(False) |
947 |
943 |
948 self.NMT_Heartbeat = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_HEARTBEAT, |
944 self.NMT_Heartbeat = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_HEARTBEAT, |
949 label='Heartbeat', name='NMT_Heartbeat', parent=self, |
945 label=_('Heartbeat'), name='NMT_Heartbeat', parent=self, |
950 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
946 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
951 self.NMT_Heartbeat.SetValue(False) |
947 self.NMT_Heartbeat.SetValue(False) |
952 |
948 |
953 self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
949 self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
954 label='Options:', name='staticText6', parent=self, |
950 label=_('Options:'), name='staticText6', parent=self, |
955 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
951 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
956 |
952 |
957 self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
953 self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
958 label='DS-302 Profile', name='DS302', parent=self, |
954 label=_('DS-302 Profile'), name='DS302', parent=self, |
959 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
955 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
960 self.DS302.SetValue(False) |
956 self.DS302.SetValue(False) |
961 #self.DS302.Enable(False) |
957 #self.DS302.Enable(False) |
962 |
958 |
963 self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
959 self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
964 label='Generate SYNC', name='GenSYNC', parent=self, |
960 label=_('Generate SYNC'), name='GenSYNC', parent=self, |
965 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
961 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
966 self.GenSYNC.SetValue(False) |
962 self.GenSYNC.SetValue(False) |
967 |
963 |
968 self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
964 self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
969 label='Emergency support', name='Emergency', |
965 label=_('Emergency support'), name='Emergency', |
970 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
966 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
971 self.Emergency.SetValue(False) |
967 self.Emergency.SetValue(False) |
972 |
968 |
973 self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
969 self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
974 label='Save Configuration', name='SaveConfig', parent=self, |
970 label=_('Save Configuration'), name='SaveConfig', parent=self, |
975 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
971 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
976 self.SaveConfig.SetValue(False) |
972 self.SaveConfig.SetValue(False) |
977 self.SaveConfig.Enable(False) |
973 self.SaveConfig.Enable(False) |
978 |
974 |
979 self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
975 self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
980 label='Store EDS', name='StoreEDS', parent=self, |
976 label=_('Store EDS'), name='StoreEDS', parent=self, |
981 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
977 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
982 self.StoreEDS.SetValue(False) |
978 self.StoreEDS.SetValue(False) |
983 self.StoreEDS.Hide() |
979 self.StoreEDS.Hide() |
984 |
980 |
985 self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
981 self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
986 label='Description:', name='staticText7', parent=self, |
982 label=_('Description:'), name='staticText7', parent=self, |
987 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
983 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
988 |
984 |
989 self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
985 self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
990 name='Description', parent=self, pos=wx.Point(0, 0), |
986 name='Description', parent=self, pos=wx.Point(0, 0), |
991 size=wx.Size(0, 24), style=0, value='') |
987 size=wx.Size(0, 24), style=0, value='') |
1004 |
1000 |
1005 self.staticText3.Hide() |
1001 self.staticText3.Hide() |
1006 self.NodeID.Hide() |
1002 self.NodeID.Hide() |
1007 |
1003 |
1008 self.NodeID.SetValue("0x00") |
1004 self.NodeID.SetValue("0x00") |
1009 self.Type.Append("master") |
1005 for node_type in GetNodeTypes(): |
1010 self.Type.Append("slave") |
1006 self.Type.Append(_(node_type)) |
1011 self.Type.SetStringSelection("slave") |
1007 self.Type.SetStringSelection(_("slave")) |
1012 self.Description.SetValue("") |
1008 self.Description.SetValue("") |
1013 self.ListProfile = {"None" : ""} |
1009 self.ListProfile = {"None" : ""} |
1014 self.Profile.Append("None") |
1010 self.Profile.Append(_("None")) |
1015 self.Directory = os.path.join(ScriptDirectory, "config") |
1011 self.Directory = os.path.join(ScriptDirectory, "config") |
1016 listfiles = os.listdir(self.Directory) |
1012 listfiles = os.listdir(self.Directory) |
1017 listfiles.sort() |
1013 listfiles.sort() |
1018 for item in listfiles: |
1014 for item in listfiles: |
1019 name, extend = os.path.splitext(item) |
1015 name, extend = os.path.splitext(item) |
1020 if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
1016 if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
1021 self.ListProfile[name] = os.path.join(self.Directory, item) |
1017 self.ListProfile[name] = os.path.join(self.Directory, item) |
1022 self.Profile.Append(name) |
1018 self.Profile.Append(name) |
1023 self.Profile.Append("Other") |
1019 self.Profile.Append(_("Other")) |
1024 self.Profile.SetStringSelection("None") |
1020 self.Profile.SetStringSelection(_("None")) |
1025 self.NodeName.SetFocus() |
1021 self.NodeName.SetFocus() |
1026 |
1022 |
1027 def OnOK(self, event): |
1023 def OnOK(self, event): |
1028 name = self.NodeName.GetValue() |
1024 name = self.NodeName.GetValue() |
1029 message = "" |
1025 message = "" |
1030 if name != "": |
1026 if name != "": |
1031 good = not name[0].isdigit() |
1027 good = not name[0].isdigit() |
1032 for item in name.split("_"): |
1028 for item in name.split("_"): |
1033 good &= item.isalnum() |
1029 good &= item.isalnum() |
1034 if not good: |
1030 if not good: |
1035 message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
1031 message = _("Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!") |
1036 if message != "": |
1032 if message != "": |
1037 try: |
1033 try: |
1038 nodeid = int(self.NodeID.GetValue(), 16) |
1034 nodeid = int(self.NodeID.GetValue(), 16) |
1039 except: |
1035 except: |
1040 message = "Node ID must be an integer!" |
1036 message = _("Node ID must be integer!") |
1041 if message != "": |
1037 if message != "": |
1042 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
1038 message = wx.MessageDialog(self, message, _("ERROR"), wx.OK|wx.ICON_ERROR) |
1043 message.ShowModal() |
1039 message.ShowModal() |
1044 message.Destroy() |
1040 message.Destroy() |
1045 self.NodeName.SetFocus() |
1041 self.NodeName.SetFocus() |
1046 else: |
1042 else: |
1047 self.EndModal(wx.ID_OK) |
1043 self.EndModal(wx.ID_OK) |
1149 |
1147 |
1150 def _init_ctrls(self, prnt): |
1148 def _init_ctrls(self, prnt): |
1151 wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
1149 wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
1152 name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223), |
1150 name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223), |
1153 size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
1151 size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
1154 title='Add a slave to nodelist') |
1152 title=_('Add a slave to nodelist')) |
1155 self.SetClientSize(wx.Size(300, 250)) |
1153 self.SetClientSize(wx.Size(300, 250)) |
1156 |
1154 |
1157 self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
1155 self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
1158 label='Slave Name:', name='staticText1', parent=self, |
1156 label=_('Slave Name:'), name='staticText1', parent=self, |
1159 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1157 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1160 |
1158 |
1161 self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
1159 self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
1162 name='SlaveName', parent=self, pos=wx.Point(0, 0), |
1160 name='SlaveName', parent=self, pos=wx.Point(0, 0), |
1163 size=wx.Size(0, 24), style=0) |
1161 size=wx.Size(0, 24), style=0) |
1164 |
1162 |
1165 self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
1163 self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
1166 label='Slave Node ID:', name='staticText2', parent=self, |
1164 label=_('Slave Node ID:'), name='staticText2', parent=self, |
1167 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1165 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1168 |
1166 |
1169 self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
1167 self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
1170 name='SlaveName', parent=self, pos=wx.Point(0, 0), |
1168 name='SlaveName', parent=self, pos=wx.Point(0, 0), |
1171 size=wx.Size(0, 24), style=wx.ALIGN_RIGHT) |
1169 size=wx.Size(0, 24), style=wx.ALIGN_RIGHT) |
1172 |
1170 |
1173 self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
1171 self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
1174 label='EDS File:', name='staticText3', parent=self, |
1172 label=_('EDS File:'), name='staticText3', parent=self, |
1175 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1173 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
1176 |
1174 |
1177 self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE, |
1175 self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE, |
1178 name='EDSFile', parent=self, pos=wx.Point(0, 0), |
1176 name='EDSFile', parent=self, pos=wx.Point(0, 0), |
1179 size=wx.Size(0, 24), style=0) |
1177 size=wx.Size(0, 24), style=0) |
1180 |
1178 |
1181 self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label='Import EDS', |
1179 self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label=_('Import EDS'), |
1182 name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
1180 name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
1183 size=wx.Size(100, 32), style=0) |
1181 size=wx.Size(100, 32), style=0) |
1184 self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton, |
1182 self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton, |
1185 id=ID_ADDSLAVEDIALOGIMPORTEDS) |
1183 id=ID_ADDSLAVEDIALOGIMPORTEDS) |
1186 |
1184 |
1195 self.SlaveNodeID.SetValue("0x00") |
1193 self.SlaveNodeID.SetValue("0x00") |
1196 |
1194 |
1197 def OnOK(self, event): |
1195 def OnOK(self, event): |
1198 error = [] |
1196 error = [] |
1199 if self.SlaveName.GetValue() == "": |
1197 if self.SlaveName.GetValue() == "": |
1200 error.append("Slave Name") |
1198 error.append(_("Slave Name")) |
1201 if self.SlaveNodeID.GetValue() == "": |
1199 if self.SlaveNodeID.GetValue() == "": |
1202 error.append("Slave Node ID") |
1200 error.append(_("Slave Node ID")) |
1203 if self.EDSFile.GetStringSelection() == "": |
1201 if self.EDSFile.GetStringSelection() == "": |
1204 error.append("EDS File") |
1202 error.append(_("EDS File")) |
1205 if len(error) > 0: |
1203 if len(error) > 0: |
1206 text = "" |
1204 text = "" |
1207 for i, item in enumerate(error): |
1205 for i, item in enumerate(error): |
1208 if i == 0: |
1206 if i == 0: |
1209 text += item |
1207 text += item |
1210 elif i == len(error) - 1: |
1208 elif i == len(error) - 1: |
1211 text += " and %s"%item |
1209 text += _(" and %s")%item |
1212 else: |
1210 else: |
1213 text += ", %s"%item |
1211 text += _(", %s")%item |
1214 message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
1212 message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
1215 message.ShowModal() |
1213 message.ShowModal() |
1216 message.Destroy() |
1214 message.Destroy() |
1217 else: |
1215 else: |
1218 try: |
1216 try: |
1219 nodeid = self.SlaveNodeID.GetValue() |
1217 nodeid = self.SlaveNodeID.GetValue() |
1220 if nodeid.find("x") != -1: |
1218 if nodeid.find("x") != -1: |
1221 nodeid = int(nodeid, 16) |
1219 nodeid = int(nodeid, 16) |
1222 else: |
1220 else: |
1223 nodeid = int(nodeid) |
1221 nodeid = int(nodeid) |
1224 except: |
1222 except: |
1225 message = wx.MessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wx.OK|wx.ICON_ERROR) |
1223 message = wx.MessageDialog(self, _("Slave Node ID must be a value in decimal or hexadecimal!"), _("Error"), wx.OK|wx.ICON_ERROR) |
1226 message.ShowModal() |
1224 message.ShowModal() |
1227 message.Destroy() |
1225 message.Destroy() |
1228 return |
1226 return |
1229 if not 0 <= nodeid <= 127: |
1227 if not 0 <= nodeid <= 127: |
1230 message = wx.MessageDialog(self, "Slave Node ID must be between 0 and 127!", "Error", wx.OK|wx.ICON_ERROR) |
1228 message = wx.MessageDialog(self, _("Slave Node ID must be between 0 and 127!"), _("Error"), wx.OK|wx.ICON_ERROR) |
1231 message.ShowModal() |
1229 message.ShowModal() |
1232 message.Destroy() |
1230 message.Destroy() |
1233 elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys(): |
1231 elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys(): |
1234 message = wx.MessageDialog(self, "A Node with this ID already exist in the network!", "Error", wx.OK|wx.ICON_ERROR) |
1232 message = wx.MessageDialog(self, _("A Node with this ID already exist in the network!"), _("Error"), wx.OK|wx.ICON_ERROR) |
1235 message.ShowModal() |
1233 message.ShowModal() |
1236 message.Destroy() |
1234 message.Destroy() |
1237 else: |
1235 else: |
1238 self.EndModal(wx.ID_OK) |
1236 self.EndModal(wx.ID_OK) |
1239 |
1237 |
1240 def OnImportEDSButton(self, event): |
1238 def OnImportEDSButton(self, event): |
1241 dialog = wx.FileDialog(self, |
1239 dialog = wx.FileDialog(self, |
1242 "Choose an EDS file", |
1240 _("Choose an EDS file"), |
1243 os.getcwd(), |
1241 os.getcwd(), |
1244 "", |
1242 "", |
1245 "EDS files (*.eds)|*.eds|All files|*.*", |
1243 _("EDS files (*.eds)|*.eds|All files|*.*"), |
1246 wx.OPEN) |
1244 wx.OPEN) |
1247 if dialog.ShowModal() == wx.ID_OK: |
1245 if dialog.ShowModal() == wx.ID_OK: |
1248 filepath = dialog.GetPath() |
1246 filepath = dialog.GetPath() |
1249 if os.path.isfile(filepath): |
1247 if os.path.isfile(filepath): |
1250 result = self.NodeList.ImportEDSFile(filepath) |
1248 result = self.NodeList.ImportEDSFile(filepath) |
1251 if result: |
1249 if result: |
1252 message = wx.MessageDialog(self, "%s\nWould you like to replace it ?"%result, "Question", wx.YES_NO|wx.ICON_QUESTION) |
1250 message = wx.MessageDialog(self, _("%s\nWould you like to replace it ?")%result, _("Question"), wx.YES_NO|wx.ICON_QUESTION) |
1253 if message.ShowModal() == wx.ID_YES: |
1251 if message.ShowModal() == wx.ID_YES: |
1254 self.NodeList.ImportEDSFile(filepath, True) |
1252 self.NodeList.ImportEDSFile(filepath, True) |
1255 message.Destroy() |
1253 message.Destroy() |
1256 dialog.Destroy() |
1254 dialog.Destroy() |
1257 self.RefreshEDSFile() |
1255 self.RefreshEDSFile() |
1294 wx.grid.PyGridTableBase.__init__(self) |
1296 wx.grid.PyGridTableBase.__init__(self) |
1295 self.data = data |
1297 self.data = data |
1296 self.colnames = colnames |
1298 self.colnames = colnames |
1297 self.Parent = parent |
1299 self.Parent = parent |
1298 # XXX |
1300 # XXX |
1299 # we need to store the row length and collength to |
1301 # we need to store the row length and col length to |
1300 # see if the table has changed size |
1302 # see if the table has changed size |
1301 self._rows = self.GetNumberRows() |
1303 self._rows = self.GetNumberRows() |
1302 self._cols = self.GetNumberCols() |
1304 self._cols = self.GetNumberCols() |
1303 |
1305 |
1304 def GetNumberCols(self): |
1306 def GetNumberCols(self): |
1305 return len(self.colnames) |
1307 return len(self.colnames) |
1306 |
1308 |
1307 def GetNumberRows(self): |
1309 def GetNumberRows(self): |
1308 return len(self.data) |
1310 return len(self.data) |
1309 |
1311 |
1310 def GetColLabelValue(self, col): |
1312 def GetColLabelValue(self, col, translate=True): |
1311 if col < len(self.colnames): |
1313 if col < len(self.colnames): |
|
1314 if translate: |
|
1315 return _(self.colnames[col]) |
1312 return self.colnames[col] |
1316 return self.colnames[col] |
1313 |
1317 |
1314 def GetRowLabelValues(self, row): |
1318 def GetRowLabelValues(self, row, translate=True): |
1315 return row |
1319 return row |
1316 |
1320 |
1317 def GetValue(self, row, col): |
1321 def GetValue(self, row, col): |
1318 if row < self.GetNumberRows(): |
1322 if row < self.GetNumberRows(): |
1319 return str(self.data[row].get(self.GetColLabelValue(col), "")) |
1323 return str(self.data[row].get(self.GetColLabelValue(col, False), "")) |
1320 |
1324 |
1321 def GetEditor(self, row, col): |
1325 def GetEditor(self, row, col): |
1322 if row < self.GetNumberRows(): |
1326 if row < self.GetNumberRows(): |
1323 return self.editors[row].get(self.GetColLabelValue(col), "") |
1327 return self.editors[row].get(self.GetColLabelValue(col, False), "") |
1324 |
1328 |
1325 def GetValueByName(self, row, colname): |
1329 def GetValueByName(self, row, colname): |
1326 return self.data[row].get(colname) |
1330 return self.data[row].get(colname) |
1327 |
1331 |
1328 def SetValue(self, row, col, value): |
1332 def SetValue(self, row, col, value): |
1329 if col < len(self.colnames): |
1333 if col < len(self.colnames): |
1330 self.data[row][self.GetColLabelValue(col)] = value |
1334 self.data[row][self.GetColLabelValue(col, False)] = value |
1331 |
1335 |
1332 def ResetView(self, grid): |
1336 def ResetView(self, grid): |
1333 """ |
1337 """ |
1334 (wx.grid.Grid) -> Reset the grid view. Call this to |
1338 (wx.grid.Grid) -> Reset the grid view. Call this to |
1335 update the grid if rows and columns have been added or deleted |
1339 update the grid if rows and columns have been added or deleted |
1435 |
1439 |
1436 def _init_ctrls(self, prnt): |
1440 def _init_ctrls(self, prnt): |
1437 wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG, |
1441 wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG, |
1438 name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223), |
1442 name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223), |
1439 size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
1443 size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
1440 title='Edit DCF Entry Values') |
1444 title=_('Edit DCF Entry Values')) |
1441 self.SetClientSize(wx.Size(400, 300)) |
1445 self.SetClientSize(wx.Size(400, 300)) |
1442 |
1446 |
1443 self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
1447 self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
1444 label='Entry Values:', name='staticText1', parent=self, |
1448 label=_('Entry Values:'), name='staticText1', parent=self, |
1445 pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
1449 pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
1446 |
1450 |
1447 self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID, |
1451 self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID, |
1448 name='ValuesGrid', parent=self, pos=wx.Point(0, 0), |
1452 name='ValuesGrid', parent=self, pos=wx.Point(0, 0), |
1449 size=wx.Size(0, 150), style=wx.VSCROLL) |
1453 size=wx.Size(0, 150), style=wx.VSCROLL) |
1459 self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell) |
1463 self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell) |
1460 else: |
1464 else: |
1461 wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange) |
1465 wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange) |
1462 wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell) |
1466 wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell) |
1463 |
1467 |
1464 self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label='Add', |
1468 self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label=_('Add'), |
1465 name='AddButton', parent=self, pos=wx.Point(0, 0), |
1469 name='AddButton', parent=self, pos=wx.Point(0, 0), |
1466 size=wx.Size(72, 32), style=0) |
1470 size=wx.Size(72, 32), style=0) |
1467 self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON) |
1471 self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON) |
1468 |
1472 |
1469 self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label='Delete', |
1473 self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label=_('Delete'), |
1470 name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
1474 name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
1471 size=wx.Size(72, 32), style=0) |
1475 size=wx.Size(72, 32), style=0) |
1472 self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON) |
1476 self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON) |
1473 |
1477 |
1474 self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^', |
1478 self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^', |