コード例 #1
0
ファイル: Main.py プロジェクト: elephant03/LoginAccess-v4
    def __init__(self, root):
        '''
        Crates the root and Mina_fr objects
        Then calls the Login screen GUI
        '''

        # Sets up the database
        with lite.connect("myDatabase.db") as self.Con:
            self.Cur = self.Con.cursor()
            self.Cur.execute("""
            CREATE TABLE IF NOT EXISTS Users (
            Username TEXT NOT NULL PRIMARY KEY,
            Password TEXT NOT NULL,
            AccountType INTEGER NOT NULL,
            Email INTEGER);""")

        # Creats an instance of the tkinter_basics class
        self.tb = tkinter_basics.Basics()

        # Sets up the root
        self.root = root
        # Adds a title
        self.root.title("Login Access")
        # Adds an icon
        self.root.wm_iconbitmap("./Libary/Icons/MainIcon.ico")

        # Creats the main frame object for other frames to cramed into
        self.Main_fr = TK.Frame(self.root)
        self.Main_fr.pack(fill=TK.BOTH, expand=True)

        # Calls the Login screens GUI
        self.LoginScreen_GUI()

        return
コード例 #2
0
    def __init__(self, Main_fr):
        '''
        Brings up the help screen for Logins
        '''

        self.tb = tkinter_basics.Basics()

        self.Main_fr = Main_fr

        self.LoginHelp_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.LoginHelp_fr.grid(row=0, column=0, sticky="nsew", padx=0, pady=0)

        self.Title_lbl = self.tb.AddLabel_title(self.LoginHelp_fr,
                                                "Login Help",
                                                Row=0,
                                                Column=0,
                                                CSpan=2)

        self.Space_lbl = self.tb.AddLabel_spacer(self.LoginHelp_fr,
                                                 Row=2,
                                                 Column=0,
                                                 CSpan=2)

        self.Instructions = [
            "Welcome to the Login Access program",
            "To create an account please press \"back\" then \"new account\"",
            "If you need to reset your password please press the button below",
            "If you already have an account enter your information then press \"login\"",
            "If you need further assitance please look at the wiki or contact admin"
        ]

        for Line in self.Instructions:
            self.Line = self.tb.AddLabel(self.LoginHelp_fr,
                                         Line,
                                         Row=self.Instructions.index(Line) + 3,
                                         Column=0,
                                         CSpan=2)

        self.Back_btn = self.tb.AddButton(self.LoginHelp_fr,
                                          "Back",
                                          Row=len(self.Instructions) + 3,
                                          Column=0)
        self.Back_btn.config(command=lambda: self.LoginHelp_fr.destroy())

        self.Reset_btn = self.tb.AddButton(self.LoginHelp_fr,
                                           "Reset Password",
                                           Row=len(self.Instructions) + 3,
                                           Column=1)
        self.Reset_btn.config(
            command=lambda:
            [self.LoginHelp_fr.destroy(),
             PasswordReset.Reset(self.Main_fr)])

        self.tb.Align_Grid(self.LoginHelp_fr)

        return
コード例 #3
0
ファイル: Teacher.py プロジェクト: elephant03/LoginAccess-v4
    def __init__(self, Main_fr, Username):
        '''
        Sets up the menu's GUI and base varables
        '''
        # Creats a main_fr object
        self.Main_fr = Main_fr

        # Stores the username for the GUI colours and tracking
        self.Username = Username

        # Heps handle building the GUI
        self.tb = tkinter_basics.Basics()
コード例 #4
0
    def __init__(self, Main_fr):
        '''
        Brings up the help screen for using the menu system
        '''

        self.tb = tkinter_basics.Basics()

        self.Main_fr = Main_fr

        self.MainMenuHelp_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.MainMenuHelp_fr.grid(row=0,
                                  column=0,
                                  sticky="nsew",
                                  padx=0,
                                  pady=0)

        self.Title_lbl = self.tb.AddLabel_title(self.MainMenuHelp_fr,
                                                "Menu Help",
                                                Row=0,
                                                Column=0,
                                                CSpan=2)

        self.Space_lbl = self.tb.AddLabel_spacer(self.MainMenuHelp_fr,
                                                 Row=2,
                                                 Column=0,
                                                 CSpan=2)

        self.Instructions = [
            "This is the main menu",
            "It allows you to access the functionality of the program",
            "To use it please click on one of the available sub-menus",
            "If you need more help please read the wiki", "Or contact an admin"
        ]

        for Line in self.Instructions:
            self.Line = self.tb.AddLabel(self.MainMenuHelp_fr,
                                         Line,
                                         Row=self.Instructions.index(Line) + 3,
                                         Column=0)

        self.Back_btn = self.tb.AddButton(self.MainMenuHelp_fr,
                                          "Back",
                                          Row=len(self.Instructions) + 3,
                                          Column=0)
        self.Back_btn.config(command=lambda: self.MainMenuHelp_fr.destroy())

        self.tb.Align_Grid(self.MainMenuHelp_fr)

        return
