我正在设置一个新服务器,以在tkinter窗口上发送按钮命令并打印消息。当ı按下按钮时,消息“ A”将打印在tkinter窗口上,当我释放按钮时,消息“ B” '将一直打印,直到再次按下该按钮为止。我希望消息在tkinter窗口上连续更改,但是ı只要按下按钮,我都不知道如何将tkinter窗口保持在屏幕上。您能帮我吗?
import socket as s
import RPI.GPIO as GPIO
import Tkinter
port=9225
host=127.1.1.0
soket=s.socket(s.AD_INET,s.SOCK_STREAM)
GPIO.setmode(..)
GPIO.setup(..)
soket.connect(host,port)
signal low=bool(0)
signalhigh=bool(1)
while True:
if signallow:
if GPIO.input()==GPIO.HIGH:
output='1'
soket.sendall(output.encode('utf-8'))
print(output)
window=Tkinter.TK()
laebel=Tkinter.Label(text='A')
laebel.pack()
laebel.mainloop()
#ı should write a code here probably
signallow=0;
signahigh=1;
if signalhigh:
if GPIO.input()==GPIO.LOW
output=0
soket.sendall(output.encode('utf-8'))
print(output)
laebel=Tkinter.Label(text='B')
laebel.pack()
laebel.mainloop()
#ı should write a code here probably
signallow=1;
signalhigh=0;