I am new to Python. I try to use it to create a GUI, in order to control my arduino.
Since i don't fully understand python, much less Tkinter or pySerial, i found a snippet of code online.
The snippet is supposed to create a GUI, and also there will be an option to select the COM port, to communicate with the arduino.
This is the code:
import serial.tools.list_ports
from tkinter import *
def on_select(selection):
# open the port and command it to start the LED blinking here
print(selection)
root = Tk()
ports = serial.tools.list_ports.comports()
default = StringVar(root, "Please Select Port")
OptionMenu(root, default, *ports, command=on_select).pack()
root.mainloop()
I run this (i have Python 3.8.2) and this is the error i get:
Traceback (most recent call last):
File "code.py", line 11, in <module>
OptionMenu(root, default, *ports, command=on_select).pack()
TypeError: __init__() missing 1 required positional argument: 'value'
However, i do not have an init() in order to pass an argument.