+ def OnBuildMasterMenu(self, event):
+ if self.NodeList:
+ dialog = wxFileDialog(self, "Choose a locations file", os.getcwd(), "", "text files (*.txt)|*.od|All files|*.*", wxOPEN|wxCHANGE_DIR)
+ if dialog.ShowModal() == wxID_OK:
+ filepath = dialog.GetPath()
+ dialog.Destroy()
+ if os.path.isfile(filepath):
+ dialog = wxTextEntryDialog(self, "Busname selection", "Please enter the bus number", "", wxOK|wxCANCEL)
+ if dialog.ShowModal() == wxID_OK:
+ busname = None
+ try:
+ busname = int(dialog.GetValue())
+ except:
+ pass
+ if busname:
+ file = open(filepath, "r")
+ locations = [(elements[0], elements[1]) for elements in [line.strip().split(" ") for line in file.readlines()]]
+ GenerateConciseDCF(locations, busname, self.NodeList)
+ message = wxMessageDialog(self, "Master node generation successful!", "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ else:
+ message = wxMessageDialog(self, "Busname must be a number!", "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ else:
+ message = wxMessageDialog(self, "\"%s\" isn't a valid file!"%filepath, "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ event.Skip()
+
+