Skip to content

PatrykMprojects/Fist-GUI-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fist GUI Python

This is a code for GUI application in Python. I created that for my first-year project at University.

Project explanation

I decided to create classes that represent each of the sub-features and assign them to the separate class responsible for the main screen. This kind of design and organization allows me to control the functionality of sub-features. I created a ‘MainScreen’ class which represents the main window that appears when we run the program. Each of the following: ‘RegisterScreen, Login, Categories, Products, Stock’ classes are implemented into ‘MainScreen’ where I assign them to relevant buttons to switch between different program functionalities. Each class has its own frame. In this way, users can interact with the program features and stay on the same window. There are a few additional windows that are implemented such as error windows, warnings or updates to get the attention of users as they represent important changes in the database. The edit class method has a separate window to allow users to see the table with data for convenience and practical reasons. All of the classes define their main frame alongside labels, entry windows and other needed attributes. The instance attributes are used inside class methods which are defining different functionalities of my program. Some of the class methods define informative popup windows according to the error type or displayed information. In ‘low_in_stock(self, lst=None)’, I passed the list with names of toys that are less than 20 in stock. The list was appended earlier inside the for loop in display() and update() method and used as a popup window in if statement outside the loop but still inside the display() and update() method. This is an example of how variables are passed within different class methods. The Encapsulation method can be observed in the ‘MainScreen’ class where I assign each created class to the buttons on the main screen. Each button represents a different class and sub-feature. In these buttons, I called classes with their class methods to run functionalities defined inside them and allocate them in created earlier frames(each class has its own frame). I used the inheritance method between the ‘Login(object)’ and ‘RegisterScreen(Login)’. From the class ‘Login’ I inherit the attribute ‘self.login_master’ into the ‘RegisterScreen(Login)’ to switch between login and register. Functions that are responsible for frame allocation were defined inside the ‘RegisterScreen(Login)’ class.

I was responsible for developing the administration features. According to the given specification, the login sub-feature should take the user's credentials, check if they are correct and prompt the message if they do not exist or they are incorrect. My login system allows users to create an account in the register frame where credentials are checked if they already exist or if it is a new account. The program will prompt accurate messages if either user exists or not and it will append the file with credentials only if it is a new account. The user can switch between the frames ‘register’ and ‘login’. I inherit the instance attribute from class login to register this authorizes me to create the methods that allow users to switch between frames inside the class 'RegisterScreen'. Then inside the frame login, users can log in to the system which was created in registered accounts. The program will take the user’s credentials and check if they exist inside the file. If yes it will prompt the message that login is successful, if not it will display a pop-up window that invalid credentials have been provided. For the sub-features category and products, I decided to use similar methods as the course work specification requires same functionalities: add, edit, delete. I had to divide it so that each of mentioned above has been assigned its own table in the database. The add method is taking the user’s input and checking if the category or product exists inside the table. If it exists the pop-up window will display the message that item already exist, if not it will add a new entry into the table. The edit method is assigned to the separate button Edit record. This method will take the primary key which is generated by SQL automatically and provided by the user in the entry box of the category or product and display the chosen record inside the new pop-up window. Inside the pop-up window, users can edit the record and update it by clicking on the Update button. After, the record is updated the program will display a message that records has been updated with a timestamp. The delete method takes the primary key of the product or category which is provided by the user in the same entry window named ID and removes the record from the database. If the user forgets to provide ID the pop-up window will be display that the ID is needed. In addition, I created a buttons that allows users to display or clear out the records inside the treeview table so every time a user makes changes the output can be display in GUI. The remove_all method will clear the table in GUI but it will not make any changes into the database. The last sub-feature stock has the same functionalities as category or products. Users can display the data inside the treeview table, clear that table, add, delete or edit records. In addition when users click on the view table or update records, the message in the pop-up window will display either the list of toy names that quantity is below 20 or update record message with the timestamp. The permanent record has been created and it is a part of the code. I used INSERT INTO to highlight the records that can always be brought up by running the code again. Also, users can save the records to csv file. The save to file button has defined method that will take all the records from stock table and convert it into the csv file. The display label will show the file path directory alongside with the timestamp. The timestamp will be automatically updated and attached to the label and name of the file. The main interface has its own window and separate frames to reveal different functionalities of the program. Each of the sub-features is assigned to the different class and allocated in another class MainScreen. In the MainScreen class, I created a different buttons that controls switching between different functionalities/ frames of my program. I decided to create classes that represents each of the sub-features and assign them to the separate class responsible for the main screen. This kind of design and organization allows me to control functionality of sub-features. I created a ‘MainScreen’ class which represents the main window that appears when we run the program. Each of the following: ‘RegisterScreen, Login, Categories, Products, Stock’ classes are implemented into ‘MainScreen’ where I assign them into relevant buttons to switch between different program functionalities. Each class has its own frame. In this way, users can interact with the program features and stay on the same window. There are few additional windows that are implemented such as error windows, warnings or updates to get the attention of users as they represent important changes of the database. The edit class method has a separate window to allow users to see the table with data for convenience and practical reasons. All of the classes define their main frame alongside with labels, entry windows and other needed attributes. The instance attributes are used inside class methods which are defining different functionalities of my program. Some of the class methods definine informative popup windows according to the error type or displayed information. In ‘low_in_stock(self, lst=None)’, I passed the list with names of toys that are less than 20 in stock. The list was appended earlier inside the for loop in display() and update() method and used as a popup window in if statement outside the loop but still inside the display() and update() method. This is an example of how variables are passed within different class methods. The Encapsulation method can be observed in ‘MainScreen’ class where I assign each created class into the buttons on the main screen. Each button represents different class and sub-feature. In these buttons I called classes with their class methods to run functionalities defined inside them and allocate them in created earlier frames(each class has its own frame). I used the inheritance method between the ‘Login(object)’ and ‘RegisterScreen(Login)’. From the class ‘Login’ I inherit the attribute ‘self.login_master’ into the ‘RegisterScreen(Login)’ to switch between login and register. Functions that are responsible for frame allocation were defined inside ‘RegisterScreen(Login)’ class.

