Skip to content
Permalink
Browse files
Added hyperlink detection to receive message, opening link on click i…
…s still broken
  • Loading branch information
hortonr6 committed Nov 15, 2017
1 parent d72a9d2 commit 3191a4046a283ac040a3243d71c16379f43aa028
Showing 1 changed file with 16 additions and 2 deletions.
@@ -1,10 +1,15 @@
import socket
import tkinter as tk
import tkHyperlinkManager as tkHLM
import webbrowser

# Create Socket and connect to server
thisSocket = socket.socket()
thisSocket.connect(("127.0.0.1",5001))

def openLink(url):
webbrowser.open(url, new=2)

def receiveMessage(i):
''' Receives multiple messages from server if needed, until server
sends EndOfMessage and displays the recieved messages on the user
@@ -17,13 +22,22 @@ def receiveMessage(i):
message = thisSocket.recv(1024).decode()
print(message)
while (message != "EndOfMessage"):
if username == "User" and "YOURNAMEWILLBE" in message:
if username == "User" and "YOURNAMEWILLBE" in message: #Checks if username has been changed and for tag identifying new name
nameholder = message.split()[1:]
username = ''.join(nameholder)
username = username.title()
username = username.title() #Assigns username
thisSocket.send("Received".encode())
message = thisSocket.recv(1024).decode()
continue
if "https://" in message:
searchLink = message
hyperlinkObj = tkHLM.HyperlinkManager(chatHistory)
chatHistory.configure(state="normal")
chatHistory.insert(tk.END, "Click here", hyperlinkObj.add()) #broken line
chatHistory.insert(tk.END, "\n")
chatHistory.configure(state="disabled")
thisSocket.send("Received".encode())
message = thisSocket.recv(1024).decode()
chatHistory.configure(state="normal")
thisSocket.send("Received".encode())
chatHistory.insert(tk.END, "Jeff: " + message + "\n")

0 comments on commit 3191a40

Please sign in to comment.