Max_Leb

Untitled

Mar 30th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from tkinter import *
  2. import socket
  3. from threading import Thread
  4.  
  5. def host():
  6.     sock = socket.socket()
  7.     sock.connect(('localhost', 9090))
  8.     sock.send("change".encode())
  9.     sock.close()
  10.  
  11. window = Tk()
  12.  
  13. def handle_click(event):
  14.     th = Thread(target=host)
  15.     th.start()
  16.  
  17. window.geometry("300x300")
  18. window.columnconfigure(1, weight=1, minsize=75)
  19. window.rowconfigure(1, weight=1, minsize=50)
  20.  
  21. frm = Frame(master=window, relief=RAISED, borderwidth=5)
  22. frm.grid(row=1, column=1)
  23. btn = Button(master=frm, text="Change", background="#28AFEA")
  24. btn.grid(row=1, column=1)
  25.  
  26. btn.bind("<Button-1>", handle_click)
  27.  
  28. window.mainloop()
  29.  
Advertisement
Add Comment
Please, Sign In to add comment