Is there a way to auto-refresh tableview from a database ? maybe with a button or auto ? I Created a Manual Refresh Visual Button to do the job "click_Refresh()" can any one help ?
CODE :
import ttkbootstrap as ttk
import cx_Oracle
from ttkbootstrap.tableview import Tableview
from ttkbootstrap.constants import *
from ttkbootstrap.toast import ToastNotification
dsn_tns = cx_Oracle.makedsn('****', '****', service_name='****')
con = cx_Oracle.connect(user=r'****', password='****', dsn=dsn_tns)
cur = con.cursor()
rowdata = cur.execute('''SELECT USER_ID,EMAIL,USER_STATUS from table
''')
def click_Refresh():
# Display message
toast.show_toast()
coldata = [
{"text": "USER_ID", "stretch": True},
{"text": "EMAIL", "stretch": True},
{"text": "USER_STATUS", "stretch": True},
]
app = ttk.Window(themename="superhero", size=(100, 100))
app.geometry("1000x500")
app.title("USER MANAGEMENT")
app.resizable(True, True)
app.place_window_center()
label = ttk.Label(app, text="USER MANAGEMENT VERSION 1.0", bootstyle=DEFAULT)
label.pack(pady=5)
label.config(font=("Arial", 20, "bold"))
button_frame = ttk.Frame(app)
button_frame.pack(pady=10, padx=2, fill="x")
ttk.Button(button_frame, text="Refresh", bootstyle="OUTLINE-SUCCESS",
command=click_Refresh).pack(side=LEFT, padx=10, pady=5)
dt = Tableview(
master=app, # The parent widget
paginated=False,
searchable=True,
height=50,
autoalign=False,
autofit=True,
pagesize=30,
coldata=coldata,
rowdata=rowdata,
bootstyle=DANGER,
)
dt.pack(fill=BOTH, expand=YES, padx=10, pady=10)
dt.autofit_columns() # Fit in current view
# Define the toast notice (temporary message)
toast = ToastNotification(
title="Refresh Notifcation",
message=("Database version:", cx_Oracle.version,
"Database version:", con.version,
"Client version:", cx_Oracle.clientversion()
),
duration=9000,
bootstyle=DARK,
alert=True,
)
app.mainloop()