Skip to main content
6 of 6
use inline code span format for code within text, update grammar

There are a few things that need looking at.

There seems to be an error in the def add_item method. The 'Build the SQL' section joins sections for table, column names and new values from the entry boxes but the last two items in the .format method BOTH insert 'column_names' whereas I would expect the last one to be 'entries'.

You seem to have gotten confused with the use of *args.

In 'main' you have

create_table(db, tbl, *columns) 

and

demo_window = EntryWindow(root, *[db, tbl]) 

The asterisks (i.e. *) is used in the method DEFINITION as a place holder for the arguments that may not appear in the method call. If they do appear then they will be accessible as a tuple in the body of the method definition.

So

create_table(db, tbl, columns) # no * 

would pass the columns list as the first item of the *col_defs in the create_table method and be accessible as

col_defs[0]. 

Also

demo_window = EntryWindow(root, [db, tbl]) # no * 

would pass the database and table list as the first item of the *args in the EntryWindow method to be accessible as

args[0][0] 

and

args[0][1]. 

Note the double indices. The first accesses the first item in the *args tuple (even if there is only one!) and the second accesses the item within your list.

You could change the call to

demo_window = EntryWindow(root, db, tbl) # no list and still no * 

and then use

args[0] 

and

args[1] 

as you have done but to access the items within the *args tuple not items within a list.