コード例 #5
0
    def __init__(self, Main_fr):
        '''
        Creats and loads the password reset GUI
        '''
        self.tb = tkinter_basics.Basics()

        self.Main_fr = Main_fr

        self.ResetPassword_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.ResetPassword_fr.grid(row=0,
                                   column=0,
                                   sticky="nsew",
                                   columnspan=2,
                                   padx=0,
                                   pady=0)

        self.Title_lbl = self.tb.AddLabel_title(self.ResetPassword_fr,
                                                "Password Reset",
                                                Row=0,
                                                Column=0,
                                                CSpan=2)

        self.Space_lbl = self.tb.AddLabel_spacer(self.ResetPassword_fr,
                                                 Row=1,
                                                 Column=0,
                                                 CSpan=2)

        self.Back_btn = self.tb.AddButton(self.ResetPassword_fr,
                                          "Back",
                                          Row=2,
                                          Column=0)
        self.Back_btn.config(command=lambda: self.ResetPassword_fr.destroy())

        self.Reset_btn = self.tb.AddButton(self.ResetPassword_fr,
                                           "Reset Password",
                                           Row=2,
                                           Column=1)
        self.Reset_btn.config(command=lambda: self.Reset())

        self.tb.WorkInProgress()

        self.tb.Align_Grid(self.Main_fr)
        self.tb.Align_Grid(self.ResetPassword_fr)

        return
