From 33aa1983e319fb9714a9389b7bb9626235db9781 Mon Sep 17 00:00:00 2001 From: nathan <nathan9.baker@live.uwe.ac.uk> Date: Mon, 4 Nov 2024 15:50:10 +0000 Subject: [PATCH] setup python classes as per the class diagram. --- GUI.py | 30 ++++++++++++++++-------------- main.py | 25 +++++++++++++++++++++++++ src/__init__.py | 7 +++++++ src/adminUser.py | 20 ++++++++++++++++++++ src/cinemaObj.py | 21 +++++++++++++++++++++ src/filmObj.py | 15 +++++++++++++++ src/managerUser.py | 28 ++++++++++++++++++++++++++++ src/reciptObj.py | 22 ++++++++++++++++++++++ src/reportObj.py | 17 +++++++++++++++++ src/staffUser.py | 30 ++++++++++++++++++++++++++++++ src/userClass.py | 30 ++++++++++++++++++++++++++++++ 11 files changed, 231 insertions(+), 14 deletions(-) create mode 100644 main.py create mode 100644 src/__init__.py create mode 100644 src/adminUser.py create mode 100644 src/cinemaObj.py create mode 100644 src/filmObj.py create mode 100644 src/managerUser.py create mode 100644 src/reciptObj.py create mode 100644 src/reportObj.py create mode 100644 src/staffUser.py create mode 100644 src/userClass.py diff --git a/GUI.py b/GUI.py index 8d085a0..c555654 100644 --- a/GUI.py +++ b/GUI.py @@ -1,4 +1,5 @@ from tkinter import Tk, Frame, Label, Entry, Button, messagebox +from main import * # Initialize main window window = Tk() @@ -51,10 +52,13 @@ def apply_theme(): def login(): username = username_entry.get() password = password_entry.get() + # check form not empty if not username or not password: messagebox.showwarning("Warning", "Please fill in both fields.") else: + messagebox.showinfo("Login", "Login successful!") + # Make rows and columns in the main window expand to center the form frame window.grid_rowconfigure(0, weight=1) @@ -78,22 +82,20 @@ login_button = Button(form_frame, text="Login", command=login, bg=current_theme[ theme_toggle_button = Button(form_frame, text="Toggle Light/Dark Mode", command=toggle_theme, bg=current_theme["button_bg"], fg=current_theme["button_fg"]) -def main(): - # Place widgets on the screen - login_label.grid(row=0, column=0, columnspan=2, pady=(10, 10)) - username_label.grid(row=1, column=0, padx=5, pady=5, sticky="e") - username_entry.grid(row=1, column=1, padx=5, pady=5, sticky="w") - password_label.grid(row=2, column=0, padx=5, pady=5, sticky="e") - password_entry.grid(row=2, column=1, padx=5, pady=5, sticky="w") - login_button.grid(row=3, column=0, columnspan=2, pady=(10, 10)) - theme_toggle_button.grid(row=4, column=0, columnspan=2, pady=(10, 10)) +# Place widgets on the screen +login_label.grid(row=0, column=0, columnspan=2, pady=(10, 10)) +username_label.grid(row=1, column=0, padx=5, pady=5, sticky="e") +username_entry.grid(row=1, column=1, padx=5, pady=5, sticky="w") +password_label.grid(row=2, column=0, padx=5, pady=5, sticky="e") +password_entry.grid(row=2, column=1, padx=5, pady=5, sticky="w") +login_button.grid(row=3, column=0, columnspan=2, pady=(10, 10)) +theme_toggle_button.grid(row=4, column=0, columnspan=2, pady=(10, 10)) + +# Enable to use theme +apply_theme() - # Enable to use theme - apply_theme() - window.mainloop() - # app will only launch if run directly from this file. if __name__ == "__main__": - main() \ No newline at end of file + window.mainloop() \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..905ec35 --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +from src import * + +""" +_summary_ +- logic should be seprate from the GUI +- this file handles interfacing with the database and classes. + +'idealy there should be a sort of intermeditary between the GUI and database, for example last year most groups queried the database directly from tkintet, although thats not ideal.' - lecturer idk there name +'you should be able to make python classes directly from your class diagram' - same lecturer + +""" + + + + + + + + +def main() -> None: + pass + +if __name__ == "__main__": + #main() + pass \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..57bcd32 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,7 @@ +from adminUser import * +from cinemaObj import * +from managerUser import * +from reciptObj import * +from reportObj import * +from staffUser import * +from userClass import * \ No newline at end of file diff --git a/src/adminUser.py b/src/adminUser.py new file mode 100644 index 0000000..1113af6 --- /dev/null +++ b/src/adminUser.py @@ -0,0 +1,20 @@ +from . import userClass + +class AdminUser(userClass.User): + pass + + + + + + + + + + + +# following code will only execute if run directly from this file. +if __name__ == "__main__": + # test + user1 = AdminUser() + print(user1) diff --git a/src/cinemaObj.py b/src/cinemaObj.py new file mode 100644 index 0000000..86d21b9 --- /dev/null +++ b/src/cinemaObj.py @@ -0,0 +1,21 @@ +class Cinema(object): + """_summary_ + + Args: + object (_type_): _description_ + """ + def addScreen(self): + pass + + def updateScreen(self): + pass + + def operation3(self): + pass + + + + +if __name__ == "__main__": + #test() + pass \ No newline at end of file diff --git a/src/filmObj.py b/src/filmObj.py new file mode 100644 index 0000000..c520910 --- /dev/null +++ b/src/filmObj.py @@ -0,0 +1,15 @@ +class Film(object): + """_summary_ + + Args: + object (_type_): _description_ + """ + + def addListing(self): + pass + + def updateListing(self): + pass + + def removeListing(self): + pass \ No newline at end of file diff --git a/src/managerUser.py b/src/managerUser.py new file mode 100644 index 0000000..1c21ee1 --- /dev/null +++ b/src/managerUser.py @@ -0,0 +1,28 @@ +from . import userClass + +class ManagerUser(userClass.User): + """ + + Args: + userClass (_type_): _description_ + """ + + def expandBuisness(self): + # creates new cinemaObj and adds it to db. + pass + + + + + + + + + + + +# following code will only execute if run directly from this file. +if __name__ == "__main__": + # test + user1 = ManagerUser() + print(user1) diff --git a/src/reciptObj.py b/src/reciptObj.py new file mode 100644 index 0000000..2367642 --- /dev/null +++ b/src/reciptObj.py @@ -0,0 +1,22 @@ +class Recipt(object): + """_summary_ + + Args: + object (_type_): _description_ + """ + + def __str__(self): + # output attributes in readable format + pass + + def displayFormat(self): + # output attributes in format for GUI.py + pass + + + + + +if __name__ == "__main__": + #test() + pass \ No newline at end of file diff --git a/src/reportObj.py b/src/reportObj.py new file mode 100644 index 0000000..63e9378 --- /dev/null +++ b/src/reportObj.py @@ -0,0 +1,17 @@ +class Report(object): + """_summary_ + + Args: + object (_type_): _description_ + """ + def generateRevenueReport(self): + pass + + + + + + +if __name__ == "__main__": + #test() + pass \ No newline at end of file diff --git a/src/staffUser.py b/src/staffUser.py new file mode 100644 index 0000000..2a7ec89 --- /dev/null +++ b/src/staffUser.py @@ -0,0 +1,30 @@ +from . import userClass + +class StaffUser(userClass.User): + """_summary_ + + Args: + userClass (_type_): _description_ + """ + + def veiwFilmListing(self): + pass + + def manageBooking(): + pass + + + + + + + + + + + +# following code will only execute if run directly from this file. +if __name__ == "__main__": + # test + user1 = StaffUser() + print(user1) diff --git a/src/userClass.py b/src/userClass.py new file mode 100644 index 0000000..79564fc --- /dev/null +++ b/src/userClass.py @@ -0,0 +1,30 @@ +import random +from . import dbfunc + +class User(object): + def __init__(self): + + self.userID:int = random.randint(0,10000) + self.userName:str = self.encrypt("") + self.userPass:str = self.encrypt("") + + def __str__(self): + return f"'User' Object(userID={self.userID}, userName={self.userName}, userPass={self.userPass})" + + def login(self): + pass + + def logout(self): + pass + + def encrypt(self, inputString): + return inputString + + + + +# following code will only execute if run directly from this file. +if __name__ == "__main__": + # test + user1 = User() + print(user1) \ No newline at end of file -- GitLab