def SendInvite(): ContactName = "" while ContactName == "": ContactName = askstring( "input", "What is the name of the contact you want to add?") if ContactName == None: return () InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files", "*.png"), )) if InputFile == "": return () OutputFile = selectsavefile(title="Select location to save invite", filetypes=(("png files", "*.png"), )) if OutputFile == "": return () NoticeText = tkinter.StringVar() notice = tkinter.Label(master=MainWindow, textvariable=NoticeText) notice.grid(row=3, column=0, columnspan=3, sticky="ew") MainWindow.update_idletasks() for progress in CreateInvite(ContactName, InputFile, OutputFile): #CreateInvite uses yeild NoticeText.set(progress) MainWindow.update_idletasks() NoticeText.set("Invite created") MainWindow.update_idletasks() time.sleep(3) notice.destroy()
def OpenInvite(): ContactName = "" while ContactName == "": ContactName = askstring("input", "What is the name of the contact you want to add?") if ContactName == None: return() InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),)) NoticeText = tkinter.StringVar() notice = tkinter.Label(master=MainWindow, textvariable=NoticeText) notice.grid(row=3, column=0, columnspan=3,sticky="ew") MainWindow.update_idletasks() Unsent, FirstTry,OutputFile = True, True,InputFile while Unsent: if InputFile == "": return() try: for attempt in AcceptInvite(ContactName,InputFile,OutputFile): #CreateInvite uses yeild NoticeText.set(attempt) MainWindow.update_idletasks() Unsent = False notice.destroy() except TypeError: raise return() except Exception as exception: if FirstTry: message = "Sorry but the image contained in the invite was not big enough " else: message = "Sorry but the image you selected was not big enough " FirstTry = False message = message + "to hide the reply in. Press ok to select a new image." tkinter.messagebox.showinfo(message=message) OutputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),)) RenderContactBar()
def SendInvite(): ContactName = "" while ContactName == "": ContactName = askstring("input", "What is the name of the contact you want to add?") if ContactName == None: return() InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),)) if InputFile == "": return() OutputFile = selectsavefile(title="Select location to save invite", filetypes=(("png files","*.png"),)) if OutputFile == "": return() NoticeText = tkinter.StringVar() notice = tkinter.Label(master=MainWindow, textvariable=NoticeText) notice.grid(row=3, column=0, columnspan=3,sticky="ew") MainWindow.update_idletasks() Unsent = True while Unsent: if InputFile == "": return() try: for progress in CreateInvite(ContactName,InputFile,OutputFile): #CreateInvite uses yeild NoticeText.set(progress) MainWindow.update_idletasks() Unsent = False except Exception: message = "Sorry but the image you selected was not big enough to store " message = message + "the invite in. Press ok to select a new image." tkinter.messagebox.showinfo(message=message) InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),)) NoticeText.set("Invite created") MainWindow.update_idletasks() time.sleep(3) notice.destroy()
def OpenInvite(): ContactName = "" while ContactName == "": ContactName = askstring( "input", "What is the name of the contact you want to add?") if ContactName == None: return () InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files", "*.png"), )) if InputFile == "": return () NoticeText = tkinter.StringVar() notice = tkinter.Label(master=MainWindow, textvariable=NoticeText) notice.grid(row=2, column=0, columnspan=3, sticky="ew") MainWindow.update_idletasks() for attempt in AcceptInvite(ContactName, InputFile): #CreateInvite uses yeild NoticeText.set("Generating Keypair, Attempt: " + attempt) MainWindow.update_idletasks()
def SendMessageGUI(): #This function processes entries into the Send Message Field text box. global ContactID if ContactID == 1: # If ContactID the user hasn't selected a contact yet. return() PKID, PublicKey, Max, IDpw = GetContactKey(ContactID) if Max == "1": #if the first key hasn't been recieved then don't allow a message to be sent message = "Sorry but that contact hasn't opened your invite yet. " message = message + "As a result you can't send them messages" tkinter.messagebox.showinfo(message=message) return() global SendMessageField text = SendMessageField.get() InputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),)) if InputFile == "": # InputFile will be empty if cancel was clicked. return() #Get contents for message: LMM = LatestMessageMine(ContactID) # Was the last message send by the user if LMM == 0: # If 0 then the answer is no so a new keypair should be generated NoticeText = tkinter.StringVar() notice = tkinter.Label(master=MainWindow, textvariable=NoticeText) notice.grid(row=3, column=0, columnspan=3,sticky="ew") MainWindow.update_idletasks() for ReturnedData in CreateKeypair(ContactID): # Create Keypair to send if type(ReturnedData) is str: NoticeText.set(ReturnedData) MainWindow.update_idletasks() else: MyPublicKeyID,MyPublicKey,MyMax = ReturnedData notice.destroy() message = json.dumps([text,MyPublicKeyID,MyPublicKey,MyMax]) else: # Otherwise... message = json.dumps([text]) #...place the text in a list and then place it in a JSON print(message) SendMessageField.delete(0, tkinter.END) #Send message contents: Unsent = True while Unsent: if InputFile == "": return() try: for attempt in SendMessage(InputFile,message,IDpw,PublicKey,Max,ContactID, PKID): NoticeText.set(attempt) MainWindow.update_idletasks() Unsent = False notice.destroy() except TypeError: #in the event of a networking error ... raise #... do not handle this (as it should not occur) ... return() #... and don't let the next statement handle it either except Exception as exception: message = "Sorry but the image you selected was not big enough " message = message + "to hide the reply in. Press ok to select a new image." tkinter.messagebox.showinfo(message=message) OutputFile = selectfile(title="Select image to hide invite in", filetypes=(("png files","*.png"),))