I have a code using Tkinter and everytime the user change the OptionMenu variable the window will show something diffent but now everytime I try to run a function based on the OptionMenu variable it says: Exception in Tkinter callback Traceback (most recent call last): File "c:\users\pedri\appdata\local\programs\python\python39\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "c:\users\pedri\appdata\local\programs\python\python39\lib\tkinter\__init__.py", line 3948, in __call__ self.__callback(self.__value, *args) TypeError: teste() takes 0 positional arguments but 1 was given
Here is the code:
from tkinter.ttk import *
import pandas as pd
import plotly.express as px
import pyautogui
import time
import os
root=Tk()
root.title("SheetToChart")
root.resizable(False, False)
myLabel1=Label(root,text="Please, fill out the form below")
myLabel1.grid(row=0, pady=10)
archiveName=Entry(root, width=40)
archiveName.grid(row=1, column=0, padx=10, pady=10)
archiveName.insert (0, "Example: sheet.csv")
def pathOpen():
path = "C:/AutoGraphPath/Tabela"
path = os.path.realpath(path)
os.startfile(path)
archiveOpen=Button(root, text="Open folder to insert spreadsheet", command=pathOpen, width=30)
archiveOpen.grid (row=1, column=1, padx=10, pady=10)
archivePrim=Entry(root, width=74)
archivePrim.grid(row=2, column=0, columnspan=2, padx=10, pady=10)
archivePrim.insert (0, "Write the exact column name")
myLabel2=Label(root,text="Choose the type of chart")
myLabel2.grid(row=3, pady=10, padx=5, column=0, columnspan=2)
def teste():
myLabel3=Label(root,text="Choose the type of chart")
myLabel3.grid(row=5, pady=10, padx=5, column=0, columnspan=2)
choices = ['Bar', 'Bar', 'Line', 'Pie']
variable = StringVar(root)
variable.set('Bar')
typeChart = OptionMenu(root, variable, *choices, command=teste)
typeChart.grid(row=4, column=0, columnspan=2, padx=10, pady=5)
root.mainloop()