Tutorial

Table Of Contents
111
'''
Python uses Tkinter to quickly create GUI applications and instantiate them while importing
'''
import tkinter as tk
def lights_on():
'''
Call this method to send the light-on command 'on'
'''
tcpClicSock.send(('on').encode())
def lights_off():
'''
Call this method to send the light off command 'off'
'''
tcpClicSock.send(('off').encode())
'''
Enter the IP address of the Raspberry Pi here
'''
SERVER_IP = '192.168.3.35'
'''
Next is the configuration related to TCP communication, where PORT is a defined port number, you can choose freely
from 0-65535, it is recommended to choose the number after 1023, which needs to be consistent with the port number
defined by the server in the Raspberry Pi
'''
SERVER_PORT = 10223
BUFSIZ = 1024
ADDR = (SERVER_IP, SERVER_PORT)
tcpClicSock = socket(AF_INET, SOCK_STREAM)
tcpClicSock.connect(ADDR)
'''
The following is the GUI part
'''
root = tk.Tk() # Define a window
root.title('Lights') # Window title
root.geometry('175x55')# The size of the window, the middle x is the English letter x
root.config(bg='#000000') # Define the background color of the window