So I am working on my first "large" python project (second GUI), and it is a simple SQLite database manager. As of now, this is what it looks like...

At the top, as you can see, there is a change table button and a drop-down to select what table you wish to switch to.
What I want to do is to remove the button, replace it with an ordenary label(This is easy to do), and then have the OptionMenu change the table a different one is selected automatically.
This is what I have for the changing.
def change(self, root, c, tableToChangeTo, table, list_columns):
table = tableToChangeTo.get()
cursor = c.execute('select Rowid, * from ' + table)
list_columns = [description[0] for description in cursor.description]
self.clear()
self.table(root, c, table, list_columns)
self.addGui(root, c, table, list_columns)
self.editGui(root, c, table, list_columns)
self.delGui(root, c, table, list_columns)
self.changeGui(root, c, table, list_columns)
def changeGui(self, root, c, table, list_columns):
gridRow = self.rowTotal
self.changeButton = Button(root, text="Change Table", command= lambda: self.change(root, c, var, table, list_columns))
self.changeButton.grid(row = 0 , column = 0)
var = StringVar(root)
var.set(table)
options = {""}
global tableList
ta = tableList
for t in ta:
options.add(t)
self.changeOption = OptionMenu(root, var, *options)
self.changeOption.grid(row = 0, column = 1)
So to make it short and sweet, I want to make it where when you select another table, it will automatically run the change method. The big problem is I can not seem to figure out how to make a method an event while at the same time being able to pass variables to it.
So thank you for any help, and if you need anything else, let me know!