Tkinter to open Access database and load tables into combo box

I am creating a tkinter GUI where I need to open an Access database and create a list of available tables in a combo box so that I can choose which table I want and it can be stored into a variable and then used in the query. I can’t get the combo box to show. If anyone can point me in the right direction.

from tkinter import *
from tkinter import ttk, filedialog
from tkinter.filedialog import askopenfile
import os
import pathlib
from tkinter.messagebox import showinfo

win = Tk()

Set the geometry of tkinter frame

win.title(‘D016 Database’)

def open_file():
file = filedialog.askopenfile(mode=‘r’, filetypes=[(‘MS Access File’, ‘*.accdb’)])
global dataf

if file:
filepath = os.path.abspath(
Label(win, text="The File is located at : " + str(filepath), font=(‘Aerial 8’)).pack()
conn = pyodbc.connect(r’Driver={Microsoft Access Driver (*.mdb, *.accdb)};‘r’DBQ=’+filepath+’;’)

  #Get tables
  cursor = conn.cursor()
  for row in cursor.tables():
     table_combo['values'] = row.table_name
  #Create combobox
  my_combo = ttk.combobox(win, values=table_combo)
  my_combo(row=1, column=1, padx=10, pady=20)

  qry=("select * from selected_table")
  dataf = pd.read_sql(qry, conn)

#Access database Label widget
label = Label(win, text=“Click the Button to browse the Files”, font=(‘Georgia 13’))

#Access database table
label = Label(win, text=“Choose a table”, font=(‘Georgia 13’))

Create a Browse Button

ttk.Button(win, text=“Browse”, command=open_file).pack(pady=20)


In the same way as you’ve used a the .pack() geometry manager for your other widgets, you need to do the same thing with your combo box.