I used to work with this way of coding and it worked fine, but after going back to it a few weeks later, it does not anymore. I simplidied my code so it is easy to type here.
import tkinter as tk
from tkinter import ttk
class wind(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
# id shutter
self.SOURCE_SHUTTER = "/dev/ttyUSB0"
# menu deroulant
self.listeFlux = ["/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3"]
self.listeCombo = ttk.Combobox(self, values=self.listeFlux)
self.listeCombo.current(0)
self.listeCombo.bind("<<ComboboxSelected>>", self.action)
self.listeCombo.pack(side="top")
def action(self):
self.SOURCE_SHUTTER = self.listeCombo.get()
print(self.SOURCE_SHUTTER)
if __name__ == "__main__":
win = wind()
win.geometry("800x600")
win.mainloop()
This code gives me the error : TypeError: action() takes 1 positional argument but 2 were given. Does someone know why ? I have seen people make this mistake but their error was that a parameter was missing "self" somewhere in their code, which I don't think I am forgetting here.
Thanks a lot for your help. Valentin
I tried looking in another topic that had the same problem but mine seems different here.