570 good = False |
570 good = False |
571 if not good: |
571 if not good: |
572 message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR) |
572 message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR) |
573 message.ShowModal() |
573 message.ShowModal() |
574 message.Destroy() |
574 message.Destroy() |
575 self.Name.SetFocus() |
|
576 else: |
575 else: |
577 self.EndModal(wx.ID_OK) |
576 self.EndModal(wx.ID_OK) |
578 |
577 |
579 def SetValues(self, min = None, max = None, length = None): |
578 def SetValues(self, min = None, max = None, length = None): |
580 if min != None: |
579 if min != None: |
658 parent.AddGrowableCol(0) |
657 parent.AddGrowableCol(0) |
659 parent.AddGrowableRow(0) |
658 parent.AddGrowableRow(0) |
660 |
659 |
661 def _init_coll_MainSizer_Items(self, parent): |
660 def _init_coll_MainSizer_Items(self, parent): |
662 parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
661 parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
663 parent.AddWindow(self.Name, 0, border=0, flag=wx.GROW) |
662 parent.AddWindow(self.NodeName, 0, border=0, flag=wx.GROW) |
664 parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
663 parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
665 parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW) |
664 parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW) |
666 parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
665 parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
667 parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW) |
666 parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW) |
668 parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
667 parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
691 |
690 |
692 self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
691 self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
693 label='Name:', name='staticText1', parent=self, |
692 label='Name:', name='staticText1', parent=self, |
694 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
693 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
695 |
694 |
696 self.Name = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='Name', |
695 self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName', |
697 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
696 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
698 style=0, value='') |
697 style=0, value='') |
699 |
698 |
700 self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
699 self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
701 label='Node ID:', name='staticText2', parent=self, |
700 label='Node ID:', name='staticText2', parent=self, |
731 |
730 |
732 self.Type.Append("master") |
731 self.Type.Append("master") |
733 self.Type.Append("slave") |
732 self.Type.Append("slave") |
734 |
733 |
735 def OnOK(self, event): |
734 def OnOK(self, event): |
736 name = self.Name.GetValue() |
735 name = self.NodeName.GetValue() |
737 message = "" |
736 message = "" |
738 if name != "": |
737 if name != "": |
739 good = not name[0].isdigit() |
738 good = not name[0].isdigit() |
740 for item in name.split("_"): |
739 for item in name.split("_"): |
741 good &= item.isalnum() |
740 good &= item.isalnum() |
748 message = "Node ID must be integer!" |
747 message = "Node ID must be integer!" |
749 if message != "": |
748 if message != "": |
750 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
749 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
751 message.ShowModal() |
750 message.ShowModal() |
752 message.Destroy() |
751 message.Destroy() |
753 self.Name.SetFocus() |
752 self.NodeName.SetFocus() |
754 else: |
753 else: |
755 self.EndModal(wx.ID_OK) |
754 self.EndModal(wx.ID_OK) |
756 |
755 |
757 def SetValues(self, name, id, type, description): |
756 def SetValues(self, name, id, type, description): |
758 self.Name.SetValue(name) |
757 self.NodeName.SetValue(name) |
759 self.NodeID.SetValue("0x%02X"%id) |
758 self.NodeID.SetValue("0x%02X"%id) |
760 self.Type.SetStringSelection(type) |
759 self.Type.SetStringSelection(type) |
761 self.Description.SetValue(description) |
760 self.Description.SetValue(description) |
762 |
761 |
763 def GetValues(self): |
762 def GetValues(self): |
764 name = self.Name.GetValue() |
763 name = self.NodeName.GetValue() |
765 nodeid = int(self.NodeID.GetValue(), 16) |
764 nodeid = int(self.NodeID.GetValue(), 16) |
766 type = self.Type.GetStringSelection() |
765 type = self.Type.GetStringSelection() |
767 description = self.Description.GetValue() |
766 description = self.Description.GetValue() |
768 return name, nodeid, type, description |
767 return name, nodeid, type, description |
769 |
768 |
811 |
810 |
812 def _init_coll_LeftBoxSizer_Items(self, parent): |
811 def _init_coll_LeftBoxSizer_Items(self, parent): |
813 parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
812 parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
814 parent.AddWindow(self.Type, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
813 parent.AddWindow(self.Type, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
815 parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
814 parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
816 parent.AddWindow(self.Name, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
815 parent.AddWindow(self.NodeName, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
817 parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
816 parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
818 parent.AddWindow(self.NodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
817 parent.AddWindow(self.NodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
819 parent.AddWindow(self.staticText4, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
818 parent.AddWindow(self.staticText4, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
820 parent.AddWindow(self.Profile, 0, border=20, flag=wx.GROW|wx.BOTTOM) |
819 parent.AddWindow(self.Profile, 0, border=20, flag=wx.GROW|wx.BOTTOM) |
821 |
820 |
897 |
896 |
898 self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
897 self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
899 name='Type', parent=self, pos=wx.Point(0, 0), |
898 name='Type', parent=self, pos=wx.Point(0, 0), |
900 size=wx.Size(0, 25), style=0) |
899 size=wx.Size(0, 25), style=0) |
901 |
900 |
902 self.Name = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='Name', |
901 self.NodeName = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='NodeName', |
903 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
902 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
904 style=0, value='') |
903 style=0, value='') |
905 |
904 |
906 self.NodeID = wx.TextCtrl(id=ID_CREATENODEDIALOGNODEID, name='NodeID', |
905 self.NodeID = wx.TextCtrl(id=ID_CREATENODEDIALOGNODEID, name='NodeID', |
907 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
906 parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
1000 if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
999 if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
1001 self.ListProfile[name] = os.path.join(self.Directory, item) |
1000 self.ListProfile[name] = os.path.join(self.Directory, item) |
1002 self.Profile.Append(name) |
1001 self.Profile.Append(name) |
1003 self.Profile.Append("Other") |
1002 self.Profile.Append("Other") |
1004 self.Profile.SetStringSelection("None") |
1003 self.Profile.SetStringSelection("None") |
1005 self.Name.SetFocus() |
1004 self.NodeName.SetFocus() |
1006 |
1005 |
1007 def OnOK(self, event): |
1006 def OnOK(self, event): |
1008 name = self.Name.GetValue() |
1007 name = self.NodeName.GetValue() |
1009 message = "" |
1008 message = "" |
1010 if name != "": |
1009 if name != "": |
1011 good = not name[0].isdigit() |
1010 good = not name[0].isdigit() |
1012 for item in name.split("_"): |
1011 for item in name.split("_"): |
1013 good &= item.isalnum() |
1012 good &= item.isalnum() |
1020 message = "Node ID must be an integer!" |
1019 message = "Node ID must be an integer!" |
1021 if message != "": |
1020 if message != "": |
1022 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
1021 message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
1023 message.ShowModal() |
1022 message.ShowModal() |
1024 message.Destroy() |
1023 message.Destroy() |
1025 self.Name.SetFocus() |
1024 self.NodeName.SetFocus() |
1026 else: |
1025 else: |
1027 self.EndModal(wx.ID_OK) |
1026 self.EndModal(wx.ID_OK) |
1028 |
1027 |
1029 def GetValues(self): |
1028 def GetValues(self): |
1030 name = self.Name.GetValue() |
1029 name = self.NodeName.GetValue() |
1031 nodeid = 0 |
1030 nodeid = 0 |
1032 if self.NodeID.GetValue() != "": |
1031 if self.NodeID.GetValue() != "": |
1033 nodeid = int(self.NodeID.GetValue(), 16) |
1032 nodeid = int(self.NodeID.GetValue(), 16) |
1034 type = self.Type.GetStringSelection() |
1033 type = self.Type.GetStringSelection() |
1035 description = self.Description.GetValue() |
1034 description = self.Description.GetValue() |