Ejemplo n.º 1
0
 def on_import(self, event):
     openFileDialog = wx.FileDialog(self, "Import .tsv file", "", "", ".tsv files (*.tsv)|*.tsv", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     if openFileDialog.ShowModal() == wx.ID_CANCEL:
         return
     inFilePath = openFileDialog.GetPath()
     if self.validation.isValidUSPS(inFilePath):
         temp = AddressBook()
         temp.loadTSV(inFilePath)
         for contact in temp.contacts:
             self.addressBook.contacts.append(contact)
         self.addressBook.sort(self.addressBook.sortMethod[0],self.addressBook.sortMethod[1])
         self.display()
         self.flash_status_message("Imported address book {}".format(inFilePath))
         self.addressBook.changed = True
     else:
         dlg = wx.MessageDialog(self, "Unable to import {}".format(inFilePath.split('/')[len(inFilePath.split('/'))-1]), "Invalid File", wx.OK)
         dlg.ShowModal()
         dlg.Destroy()