Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Tkinter as tk
- import sys
- import os
- import socket
- import random
- import tkMessageBox
- root= tk.Tk()
- root.title("UDP Messenger")
- w = 300
- h = 200
- x = 50
- y = 100
- root.geometry("%dx%d+%d+%d" % (w, h, x, y))
- frame = tk.Frame(root, bg='white')
- frame.pack(fill='both', expand='yes')
- ip1 = tk.Label(frame, font="Arial", text="IP: ")
- ip1.place(x=10, y=10)
- ip2 = tk.Entry(frame, bd=5)
- ip2.place(x=60, y=10)
- msg1 = tk.Label(frame, font="Arial",text="Message: ")
- msg1.place(x=10, y=50)
- msg2 = tk.Entry(frame, bd=5, width=30)
- msg2.place(x=90, y=50)
- def mail():
- hostname = (ip2.get())
- if hostname == "":
- tkMessageBox.showinfo("Error", "IP Address is not defined")
- msg3 = (msg2.get())
- host = str(hostname)
- msg = str(msg3)
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- s.sendto(msg, (host, 5005))
- def quit():
- sys.exit()
- button = tk.Button(frame, text="Send", bg="yellow", font="Arial",width=10,command=mail)
- button.place(x=10, y=100)
- button1 = tk.Button(frame, text="Quit", bg="red", font="Arial", fg="white", width=10,command=quit)
- button1.place(x=170, y=100)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement