本帖最后由 云天 于 2023-8-24 17:59 编辑
作为市场上最受欢迎的开源硬件之一,Arduino Uno R3 早在 2010 年就推出了,这款诞生已经超过十年的硬件可以说性能已经有点落后了。在大家都在翘首期盼之时,2023年3月份 Arduino 正式发布了 Arduino Uno R3 的升级版 —— Arduino Uno R4,新产品在处理能力、内存、存储和连接等方面都带来了巨大提升。
在 Uno R4 的官方照片中(上面的图),Arduino 用黄色和蓝绿色遮盖了 PCB 的部分区域,官方表示只有在接近发售时才会透露隐藏在这些区域的到底是什么?
原来是板载12x8的LED矩阵。
- 具备WiFi和蓝牙功能
- UNO R4 WiFi具有ESP32-S3-MINI协处理器,可增强RA4M1微控制器的功能。具备WiFi和蓝牙连接功能,使得开发者可以轻松连接到互联网并创建物联网项目。
- 板载12x8的LED矩阵。
- UNO R4 WiFi板载了一个明亮的12x8红色LED矩阵(总共96个点)。该功能非常适合使用动画或绘制传感器数据的创意项目,无需任何额外的硬件。
下面我来测试一下WIFI和LED矩阵,本项目一个亮点是用程序生成程序代码。
一、网页控制LED矩阵
1.UNO R4程序
- /*
- WiFi Web Server LED Blink
-
- A simple web server that lets you blink an LED via the web.
- This sketch will print the IP address of your WiFi module (once connected)
- to the Serial Monitor. From there, you can open that address in a web browser
- to turn on and off the LED_BUILTIN.
-
- If the IP address of your board is yourAddress:
- http://yourAddress/H turns the LED on
- http://yourAddress/L turns it off
-
- This example is written for a network using WPA encryption. For
- WEP or WPA, change the WiFi.begin() call accordingly.
-
- Circuit:
- * Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2)
- * LED attached to pin 9
-
- created 25 Nov 2012
- by Tom Igoe
- */
-
- #include "WiFiS3.h"
-
- #include "arduino_secrets.h"
- #include "Arduino_LED_Matrix.h"
- ArduinoLEDMatrix matrix;
- uint8_t frame[2][8][12] = {{
- { 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0 },
- { 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 },
- { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1 },
- { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
- { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
- { 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
- { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
- { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }
- },{
- { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
- { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
- { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
- }
- };
- ///////please enter your sensitive data in the Secret tab/arduino_secrets.h
- char ssid[] = SECRET_SSID; // your network SSID (name)
- char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
- int keyIndex = 0; // your network key index number (needed only for WEP)
-
- int led = LED_BUILTIN;
- int status = WL_IDLE_STATUS;
- WiFiServer server(80);
-
- void setup() {
- Serial.begin(9600); // initialize serial communication
- pinMode(led, OUTPUT); // set the LED pin mode
- matrix.begin();
- // check for the WiFi module:
- if (WiFi.status() == WL_NO_MODULE) {
- Serial.println("Communication with WiFi module failed!");
- // don't continue
- while (true);
- }
-
- String fv = WiFi.firmwareVersion();
- if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
- Serial.println("Please upgrade the firmware");
- }
-
- // attempt to connect to WiFi network:
- while (status != WL_CONNECTED) {
- Serial.print("Attempting to connect to Network named: ");
- Serial.println(ssid); // print the network name (SSID);
-
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.begin(ssid, pass);
- // wait 10 seconds for connection:
- delay(10000);
- }
- server.begin(); // start the web server on port 80
- printWifiStatus(); // you're connected now, so print out the status
- }
-
-
- void loop() {
- WiFiClient client = server.available(); // listen for incoming clients
-
- if (client) { // if you get a client,
- Serial.println("new client"); // print a message out the serial port
- String currentLine = ""; // make a String to hold incoming data from the client
- while (client.connected()) { // loop while the client's connected
- if (client.available()) { // if there's bytes to read from the client,
- char c = client.read(); // read a byte, then
- Serial.write(c); // print it out to the serial monitor
- if (c == '\n') { // if the byte is a newline character
-
- // if the current line is blank, you got two newline characters in a row.
- // that's the end of the client HTTP request, so send a response:
- if (currentLine.length() == 0) {
- // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
- // and a content-type so the client knows what's coming, then a blank line:
- client.println("HTTP/1.1 200 OK");
- client.println("Content-type:text/html");
- client.println();
-
- // the content of the HTTP response follows the header:
- client.print("<p style="font-size:7vw;">Click <a href="/H">here</a> turn the LED on<br></p>");
- client.print("<p style="font-size:7vw;">Click <a href="/L">here</a> turn the LED off<br></p>");
-
- // The HTTP response ends with another blank line:
- client.println();
- // break out of the while loop:
- break;
- } else { // if you got a newline, then clear currentLine:
- currentLine = "";
- }
- } else if (c != '\r') { // if you got anything else but a carriage return character,
- currentLine += c; // add it to the end of the currentLine
- }
-
- // Check to see if the client request was "GET /H" or "GET /L":
- if (currentLine.endsWith("GET /H")) {
- digitalWrite(LED_BUILTIN, HIGH); // GET /H turns the LED on
- matrix.renderBitmap(frame[0], 8, 12);
- }
- if (currentLine.endsWith("GET /L")) {
- digitalWrite(LED_BUILTIN, LOW); // GET /L turns the LED off
- matrix.renderBitmap(frame[1], 8, 12);
- }
- }
-
- }
- // close the connection:
- client.stop();
- Serial.println("client disconnected");
- }
- }
-
- void printWifiStatus() {
- // print the SSID of the network you're attached to:
- Serial.print("SSID: ");
- Serial.println(WiFi.SSID());
-
- // print your board's IP address:
- IPAddress ip = WiFi.localIP();
- Serial.print("IP Address: ");
- Serial.println(ip);
-
- // print the received signal strength:
- long rssi = WiFi.RSSI();
- Serial.print("signal strength (RSSI):");
- Serial.print(rssi);
- Serial.println(" dBm");
- // print where to go in a browser:
- Serial.print("To see this page in action, open a browser to http://");
- Serial.println(ip);
- }
复制代码
2.演示视频
二、UNO R4与行空板LED矩阵互动
1.分析LED矩阵
LED矩阵为8*12
2.分析显示程序中数据结构
- const uint32_t heart[] = {
- 0x3184a444,
- 0x44042081,
- 0x100a0040
- };
复制代码
数组中三个数据,十六进制,一个数据共32位,共96位,每位与LED灯珠一一对应。
3.行空板上“灯珠”设计
与UNO R4 LED矩阵一一对应。
4.UNO R4程序
- /*
- WiFi UDP Send and Receive String
-
- This sketch waits for a UDP packet on localPort using the WiFi module.
- When a packet is received an Acknowledge packet is sent to the client on port remotePort
-
- created 30 December 2012
- by dlf (Metodo2 srl)
-
- */
-
-
- #include <WiFiS3.h>
-
- int status = WL_IDLE_STATUS;
- #include "arduino_secrets.h"
- #include "Arduino_LED_Matrix.h"
-
- ArduinoLEDMatrix matrix;
- ///////please enter your sensitive data in the Secret tab/arduino_secrets.h
- char ssid[] = SECRET_SSID; // your network SSID (name)
- char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
- int keyIndex = 0; // your network key index number (needed only for WEP)
-
- unsigned int localPort = 2390; // local port to listen on
-
- char packetBuffer[256]; //buffer to hold incoming packet
- char ReplyBuffer[] = "acknowledged\n"; // a string to send back
-
- WiFiUDP Udp;
- uint32_t frame[] = {
- 0, 0, 0, 0
- };
- void setup() {
- //Initialize serial and wait for port to open:
- Serial.begin(9600);
- matrix.begin();
- while (!Serial) {
- ; // wait for serial port to connect. Needed for native USB port only
- }
-
- // check for the WiFi module:
- if (WiFi.status() == WL_NO_MODULE) {
- Serial.println("Communication with WiFi module failed!");
- // don't continue
- while (true);
- }
-
- String fv = WiFi.firmwareVersion();
- if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
- Serial.println("Please upgrade the firmware");
- }
-
- // attempt to connect to WiFi network:
- while (status != WL_CONNECTED) {
- Serial.print("Attempting to connect to SSID: ");
- Serial.println(ssid);
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.begin(ssid, pass);
-
- // wait 10 seconds for connection:
- delay(10000);
- }
- Serial.println("Connected to WiFi");
- printWifiStatus();
-
- Serial.println("\nStarting connection to server...");
- // if you get a connection, report back via serial:
- Udp.begin(localPort);
- }
-
- void loop() {
-
- // if there's data available, read a packet
- int packetSize = Udp.parsePacket();
- if (packetSize) {
- Serial.print("Received packet of size ");
- Serial.println(packetSize);
- Serial.print("From ");
- IPAddress remoteIp = Udp.remoteIP();
- Serial.print(remoteIp);
- Serial.print(", port ");
- Serial.println(Udp.remotePort());
-
- // read the packet into packetBuffer
- int len = Udp.read(packetBuffer, 255);
- if (len > 0) {
- packetBuffer[len] = 0;
- }
- Serial.println("Contents:");
- Serial.println(packetBuffer);
- int fra=String(packetBuffer[0]).toInt();
- String MyString="";
- MyString.concat(packetBuffer[1]);
- MyString.concat(packetBuffer[2]);
- int num=31-MyString.toInt();
- frame[fra]=frame[fra]^(1<<num);
-
- matrix.loadFrame(frame);
-
-
- // send a reply, to the IP address and port that sent us the packet we received
- //Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
- //Udp.write(ReplyBuffer);
-
- //Udp.endPacket();
- }
- }
-
-
- void printWifiStatus() {
- // print the SSID of the network you're attached to:
- Serial.print("SSID: ");
- Serial.println(WiFi.SSID());
-
- // print your board's IP address:
- IPAddress ip = WiFi.localIP();
- Serial.print("IP Address: ");
- Serial.println(ip);
-
- // print the received signal strength:
- long rssi = WiFi.RSSI();
- Serial.print("signal strength (RSSI):");
- Serial.print(rssi);
- Serial.println(" dBm");
- }
-
复制代码
重点程序是对接收的数据进行分析,并显示在LED矩阵上。
- int fra=String(packetBuffer[0]).toInt();
- String MyString="";
- MyString.concat(packetBuffer[1]);
- MyString.concat(packetBuffer[2]);
- int num=31-MyString.toInt();
- frame[fra]=frame[fra]^(1<<num);
-
- matrix.loadFrame(frame);
复制代码
5.行空板程序
(1)先生成两个“灯珠”进行测试
-
- from unihiker import GUI
- import socket
-
- # 创建UDP socket
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-
- # 绑定要发送的IP地址和端口号
- target_ip = '192.168.31.210'
- target_port = 2390
- data=[]
- for i in range(0,96):
- data.append(0)
- # 事件回调函数
- def button_click031():
- global data
- if data[1]:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#000000')
- data[1]=0
- else:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#FF0000')
- data[1]=1
-
- def button_click030():
- global data
- if data[0]:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#000000')
- data[0]=0
- else:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#FF0000')
- data[0]=1
-
- u_gui=GUI()
-
- d031=u_gui.fill_circle(x=226,y=13,r=13,color="#000000")
- d031.config(onclick=button_click031)
- d030=u_gui.fill_circle(x=226,y=39,r=13,color="#000000")
- d030.config(onclick=button_click030)
- while 1:
- pass
- s.close()
复制代码
(2)因要生成96个“灯珠”和96个“回调函数”,所以我使用Python程序生成程序代码。
1)生成96个“回调函数”程序
-
- fileObj = open("Mind+.txt", "w", encoding="UTF8")
-
- for k in range(0,3):
- for i in range(0,32):
- if i<10:
- j="0"+str(i)
- else:
- j=str(i)
- fileObj.write("def button_click"+str(k)+j+"():\r")
- fileObj.write(" global data\r")
- fileObj.write(" if data["+str(32*k+i)+"]:\r")
- fileObj.write(" s.sendto("+"""+str(k)+j+"""+".encode(), (target_ip, target_port))\r")
- fileObj.write(" d"+str(k)+j+".config(color="+"'#000000')\r")
- fileObj.write(" data["+str(32*k+i)+"]=0\r")
- fileObj.write(" else:\r")
- fileObj.write(" s.sendto("+"""+str(k)+j+"""+".encode(), (target_ip, target_port))\r")
- fileObj.write(" d"+str(k)+j+".config(color="+"'#FF0000')\r")
- fileObj.write(" data["+str(32*k+i)+"]=1\r")
- fileObj.close()
复制代码
生成的“回调函数”代码
- def button_click000():
- global data
- if data[0]:
- s.sendto("000".encode(), (target_ip, target_port))
- d000.config(color='#000000')
- data[0]=0
- else:
- s.sendto("000".encode(), (target_ip, target_port))
- d000.config(color='#FF0000')
- data[0]=1
- def button_click001():
- global data
- if data[1]:
- s.sendto("001".encode(), (target_ip, target_port))
- d001.config(color='#000000')
- data[1]=0
- else:
- s.sendto("001".encode(), (target_ip, target_port))
- d001.config(color='#FF0000')
- data[1]=1
- def button_click002():
- global data
- if data[2]:
- s.sendto("002".encode(), (target_ip, target_port))
- d002.config(color='#000000')
- data[2]=0
- else:
- s.sendto("002".encode(), (target_ip, target_port))
- d002.config(color='#FF0000')
- data[2]=1
- def button_click003():
- global data
- if data[3]:
- s.sendto("003".encode(), (target_ip, target_port))
- d003.config(color='#000000')
- data[3]=0
- else:
- s.sendto("003".encode(), (target_ip, target_port))
- d003.config(color='#FF0000')
- data[3]=1
- def button_click004():
- global data
- if data[4]:
- s.sendto("004".encode(), (target_ip, target_port))
- d004.config(color='#000000')
- data[4]=0
- else:
- s.sendto("004".encode(), (target_ip, target_port))
- d004.config(color='#FF0000')
- data[4]=1
- def button_click005():
- global data
- if data[5]:
- s.sendto("005".encode(), (target_ip, target_port))
- d005.config(color='#000000')
- data[5]=0
- else:
- s.sendto("005".encode(), (target_ip, target_port))
- d005.config(color='#FF0000')
- data[5]=1
- def button_click006():
- global data
- if data[6]:
- s.sendto("006".encode(), (target_ip, target_port))
- d006.config(color='#000000')
- data[6]=0
- else:
- s.sendto("006".encode(), (target_ip, target_port))
- d006.config(color='#FF0000')
- data[6]=1
- def button_click007():
- global data
- if data[7]:
- s.sendto("007".encode(), (target_ip, target_port))
- d007.config(color='#000000')
- data[7]=0
- else:
- s.sendto("007".encode(), (target_ip, target_port))
- d007.config(color='#FF0000')
- data[7]=1
- def button_click008():
- global data
- if data[8]:
- s.sendto("008".encode(), (target_ip, target_port))
- d008.config(color='#000000')
- data[8]=0
- else:
- s.sendto("008".encode(), (target_ip, target_port))
- d008.config(color='#FF0000')
- data[8]=1
- def button_click009():
- global data
- if data[9]:
- s.sendto("009".encode(), (target_ip, target_port))
- d009.config(color='#000000')
- data[9]=0
- else:
- s.sendto("009".encode(), (target_ip, target_port))
- d009.config(color='#FF0000')
- data[9]=1
- def button_click010():
- global data
- if data[10]:
- s.sendto("010".encode(), (target_ip, target_port))
- d010.config(color='#000000')
- data[10]=0
- else:
- s.sendto("010".encode(), (target_ip, target_port))
- d010.config(color='#FF0000')
- data[10]=1
- def button_click011():
- global data
- if data[11]:
- s.sendto("011".encode(), (target_ip, target_port))
- d011.config(color='#000000')
- data[11]=0
- else:
- s.sendto("011".encode(), (target_ip, target_port))
- d011.config(color='#FF0000')
- data[11]=1
- def button_click012():
- global data
- if data[12]:
- s.sendto("012".encode(), (target_ip, target_port))
- d012.config(color='#000000')
- data[12]=0
- else:
- s.sendto("012".encode(), (target_ip, target_port))
- d012.config(color='#FF0000')
- data[12]=1
- def button_click013():
- global data
- if data[13]:
- s.sendto("013".encode(), (target_ip, target_port))
- d013.config(color='#000000')
- data[13]=0
- else:
- s.sendto("013".encode(), (target_ip, target_port))
- d013.config(color='#FF0000')
- data[13]=1
- def button_click014():
- global data
- if data[14]:
- s.sendto("014".encode(), (target_ip, target_port))
- d014.config(color='#000000')
- data[14]=0
- else:
- s.sendto("014".encode(), (target_ip, target_port))
- d014.config(color='#FF0000')
- data[14]=1
- def button_click015():
- global data
- if data[15]:
- s.sendto("015".encode(), (target_ip, target_port))
- d015.config(color='#000000')
- data[15]=0
- else:
- s.sendto("015".encode(), (target_ip, target_port))
- d015.config(color='#FF0000')
- data[15]=1
- def button_click016():
- global data
- if data[16]:
- s.sendto("016".encode(), (target_ip, target_port))
- d016.config(color='#000000')
- data[16]=0
- else:
- s.sendto("016".encode(), (target_ip, target_port))
- d016.config(color='#FF0000')
- data[16]=1
- def button_click017():
- global data
- if data[17]:
- s.sendto("017".encode(), (target_ip, target_port))
- d017.config(color='#000000')
- data[17]=0
- else:
- s.sendto("017".encode(), (target_ip, target_port))
- d017.config(color='#FF0000')
- data[17]=1
- def button_click018():
- global data
- if data[18]:
- s.sendto("018".encode(), (target_ip, target_port))
- d018.config(color='#000000')
- data[18]=0
- else:
- s.sendto("018".encode(), (target_ip, target_port))
- d018.config(color='#FF0000')
- data[18]=1
- def button_click019():
- global data
- if data[19]:
- s.sendto("019".encode(), (target_ip, target_port))
- d019.config(color='#000000')
- data[19]=0
- else:
- s.sendto("019".encode(), (target_ip, target_port))
- d019.config(color='#FF0000')
- data[19]=1
- def button_click020():
- global data
- if data[20]:
- s.sendto("020".encode(), (target_ip, target_port))
- d020.config(color='#000000')
- data[20]=0
- else:
- s.sendto("020".encode(), (target_ip, target_port))
- d020.config(color='#FF0000')
- data[20]=1
- def button_click021():
- global data
- if data[21]:
- s.sendto("021".encode(), (target_ip, target_port))
- d021.config(color='#000000')
- data[21]=0
- else:
- s.sendto("021".encode(), (target_ip, target_port))
- d021.config(color='#FF0000')
- data[21]=1
- def button_click022():
- global data
- if data[22]:
- s.sendto("022".encode(), (target_ip, target_port))
- d022.config(color='#000000')
- data[22]=0
- else:
- s.sendto("022".encode(), (target_ip, target_port))
- d022.config(color='#FF0000')
- data[22]=1
- def button_click023():
- global data
- if data[23]:
- s.sendto("023".encode(), (target_ip, target_port))
- d023.config(color='#000000')
- data[23]=0
- else:
- s.sendto("023".encode(), (target_ip, target_port))
- d023.config(color='#FF0000')
- data[23]=1
- def button_click024():
- global data
- if data[24]:
- s.sendto("024".encode(), (target_ip, target_port))
- d024.config(color='#000000')
- data[24]=0
- else:
- s.sendto("024".encode(), (target_ip, target_port))
- d024.config(color='#FF0000')
- data[24]=1
- def button_click025():
- global data
- if data[25]:
- s.sendto("025".encode(), (target_ip, target_port))
- d025.config(color='#000000')
- data[25]=0
- else:
- s.sendto("025".encode(), (target_ip, target_port))
- d025.config(color='#FF0000')
- data[25]=1
- def button_click026():
- global data
- if data[26]:
- s.sendto("026".encode(), (target_ip, target_port))
- d026.config(color='#000000')
- data[26]=0
- else:
- s.sendto("026".encode(), (target_ip, target_port))
- d026.config(color='#FF0000')
- data[26]=1
- def button_click027():
- global data
- if data[27]:
- s.sendto("027".encode(), (target_ip, target_port))
- d027.config(color='#000000')
- data[27]=0
- else:
- s.sendto("027".encode(), (target_ip, target_port))
- d027.config(color='#FF0000')
- data[27]=1
- def button_click028():
- global data
- if data[28]:
- s.sendto("028".encode(), (target_ip, target_port))
- d028.config(color='#000000')
- data[28]=0
- else:
- s.sendto("028".encode(), (target_ip, target_port))
- d028.config(color='#FF0000')
- data[28]=1
- def button_click029():
- global data
- if data[29]:
- s.sendto("029".encode(), (target_ip, target_port))
- d029.config(color='#000000')
- data[29]=0
- else:
- s.sendto("029".encode(), (target_ip, target_port))
- d029.config(color='#FF0000')
- data[29]=1
- def button_click030():
- global data
- if data[30]:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#000000')
- data[30]=0
- else:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#FF0000')
- data[30]=1
- def button_click031():
- global data
- if data[31]:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#000000')
- data[31]=0
- else:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#FF0000')
- data[31]=1
- def button_click100():
- global data
- if data[32]:
- s.sendto("100".encode(), (target_ip, target_port))
- d100.config(color='#000000')
- data[32]=0
- else:
- s.sendto("100".encode(), (target_ip, target_port))
- d100.config(color='#FF0000')
- data[32]=1
- def button_click101():
- global data
- if data[33]:
- s.sendto("101".encode(), (target_ip, target_port))
- d101.config(color='#000000')
- data[33]=0
- else:
- s.sendto("101".encode(), (target_ip, target_port))
- d101.config(color='#FF0000')
- data[33]=1
- def button_click102():
- global data
- if data[34]:
- s.sendto("102".encode(), (target_ip, target_port))
- d102.config(color='#000000')
- data[34]=0
- else:
- s.sendto("102".encode(), (target_ip, target_port))
- d102.config(color='#FF0000')
- data[34]=1
- def button_click103():
- global data
- if data[35]:
- s.sendto("103".encode(), (target_ip, target_port))
- d103.config(color='#000000')
- data[35]=0
- else:
- s.sendto("103".encode(), (target_ip, target_port))
- d103.config(color='#FF0000')
- data[35]=1
- def button_click104():
- global data
- if data[36]:
- s.sendto("104".encode(), (target_ip, target_port))
- d104.config(color='#000000')
- data[36]=0
- else:
- s.sendto("104".encode(), (target_ip, target_port))
- d104.config(color='#FF0000')
- data[36]=1
- def button_click105():
- global data
- if data[37]:
- s.sendto("105".encode(), (target_ip, target_port))
- d105.config(color='#000000')
- data[37]=0
- else:
- s.sendto("105".encode(), (target_ip, target_port))
- d105.config(color='#FF0000')
- data[37]=1
- def button_click106():
- global data
- if data[38]:
- s.sendto("106".encode(), (target_ip, target_port))
- d106.config(color='#000000')
- data[38]=0
- else:
- s.sendto("106".encode(), (target_ip, target_port))
- d106.config(color='#FF0000')
- data[38]=1
- def button_click107():
- global data
- if data[39]:
- s.sendto("107".encode(), (target_ip, target_port))
- d107.config(color='#000000')
- data[39]=0
- else:
- s.sendto("107".encode(), (target_ip, target_port))
- d107.config(color='#FF0000')
- data[39]=1
- def button_click108():
- global data
- if data[40]:
- s.sendto("108".encode(), (target_ip, target_port))
- d108.config(color='#000000')
- data[40]=0
- else:
- s.sendto("108".encode(), (target_ip, target_port))
- d108.config(color='#FF0000')
- data[40]=1
- def button_click109():
- global data
- if data[41]:
- s.sendto("109".encode(), (target_ip, target_port))
- d109.config(color='#000000')
- data[41]=0
- else:
- s.sendto("109".encode(), (target_ip, target_port))
- d109.config(color='#FF0000')
- data[41]=1
- def button_click110():
- global data
- if data[42]:
- s.sendto("110".encode(), (target_ip, target_port))
- d110.config(color='#000000')
- data[42]=0
- else:
- s.sendto("110".encode(), (target_ip, target_port))
- d110.config(color='#FF0000')
- data[42]=1
- def button_click111():
- global data
- if data[43]:
- s.sendto("111".encode(), (target_ip, target_port))
- d111.config(color='#000000')
- data[43]=0
- else:
- s.sendto("111".encode(), (target_ip, target_port))
- d111.config(color='#FF0000')
- data[43]=1
- def button_click112():
- global data
- if data[44]:
- s.sendto("112".encode(), (target_ip, target_port))
- d112.config(color='#000000')
- data[44]=0
- else:
- s.sendto("112".encode(), (target_ip, target_port))
- d112.config(color='#FF0000')
- data[44]=1
- def button_click113():
- global data
- if data[45]:
- s.sendto("113".encode(), (target_ip, target_port))
- d113.config(color='#000000')
- data[45]=0
- else:
- s.sendto("113".encode(), (target_ip, target_port))
- d113.config(color='#FF0000')
- data[45]=1
- def button_click114():
- global data
- if data[46]:
- s.sendto("114".encode(), (target_ip, target_port))
- d114.config(color='#000000')
- data[46]=0
- else:
- s.sendto("114".encode(), (target_ip, target_port))
- d114.config(color='#FF0000')
- data[46]=1
- def button_click115():
- global data
- if data[47]:
- s.sendto("115".encode(), (target_ip, target_port))
- d115.config(color='#000000')
- data[47]=0
- else:
- s.sendto("115".encode(), (target_ip, target_port))
- d115.config(color='#FF0000')
- data[47]=1
- def button_click116():
- global data
- if data[48]:
- s.sendto("116".encode(), (target_ip, target_port))
- d116.config(color='#000000')
- data[48]=0
- else:
- s.sendto("116".encode(), (target_ip, target_port))
- d116.config(color='#FF0000')
- data[48]=1
- def button_click117():
- global data
- if data[49]:
- s.sendto("117".encode(), (target_ip, target_port))
- d117.config(color='#000000')
- data[49]=0
- else:
- s.sendto("117".encode(), (target_ip, target_port))
- d117.config(color='#FF0000')
- data[49]=1
- def button_click118():
- global data
- if data[50]:
- s.sendto("118".encode(), (target_ip, target_port))
- d118.config(color='#000000')
- data[50]=0
- else:
- s.sendto("118".encode(), (target_ip, target_port))
- d118.config(color='#FF0000')
- data[50]=1
- def button_click119():
- global data
- if data[51]:
- s.sendto("119".encode(), (target_ip, target_port))
- d119.config(color='#000000')
- data[51]=0
- else:
- s.sendto("119".encode(), (target_ip, target_port))
- d119.config(color='#FF0000')
- data[51]=1
- def button_click120():
- global data
- if data[52]:
- s.sendto("120".encode(), (target_ip, target_port))
- d120.config(color='#000000')
- data[52]=0
- else:
- s.sendto("120".encode(), (target_ip, target_port))
- d120.config(color='#FF0000')
- data[52]=1
- def button_click121():
- global data
- if data[53]:
- s.sendto("121".encode(), (target_ip, target_port))
- d121.config(color='#000000')
- data[53]=0
- else:
- s.sendto("121".encode(), (target_ip, target_port))
- d121.config(color='#FF0000')
- data[53]=1
- def button_click122():
- global data
- if data[54]:
- s.sendto("122".encode(), (target_ip, target_port))
- d122.config(color='#000000')
- data[54]=0
- else:
- s.sendto("122".encode(), (target_ip, target_port))
- d122.config(color='#FF0000')
- data[54]=1
- def button_click123():
- global data
- if data[55]:
- s.sendto("123".encode(), (target_ip, target_port))
- d123.config(color='#000000')
- data[55]=0
- else:
- s.sendto("123".encode(), (target_ip, target_port))
- d123.config(color='#FF0000')
- data[55]=1
- def button_click124():
- global data
- if data[56]:
- s.sendto("124".encode(), (target_ip, target_port))
- d124.config(color='#000000')
- data[56]=0
- else:
- s.sendto("124".encode(), (target_ip, target_port))
- d124.config(color='#FF0000')
- data[56]=1
- def button_click125():
- global data
- if data[57]:
- s.sendto("125".encode(), (target_ip, target_port))
- d125.config(color='#000000')
- data[57]=0
- else:
- s.sendto("125".encode(), (target_ip, target_port))
- d125.config(color='#FF0000')
- data[57]=1
- def button_click126():
- global data
- if data[58]:
- s.sendto("126".encode(), (target_ip, target_port))
- d126.config(color='#000000')
- data[58]=0
- else:
- s.sendto("126".encode(), (target_ip, target_port))
- d126.config(color='#FF0000')
- data[58]=1
- def button_click127():
- global data
- if data[59]:
- s.sendto("127".encode(), (target_ip, target_port))
- d127.config(color='#000000')
- data[59]=0
- else:
- s.sendto("127".encode(), (target_ip, target_port))
- d127.config(color='#FF0000')
- data[59]=1
- def button_click128():
- global data
- if data[60]:
- s.sendto("128".encode(), (target_ip, target_port))
- d128.config(color='#000000')
- data[60]=0
- else:
- s.sendto("128".encode(), (target_ip, target_port))
- d128.config(color='#FF0000')
- data[60]=1
- def button_click129():
- global data
- if data[61]:
- s.sendto("129".encode(), (target_ip, target_port))
- d129.config(color='#000000')
- data[61]=0
- else:
- s.sendto("129".encode(), (target_ip, target_port))
- d129.config(color='#FF0000')
- data[61]=1
- def button_click130():
- global data
- if data[62]:
- s.sendto("130".encode(), (target_ip, target_port))
- d130.config(color='#000000')
- data[62]=0
- else:
- s.sendto("130".encode(), (target_ip, target_port))
- d130.config(color='#FF0000')
- data[62]=1
- def button_click131():
- global data
- if data[63]:
- s.sendto("131".encode(), (target_ip, target_port))
- d131.config(color='#000000')
- data[63]=0
- else:
- s.sendto("131".encode(), (target_ip, target_port))
- d131.config(color='#FF0000')
- data[63]=1
- def button_click200():
- global data
- if data[64]:
- s.sendto("200".encode(), (target_ip, target_port))
- d200.config(color='#000000')
- data[64]=0
- else:
- s.sendto("200".encode(), (target_ip, target_port))
- d200.config(color='#FF0000')
- data[64]=1
- def button_click201():
- global data
- if data[65]:
- s.sendto("201".encode(), (target_ip, target_port))
- d201.config(color='#000000')
- data[65]=0
- else:
- s.sendto("201".encode(), (target_ip, target_port))
- d201.config(color='#FF0000')
- data[65]=1
- def button_click202():
- global data
- if data[66]:
- s.sendto("202".encode(), (target_ip, target_port))
- d202.config(color='#000000')
- data[66]=0
- else:
- s.sendto("202".encode(), (target_ip, target_port))
- d202.config(color='#FF0000')
- data[66]=1
- def button_click203():
- global data
- if data[67]:
- s.sendto("203".encode(), (target_ip, target_port))
- d203.config(color='#000000')
- data[67]=0
- else:
- s.sendto("203".encode(), (target_ip, target_port))
- d203.config(color='#FF0000')
- data[67]=1
- def button_click204():
- global data
- if data[68]:
- s.sendto("204".encode(), (target_ip, target_port))
- d204.config(color='#000000')
- data[68]=0
- else:
- s.sendto("204".encode(), (target_ip, target_port))
- d204.config(color='#FF0000')
- data[68]=1
- def button_click205():
- global data
- if data[69]:
- s.sendto("205".encode(), (target_ip, target_port))
- d205.config(color='#000000')
- data[69]=0
- else:
- s.sendto("205".encode(), (target_ip, target_port))
- d205.config(color='#FF0000')
- data[69]=1
- def button_click206():
- global data
- if data[70]:
- s.sendto("206".encode(), (target_ip, target_port))
- d206.config(color='#000000')
- data[70]=0
- else:
- s.sendto("206".encode(), (target_ip, target_port))
- d206.config(color='#FF0000')
- data[70]=1
- def button_click207():
- global data
- if data[71]:
- s.sendto("207".encode(), (target_ip, target_port))
- d207.config(color='#000000')
- data[71]=0
- else:
- s.sendto("207".encode(), (target_ip, target_port))
- d207.config(color='#FF0000')
- data[71]=1
- def button_click208():
- global data
- if data[72]:
- s.sendto("208".encode(), (target_ip, target_port))
- d208.config(color='#000000')
- data[72]=0
- else:
- s.sendto("208".encode(), (target_ip, target_port))
- d208.config(color='#FF0000')
- data[72]=1
- def button_click209():
- global data
- if data[73]:
- s.sendto("209".encode(), (target_ip, target_port))
- d209.config(color='#000000')
- data[73]=0
- else:
- s.sendto("209".encode(), (target_ip, target_port))
- d209.config(color='#FF0000')
- data[73]=1
- def button_click210():
- global data
- if data[74]:
- s.sendto("210".encode(), (target_ip, target_port))
- d210.config(color='#000000')
- data[74]=0
- else:
- s.sendto("210".encode(), (target_ip, target_port))
- d210.config(color='#FF0000')
- data[74]=1
- def button_click211():
- global data
- if data[75]:
- s.sendto("211".encode(), (target_ip, target_port))
- d211.config(color='#000000')
- data[75]=0
- else:
- s.sendto("211".encode(), (target_ip, target_port))
- d211.config(color='#FF0000')
- data[75]=1
- def button_click212():
- global data
- if data[76]:
- s.sendto("212".encode(), (target_ip, target_port))
- d212.config(color='#000000')
- data[76]=0
- else:
- s.sendto("212".encode(), (target_ip, target_port))
- d212.config(color='#FF0000')
- data[76]=1
- def button_click213():
- global data
- if data[77]:
- s.sendto("213".encode(), (target_ip, target_port))
- d213.config(color='#000000')
- data[77]=0
- else:
- s.sendto("213".encode(), (target_ip, target_port))
- d213.config(color='#FF0000')
- data[77]=1
- def button_click214():
- global data
- if data[78]:
- s.sendto("214".encode(), (target_ip, target_port))
- d214.config(color='#000000')
- data[78]=0
- else:
- s.sendto("214".encode(), (target_ip, target_port))
- d214.config(color='#FF0000')
- data[78]=1
- def button_click215():
- global data
- if data[79]:
- s.sendto("215".encode(), (target_ip, target_port))
- d215.config(color='#000000')
- data[79]=0
- else:
- s.sendto("215".encode(), (target_ip, target_port))
- d215.config(color='#FF0000')
- data[79]=1
- def button_click216():
- global data
- if data[80]:
- s.sendto("216".encode(), (target_ip, target_port))
- d216.config(color='#000000')
- data[80]=0
- else:
- s.sendto("216".encode(), (target_ip, target_port))
- d216.config(color='#FF0000')
- data[80]=1
- def button_click217():
- global data
- if data[81]:
- s.sendto("217".encode(), (target_ip, target_port))
- d217.config(color='#000000')
- data[81]=0
- else:
- s.sendto("217".encode(), (target_ip, target_port))
- d217.config(color='#FF0000')
- data[81]=1
- def button_click218():
- global data
- if data[82]:
- s.sendto("218".encode(), (target_ip, target_port))
- d218.config(color='#000000')
- data[82]=0
- else:
- s.sendto("218".encode(), (target_ip, target_port))
- d218.config(color='#FF0000')
- data[82]=1
- def button_click219():
- global data
- if data[83]:
- s.sendto("219".encode(), (target_ip, target_port))
- d219.config(color='#000000')
- data[83]=0
- else:
- s.sendto("219".encode(), (target_ip, target_port))
- d219.config(color='#FF0000')
- data[83]=1
- def button_click220():
- global data
- if data[84]:
- s.sendto("220".encode(), (target_ip, target_port))
- d220.config(color='#000000')
- data[84]=0
- else:
- s.sendto("220".encode(), (target_ip, target_port))
- d220.config(color='#FF0000')
- data[84]=1
- def button_click221():
- global data
- if data[85]:
- s.sendto("221".encode(), (target_ip, target_port))
- d221.config(color='#000000')
- data[85]=0
- else:
- s.sendto("221".encode(), (target_ip, target_port))
- d221.config(color='#FF0000')
- data[85]=1
- def button_click222():
- global data
- if data[86]:
- s.sendto("222".encode(), (target_ip, target_port))
- d222.config(color='#000000')
- data[86]=0
- else:
- s.sendto("222".encode(), (target_ip, target_port))
- d222.config(color='#FF0000')
- data[86]=1
- def button_click223():
- global data
- if data[87]:
- s.sendto("223".encode(), (target_ip, target_port))
- d223.config(color='#000000')
- data[87]=0
- else:
- s.sendto("223".encode(), (target_ip, target_port))
- d223.config(color='#FF0000')
- data[87]=1
- def button_click224():
- global data
- if data[88]:
- s.sendto("224".encode(), (target_ip, target_port))
- d224.config(color='#000000')
- data[88]=0
- else:
- s.sendto("224".encode(), (target_ip, target_port))
- d224.config(color='#FF0000')
- data[88]=1
- def button_click225():
- global data
- if data[89]:
- s.sendto("225".encode(), (target_ip, target_port))
- d225.config(color='#000000')
- data[89]=0
- else:
- s.sendto("225".encode(), (target_ip, target_port))
- d225.config(color='#FF0000')
- data[89]=1
- def button_click226():
- global data
- if data[90]:
- s.sendto("226".encode(), (target_ip, target_port))
- d226.config(color='#000000')
- data[90]=0
- else:
- s.sendto("226".encode(), (target_ip, target_port))
- d226.config(color='#FF0000')
- data[90]=1
- def button_click227():
- global data
- if data[91]:
- s.sendto("227".encode(), (target_ip, target_port))
- d227.config(color='#000000')
- data[91]=0
- else:
- s.sendto("227".encode(), (target_ip, target_port))
- d227.config(color='#FF0000')
- data[91]=1
- def button_click228():
- global data
- if data[92]:
- s.sendto("228".encode(), (target_ip, target_port))
- d228.config(color='#000000')
- data[92]=0
- else:
- s.sendto("228".encode(), (target_ip, target_port))
- d228.config(color='#FF0000')
- data[92]=1
- def button_click229():
- global data
- if data[93]:
- s.sendto("229".encode(), (target_ip, target_port))
- d229.config(color='#000000')
- data[93]=0
- else:
- s.sendto("229".encode(), (target_ip, target_port))
- d229.config(color='#FF0000')
- data[93]=1
- def button_click230():
- global data
- if data[94]:
- s.sendto("230".encode(), (target_ip, target_port))
- d230.config(color='#000000')
- data[94]=0
- else:
- s.sendto("230".encode(), (target_ip, target_port))
- d230.config(color='#FF0000')
- data[94]=1
- def button_click231():
- global data
- if data[95]:
- s.sendto("231".encode(), (target_ip, target_port))
- d231.config(color='#000000')
- data[95]=0
- else:
- s.sendto("231".encode(), (target_ip, target_port))
- d231.config(color='#FF0000')
- data[95]=1
复制代码
2)生成“灯珠”程序
- import math
- fileObj = open("Mind1+.txt", "w", encoding="UTF8")
-
- for k in range(0,3):
- for i in range(0,32):
- if i<10:
- j="0"+str(i)
- else:
- j=str(i)
- num1=math.floor((32*k+i)/12)
- num2=(32*k+i)%12
- fileObj.write("d"+str(k)+j+"=u_gui.fill_circle(x="+str(240-(13+26*num1))+",y="+str(13+26*num2)+",r=13,color="#000000")\r")
- fileObj.write("d"+str(k)+j+".config(onclick=button_click"+str(k)+j+")\r")
- fileObj.close()
复制代码
生成的“灯珠”程序代码
- d000=u_gui.fill_circle(x=227,y=13,r=13,color="#000000")
- d000.config(onclick=button_click000)
- d001=u_gui.fill_circle(x=227,y=39,r=13,color="#000000")
- d001.config(onclick=button_click001)
- d002=u_gui.fill_circle(x=227,y=65,r=13,color="#000000")
- d002.config(onclick=button_click002)
- d003=u_gui.fill_circle(x=227,y=91,r=13,color="#000000")
- d003.config(onclick=button_click003)
- d004=u_gui.fill_circle(x=227,y=117,r=13,color="#000000")
- d004.config(onclick=button_click004)
- d005=u_gui.fill_circle(x=227,y=143,r=13,color="#000000")
- d005.config(onclick=button_click005)
- d006=u_gui.fill_circle(x=227,y=169,r=13,color="#000000")
- d006.config(onclick=button_click006)
- d007=u_gui.fill_circle(x=227,y=195,r=13,color="#000000")
- d007.config(onclick=button_click007)
- d008=u_gui.fill_circle(x=227,y=221,r=13,color="#000000")
- d008.config(onclick=button_click008)
- d009=u_gui.fill_circle(x=227,y=247,r=13,color="#000000")
- d009.config(onclick=button_click009)
- d010=u_gui.fill_circle(x=227,y=273,r=13,color="#000000")
- d010.config(onclick=button_click010)
- d011=u_gui.fill_circle(x=227,y=299,r=13,color="#000000")
- d011.config(onclick=button_click011)
- d012=u_gui.fill_circle(x=201,y=13,r=13,color="#000000")
- d012.config(onclick=button_click012)
- d013=u_gui.fill_circle(x=201,y=39,r=13,color="#000000")
- d013.config(onclick=button_click013)
- d014=u_gui.fill_circle(x=201,y=65,r=13,color="#000000")
- d014.config(onclick=button_click014)
- d015=u_gui.fill_circle(x=201,y=91,r=13,color="#000000")
- d015.config(onclick=button_click015)
- d016=u_gui.fill_circle(x=201,y=117,r=13,color="#000000")
- d016.config(onclick=button_click016)
- d017=u_gui.fill_circle(x=201,y=143,r=13,color="#000000")
- d017.config(onclick=button_click017)
- d018=u_gui.fill_circle(x=201,y=169,r=13,color="#000000")
- d018.config(onclick=button_click018)
- d019=u_gui.fill_circle(x=201,y=195,r=13,color="#000000")
- d019.config(onclick=button_click019)
- d020=u_gui.fill_circle(x=201,y=221,r=13,color="#000000")
- d020.config(onclick=button_click020)
- d021=u_gui.fill_circle(x=201,y=247,r=13,color="#000000")
- d021.config(onclick=button_click021)
- d022=u_gui.fill_circle(x=201,y=273,r=13,color="#000000")
- d022.config(onclick=button_click022)
- d023=u_gui.fill_circle(x=201,y=299,r=13,color="#000000")
- d023.config(onclick=button_click023)
- d024=u_gui.fill_circle(x=175,y=13,r=13,color="#000000")
- d024.config(onclick=button_click024)
- d025=u_gui.fill_circle(x=175,y=39,r=13,color="#000000")
- d025.config(onclick=button_click025)
- d026=u_gui.fill_circle(x=175,y=65,r=13,color="#000000")
- d026.config(onclick=button_click026)
- d027=u_gui.fill_circle(x=175,y=91,r=13,color="#000000")
- d027.config(onclick=button_click027)
- d028=u_gui.fill_circle(x=175,y=117,r=13,color="#000000")
- d028.config(onclick=button_click028)
- d029=u_gui.fill_circle(x=175,y=143,r=13,color="#000000")
- d029.config(onclick=button_click029)
- d030=u_gui.fill_circle(x=175,y=169,r=13,color="#000000")
- d030.config(onclick=button_click030)
- d031=u_gui.fill_circle(x=175,y=195,r=13,color="#000000")
- d031.config(onclick=button_click031)
- d100=u_gui.fill_circle(x=175,y=221,r=13,color="#000000")
- d100.config(onclick=button_click100)
- d101=u_gui.fill_circle(x=175,y=247,r=13,color="#000000")
- d101.config(onclick=button_click101)
- d102=u_gui.fill_circle(x=175,y=273,r=13,color="#000000")
- d102.config(onclick=button_click102)
- d103=u_gui.fill_circle(x=175,y=299,r=13,color="#000000")
- d103.config(onclick=button_click103)
- d104=u_gui.fill_circle(x=149,y=13,r=13,color="#000000")
- d104.config(onclick=button_click104)
- d105=u_gui.fill_circle(x=149,y=39,r=13,color="#000000")
- d105.config(onclick=button_click105)
- d106=u_gui.fill_circle(x=149,y=65,r=13,color="#000000")
- d106.config(onclick=button_click106)
- d107=u_gui.fill_circle(x=149,y=91,r=13,color="#000000")
- d107.config(onclick=button_click107)
- d108=u_gui.fill_circle(x=149,y=117,r=13,color="#000000")
- d108.config(onclick=button_click108)
- d109=u_gui.fill_circle(x=149,y=143,r=13,color="#000000")
- d109.config(onclick=button_click109)
- d110=u_gui.fill_circle(x=149,y=169,r=13,color="#000000")
- d110.config(onclick=button_click110)
- d111=u_gui.fill_circle(x=149,y=195,r=13,color="#000000")
- d111.config(onclick=button_click111)
- d112=u_gui.fill_circle(x=149,y=221,r=13,color="#000000")
- d112.config(onclick=button_click112)
- d113=u_gui.fill_circle(x=149,y=247,r=13,color="#000000")
- d113.config(onclick=button_click113)
- d114=u_gui.fill_circle(x=149,y=273,r=13,color="#000000")
- d114.config(onclick=button_click114)
- d115=u_gui.fill_circle(x=149,y=299,r=13,color="#000000")
- d115.config(onclick=button_click115)
- d116=u_gui.fill_circle(x=123,y=13,r=13,color="#000000")
- d116.config(onclick=button_click116)
- d117=u_gui.fill_circle(x=123,y=39,r=13,color="#000000")
- d117.config(onclick=button_click117)
- d118=u_gui.fill_circle(x=123,y=65,r=13,color="#000000")
- d118.config(onclick=button_click118)
- d119=u_gui.fill_circle(x=123,y=91,r=13,color="#000000")
- d119.config(onclick=button_click119)
- d120=u_gui.fill_circle(x=123,y=117,r=13,color="#000000")
- d120.config(onclick=button_click120)
- d121=u_gui.fill_circle(x=123,y=143,r=13,color="#000000")
- d121.config(onclick=button_click121)
- d122=u_gui.fill_circle(x=123,y=169,r=13,color="#000000")
- d122.config(onclick=button_click122)
- d123=u_gui.fill_circle(x=123,y=195,r=13,color="#000000")
- d123.config(onclick=button_click123)
- d124=u_gui.fill_circle(x=123,y=221,r=13,color="#000000")
- d124.config(onclick=button_click124)
- d125=u_gui.fill_circle(x=123,y=247,r=13,color="#000000")
- d125.config(onclick=button_click125)
- d126=u_gui.fill_circle(x=123,y=273,r=13,color="#000000")
- d126.config(onclick=button_click126)
- d127=u_gui.fill_circle(x=123,y=299,r=13,color="#000000")
- d127.config(onclick=button_click127)
- d128=u_gui.fill_circle(x=97,y=13,r=13,color="#000000")
- d128.config(onclick=button_click128)
- d129=u_gui.fill_circle(x=97,y=39,r=13,color="#000000")
- d129.config(onclick=button_click129)
- d130=u_gui.fill_circle(x=97,y=65,r=13,color="#000000")
- d130.config(onclick=button_click130)
- d131=u_gui.fill_circle(x=97,y=91,r=13,color="#000000")
- d131.config(onclick=button_click131)
- d200=u_gui.fill_circle(x=97,y=117,r=13,color="#000000")
- d200.config(onclick=button_click200)
- d201=u_gui.fill_circle(x=97,y=143,r=13,color="#000000")
- d201.config(onclick=button_click201)
- d202=u_gui.fill_circle(x=97,y=169,r=13,color="#000000")
- d202.config(onclick=button_click202)
- d203=u_gui.fill_circle(x=97,y=195,r=13,color="#000000")
- d203.config(onclick=button_click203)
- d204=u_gui.fill_circle(x=97,y=221,r=13,color="#000000")
- d204.config(onclick=button_click204)
- d205=u_gui.fill_circle(x=97,y=247,r=13,color="#000000")
- d205.config(onclick=button_click205)
- d206=u_gui.fill_circle(x=97,y=273,r=13,color="#000000")
- d206.config(onclick=button_click206)
- d207=u_gui.fill_circle(x=97,y=299,r=13,color="#000000")
- d207.config(onclick=button_click207)
- d208=u_gui.fill_circle(x=71,y=13,r=13,color="#000000")
- d208.config(onclick=button_click208)
- d209=u_gui.fill_circle(x=71,y=39,r=13,color="#000000")
- d209.config(onclick=button_click209)
- d210=u_gui.fill_circle(x=71,y=65,r=13,color="#000000")
- d210.config(onclick=button_click210)
- d211=u_gui.fill_circle(x=71,y=91,r=13,color="#000000")
- d211.config(onclick=button_click211)
- d212=u_gui.fill_circle(x=71,y=117,r=13,color="#000000")
- d212.config(onclick=button_click212)
- d213=u_gui.fill_circle(x=71,y=143,r=13,color="#000000")
- d213.config(onclick=button_click213)
- d214=u_gui.fill_circle(x=71,y=169,r=13,color="#000000")
- d214.config(onclick=button_click214)
- d215=u_gui.fill_circle(x=71,y=195,r=13,color="#000000")
- d215.config(onclick=button_click215)
- d216=u_gui.fill_circle(x=71,y=221,r=13,color="#000000")
- d216.config(onclick=button_click216)
- d217=u_gui.fill_circle(x=71,y=247,r=13,color="#000000")
- d217.config(onclick=button_click217)
- d218=u_gui.fill_circle(x=71,y=273,r=13,color="#000000")
- d218.config(onclick=button_click218)
- d219=u_gui.fill_circle(x=71,y=299,r=13,color="#000000")
- d219.config(onclick=button_click219)
- d220=u_gui.fill_circle(x=45,y=13,r=13,color="#000000")
- d220.config(onclick=button_click220)
- d221=u_gui.fill_circle(x=45,y=39,r=13,color="#000000")
- d221.config(onclick=button_click221)
- d222=u_gui.fill_circle(x=45,y=65,r=13,color="#000000")
- d222.config(onclick=button_click222)
- d223=u_gui.fill_circle(x=45,y=91,r=13,color="#000000")
- d223.config(onclick=button_click223)
- d224=u_gui.fill_circle(x=45,y=117,r=13,color="#000000")
- d224.config(onclick=button_click224)
- d225=u_gui.fill_circle(x=45,y=143,r=13,color="#000000")
- d225.config(onclick=button_click225)
- d226=u_gui.fill_circle(x=45,y=169,r=13,color="#000000")
- d226.config(onclick=button_click226)
- d227=u_gui.fill_circle(x=45,y=195,r=13,color="#000000")
- d227.config(onclick=button_click227)
- d228=u_gui.fill_circle(x=45,y=221,r=13,color="#000000")
- d228.config(onclick=button_click228)
- d229=u_gui.fill_circle(x=45,y=247,r=13,color="#000000")
- d229.config(onclick=button_click229)
- d230=u_gui.fill_circle(x=45,y=273,r=13,color="#000000")
- d230.config(onclick=button_click230)
- d231=u_gui.fill_circle(x=45,y=299,r=13,color="#000000")
- d231.config(onclick=button_click231)
复制代码
三、完整程序
- from unihiker import GUI
- import socket
-
- # 创建UDP socket
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-
- # 绑定要发送的IP地址和端口号
- target_ip = '192.168.31.210'
- target_port = 2390
- data=[]
- for i in range(0,96):
- data.append(0)
- # 事件回调函数
- def button_click000():
- global data
- if data[0]:
- s.sendto("000".encode(), (target_ip, target_port))
- d000.config(color='#000000')
- data[0]=0
- else:
- s.sendto("000".encode(), (target_ip, target_port))
- d000.config(color='#FF0000')
- data[0]=1
- def button_click001():
- global data
- if data[1]:
- s.sendto("001".encode(), (target_ip, target_port))
- d001.config(color='#000000')
- data[1]=0
- else:
- s.sendto("001".encode(), (target_ip, target_port))
- d001.config(color='#FF0000')
- data[1]=1
- def button_click002():
- global data
- if data[2]:
- s.sendto("002".encode(), (target_ip, target_port))
- d002.config(color='#000000')
- data[2]=0
- else:
- s.sendto("002".encode(), (target_ip, target_port))
- d002.config(color='#FF0000')
- data[2]=1
- def button_click003():
- global data
- if data[3]:
- s.sendto("003".encode(), (target_ip, target_port))
- d003.config(color='#000000')
- data[3]=0
- else:
- s.sendto("003".encode(), (target_ip, target_port))
- d003.config(color='#FF0000')
- data[3]=1
- def button_click004():
- global data
- if data[4]:
- s.sendto("004".encode(), (target_ip, target_port))
- d004.config(color='#000000')
- data[4]=0
- else:
- s.sendto("004".encode(), (target_ip, target_port))
- d004.config(color='#FF0000')
- data[4]=1
- def button_click005():
- global data
- if data[5]:
- s.sendto("005".encode(), (target_ip, target_port))
- d005.config(color='#000000')
- data[5]=0
- else:
- s.sendto("005".encode(), (target_ip, target_port))
- d005.config(color='#FF0000')
- data[5]=1
- def button_click006():
- global data
- if data[6]:
- s.sendto("006".encode(), (target_ip, target_port))
- d006.config(color='#000000')
- data[6]=0
- else:
- s.sendto("006".encode(), (target_ip, target_port))
- d006.config(color='#FF0000')
- data[6]=1
- def button_click007():
- global data
- if data[7]:
- s.sendto("007".encode(), (target_ip, target_port))
- d007.config(color='#000000')
- data[7]=0
- else:
- s.sendto("007".encode(), (target_ip, target_port))
- d007.config(color='#FF0000')
- data[7]=1
- def button_click008():
- global data
- if data[8]:
- s.sendto("008".encode(), (target_ip, target_port))
- d008.config(color='#000000')
- data[8]=0
- else:
- s.sendto("008".encode(), (target_ip, target_port))
- d008.config(color='#FF0000')
- data[8]=1
- def button_click009():
- global data
- if data[9]:
- s.sendto("009".encode(), (target_ip, target_port))
- d009.config(color='#000000')
- data[9]=0
- else:
- s.sendto("009".encode(), (target_ip, target_port))
- d009.config(color='#FF0000')
- data[9]=1
- def button_click010():
- global data
- if data[10]:
- s.sendto("010".encode(), (target_ip, target_port))
- d010.config(color='#000000')
- data[10]=0
- else:
- s.sendto("010".encode(), (target_ip, target_port))
- d010.config(color='#FF0000')
- data[10]=1
- def button_click011():
- global data
- if data[11]:
- s.sendto("011".encode(), (target_ip, target_port))
- d011.config(color='#000000')
- data[11]=0
- else:
- s.sendto("011".encode(), (target_ip, target_port))
- d011.config(color='#FF0000')
- data[11]=1
- def button_click012():
- global data
- if data[12]:
- s.sendto("012".encode(), (target_ip, target_port))
- d012.config(color='#000000')
- data[12]=0
- else:
- s.sendto("012".encode(), (target_ip, target_port))
- d012.config(color='#FF0000')
- data[12]=1
- def button_click013():
- global data
- if data[13]:
- s.sendto("013".encode(), (target_ip, target_port))
- d013.config(color='#000000')
- data[13]=0
- else:
- s.sendto("013".encode(), (target_ip, target_port))
- d013.config(color='#FF0000')
- data[13]=1
- def button_click014():
- global data
- if data[14]:
- s.sendto("014".encode(), (target_ip, target_port))
- d014.config(color='#000000')
- data[14]=0
- else:
- s.sendto("014".encode(), (target_ip, target_port))
- d014.config(color='#FF0000')
- data[14]=1
- def button_click015():
- global data
- if data[15]:
- s.sendto("015".encode(), (target_ip, target_port))
- d015.config(color='#000000')
- data[15]=0
- else:
- s.sendto("015".encode(), (target_ip, target_port))
- d015.config(color='#FF0000')
- data[15]=1
- def button_click016():
- global data
- if data[16]:
- s.sendto("016".encode(), (target_ip, target_port))
- d016.config(color='#000000')
- data[16]=0
- else:
- s.sendto("016".encode(), (target_ip, target_port))
- d016.config(color='#FF0000')
- data[16]=1
- def button_click017():
- global data
- if data[17]:
- s.sendto("017".encode(), (target_ip, target_port))
- d017.config(color='#000000')
- data[17]=0
- else:
- s.sendto("017".encode(), (target_ip, target_port))
- d017.config(color='#FF0000')
- data[17]=1
- def button_click018():
- global data
- if data[18]:
- s.sendto("018".encode(), (target_ip, target_port))
- d018.config(color='#000000')
- data[18]=0
- else:
- s.sendto("018".encode(), (target_ip, target_port))
- d018.config(color='#FF0000')
- data[18]=1
- def button_click019():
- global data
- if data[19]:
- s.sendto("019".encode(), (target_ip, target_port))
- d019.config(color='#000000')
- data[19]=0
- else:
- s.sendto("019".encode(), (target_ip, target_port))
- d019.config(color='#FF0000')
- data[19]=1
- def button_click020():
- global data
- if data[20]:
- s.sendto("020".encode(), (target_ip, target_port))
- d020.config(color='#000000')
- data[20]=0
- else:
- s.sendto("020".encode(), (target_ip, target_port))
- d020.config(color='#FF0000')
- data[20]=1
- def button_click021():
- global data
- if data[21]:
- s.sendto("021".encode(), (target_ip, target_port))
- d021.config(color='#000000')
- data[21]=0
- else:
- s.sendto("021".encode(), (target_ip, target_port))
- d021.config(color='#FF0000')
- data[21]=1
- def button_click022():
- global data
- if data[22]:
- s.sendto("022".encode(), (target_ip, target_port))
- d022.config(color='#000000')
- data[22]=0
- else:
- s.sendto("022".encode(), (target_ip, target_port))
- d022.config(color='#FF0000')
- data[22]=1
- def button_click023():
- global data
- if data[23]:
- s.sendto("023".encode(), (target_ip, target_port))
- d023.config(color='#000000')
- data[23]=0
- else:
- s.sendto("023".encode(), (target_ip, target_port))
- d023.config(color='#FF0000')
- data[23]=1
- def button_click024():
- global data
- if data[24]:
- s.sendto("024".encode(), (target_ip, target_port))
- d024.config(color='#000000')
- data[24]=0
- else:
- s.sendto("024".encode(), (target_ip, target_port))
- d024.config(color='#FF0000')
- data[24]=1
- def button_click025():
- global data
- if data[25]:
- s.sendto("025".encode(), (target_ip, target_port))
- d025.config(color='#000000')
- data[25]=0
- else:
- s.sendto("025".encode(), (target_ip, target_port))
- d025.config(color='#FF0000')
- data[25]=1
- def button_click026():
- global data
- if data[26]:
- s.sendto("026".encode(), (target_ip, target_port))
- d026.config(color='#000000')
- data[26]=0
- else:
- s.sendto("026".encode(), (target_ip, target_port))
- d026.config(color='#FF0000')
- data[26]=1
- def button_click027():
- global data
- if data[27]:
- s.sendto("027".encode(), (target_ip, target_port))
- d027.config(color='#000000')
- data[27]=0
- else:
- s.sendto("027".encode(), (target_ip, target_port))
- d027.config(color='#FF0000')
- data[27]=1
- def button_click028():
- global data
- if data[28]:
- s.sendto("028".encode(), (target_ip, target_port))
- d028.config(color='#000000')
- data[28]=0
- else:
- s.sendto("028".encode(), (target_ip, target_port))
- d028.config(color='#FF0000')
- data[28]=1
- def button_click029():
- global data
- if data[29]:
- s.sendto("029".encode(), (target_ip, target_port))
- d029.config(color='#000000')
- data[29]=0
- else:
- s.sendto("029".encode(), (target_ip, target_port))
- d029.config(color='#FF0000')
- data[29]=1
- def button_click030():
- global data
- if data[30]:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#000000')
- data[30]=0
- else:
- s.sendto("030".encode(), (target_ip, target_port))
- d030.config(color='#FF0000')
- data[30]=1
- def button_click031():
- global data
- if data[31]:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#000000')
- data[31]=0
- else:
- s.sendto("031".encode(), (target_ip, target_port))
- d031.config(color='#FF0000')
- data[31]=1
- def button_click100():
- global data
- if data[32]:
- s.sendto("100".encode(), (target_ip, target_port))
- d100.config(color='#000000')
- data[32]=0
- else:
- s.sendto("100".encode(), (target_ip, target_port))
- d100.config(color='#FF0000')
- data[32]=1
- def button_click101():
- global data
- if data[33]:
- s.sendto("101".encode(), (target_ip, target_port))
- d101.config(color='#000000')
- data[33]=0
- else:
- s.sendto("101".encode(), (target_ip, target_port))
- d101.config(color='#FF0000')
- data[33]=1
- def button_click102():
- global data
- if data[34]:
- s.sendto("102".encode(), (target_ip, target_port))
- d102.config(color='#000000')
- data[34]=0
- else:
- s.sendto("102".encode(), (target_ip, target_port))
- d102.config(color='#FF0000')
- data[34]=1
- def button_click103():
- global data
- if data[35]:
- s.sendto("103".encode(), (target_ip, target_port))
- d103.config(color='#000000')
- data[35]=0
- else:
- s.sendto("103".encode(), (target_ip, target_port))
- d103.config(color='#FF0000')
- data[35]=1
- def button_click104():
- global data
- if data[36]:
- s.sendto("104".encode(), (target_ip, target_port))
- d104.config(color='#000000')
- data[36]=0
- else:
- s.sendto("104".encode(), (target_ip, target_port))
- d104.config(color='#FF0000')
- data[36]=1
- def button_click105():
- global data
- if data[37]:
- s.sendto("105".encode(), (target_ip, target_port))
- d105.config(color='#000000')
- data[37]=0
- else:
- s.sendto("105".encode(), (target_ip, target_port))
- d105.config(color='#FF0000')
- data[37]=1
- def button_click106():
- global data
- if data[38]:
- s.sendto("106".encode(), (target_ip, target_port))
- d106.config(color='#000000')
- data[38]=0
- else:
- s.sendto("106".encode(), (target_ip, target_port))
- d106.config(color='#FF0000')
- data[38]=1
- def button_click107():
- global data
- if data[39]:
- s.sendto("107".encode(), (target_ip, target_port))
- d107.config(color='#000000')
- data[39]=0
- else:
- s.sendto("107".encode(), (target_ip, target_port))
- d107.config(color='#FF0000')
- data[39]=1
- def button_click108():
- global data
- if data[40]:
- s.sendto("108".encode(), (target_ip, target_port))
- d108.config(color='#000000')
- data[40]=0
- else:
- s.sendto("108".encode(), (target_ip, target_port))
- d108.config(color='#FF0000')
- data[40]=1
- def button_click109():
- global data
- if data[41]:
- s.sendto("109".encode(), (target_ip, target_port))
- d109.config(color='#000000')
- data[41]=0
- else:
- s.sendto("109".encode(), (target_ip, target_port))
- d109.config(color='#FF0000')
- data[41]=1
- def button_click110():
- global data
- if data[42]:
- s.sendto("110".encode(), (target_ip, target_port))
- d110.config(color='#000000')
- data[42]=0
- else:
- s.sendto("110".encode(), (target_ip, target_port))
- d110.config(color='#FF0000')
- data[42]=1
- def button_click111():
- global data
- if data[43]:
- s.sendto("111".encode(), (target_ip, target_port))
- d111.config(color='#000000')
- data[43]=0
- else:
- s.sendto("111".encode(), (target_ip, target_port))
- d111.config(color='#FF0000')
- data[43]=1
- def button_click112():
- global data
- if data[44]:
- s.sendto("112".encode(), (target_ip, target_port))
- d112.config(color='#000000')
- data[44]=0
- else:
- s.sendto("112".encode(), (target_ip, target_port))
- d112.config(color='#FF0000')
- data[44]=1
- def button_click113():
- global data
- if data[45]:
- s.sendto("113".encode(), (target_ip, target_port))
- d113.config(color='#000000')
- data[45]=0
- else:
- s.sendto("113".encode(), (target_ip, target_port))
- d113.config(color='#FF0000')
- data[45]=1
- def button_click114():
- global data
- if data[46]:
- s.sendto("114".encode(), (target_ip, target_port))
- d114.config(color='#000000')
- data[46]=0
- else:
- s.sendto("114".encode(), (target_ip, target_port))
- d114.config(color='#FF0000')
- data[46]=1
- def button_click115():
- global data
- if data[47]:
- s.sendto("115".encode(), (target_ip, target_port))
- d115.config(color='#000000')
- data[47]=0
- else:
- s.sendto("115".encode(), (target_ip, target_port))
- d115.config(color='#FF0000')
- data[47]=1
- def button_click116():
- global data
- if data[48]:
- s.sendto("116".encode(), (target_ip, target_port))
- d116.config(color='#000000')
- data[48]=0
- else:
- s.sendto("116".encode(), (target_ip, target_port))
- d116.config(color='#FF0000')
- data[48]=1
- def button_click117():
- global data
- if data[49]:
- s.sendto("117".encode(), (target_ip, target_port))
- d117.config(color='#000000')
- data[49]=0
- else:
- s.sendto("117".encode(), (target_ip, target_port))
- d117.config(color='#FF0000')
- data[49]=1
- def button_click118():
- global data
- if data[50]:
- s.sendto("118".encode(), (target_ip, target_port))
- d118.config(color='#000000')
- data[50]=0
- else:
- s.sendto("118".encode(), (target_ip, target_port))
- d118.config(color='#FF0000')
- data[50]=1
- def button_click119():
- global data
- if data[51]:
- s.sendto("119".encode(), (target_ip, target_port))
- d119.config(color='#000000')
- data[51]=0
- else:
- s.sendto("119".encode(), (target_ip, target_port))
- d119.config(color='#FF0000')
- data[51]=1
- def button_click120():
- global data
- if data[52]:
- s.sendto("120".encode(), (target_ip, target_port))
- d120.config(color='#000000')
- data[52]=0
- else:
- s.sendto("120".encode(), (target_ip, target_port))
- d120.config(color='#FF0000')
- data[52]=1
- def button_click121():
- global data
- if data[53]:
- s.sendto("121".encode(), (target_ip, target_port))
- d121.config(color='#000000')
- data[53]=0
- else:
- s.sendto("121".encode(), (target_ip, target_port))
- d121.config(color='#FF0000')
- data[53]=1
- def button_click122():
- global data
- if data[54]:
- s.sendto("122".encode(), (target_ip, target_port))
- d122.config(color='#000000')
- data[54]=0
- else:
- s.sendto("122".encode(), (target_ip, target_port))
- d122.config(color='#FF0000')
- data[54]=1
- def button_click123():
- global data
- if data[55]:
- s.sendto("123".encode(), (target_ip, target_port))
- d123.config(color='#000000')
- data[55]=0
- else:
- s.sendto("123".encode(), (target_ip, target_port))
- d123.config(color='#FF0000')
- data[55]=1
- def button_click124():
- global data
- if data[56]:
- s.sendto("124".encode(), (target_ip, target_port))
- d124.config(color='#000000')
- data[56]=0
- else:
- s.sendto("124".encode(), (target_ip, target_port))
- d124.config(color='#FF0000')
- data[56]=1
- def button_click125():
- global data
- if data[57]:
- s.sendto("125".encode(), (target_ip, target_port))
- d125.config(color='#000000')
- data[57]=0
- else:
- s.sendto("125".encode(), (target_ip, target_port))
- d125.config(color='#FF0000')
- data[57]=1
- def button_click126():
- global data
- if data[58]:
- s.sendto("126".encode(), (target_ip, target_port))
- d126.config(color='#000000')
- data[58]=0
- else:
- s.sendto("126".encode(), (target_ip, target_port))
- d126.config(color='#FF0000')
- data[58]=1
- def button_click127():
- global data
- if data[59]:
- s.sendto("127".encode(), (target_ip, target_port))
- d127.config(color='#000000')
- data[59]=0
- else:
- s.sendto("127".encode(), (target_ip, target_port))
- d127.config(color='#FF0000')
- data[59]=1
- def button_click128():
- global data
- if data[60]:
- s.sendto("128".encode(), (target_ip, target_port))
- d128.config(color='#000000')
- data[60]=0
- else:
- s.sendto("128".encode(), (target_ip, target_port))
- d128.config(color='#FF0000')
- data[60]=1
- def button_click129():
- global data
- if data[61]:
- s.sendto("129".encode(), (target_ip, target_port))
- d129.config(color='#000000')
- data[61]=0
- else:
- s.sendto("129".encode(), (target_ip, target_port))
- d129.config(color='#FF0000')
- data[61]=1
- def button_click130():
- global data
- if data[62]:
- s.sendto("130".encode(), (target_ip, target_port))
- d130.config(color='#000000')
- data[62]=0
- else:
- s.sendto("130".encode(), (target_ip, target_port))
- d130.config(color='#FF0000')
- data[62]=1
- def button_click131():
- global data
- if data[63]:
- s.sendto("131".encode(), (target_ip, target_port))
- d131.config(color='#000000')
- data[63]=0
- else:
- s.sendto("131".encode(), (target_ip, target_port))
- d131.config(color='#FF0000')
- data[63]=1
- def button_click200():
- global data
- if data[64]:
- s.sendto("200".encode(), (target_ip, target_port))
- d200.config(color='#000000')
- data[64]=0
- else:
- s.sendto("200".encode(), (target_ip, target_port))
- d200.config(color='#FF0000')
- data[64]=1
- def button_click201():
- global data
- if data[65]:
- s.sendto("201".encode(), (target_ip, target_port))
- d201.config(color='#000000')
- data[65]=0
- else:
- s.sendto("201".encode(), (target_ip, target_port))
- d201.config(color='#FF0000')
- data[65]=1
- def button_click202():
- global data
- if data[66]:
- s.sendto("202".encode(), (target_ip, target_port))
- d202.config(color='#000000')
- data[66]=0
- else:
- s.sendto("202".encode(), (target_ip, target_port))
- d202.config(color='#FF0000')
- data[66]=1
- def button_click203():
- global data
- if data[67]:
- s.sendto("203".encode(), (target_ip, target_port))
- d203.config(color='#000000')
- data[67]=0
- else:
- s.sendto("203".encode(), (target_ip, target_port))
- d203.config(color='#FF0000')
- data[67]=1
- def button_click204():
- global data
- if data[68]:
- s.sendto("204".encode(), (target_ip, target_port))
- d204.config(color='#000000')
- data[68]=0
- else:
- s.sendto("204".encode(), (target_ip, target_port))
- d204.config(color='#FF0000')
- data[68]=1
- def button_click205():
- global data
- if data[69]:
- s.sendto("205".encode(), (target_ip, target_port))
- d205.config(color='#000000')
- data[69]=0
- else:
- s.sendto("205".encode(), (target_ip, target_port))
- d205.config(color='#FF0000')
- data[69]=1
- def button_click206():
- global data
- if data[70]:
- s.sendto("206".encode(), (target_ip, target_port))
- d206.config(color='#000000')
- data[70]=0
- else:
- s.sendto("206".encode(), (target_ip, target_port))
- d206.config(color='#FF0000')
- data[70]=1
- def button_click207():
- global data
- if data[71]:
- s.sendto("207".encode(), (target_ip, target_port))
- d207.config(color='#000000')
- data[71]=0
- else:
- s.sendto("207".encode(), (target_ip, target_port))
- d207.config(color='#FF0000')
- data[71]=1
- def button_click208():
- global data
- if data[72]:
- s.sendto("208".encode(), (target_ip, target_port))
- d208.config(color='#000000')
- data[72]=0
- else:
- s.sendto("208".encode(), (target_ip, target_port))
- d208.config(color='#FF0000')
- data[72]=1
- def button_click209():
- global data
- if data[73]:
- s.sendto("209".encode(), (target_ip, target_port))
- d209.config(color='#000000')
- data[73]=0
- else:
- s.sendto("209".encode(), (target_ip, target_port))
- d209.config(color='#FF0000')
- data[73]=1
- def button_click210():
- global data
- if data[74]:
- s.sendto("210".encode(), (target_ip, target_port))
- d210.config(color='#000000')
- data[74]=0
- else:
- s.sendto("210".encode(), (target_ip, target_port))
- d210.config(color='#FF0000')
- data[74]=1
- def button_click211():
- global data
- if data[75]:
- s.sendto("211".encode(), (target_ip, target_port))
- d211.config(color='#000000')
- data[75]=0
- else:
- s.sendto("211".encode(), (target_ip, target_port))
- d211.config(color='#FF0000')
- data[75]=1
- def button_click212():
- global data
- if data[76]:
- s.sendto("212".encode(), (target_ip, target_port))
- d212.config(color='#000000')
- data[76]=0
- else:
- s.sendto("212".encode(), (target_ip, target_port))
- d212.config(color='#FF0000')
- data[76]=1
- def button_click213():
- global data
- if data[77]:
- s.sendto("213".encode(), (target_ip, target_port))
- d213.config(color='#000000')
- data[77]=0
- else:
- s.sendto("213".encode(), (target_ip, target_port))
- d213.config(color='#FF0000')
- data[77]=1
- def button_click214():
- global data
- if data[78]:
- s.sendto("214".encode(), (target_ip, target_port))
- d214.config(color='#000000')
- data[78]=0
- else:
- s.sendto("214".encode(), (target_ip, target_port))
- d214.config(color='#FF0000')
- data[78]=1
- def button_click215():
- global data
- if data[79]:
- s.sendto("215".encode(), (target_ip, target_port))
- d215.config(color='#000000')
- data[79]=0
- else:
- s.sendto("215".encode(), (target_ip, target_port))
- d215.config(color='#FF0000')
- data[79]=1
- def button_click216():
- global data
- if data[80]:
- s.sendto("216".encode(), (target_ip, target_port))
- d216.config(color='#000000')
- data[80]=0
- else:
- s.sendto("216".encode(), (target_ip, target_port))
- d216.config(color='#FF0000')
- data[80]=1
- def button_click217():
- global data
- if data[81]:
- s.sendto("217".encode(), (target_ip, target_port))
- d217.config(color='#000000')
- data[81]=0
- else:
- s.sendto("217".encode(), (target_ip, target_port))
- d217.config(color='#FF0000')
- data[81]=1
- def button_click218():
- global data
- if data[82]:
- s.sendto("218".encode(), (target_ip, target_port))
- d218.config(color='#000000')
- data[82]=0
- else:
- s.sendto("218".encode(), (target_ip, target_port))
- d218.config(color='#FF0000')
- data[82]=1
- def button_click219():
- global data
- if data[83]:
- s.sendto("219".encode(), (target_ip, target_port))
- d219.config(color='#000000')
- data[83]=0
- else:
- s.sendto("219".encode(), (target_ip, target_port))
- d219.config(color='#FF0000')
- data[83]=1
- def button_click220():
- global data
- if data[84]:
- s.sendto("220".encode(), (target_ip, target_port))
- d220.config(color='#000000')
- data[84]=0
- else:
- s.sendto("220".encode(), (target_ip, target_port))
- d220.config(color='#FF0000')
- data[84]=1
- def button_click221():
- global data
- if data[85]:
- s.sendto("221".encode(), (target_ip, target_port))
- d221.config(color='#000000')
- data[85]=0
- else:
- s.sendto("221".encode(), (target_ip, target_port))
- d221.config(color='#FF0000')
- data[85]=1
- def button_click222():
- global data
- if data[86]:
- s.sendto("222".encode(), (target_ip, target_port))
- d222.config(color='#000000')
- data[86]=0
- else:
- s.sendto("222".encode(), (target_ip, target_port))
- d222.config(color='#FF0000')
- data[86]=1
- def button_click223():
- global data
- if data[87]:
- s.sendto("223".encode(), (target_ip, target_port))
- d223.config(color='#000000')
- data[87]=0
- else:
- s.sendto("223".encode(), (target_ip, target_port))
- d223.config(color='#FF0000')
- data[87]=1
- def button_click224():
- global data
- if data[88]:
- s.sendto("224".encode(), (target_ip, target_port))
- d224.config(color='#000000')
- data[88]=0
- else:
- s.sendto("224".encode(), (target_ip, target_port))
- d224.config(color='#FF0000')
- data[88]=1
- def button_click225():
- global data
- if data[89]:
- s.sendto("225".encode(), (target_ip, target_port))
- d225.config(color='#000000')
- data[89]=0
- else:
- s.sendto("225".encode(), (target_ip, target_port))
- d225.config(color='#FF0000')
- data[89]=1
- def button_click226():
- global data
- if data[90]:
- s.sendto("226".encode(), (target_ip, target_port))
- d226.config(color='#000000')
- data[90]=0
- else:
- s.sendto("226".encode(), (target_ip, target_port))
- d226.config(color='#FF0000')
- data[90]=1
- def button_click227():
- global data
- if data[91]:
- s.sendto("227".encode(), (target_ip, target_port))
- d227.config(color='#000000')
- data[91]=0
- else:
- s.sendto("227".encode(), (target_ip, target_port))
- d227.config(color='#FF0000')
- data[91]=1
- def button_click228():
- global data
- if data[92]:
- s.sendto("228".encode(), (target_ip, target_port))
- d228.config(color='#000000')
- data[92]=0
- else:
- s.sendto("228".encode(), (target_ip, target_port))
- d228.config(color='#FF0000')
- data[92]=1
- def button_click229():
- global data
- if data[93]:
- s.sendto("229".encode(), (target_ip, target_port))
- d229.config(color='#000000')
- data[93]=0
- else:
- s.sendto("229".encode(), (target_ip, target_port))
- d229.config(color='#FF0000')
- data[93]=1
- def button_click230():
- global data
- if data[94]:
- s.sendto("230".encode(), (target_ip, target_port))
- d230.config(color='#000000')
- data[94]=0
- else:
- s.sendto("230".encode(), (target_ip, target_port))
- d230.config(color='#FF0000')
- data[94]=1
- def button_click231():
- global data
- if data[95]:
- s.sendto("231".encode(), (target_ip, target_port))
- d231.config(color='#000000')
- data[95]=0
- else:
- s.sendto("231".encode(), (target_ip, target_port))
- d231.config(color='#FF0000')
- data[95]=1
-
- u_gui=GUI()
- d000=u_gui.fill_circle(x=227,y=13,r=13,color="#000000")
- d000.config(onclick=button_click000)
- d001=u_gui.fill_circle(x=227,y=39,r=13,color="#000000")
- d001.config(onclick=button_click001)
- d002=u_gui.fill_circle(x=227,y=65,r=13,color="#000000")
- d002.config(onclick=button_click002)
- d003=u_gui.fill_circle(x=227,y=91,r=13,color="#000000")
- d003.config(onclick=button_click003)
- d004=u_gui.fill_circle(x=227,y=117,r=13,color="#000000")
- d004.config(onclick=button_click004)
- d005=u_gui.fill_circle(x=227,y=143,r=13,color="#000000")
- d005.config(onclick=button_click005)
- d006=u_gui.fill_circle(x=227,y=169,r=13,color="#000000")
- d006.config(onclick=button_click006)
- d007=u_gui.fill_circle(x=227,y=195,r=13,color="#000000")
- d007.config(onclick=button_click007)
- d008=u_gui.fill_circle(x=227,y=221,r=13,color="#000000")
- d008.config(onclick=button_click008)
- d009=u_gui.fill_circle(x=227,y=247,r=13,color="#000000")
- d009.config(onclick=button_click009)
- d010=u_gui.fill_circle(x=227,y=273,r=13,color="#000000")
- d010.config(onclick=button_click010)
- d011=u_gui.fill_circle(x=227,y=299,r=13,color="#000000")
- d011.config(onclick=button_click011)
- d012=u_gui.fill_circle(x=201,y=13,r=13,color="#000000")
- d012.config(onclick=button_click012)
- d013=u_gui.fill_circle(x=201,y=39,r=13,color="#000000")
- d013.config(onclick=button_click013)
- d014=u_gui.fill_circle(x=201,y=65,r=13,color="#000000")
- d014.config(onclick=button_click014)
- d015=u_gui.fill_circle(x=201,y=91,r=13,color="#000000")
- d015.config(onclick=button_click015)
- d016=u_gui.fill_circle(x=201,y=117,r=13,color="#000000")
- d016.config(onclick=button_click016)
- d017=u_gui.fill_circle(x=201,y=143,r=13,color="#000000")
- d017.config(onclick=button_click017)
- d018=u_gui.fill_circle(x=201,y=169,r=13,color="#000000")
- d018.config(onclick=button_click018)
- d019=u_gui.fill_circle(x=201,y=195,r=13,color="#000000")
- d019.config(onclick=button_click019)
- d020=u_gui.fill_circle(x=201,y=221,r=13,color="#000000")
- d020.config(onclick=button_click020)
- d021=u_gui.fill_circle(x=201,y=247,r=13,color="#000000")
- d021.config(onclick=button_click021)
- d022=u_gui.fill_circle(x=201,y=273,r=13,color="#000000")
- d022.config(onclick=button_click022)
- d023=u_gui.fill_circle(x=201,y=299,r=13,color="#000000")
- d023.config(onclick=button_click023)
- d024=u_gui.fill_circle(x=175,y=13,r=13,color="#000000")
- d024.config(onclick=button_click024)
- d025=u_gui.fill_circle(x=175,y=39,r=13,color="#000000")
- d025.config(onclick=button_click025)
- d026=u_gui.fill_circle(x=175,y=65,r=13,color="#000000")
- d026.config(onclick=button_click026)
- d027=u_gui.fill_circle(x=175,y=91,r=13,color="#000000")
- d027.config(onclick=button_click027)
- d028=u_gui.fill_circle(x=175,y=117,r=13,color="#000000")
- d028.config(onclick=button_click028)
- d029=u_gui.fill_circle(x=175,y=143,r=13,color="#000000")
- d029.config(onclick=button_click029)
- d030=u_gui.fill_circle(x=175,y=169,r=13,color="#000000")
- d030.config(onclick=button_click030)
- d031=u_gui.fill_circle(x=175,y=195,r=13,color="#000000")
- d031.config(onclick=button_click031)
- d100=u_gui.fill_circle(x=175,y=221,r=13,color="#000000")
- d100.config(onclick=button_click100)
- d101=u_gui.fill_circle(x=175,y=247,r=13,color="#000000")
- d101.config(onclick=button_click101)
- d102=u_gui.fill_circle(x=175,y=273,r=13,color="#000000")
- d102.config(onclick=button_click102)
- d103=u_gui.fill_circle(x=175,y=299,r=13,color="#000000")
- d103.config(onclick=button_click103)
- d104=u_gui.fill_circle(x=149,y=13,r=13,color="#000000")
- d104.config(onclick=button_click104)
- d105=u_gui.fill_circle(x=149,y=39,r=13,color="#000000")
- d105.config(onclick=button_click105)
- d106=u_gui.fill_circle(x=149,y=65,r=13,color="#000000")
- d106.config(onclick=button_click106)
- d107=u_gui.fill_circle(x=149,y=91,r=13,color="#000000")
- d107.config(onclick=button_click107)
- d108=u_gui.fill_circle(x=149,y=117,r=13,color="#000000")
- d108.config(onclick=button_click108)
- d109=u_gui.fill_circle(x=149,y=143,r=13,color="#000000")
- d109.config(onclick=button_click109)
- d110=u_gui.fill_circle(x=149,y=169,r=13,color="#000000")
- d110.config(onclick=button_click110)
- d111=u_gui.fill_circle(x=149,y=195,r=13,color="#000000")
- d111.config(onclick=button_click111)
- d112=u_gui.fill_circle(x=149,y=221,r=13,color="#000000")
- d112.config(onclick=button_click112)
- d113=u_gui.fill_circle(x=149,y=247,r=13,color="#000000")
- d113.config(onclick=button_click113)
- d114=u_gui.fill_circle(x=149,y=273,r=13,color="#000000")
- d114.config(onclick=button_click114)
- d115=u_gui.fill_circle(x=149,y=299,r=13,color="#000000")
- d115.config(onclick=button_click115)
- d116=u_gui.fill_circle(x=123,y=13,r=13,color="#000000")
- d116.config(onclick=button_click116)
- d117=u_gui.fill_circle(x=123,y=39,r=13,color="#000000")
- d117.config(onclick=button_click117)
- d118=u_gui.fill_circle(x=123,y=65,r=13,color="#000000")
- d118.config(onclick=button_click118)
- d119=u_gui.fill_circle(x=123,y=91,r=13,color="#000000")
- d119.config(onclick=button_click119)
- d120=u_gui.fill_circle(x=123,y=117,r=13,color="#000000")
- d120.config(onclick=button_click120)
- d121=u_gui.fill_circle(x=123,y=143,r=13,color="#000000")
- d121.config(onclick=button_click121)
- d122=u_gui.fill_circle(x=123,y=169,r=13,color="#000000")
- d122.config(onclick=button_click122)
- d123=u_gui.fill_circle(x=123,y=195,r=13,color="#000000")
- d123.config(onclick=button_click123)
- d124=u_gui.fill_circle(x=123,y=221,r=13,color="#000000")
- d124.config(onclick=button_click124)
- d125=u_gui.fill_circle(x=123,y=247,r=13,color="#000000")
- d125.config(onclick=button_click125)
- d126=u_gui.fill_circle(x=123,y=273,r=13,color="#000000")
- d126.config(onclick=button_click126)
- d127=u_gui.fill_circle(x=123,y=299,r=13,color="#000000")
- d127.config(onclick=button_click127)
- d128=u_gui.fill_circle(x=97,y=13,r=13,color="#000000")
- d128.config(onclick=button_click128)
- d129=u_gui.fill_circle(x=97,y=39,r=13,color="#000000")
- d129.config(onclick=button_click129)
- d130=u_gui.fill_circle(x=97,y=65,r=13,color="#000000")
- d130.config(onclick=button_click130)
- d131=u_gui.fill_circle(x=97,y=91,r=13,color="#000000")
- d131.config(onclick=button_click131)
- d200=u_gui.fill_circle(x=97,y=117,r=13,color="#000000")
- d200.config(onclick=button_click200)
- d201=u_gui.fill_circle(x=97,y=143,r=13,color="#000000")
- d201.config(onclick=button_click201)
- d202=u_gui.fill_circle(x=97,y=169,r=13,color="#000000")
- d202.config(onclick=button_click202)
- d203=u_gui.fill_circle(x=97,y=195,r=13,color="#000000")
- d203.config(onclick=button_click203)
- d204=u_gui.fill_circle(x=97,y=221,r=13,color="#000000")
- d204.config(onclick=button_click204)
- d205=u_gui.fill_circle(x=97,y=247,r=13,color="#000000")
- d205.config(onclick=button_click205)
- d206=u_gui.fill_circle(x=97,y=273,r=13,color="#000000")
- d206.config(onclick=button_click206)
- d207=u_gui.fill_circle(x=97,y=299,r=13,color="#000000")
- d207.config(onclick=button_click207)
- d208=u_gui.fill_circle(x=71,y=13,r=13,color="#000000")
- d208.config(onclick=button_click208)
- d209=u_gui.fill_circle(x=71,y=39,r=13,color="#000000")
- d209.config(onclick=button_click209)
- d210=u_gui.fill_circle(x=71,y=65,r=13,color="#000000")
- d210.config(onclick=button_click210)
- d211=u_gui.fill_circle(x=71,y=91,r=13,color="#000000")
- d211.config(onclick=button_click211)
- d212=u_gui.fill_circle(x=71,y=117,r=13,color="#000000")
- d212.config(onclick=button_click212)
- d213=u_gui.fill_circle(x=71,y=143,r=13,color="#000000")
- d213.config(onclick=button_click213)
- d214=u_gui.fill_circle(x=71,y=169,r=13,color="#000000")
- d214.config(onclick=button_click214)
- d215=u_gui.fill_circle(x=71,y=195,r=13,color="#000000")
- d215.config(onclick=button_click215)
- d216=u_gui.fill_circle(x=71,y=221,r=13,color="#000000")
- d216.config(onclick=button_click216)
- d217=u_gui.fill_circle(x=71,y=247,r=13,color="#000000")
- d217.config(onclick=button_click217)
- d218=u_gui.fill_circle(x=71,y=273,r=13,color="#000000")
- d218.config(onclick=button_click218)
- d219=u_gui.fill_circle(x=71,y=299,r=13,color="#000000")
- d219.config(onclick=button_click219)
- d220=u_gui.fill_circle(x=45,y=13,r=13,color="#000000")
- d220.config(onclick=button_click220)
- d221=u_gui.fill_circle(x=45,y=39,r=13,color="#000000")
- d221.config(onclick=button_click221)
- d222=u_gui.fill_circle(x=45,y=65,r=13,color="#000000")
- d222.config(onclick=button_click222)
- d223=u_gui.fill_circle(x=45,y=91,r=13,color="#000000")
- d223.config(onclick=button_click223)
- d224=u_gui.fill_circle(x=45,y=117,r=13,color="#000000")
- d224.config(onclick=button_click224)
- d225=u_gui.fill_circle(x=45,y=143,r=13,color="#000000")
- d225.config(onclick=button_click225)
- d226=u_gui.fill_circle(x=45,y=169,r=13,color="#000000")
- d226.config(onclick=button_click226)
- d227=u_gui.fill_circle(x=45,y=195,r=13,color="#000000")
- d227.config(onclick=button_click227)
- d228=u_gui.fill_circle(x=45,y=221,r=13,color="#000000")
- d228.config(onclick=button_click228)
- d229=u_gui.fill_circle(x=45,y=247,r=13,color="#000000")
- d229.config(onclick=button_click229)
- d230=u_gui.fill_circle(x=45,y=273,r=13,color="#000000")
- d230.config(onclick=button_click230)
- d231=u_gui.fill_circle(x=45,y=299,r=13,color="#000000")
- d231.config(onclick=button_click231)
-
-
- while 1:
- pass
- s.close()
复制代码
四、演示视频
|