コード例 #6
0
ファイル: MainMenu.py プロジェクト: elephant03/LoginAccess-v4
    def __init__(self, Main_fr, Username):
        '''
        Stores key verables and loads the menu GUI
        '''
        # Stores the main_fr
        self.Main_fr = Main_fr
        # Stores the username
        self.Username = Username

        # Gets the account type
        with lite.connect("myDatabase.db") as self.Con:
            self.Cur = self.Con.cursor()
            self.Cur.execute(
                "SELECT AccountType FROM Users WHERE Username = ?",
                (self.Username, ))

            self.AccountType = self.Cur.fetchall()[0][0]

            self.Cur.execute("""CREATE TABLE IF NOT EXISTS Warnings (
                Username TEXT NOT NULL,
                Issued_by TEXT NOT NULL,
                Issued_for TEXT NOT NULL,
                Issued_on TEXT NOT NULL,
                FOREIGN KEY (Username) REFERENCES Users (Username) ON UPDATE CASCADE ON DELETE CASCADE
                );""")

            self.Cur.execute("SELECT * FROM Warnings WHERE Username = ?",
                             (self.Username, ))

            try:
                self.Warnings_list = self.Cur.fetchall()
                self.Warnings_num = len(self.Warnings_list)
            except IndexError:
                self.Warnings_list = []
                self.Warnings_num = 0

        self.tb = tkinter_basics.Basics(Username=self.Username)

        if self.Warnings_num >= 3:
            self.Menu_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
            self.Menu_fr.grid(row=0, column=0, sticky="nsew", padx=0, pady=0)

            self.Title_lbl = self.tb.AddLabel_title(self.Menu_fr,
                                                    "Account Deleted:",
                                                    Row=0,
                                                    Column=0)

            self.Instructions = [
                "We are sorry but your account has now got 3 warnings",
                "Your account will now be deleted- you cannot appeal this action",
                "Only the individual warnings could have been reveiwed",
                "However, you didn't do this and so you account will be erased"
            ]

            for Line in self.Instructions:
                self.Line = self.tb.AddLabel(
                    self.Menu_fr,
                    Line,
                    Row=self.Instructions.index(Line) + 3,
                    Column=0)

            self.Continue_btn = self.tb.AddButton(self.Menu_fr,
                                                  "I acknowledge this",
                                                  Column=0,
                                                  Row=len(self.Instructions) +
                                                  4)
            self.Continue_btn.config(command=lambda: self.DeleteAccount())

            return

        self.Menu_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.Menu_fr.grid(row=0, column=0, sticky="nsew", padx=0, pady=0)

        self.Title_lbl = self.tb.AddLabel_title(self.Menu_fr,
                                                "Main Menu:",
                                                Row=0,
                                                Column=0)

        self.Options_btn = self.tb.AddButton(self.Menu_fr,
                                             "⚙",
                                             Row=0,
                                             Column=1)
        self.Options_btn.config(command=lambda: self.Options())

        self.Space_lbl = self.tb.AddLabel_spacer(self.Menu_fr,
                                                 Row=1,
                                                 Column=0,
                                                 CSpan=2)

        if self.Warnings_num != 0:
            self.Space_lbl.config(
                text="You have {} warings!".format(self.Warnings_num))

        self.Tools_btn = self.tb.AddButton(self.Menu_fr,
                                           "Tools",
                                           Row=2,
                                           Column=0,
                                           CSpan=2)
        self.Tools_btn.config(command=lambda: self.Tools_menu())

        # Increase this so that the buttons will easily align to the rest when other options are added
        self.Button_row = 3

        # if your account type allow it it will display the games menu
        if self.AccountType != self.student_hash:
            self.Button_row += 1

            self.Games_btn = self.tb.AddButton(self.Menu_fr,
                                               "Games",
                                               Row=self.Button_row - 1,
                                               Column=0,
                                               CSpan=2)
            self.Games_btn.config(command=lambda: self.Games_menu())

        # Tests if the account is admin or owner
        if self.AccountType == self.admin_hash or self.AccountType == self.owner_hash:
            self.Button_row += 1

            self.Admin_btn = self.tb.AddButton(self.Menu_fr,
                                               "Admin",
                                               Row=self.Button_row - 1,
                                               Column=0,
                                               CSpan=2)
            self.Admin_btn.config(command=lambda: self.Admin_menu())

        # Tests if the account is owner
        if self.AccountType == self.owner_hash:
            self.Button_row += 1

            self.Owner_btn = self.tb.AddButton(self.Menu_fr,
                                               "Owner",
                                               Row=self.Button_row - 1,
                                               Column=0,
                                               CSpan=2)
            self.Owner_btn.config(command=lambda: self.Owner_menu())

        if self.AccountType == self.student_hash or self.AccountType == self.owner_hash:
            self.Button_row += 1

            self.Education_btn = self.tb.AddButton(self.Menu_fr,
                                                   "Education",
                                                   Row=self.Button_row - 1,
                                                   Column=0,
                                                   CSpan=2)
            self.Education_btn.config(command=lambda: self.Education_menu())

        if self.AccountType == self.teacher_hash or self.AccountType == self.owner_hash:
            self.Button_row += 1

            self.Teacher_btn = self.tb.AddButton(self.Menu_fr,
                                                 "Teacher Options",
                                                 Row=self.Button_row - 1,
                                                 Column=0,
                                                 CSpan=2)
            self.Teacher_btn.config(command=lambda: self.Teacher_menu())

        self.Back_btn = self.tb.AddButton(self.Menu_fr,
                                          "Logout",
                                          Row=self.Button_row,
                                          Column=0)
        self.Back_btn.config(command=lambda: self.Menu_fr.destroy())

        self.Reset_btn = self.tb.AddButton(self.Menu_fr,
                                           "Help",
                                           Row=self.Button_row,
                                           Column=1)
        self.Reset_btn.config(command=lambda: self.Help())

        self.tb.Align_Grid(self.Menu_fr)
        self.tb.Align_Grid(self.Main_fr)
