import serial s = serial.Serial('/dev/ttyS0') s.setRTS(False) def Ein(event): s.setRTS(1) def Aus(event): s.setRTS(0) from tkinter import * v = Tk() v.title("RTS - CTS") v.geometry('200x100+300+300') bTaster = Button(master=v, text="Taster") bTaster.bind('',Ein) bTaster.bind('',Aus) bTaster.place(x=30,y=37) c = Canvas(master=v,width=60,height=60) c.place(x=120,y=20) led = c.create_oval(10,10,50,50,fill='#550000') def Halt(): s.close() v.quit() v.destroy() v.protocol("WM_DELETE_WINDOW",Halt) def poll(): if s.getCTS(): c.itemconfig(led,fill='#ff0000') else: c.itemconfig(led,fill='#550000') v.after(20,poll) v.after(0,poll) v.mainloop()