EMPLOYEE MANAGEMENT SYSTEM PYTHON CUSTOMTKINTER MODERN TKINTER PROJECT WITH SQLITE3 DATABASE

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial we are going to create this employee management system so let's try to add an employee without entering any data as you see we are getting enter or fields so let's enter some fake data let's say C1 and a name E1 are all let's say developer agenda it will be a mail a status let's say active let's try to add we are getting data has been inserted let's insert another one let's say C1 again E2 are all developer a female and let's say only let's try to add we are getting ID already exists so instead of C1 let's say C2 let's try to add we are getting data has been inserted okay now let's try to update this details so instead of female let's say for example male and let's click on update getting data has been updated and as you see the gender will be updated like this now let's delete click on delete we are getting data has been deleted so let's start by building this project so let's start by installing the custom teak enter which will be used in the graphical user interface click on Terminal and choose a new terminal and we are going to write the following if install custom click enter so let's start by building the project now in this file database we are going to do the following we are going to import sqli 3 then we will create a function create table and this function we will say sqli3.connect so you will connect our database and we will create this database they will create a cursor so we can interact with the database then we will say cursor.execute we will create a table if not exists and we are saying if not exists because if we run this code multiple times this table will be created multiple times and you will be getting an error okay now in this table we will create the following columns you will create ID and the data type of this column will be a text and this will be a primary key we will create an email agenda and a status we will commit the changes and we will close the connection we will create another function fetch employees again we will connect our database we will create a cursor we will select all the columns from our table we will fetch the results we will close the connection and return the result okay which is employees now we will create a function to insert an employee this function will take the following parameters like this we will connect we will create a cursor and we will say insert into employees which is our table in the following columns the following values which are these values okay we will commit and close now we will create a function delete an employee it will take an ID after connecting and creating a cursor we will delete from the table employees where the ID is equal to the ID given to this function so we will delete this employee okay now we will commit the changes and close the connection now we will create another function update employee it will take the following parameters it will connect create a cursor and we will say update employees which is our table by setting the name rule gender status where the ID is equal to the ID given to this function so you will update the details based on the ID given to this function okay we will commit and close the connection last but not least we will create a function ID exists this will take an ID and this function will check if an employee is already exists in the database or no so we will say select count from employees where ID is equal to the given ID okay we will fetch the result close the connection and we will return the result index 0 greater than zero so if we have an employee with a matching ID the account will be equal one one is greater than zero this is true so this function will return true however if the count is 0 meaning that we don't have an ID in the database matching this ID given to this function the account will be zero zero is not greater than zero so this will return false then we will call the function create table which is this function so this table will be created okay now in the lab file we are going to do the following we will start by importing the required modules like this and we will also import the database which is this file so we can use the functions in this file then we will create a simple tick enter window by saying custom tick enter.ctk we will give it a title we will give it a size and a background color and we will say resizable false and false so we cannot resize the width or the height we will be creating these faults which will be used in our project to make this window visible I will say app dot mail Loop like this let's run and see the result so as you see this is my window and this is the title now after running as you see the database file will be created like this okay now let's start by creating a simple label I will call this label ID label I will create enable by saying custom tick enter.ctk 11 I will place this label in my app which is my window I will give it a font which is font one this label will display the following text which is ID I will give it a text color and a background color now I will place this label in my window with the following X and Y coordinates then I will create an ID entry Box by saying custom tick enter.ctk entry again I will place it in my app I will give it a font a text color a foreground color a border color aboard the robots and awards for the entry box again I will place it with the following X and Y coordinates and another label for displaying name like this a name and three box a label displaying the role entry box for the rule another label for displaying the render like this then we will create a combo box for the render by saying custom tick enter Dot ctk combobox and we will say variable equal to variable one so you will create a string bar so we can keep track of the values inside this combo box okay and we will say values equal to options so options is this list so this combo box will contain the following options okay and we will say State equal to read only so we cannot modify the options inside this combo box we will say gender options dot set we will set the default value to be equal to base we will place it with the following X and Y coordinates last but not least a label and entry box for the status like this let's run and see the result these are the labels and three boxes combo box now we will start by creating a button to add an employee by saying custom tick enter.ctk button you will place it in our app will give it a font a text color and we will display the following text on our button over color a background color and a cursor shape when clicking on the button according radius and outs you will place it with the following X and Y coordinates and we will be doing the same for the clear button which will display the text new employee and the button update and delete okay let's run and see the result now we will start by creating a style for that review that we are going to create like this and we will set the font for the data Inside Out preview to be equal to form 2 which is this font the foreground color will be Allied color the background color of each row and that review will be a black color like this and the field background which is the background color for that review itself will be equal to the sculpt then we will say style.map three View background equal to selected and discolor so by selecting arrow in the tree view the row color will be converted to this color okay so this is a hover color now we'll start by creating at review with the following height and the following columns in our tree view ID name role gender and status now we will start by creating the column styles for each column like this and before creating the Styles I will just hide the default First Column of the tree view like this and I will Define the column style for the ID the anchor will be equal to TK Dot Center so you will Center this column and the width of this column will be equal to 120. and so on for each column in the tree View now we will set the heading of each column to display the following text so the ID column will display ID the name column will display the name the role will display the role and so on okay last but not least we will place the 3 with the following X unlock coordinates in our window let's run and see the result so this is our tree view this is the field background color okay and if we did not hide the default First Column like this as you see we will have an extra column at the left side so let's remove the command and this will be the result now let's create a function to insert the data from our database to our tree View we will start by creating a function add to 3 view then we will create a variable employees then we will say database dot fetch employees which is this function then we will say three dot delete three dot get children so you will delete the content in that review before inserting in Out review so you will prevent inserting the same row multiple times okay then we will say for employee in employees we will insert into our tree view the values employee okay now at the end I will call this function so I will say add to Tree View like this now what we want to do we want by clicking on the add button which will display add employee we want to create a function to insert the employee to our tree View so let's do this we will create a function insert and we will get the data from the entry boxes we will say ID and tripled get name entry dot get role entry dot get variable one which is related to the combo box dot get and last but not least status entry.get we will say if not ID name role gender and Status meaning that if we have an empty field from these fields we will show a message box saying error enter all Fields however if this is not the case we will say else if database.id exists which is this function so if this is true meaning that if the ID already exists we will show a message box saying error ID already exists however if this is not the case we would say database dot insert employee which is this function and we will call the add to three view function so we can add that data to the tree view which is this function and we will show a message box saying success data has been inserted now let's go to the up bottom and I will say command equal to insert which is our function so by clicking on the button this insert function will be executed let's run and see the result let's try to add enter or Fields so let's say for example C1 E1 foreign let's try to add we are getting data has been inserted like this okay and this is the hover color now let's try to say instead of for example mail let's say female with the same ID click on ADD we are getting ID already exists so let's say C2 data has been inserted okay now what we want to do we want by clicking on the clear button which will display new employee you want to clear the content inside the entry boxes so let's do this we will create a function clear this function will take any number of parameters then we will say if clicked meaning that if we pass an argument to this function we will say three dot selection remove three Focus this means that if we are highlighting Arrow inside this tree view like this then we click on the new employee button we want to remove this highlight okay then we will say ID entry.delete we will delete the content inside the entry box of the ID and the name Rule and we will say variable one dot set we will set variable one of the combo box to be equal to mail and we will delete the status entry box now let's go to the clear button and I will say command equal to Lambda because this function will take an argument then the name of the function which is clear in this case and I will say for example true so let's test this function let's highlight a row like this and click on new as you see the Highlight will be removed new the Highlight will be removed okay now what we want to do we're on by selecting arrow in the tree view like this we want to display the date of this Row in these entry boxes so we can update let's do this we will create a function display data this function will wait for an event and we will say selected item equal to three dot Focus and if selected item meaning that if we are clicking on a row in that review if this condition is true we will get the values of this row and we will call the Clear function which is this function to clear whatever in the entry boxes and after calling in this function we will insert in our entry boxes ID name rule variable 1 and Status the values of this row okay and if we are not clicking on arrow in the tree view we will pass so we will not do anything now let's do the following I will say 3 dot bind like this and I will say button release and the function name which is in this case display data display data so this means that if we are clicking on Arrow in that review this function will be executed okay let's run and see the result okay now what we want to do we're on by clicking on the update button to update the employee and by clicking on the delete button to delete the employee so let's create these two functions we will create the function delete we will say again selected item equal to three dot Focus if not selected item meaning that if we did not click on a row in that review we will show a message box saying choose an employee to delete however if this is not the case we will get the ID from the ID and three box and we will call the delete employee function which is this function again we will call add to review which is this function so we can get that data from the database to that review after the deletion and clear whatever in the entry Boxes by calling the clear function okay and show a message box by saying data has been deleted and the same for the update if we did not select a row we will show a message saying choose an employee to update however if this is not the case we will get the values from the entry boxes call the update employee function which is this function called the app to preview clear show a message saying data has been updated okay now let's go to the update button and I will say command equal to update and the same for the delete command equal to delete now let's test our project let's try to update choose an employee to update choose an employee to delete okay so let's choose this one let's update we are getting data has been updated okay now let's delete data has been deleted now let's insert another one C2 E2 let's try to add data has been inserted however we did not clear the entry boxes so let's do this foreign function okay let's try to add data has been inserted and the entry box has been deleted like this okay now let's check the new employee button okay now click on update as you see we are getting data has been updated however we are not selecting any room so to solve this problem I will do the following and the clear function I will say three dot Focus foreign Let's test our function again new employee update as you see you are getting choose an employee to update foreign
Info
Channel: CODE ROOM
Views: 32,699
Rating: undefined out of 5
Keywords: CODE ROOM, python tkinter projects, tkinter projects, modern tkinter gui, customtkinter, PYTHON MODER TKINTER PROJECT WITH SQLITE3 DATABASE | EMPLOYEES MANAGEMENT SYSTEM | CUSTOMTKINTER, sqlite3, python employee management system, python employee management system project, python modern employee management system project, python modern employee management system project with sqlite3 database, employee management system, python, python gui, python modern gui, gui, gui python, tkinter
Id: B0BOayNs4jI
Channel Id: undefined
Length: 26min 44sec (1604 seconds)
Published: Tue May 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.