I was responsible for developing the administration features. According to the given specification the login sub-feature should take the users credentials, check if they are correct and prompt the message if they do not exist or they are incorrect. My login system allows users to create the account in the register frame where credentials are checked if they already exist or if it is a new account. The program will prompt accurate messages if either user exist or not and it will append the file with credentials only if it is a new account. Then user can switch between the frames ‘register’ and ‘login’. I inherit the instance attribute from class login to register this authorize me to create the methods that allows users to switch between frames inside the class RegisterScreen. Then inside the frame login, users can log-in into the system which were created in register accounts. The program will take the user’s credentials and check if they exists inside the file. If yes it will prompt the message that login successful, if not it will display a pop-up window that invalid credentials has been provided. For the sub-features category and products, I decided to use similar methods as the course work specification requires same functionalities: add, edit, delete. I had to divide it so that each of mentioned above has been assigned its own table in the database. The add method is taking the user’s input and checking if the category or product exists inside the table. If it exists the pop-up window will display the message that item already exist, if not it will add a new entry into the table. The edit method is assigned to the separate button Edit record. This method will take the primary key which is generated by SQL automatically and provided by the user in the entry box of the category or product and display the chosen record inside the new pop-up window. Inside the pop-up window, users can edit the record and update it by clicking on the Update button. After, the record is updated the program will display a message that records has been updated with a timestamp. The delete method takes the primary key of the product or category which is provided by the user in the same entry window named ID and removes the record from the database. If the user forgets to provide ID the pop-up window will be display that the ID is needed. In addition, I created a buttons that allows users to display or clear out the records inside the treeview table so every time a user makes changes the output can be display in GUI. The remove_all method will clear the table in GUI but it will not make any changes into the database. The last sub-feature stock has the same functionalities as category or products. Users can display the data inside the treeview table, clear that table, add, delete or edit records. In addition when users click on the view table or update records, the message in the pop-up window will display either the list of toy names that quantity is below 20 or update record message with the timestamp. The permanent record has been created and it is a part of the code. I used INSERT INTO to highlight the records that can always be brought up by running the code again. Also, users can save the records to csv file. The save to file button has defined method that will take all the records from stock table and convert it into the csv file. The display label will show the file path directory alongside with the timestamp. The timestamp will be automatically updated and attached to the label and name of the file. The main interface has its own window and separate frames to reveal different functionalities of the program. Each of the sub-features is assigned to the different class and allocated in another class MainScreen. In the MainScreen class, I created a different buttons that controls switching between different functionalities/ frames of my program.

About

This is a code for GUI application in Python. I created that for my first year project at University.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages