Code-along project turned into a sandbox to practice Python + MySQL + TKinter. The original project was done in the video: "PYTHON MASTERCLASS - Aprende a manejar MySQL con Python" by Enrigue Barros Fernández (Programación Fácil). Because I turned it into a sandbox for practice, my code here is not a 1:1 copy of the code done in the video.
The app is about storing image URLs with a name, with the option to see the image and make a backup of the database.
- It starts with a "Login" window with the correct user and password already put so to log-in directly. The login is not meant to be serious, so it is not following patterns for secure login.
- Main window with four buttons to access the rest of the app.
- crud: Opens a windows for basic register-delete-update for the image URLs
- Ver registros: it calls a SELECT SQL command to see all entries of the table storing the image URLs.
- Ver imagen: a window to fetch and see the image by ID. In theory, if the URL passed is not a valid URL, it will attempt to open it as a local image.
- Respaldar base de datos: it creates a backup for the database inside the folder
bd/respaldos/.
For the GUI it uses TKinter, CustomTKinter and CTkMessagebox (for the messageboxen)
Notes:
- Git did not push the folders
respaldosandimagenesfor some reason - the init.py files are empty, but they were created in the video and never given an explicit use
base_datos.pycontains the class with the methods to deal with databases. This is the one used in this video, but I did not implemented everything from the video (only what I found interesting trying) and some code differsmuh_database.pyis a custom DB class for my own use of this project, sincebase_datos.pydoes not hold the methods required and the method for general SQL query was not working properly to metablas.pycontains data to create a table withbase_datos.pyimagenesfolder is meant to containlogo.icoandlogo.rngfor the GUIinterfaz_grafica.pydeals with the GUI
| Login | Main |
|---|---|
![]() |
![]() |
| CRUD | Ver registros |
![]() |
![]() |
| Ver imagen | |
![]() |
-
Install these if you have not already...
- MySQL connector:
pip install mysql-connector-python - PIL:
pip install Pillow - CustomTKinter:
pip install customtkinter - CTkMessagebox:
pip install ctkmessagebox
If you are having trouble with these commands, you might run them by adding
python -morpython3 -mat the beginning of the command. - MySQL connector:
-
In MySQL: create a DB with a single table. The attributes (columns) required can be found in the file
bd/tablas.py -
In
base_datos.pyin theacceso_bddictionary andmuh_database.pyunder its constructor put all the SQL related data (like user and password) required to interact with your DB -
Clone this repo and add a
logo.icoandlogo.pngif you wish insideinterfaz/imagenes/. -
Open the repo in VS Code and run
app.py
- The app has some basic checks so it does not die that easily
- For some reason, the icon "error" from the CTkMessagebox was resulting in a glitch with CTkMessagebox vomiting all over itself, so I changed to "warning"