コード例 #7
0
ファイル: Tools.py プロジェクト: elephant03/LoginAccess-v4
    def __init__(self, Main_fr, Username):
        '''
        Sets up the menu's GUI and base varables
        '''
        # Creats a main_fr object
        self.Main_fr = Main_fr

        # Stores the username for the GUI colours and tracking
        self.Username = Username

        # Heps handle building the GUI
        self.tb = tkinter_basics.Basics()

        self.Tools_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.Tools_fr.grid(row=0, column=0, sticky="nsew", padx=0, pady=0)

        self.Title_lbl = self.tb.AddLabel_title(
            self.Tools_fr, "Tools:", Row=0, Column=0)

        self.Space_lbl = self.tb.AddLabel_spacer(
            self.Tools_fr, Row=1, Column=0)

        # Creats an array to store the tools
        self.Tools_list = []

        # Finds the current dirrectory
        self.Tools_File = __file__
        # Removes the name of this file
        self.Tools_File = self.Tools_File[:-23]
        # Adds the path to the tools to the current dirrectory
        self.Tools_File += r"\Tools\*py"
        # Makes the file python readable
        self.Tools_File.replace("\\", "\\\\")

        # Uses glob to get all of the tools files
        self.Files = glob.glob(self.Tools_File)

        # Allows for the grid to work
        self.EndRow_Value = 2

        # Loops through all of the tools
        for i in range(len(self.Files)):

            # Imports the tool using a more veritile method as I don't know what will be in the file
            self.directory, self.module_name = os.path.split(self.Files[i])
            self.module_name = os.path.splitext(self.module_name)[0]

            self.path = list(sys.path)
            sys.path.insert(0, self.directory)
            try:
                Tool = __import__(self.module_name)
                self.Tools_list.append(Tool)
            finally:
                sys.path[:] = self.path  # restore

            # Adds the button to run the tool
            self.Tools_btn = self.tb.AddButton(
                self.Tools_fr, self.module_name, Row=self.EndRow_Value, Column=0)
            self.Tools_btn.config(command=lambda Num=i: self.RunTool(Num))

            self.EndRow_Value += 1

        self.Space_lbl1 = self.tb.AddLabel_spacer(
            self.Tools_fr, Row=self.EndRow_Value, Column=0)

        self.Back_btn = self.tb.AddButton(
            self.Tools_fr, "Back", Row=self.EndRow_Value+1, Column=0)
        self.Back_btn.config(command=lambda: self.Tools_fr.destroy())

        self.tb.Align_Grid(self.Tools_fr)
コード例 #8
0
    def __init__(self, Main_fr, LoginSpacer, Login_ent):
        '''
        Loads the GUI processes for the new account screen
        '''

        self.Main_fr = Main_fr
        self.LoginSpacer = LoginSpacer
        self.Login_ent = Login_ent

        self.tb = tkinter_basics.Basics()

        self.NewAccount_fr = self.tb.AddFrame(self.Main_fr, Row=0, Column=0)
        self.NewAccount_fr.grid(row=0, column=0, sticky="nsew", padx=0, pady=0)

        self.Title_lbl = self.tb.AddLabel_title(self.NewAccount_fr,
                                                "New Account:",
                                                Row=0,
                                                Column=0,
                                                CSpan=2)

        self.Space_lbl = self.tb.AddLabel_spacer(self.NewAccount_fr,
                                                 Row=1,
                                                 Column=0,
                                                 CSpan=2)

        # Adds a username label to show where to enter your username
        self.Username_lbl = self.tb.AddLabel(self.NewAccount_fr,
                                             "Username:"******"Password:"******"•",
                                             Row=3,
                                             Column=1)

        # Adds another password label to show where to enter your password
        self.CheckPassword_lbl = self.tb.AddLabel(self.NewAccount_fr,
                                                  "Password (again):",
                                                  Row=4,
                                                  Column=0)

        # Adds another entry so the user can type in there username
        self.CheckPassword_ent = self.tb.AddEntry(self.NewAccount_fr,
                                                  Show="•",
                                                  Row=4,
                                                  Column=1)

        self.Space_lbl_1 = self.tb.AddLabel_spacer(self.NewAccount_fr,
                                                   Row=5,
                                                   Column=0,
                                                   CSpan=2)

        self.Back_btn = self.tb.AddButton(self.NewAccount_fr,
                                          "Back",
                                          Row=6,
                                          Column=0)
        self.Back_btn.config(command=lambda: self.NewAccount_fr.destroy())

        self.Create_btn = self.tb.AddButton(self.NewAccount_fr,
                                            "Create Account",
                                            Row=6,
                                            Column=1)
        self.Create_btn.config(command=lambda: self.Create())

        self.tb.Align_Grid(self.Main_fr)
        self.tb.Align_Grid(self.NewAccount_fr)

        # Binds the enter key to create the account
        self.Username_ent.bind("<Return>", lambda e: self.Create())
        self.Password_ent.bind("<Return>", lambda e: self.Create())
        self.CheckPassword_ent.bind("<Return>", lambda e: self.Create())