def __init__(self): self.root = tk.Tk() self.root.protocol('WM_DELETE_WINDOW',lambda: self._quit(None)) self.root.title("PyTweet") self.view = view.PyTweet_Client(self.root) self.view.registerMenu(lambda: self.startAuth(), lambda: self.saveCredentials(None), lambda: self.loadCredentials(None), lambda: self._quit(None)) self.root.deiconify() self.root.geometry("540x370") self.root.resizable(False, False) if (os.path.exists('data.dat')): try: self.auth = data.loadCredentials() self.postAuth() except: os.remove('data.dat') if (tkMessageBox.askyesno(message="Invalid credentials found.\nWould you like to authorize PyTweet?")): self.startAuth() else: if (tkMessageBox.askyesno(message="No saved credentials found.\nWould you like to authorize PyTweet?")): self.startAuth()
def loadCredentials(self, event): """Load an Authorizer instance from a file""" filePath = tkFileDialog.askopenfilename(filetypes=[("Data files", "*.dat")]) self.auth = data.loadCredentials(filePath) self.postAuth() tkMessageBox.showinfo("Data loaded", "Authentication Data Loaded!")