Python Forum
Tkinter/Label/Arduino/ if Else condition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter/Label/Arduino/ if Else condition
#1
from Tkinter import *
root = Tk()
def connectToArduino():

    arduino = serial.Serial(arduinoPort,   serialTransferRate)
    arduino.timeout = None
    time.sleep(2)
    arduino.write("S\n")

    lab=Label(root, text="Connected")
    lab.grid()
    return arduino, lab
    lab.config(text="Disconnected")
arduino = connectToArduino()
arduino.pack()
root.mainloop()
When Arduino Connected serial to PC,Label has Connected MSG.When discomnected,MSG is disconnected.
How could i make if Else condition about Connected or Disconnected messages in Label?
Reply
#2
Send a request (ping) to the arduino to which it will respond if connected
If you get a response, just make sure it's not a timeout, and you have your
trigger for messages.

You can get some other idea's here: http://www.instructables.com/id/Interfac...-pySerial/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter: An image and label are not appearing. emont 7 397 Mar-21-2024, 03:00 PM
Last Post: deanhystad
  tkinter destroy label inside labelFrame Nick_tkinter 3 4,479 Sep-17-2023, 03:38 PM
Last Post: munirashraf9821
  [Tkinter] Updating Tkinter label using multiprocessing Agusms 6 3,046 Aug-15-2022, 07:10 PM
Last Post: menator01
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,664 Jun-26-2022, 06:26 PM
Last Post: menator01
  Super basic tkinter arduino issue Kurta 3 2,376 Jan-07-2021, 05:22 PM
Last Post: deanhystad
  tkinter: Image to Label Maryan 10 5,109 Oct-29-2020, 01:48 PM
Last Post: joe_momma
  Tkinter - How can I extend a label widget? TurboC 2 2,731 Oct-13-2020, 12:15 PM
Last Post: zazas321
  Tkinter: How to assign calculated value to a Label LoneStar 7 3,755 Sep-03-2020, 08:19 PM
Last Post: LoneStar
  changing tkinter label from thread nanok66 3 7,210 Jun-07-2020, 01:37 AM
Last Post: nanok66
  [Tkinter] tkinter How to pass label fiilename to another module? johnjh 0 1,974 Apr-17-2020, 11:34 PM
Last Post: johnjh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020