I am currently working on a project where I have to build an app in python. I decided to use the tkinter framework but right now I am having some trouble on how to add a specific feature. So this app is connected to a database, and while the database is online the program opens in about 1 or 2 seconds, but if it's not the case the program takes a while to open but until it opens it gives no sign that is opening or trying to connect to that database. Here's a part of my code:
try:
db = MySQLdb.connect(
host="hostname",
port=port,
user="username",
password="password",
database="database_name"
)
except MySQLdb.Error as e:
warning_box=ctypes.windll.user32.MessageBoxW(0, "Looks like there's been an error while trying to connect to the database please try again later", "Error", MB_OK | ICON_STOP)
if warning_box == 1:
exit()
I added this try except cicle in order to give me that message after it fails to connect to the database, although, like I said, it takes a while to show this error so I wanted to add something like this: