Building Out The GUI for our Database App - Python Tkinter GUI Tutorial #20
ฝัง
- เผยแพร่เมื่อ 2 พ.ย. 2024
- Building Out The GUI for our Database App. In this video we'll begin to build out the graphical user interface (GUI) for our database app with Tkinter. We'll add input boxes and buttons to add data to our database, and retrieve that data and output it onto the screen.
In this series I'll show you how to create graphical user interfaces for Python with Tkinter.
✅ Watch The Other Videos In This Python Playlist:
bit.ly/2UFLKgj
▶️ See More At:
Codemy.com
✅ Join My Facebook Group:
bit.ly/2GFmOBz
✅ Subscribe To My TH-cam Channel:
bit.ly/2IGzvOR
▶️ Learn to Code at Codemy.com
Take $22 off with coupon code: youtube
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam Channel:
bit.ly/2UFLKgj bit.ly/2IGzvOR
▶️ See More At: ✅ Join My Facebook Group:
Codemy.com bit.ly/2GFmOBz
▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
Sorry, Could I ask how I can fix the error of sqlite3.OperationError: no such table: address
@@麦天正 rewatch the video and follow the directions exactly.
@@麦天正 i can help you
@@wailsari6237 bro i m facing the same issue
@@lakshayahlawat6674 same
Object identifiers (OIDs) are used internally by SQLite as primary keys for various system tables. Also, an OID system column is added to user-created tables. Type oid represents an object identifier.
Sometimes I wish I wasn't broke just to support amazing teachers like these
Ha! Appreciate the thought!
Great video, this is exactly what I was looking for. There is 1 thing I would like to do different that I'm unsure how to do.
I would like to enter a oid into a text box, use the query button to look through the table for that oid, and populate the other input fields ( f_name, Zip, ect....). With the data that associated the the oid.
Those of you having problems with entering records to the table, try triple quotes around the INSERT INTO addressess function instead of single quotes.
i have tried this but its still saying "( "was not closed
Doesn't work, any other suggestions?
@@გიორგიიმედაშვილი-ყ1ს Not sure if this will help or if I am too late, but I just put a comma after zipcode.get() and that seemed to solve the problem
Thanks for this video. I have created a small database app to keep and manipulate golf scores and wanted a GUI front end. Plenty of stuff found about creating pretty screens and placing buttons etc but none that connect the GUI to the working program. Really good thanks. I shall be watching a lot more.
Glad it helped!
Proud owner of lifetime membership, keep up the good work! 👍👍
Awesome, enjoy!
It's amazing! Just what I'm looking for for days! Thank you sooo much, man! Keep doing it, you are great!
Thanks, will do!
Hello John,
I am a psychlogist and I collect data from large groups of students. Such as names, scores on various subjects, testscores, etc, etc. I am playing now with your program, using only first name and all kinds of scores. After that I use statistics to calculate sums per category, as well as standard deviation, percentile scores. So, this all means that I can benefit enormously from your basic database program. Thank you very much!!! :) Paul
Very cool Paul!
@@Codemycom Saint John II 🙂
@@Lennardish :-p
Just what I've been looking for. Thanks!
This channel is helpful for me cause this is the solution for my error in my thesis app. Thankyou😄
Awesome
this guy has taught me more about data science than all four of my college professors this semester
Ha, happy to hear it!
Hi. Great tutorial. I would like to point out that at 20:30 where you create the variable "print_records" in the for loop,we actually don't need it. You can write the for loop like this:
for record in records:
print(record[0])
It will workout exactly how you want it to without printing the first record twice.
yep
Is there a difference aside from syntax? Maybe like performance or memory size? Would like to know
Enjoying this video series on creating a database using python, tkinter and sqlite3. In the video you mentioned a discount code which after applying it gives you all of your videos and books. How many videos are on python and what books are included? Thanks!
You can see the list of courses at Codemy.com and my books by searching my author page on amazon.com
Best Course ever on tkinter
Thanks!
Such a simple solution to my problem revealed in this video. I could not figure out how to pick between single pieces of data once they had been queried and fetched. Every time I treated the result as an item from a list or a tuple I could not seem to move through them correctly. I did not notice that it was actually both a list and a tuple.
:-)
man love your videos
could please do a series on djnago!!!!
THANKS
Ya that's one is a headache
I like the way you teach it's really helpful for me
Glad you like it!
John, thank you for all of your great learning material provided at zero cost here on youtube. Beautiful content and amazing results. Hope its a good day in Vegas. Have a good day!
Welcome!
*Thanks! Mr. White!*
Ha
Thanks man you make this stuff easy to understand for sure.
Thanks! Glad you're enjoying it.
Thank you so much for this video, I have learnt a lot from this video!
Glad you enjoyed it!
Really Very Helpful Video. Thank.
Thank you so much!!! love your videos !
You're very welcome!
thanks for lessons good and clear
Very Useful Lesson. Thanks.
🎯 Key points for quick navigation:
00:00:00 *🖥️ The video aims to enhance a database app by building out its GUI using Tkinter and Python, following up from the previous video where a database and table were created.*
00:01:02 *📝 The tutorial covers creating text entry boxes for user input such as first name, last name, address, city, state, and zip code using Tkinter's entry widget.*
00:02:53 *🔄 Labels are added next to entry boxes for clarity, aligning them properly using Tkinter's grid system.*
00:05:29 *💾 A submit button is introduced to gather user input and prepare it for database insertion, with a focus on clearing the input fields after submission.*
00:07:14 *⌨️ The submit function is defined to clear text boxes after data entry is submitted using the "delete" method on each entry widget.*
00:08:36 *🗃️ Inside the submit function, the database connection is reiterated, ensuring data is correctly inserted into the table.*
00:13:22 *📊 A query button is added to display records from the database, implementing a method to fetch and print the database records onto the GUI.*
00:15:29 *🔍 The query function is initiated, detailing how to handle database queries and display results in Tkinter, including fetching all records.*
00:17:27 *💡 A for-loop is used to iterate over records and format them for display in the GUI, showcasing dynamic data visualization using Tkinter labels.*
00:20:27 *🔧 Demonstrates how to manage primary keys and record displays effectively within the Tkinter app, focusing on practical database interactions.*
00:26:37 *📜 The tutorial concludes by emphasizing formatting options for data display and announces plans for adding a delete function in an upcoming video.*
00:27:44 *📚 Additional resources and courses on SQLite and Python database management are introduced, inviting viewers to further their learning.*
Made with HARPA AI
Hi John. Really good tutorial! One question - regarding the need to comment out the 'create table' code after it has been run once since the table has been created. How would you go about doing this if you made a program that was to be run by the public. Would you make an if statement to check if the table already exist and only create a table if it doesn't? Thanks heaps!
Yeah I'd probably do that
Thank you! This helped me out a lot with a work project! Subbed :)
Glad to hear it!
Thank you for the video !
However , I am having an issue putting the below SQL query into Python :
insert into GERVERSION values (10, 'xxxxxxxx', 7, 4, 2, getdate(),'')
Note that in SQL , I have timestamp for the getdate() part
Can you please help me out with the right syntax to put this into work ?
NO WE WON'T HELP!
I got it to work...my dumb mistake. Thank you for an awesome video...
Excellent video, subscribed
Thanks!
oid mean object id of ORDB (object oriented data-basees).
Hello John, excellent video! I have a little problem.. When I enter a zip code that starts with a 0(zero), the record does not return the 0. Any feedback would be appreciated. Thank You
Thank you for this video. I have a question. In the query function, when selecting from thr database, you wrote 'FROM addresses and my question is where did you get the addresses?
I named that in a previous video...check the playlist
Thank you for this video. It's very clear . Chapeau! I subscribe to your chanel. Thank you again.
Glad you liked it!
Hi I was just wondering would python be a better programming language to use than a php crud application?
it depends entirely on your objective
Sir, it will be more interesting when the form in filled by individuals
and after they will submit the form we get their record in our database .
CAN WE DO THIS??
Of course. Just keep watching the videos
You are a life saver.
Glad you found what you needed!
Thank you a lot, this is very helpful !
Glad it was helpful!
excellent resource!!
hello im from México and my question is, can i connect pl/sql with python?, good video thanks!!
why not?
Yeah by mysql.connector module
loving your videos massively...pls will appreciate if you continue your flask training series and also wont mind if you can do a videos series on pygame, i also notice you dont have that on your website..thanks bro
Planning on both...
In this example, being the names of fields in the table first_name, last_name, city, etc., along the video is used for some fields a reduced name f_name, l_name, whereas for other fields its complete / unmodified name is used: city, zipcode and so on. I ask: could be used always the full name or always a reduced / modified name: s_first_name, s_city, s_zipcode, etc. for every field and in any case, for instance: s_f_name = s_f_name.get() ? Thank you.
I am getting the following error when trying to insert into the database - ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000'). Can you please help me resolve this?
Love you sir....😍😍
You solved a lot of my problems...thank you
Glad to help!
7:36 You could've placed each label in a list and iterated through each one and clear it with a for loop
Great information, just what I needed. You are a great teacher! Please keep it up!
Thanks! I will!
Such an amazing video it really helped me a lot with my project thank you! Having only 1 problem at the moment where the strings entered in the boxes are being added to the database and printing as u'string' instead of just the string. How can I fix this?
Not sure what's going on
Do str() and put in parenthesis
John goes: "So we add this variable here, go up here, create a function, then we pass this into the string, go over here place the label, name this text box, enter the database and BOOM"
Me: "Okey.... he said something about boom, where do I find boomy-thingy?!"
😂😂😂
Great videos man, just the playlist I've been looking for. 👍
ha
Thanks a lot for this! Your videos are extremely helpful.
I do have a question, is it possible for me to make a drop-down menu with options that can open up a new window? It's for a school project.
Thanks!
Of course. I have videos on opening new windows. Use that code in a function that gets called when you click a dropdown (using bindings - I have a video on dependent drop downs that will show you how to bind a dropdown to run a function).
@@Codemycom Oh thank you so much. I will make sure to check them out!
Was checking out Python as a new language to learn.
Is this the most efficient way available to create a GUI? Using a text editor?
Isn't there an Integrated Development Environment (IDE) lsimilar to MS Visual Studio where you drag fields, text boxes, labels, buttons onto screen and then change appearance, align automatically , etc??
There are several ways to do GUI's with Python. I like this one the best. There are drag and drop IDE's out there, but you still have to write the code on the backend.
U are very good my friend
Thanks!
can we make this project with for loops in order to make the entries and the labels, i had some issues with that . any helps will be appreciated
Sure...check the playlist...I have a video on that
any video for you to linked tow table in sqlite3 with tkinter ? and thanks for all that knowlege
Sure, check the playlist
Would it work if i made an input for a user which would be str and then insert this input into c.execute(input)?
try it and see, I don't see why not
Thanks a lot, A question, is this "Tutorial#20" in sequence ?
Yes
Hello Sir I am Dheeraj from India I follow whatever you said in this video and write exactly same code but I am getting 1 error which I don't understand how to solve I am new in this so can you please help me to resolve this problem.
File "d:\pyn\TinkierGUI\T.24.py", line 27, in SUBMIT
c.execute('''INSERT INTO addresses VALUES(f_name, l_name, address, city, state, Zipcode)''' ,
sqlite3.OperationalError: no such table: addresses
can you please help ....
what would be the best way to clear all of the information in the query label after you have fetched info from the database? I made a button that would .destroy the label but im having global variable issues and i can't help but think there is a much easier way im not seeing
config your label. whatever.config(text="")
@@Codemycom I knew it! So much easier than deleting the entire thing and then we making it, thank you very much!
@@Corcontv Sure thing :-)
i didnt smash the like button because i stuck here for 3 days, but i will continue ;o
me too
me three
?
Would it be possible or beneficial to create a *class record* and make it so the attributes of *record* would be name, city etc.?
Why/why not?
beneficial to what?
Hi, thank you very much for your video.
Thank you too
Hi I'm sorry to ask but for some reason I'm getting an error saying unrecognised token : ":". What should I do. Is it because I'm using multiple frame
Thanks for doing these videos! Are you able to help with the following? I double check the code and it matches what you've created. "OperationalError: table addresses has 5 columns but 6 values were supplied" do I need new glasses????
Yup, need new glasses. Missing a comma.
@@versaquest ha! Yeah that's usually the case
is there Date/Time type of column in table? how to work with it if i need extract for example 2 dates and times and calculate period between them, in days, hours, minuts etc.
I have videos on dates and times somewhere in the playlist.
I'm setting a data entry GUI, and following these videos for help. How do I set a table value if a certain criteria is met? For instance, I have a column in my table called Average, and on my form I have a checkbox allowing the user to include the entered data into the average (if it's checked then its included in average). So when inserting the values into the database, if the checkbox is checked I want it to insert "X" into the table, but if it is unchecked, I want it to be blank. Thank you so much for the help.
Use an if statement in your code.
Could you use for loops to create an array of widgets in order to prevent so much reused code?
sure
Thanks for this video.
You're welcome
How would you delete something tho? Like if it’s already in the Database can you do something like c.delete() ?
I think there are videos on deleting records in this playlist
Hello John...excellent tutorial..
Thanks!
Thanks Mr White
lol
what linter are you using? I don't' get that much of highlights in my vscode
None...just default sublime text
New drinking game: Take a shot every time John says concatenate incorrectly.
Can I use Python to connect to an existing MySQL database and extract some data?
I would like to make a GUI in Tkinter to make queries and read data from an existing MySQL database located on another PC.
Generally, not if it's located on another computer. Unless you can connect to that computer some how...
Hi john, for some reason after we create the query function, the returned values look like strings, not nicely formatted with no ()'s and ""' s, any help would be great
Without seeing your code, I couldn't guess...you must have done something weird tho :-p
@@Codemycom thanks for the quick reply, I had to continue formatting sir! But I guess I do have another question, is there a way to bring the oid to the beginning of the string, as opposed to the end? thanks man!
Not sure what you mean
i am trying to make custom window color. I changed window bg and buttons bg, yet the borderwidth and gap around button remain to have old Windows color, is it possible to overwrite it?
did you download my free tkinter widget book and check their attributes? I have lots of videos on using styles and themes
Excellent teaching !!!
where can I find the full code..?
Thanks! github.com/flatplanet/Intro-To-TKinter-TH-cam-Course
@@Codemycom Thanks for providing this. If I miss something, I can refer back to it. This is extremely helpful! Your course is great, BTW!
@@phillibob41 Thanks!
Hello!!,
Is the last entry of oid in each record automatically saved ? because in my case its not just even there .
Not sure what you mean, nothing is ever automatically saved .
@@Codemycom I am getting error when I try to print OID using 'record[6] ' - index out of range . Does it mean that my table doesn't contain a column containing OIDs
Oh Sorry,
I missed that. ' *,oid' in c.execute
@@danishbehal8135, glad you got it sorted out
lol. i got an error. then, after a few minutes, it took me some time to realize that the name of the database is different from the previous video. anyway, works like a charm
Glad you got it sorted out
Thanks a lot u r my last hope
welcome
thank you very much
You are welcome
Interesting that you didn't create the textvariables for the entry boxes and you were able to use them with .get() inside the submit button. Mine didn't work unless I created the textvariables for the entry boxes first
Then you're doing something wrong...check your code for typos..
helloo, sorry to bother u, will you please help me, i get the error 'NoneType object has no atribute get' for the first one, is this what you are talking about? how did you fix it?
I just wanna ask something. Can we store image to sqlite3 with tkinter?
sure, use BLOB data type...but you probably shouldn't. It's not standard practice.
Which theme do you use?
I use no theme
Good day sir!. May I ask a copy of the code for this video sir? If its is ok . Thank you so much for your response
github.com/flatplanet
Is there any ways to overwrite the updated data when we know it's index position
of course, basic database programming allows that
Thank you sir
You're welcome!
I'm creating a room booking system where teachers log in and can view other bookings made by users and can create their own bookings too.
I'm using Tkinter I'm making it a desktop application, so the users would have to download the code (system) to their laptop before they use it. I was wondering how I can make a centrally managed database (I think that's what it's called) so when the users log in to the system on their laptop and make a booking it is updated on the database so that everyone can see the bookings that all the teachers have made. I don't want each user to have their own database that is local to their machine and will only show their bookings. Does the database need to reside on one laptop so that the users have to connect to and use that database to see and make bookings? Do you have a tutorial on this or know of one? Thanks.
You're correct, the database would be different on each users computer. You'd need to instead link to an online database.
@@Codemycom how would I do that using sqlite? Do you have a video on it or do you recommend any site/tutorial so I can make it. Thanks
@@020cine Sorry, I don't have any videos on that...
@@Codemycom okay thanks. But do you know if I could link to an online database using sqlite? I've been looking online and I've read that I need to use PostgreSQL to link to an online database. But I'd rather use sqlite as it's built into python
@@020cine Depends on the webhost...
Hey John,
While clicking on the submit button I am getting an error message as ' f_name.get().. Nonetype object has non attribute as 'get'
Can you help me with it
Can't help you without seeing your code. But google: "Nonetype object has non attribute as 'get' " (the error you got) and you should see help.
i also got the same error....did you find solution for it
@@abhinavgupta8896 I also got the same error, bro did you find the error?
How to convert to exe file along with SQL to Clint mechine?
Hello, when i execute the def submit():
the error is showing
'sqlite3.ProgrammingError: You did not supply a value for binding 1.'
What did you do differently from the video?
very good
Thanks!
Hi , instead of table contents it returns some hexadecimal numbers . Could you please help me
You just have a typo somewhere
Sir ,Does SQlite database remain default with tkinter?
there is nothing default. SQLite comes with python, that’s all.
What’s the code to connect to SQL server instead of SQLite like on the video … do you know ?
SQL Server is a Microsoft product...it's completely different and doesnt really work here
Hello John, great videos, how do I access the source code? Thanks.
github.com/flatplanet/Tkinter.com-TH-cam
Thank You.
Welcome@@vcharles1881
Hi, thank you very much for your video. I just followed your video to connect to the database ... but you did not continue with MySQL or SQL. This is very unfortunate.
I have entire courses in both MySQL and SQLite3 on my Codemy.com website
I am unable to install PIL module.
please, suggest me a right path.
You'll have to google it
pip install pillow or if that's not working use sudo pip install pillow
@@kaushallyadealwis8192thanks but I had found the solution of this 6 months ago.
Excelente!!
Thanks!
hello , I wrote the same script but I received this message:
tkinter.tclerror cannot use geometry manager pack inside . which already has slaves managed by grid
how to fix it?
Thank u
you didn't write the same script. You can't pack and grid in the same parent widget