Ejemplo n.º 1
0
def reg_main_admin_auth(type_win):
    global reg_main_admin_auth_window, auth_window

    if type_win == "auth":
        reg_main_admin_auth_window = Windows.reg_main_admin_auth_window_create(
            type_window="TopLevel")

        reg_main_admin_auth_window.ok_button.bind(
            "<Button-1>", main_admin_auth_ok_button_event)
        reg_main_admin_auth_window.ok_button.bind(
            "<Return>", main_admin_auth_ok_button_event)

        reg_main_admin_auth_window.exit_button.bind(
            "<Button-1>", reg_main_admin_auth_exit_button_event)
        reg_main_admin_auth_window.exit_button.bind(
            "<Return>", reg_main_admin_auth_exit_button_event)
    elif type_win == "reg":
        reg_main_admin_auth_window = Windows.reg_main_admin_auth_window_create(
            type_window="Main")

        Windows.message_box("Enter Main Admin for program please", 1, "good")

        reg_main_admin_auth_window.ok_button.bind(
            "<Button-1>", reg_main_admin_ok_button_event)
        reg_main_admin_auth_window.ok_button.bind(
            "<Return>", reg_main_admin_ok_button_event)

        reg_main_admin_auth_window.exit_button.destroy()

    reg_main_admin_auth_window.login_text.bind(
        "<KeyPress>", reg_main_admin_auth_login_text_event)
    reg_main_admin_auth_window.password_text.bind(
        "<KeyPress>", reg_main_admin_auth_password_text_event)

    reg_main_admin_auth_window.root.mainloop()
Ejemplo n.º 2
0
def main_admin_auth_ok_button_event(ev):
    login = reg_main_admin_auth_window.login_text.get()
    password = reg_main_admin_auth_window.password_text.get()
    if login in log_array.keys() and log_array[login][
            0] == password and log_array[login][1] == "Main_Admin":
        login = reg_window.login_text.get()
        password = reg_window.password_text.get()

        log_array[login] = [password, "Admin"]
        with open("./app_lib/Database/manager_data/log_array.pkl",
                  "wb") as file:
            pcl.dump(log_array, file)

        reg_main_admin_auth_window.root.destroy()
        reg_window.root.destroy()
        auth_window.root.destroy()

        auth_win()
    else:
        reg_main_admin_auth_window.root.destroy()
        reg_window.root.destroy()

        text = "You're not Main Admin!\n goodbye!"
        Windows.message_box(text, 2, "bad")

        reg_win()
Ejemplo n.º 3
0
def auth_ok_button_event(_):
    user = [
        str(auth_window.login_text.get()).strip(),
        str(auth_window.password_text.get()).strip()
    ]

    # проверяем логин, если такой есть, то проверяем пароль, если все нормально идем дальше,
    # если нет, то выдаем сообщения об ошибке
    if user[0] in log_array.keys():
        if log_array[user[0]][0] == user[1]:
            auth_window.root.destroy()
            user_func.user_win(log_array[user[0]][1])
            return
        else:
            text = "Friend, I know you, but you do not know your password!\n "
            text = text + "you are real?\n prove it! remember your password!"
            Windows.message_box(text, 3, "good")
            return

    Windows.message_box(
        "Friend, I don't know who are you!\n Please sign up to me or get out from me!",
        2, "bad")
    auth_window.reg_button.configure(relief="raised",
                                     bg="#ff2200",
                                     activebackground="#ff2200")
    auth_window.ok_button.configure(relief="raised", state="normal")
    return
Ejemplo n.º 4
0
def reg_main_admin_ok_button_event(ev):
    global log_array
    login = reg_main_admin_auth_window.login_text.get()
    password = reg_main_admin_auth_window.password_text.get()

    log_array = {}
    log_array[login] = [password, "Main_Admin"]

    with open("./app_lib/Database/manager_data/log_array.pkl", "wb") as file:
        pcl.dump(log_array, file)

    Windows.message_box("Ok", 1, "good")

    reg_main_admin_auth_window.root.destroy()
Ejemplo n.º 5
0
def auth_win():
    global auth_window, log_array

    try:
        with open("./app_lib/Database/manager_data/log_array.pkl",
                  "rb") as file:
            log_array = pcl.load(file)
    except FileNotFoundError:
        reg_main_admin_auth(type_win="reg")

    auth_window = Windows.auth_window_create()

    auth_window.login_text.bind("<KeyPress>", auth_refocus_l_p)

    auth_window.password_text.bind("<KeyPress>", auth_refocus_p_b)

    auth_window.reg_button.bind("<Button-1>", auth_reg_button_event)
    auth_window.reg_button.bind("<Return>", auth_reg_button_event)

    auth_window.ok_button.bind("<Button-1>", auth_ok_button_event)
    auth_window.ok_button.bind("<Return>", auth_ok_button_event)

    auth_window.canvas.bind("<Motion>", auth_exit_button_graph)
    auth_window.exit_button.bind("<Button-1>", auth_exit_button_event)
    auth_window.exit_button.bind("<Return>", auth_exit_button_event)

    # создаем доп поток для графики
    graph = Thread(daemon=True, target=canvas_graphic())
    # стартуем доп поток
    graph.start()

    auth_window.root.mainloop()
Ejemplo n.º 6
0
def reg_ok_button_event(ev):
    condition1 = (reg_window.control_password_again_label is None or
                  reg_window.control_password_again_label["bg"] == "#ff2222")
    condition2 = (reg_window.control_password_label is None
                  or reg_window.control_password_label["bg"] == "#ff2222")
    condition3 = (reg_window.control_password_label is None
                  or reg_window.control_password_label["bg"] == "#ff2222")
    if condition1 or condition2 or condition3:
        text = "Friend, your login or password is incorrect!\n correct the problem and try again!"
        Windows.message_box(text, 2, "bad")
        return
    if 'selected' not in reg_window.check_admin.state():
        login = reg_window.login_text.get()
        password = reg_window.password_text.get()

        log_array[login] = [password, "Student"]
        with open("./app_lib/Database/manager_data/log_array.pkl",
                  "wb") as file:
            pcl.dump(log_array, file)

        reg_exit_button_event(True)
    else:
        reg_main_admin_auth(type_win="auth")
Ejemplo n.º 7
0
def user_add_win(user_type):
    global user_add_table_window, data_to_pars
    user_add_table_window = Windows.user_add_table_window_create()
    user_add_table_window.u_t = user_type
    data_to_pars = add_tabel_func.array_and_dict_realise()

    user_add_table_window.cbox_to_indicator["values"] = data_to_pars[1][1]
    user_add_table_window.cbox_to_region["values"] = data_to_pars[2][1]
    user_add_table_window.cbox_to_first_date["values"] = data_to_pars[0][1]
    user_add_table_window.cbox_to_second_date["values"] = data_to_pars[0][1]

    user_add_table_window.cbox_to_first_date.bind("<Leave>",
                                                  update_second_data)
    user_add_table_window.ok_button.bind("<Button-1>",
                                         user_add_ok_button_event)
    user_add_table_window.exit_button.bind("<Button-1>",
                                           user_add_exit_button_event)

    user_add_table_window.root.mainloop()
Ejemplo n.º 8
0
def user_win(user_type):
    global user_window
    user_window = Windows.user_window_create(user_type)

    user_window.existing_table.bind("<Button-1>", user_existing_table_event)
    user_window.view_button.bind("<Button-1>", user_view_button_event)
    user_window.exit_button.bind("<Button-1>", user_exit_button_event)
    if user_type == "Admin":
        user_window.add_button.bind("<Button-1>", user_add_button_event)

    # добавляем таблицы в лист таблиц
    list_table_inserting()

    # создаем доп поток для графики
    graph = Thread(canvas_graphic())
    # стартуем доп поток
    graph.start()

    user_window.root.mainloop()
Ejemplo n.º 9
0
def pars_run(array, name, user_type):

    global reg, pb

    reg = array[1][1]
    table_name = '''Данные о "{}" в регионе: "{}"'''.format(array[0][1], reg)
    array = _preliminary_processing_to_parser(array)
    pb = Windows.MyProgressBarWindow(num=len(array[1]) + 2,
                                     user_type=user_type)

    graph_thread = Thread(daemon=True, target=graph_for_pb)

    pars_thread = Thread(daemon=True,
                         target=_to_pickle,
                         args=(array, name, table_name))

    pb.ok_button.bind("<Button-1>", _exit)
    graph_thread.start()
    pars_thread.start()

    pb.window.mainloop()
Ejemplo n.º 10
0
def reg_win():
    global reg_window
    reg_window = Windows.auth_reg_window_create()

    reg_window.control_login_label = None
    reg_window.control_password_label = None
    reg_window.control_password_again_label = None

    reg_window.ok_button.bind("<Button-1>", reg_ok_button_event)
    reg_window.ok_button.bind("<Return>", reg_ok_button_event)
    reg_window.exit_button.bind("<Button-1>", reg_exit_button_event)
    reg_window.exit_button.bind("<Return>", reg_exit_button_event)

    reg_window.login_text.bind("<KeyPress>", reg_login_text_event)
    reg_window.password_text.bind("<KeyPress>", reg_password_text_event)
    reg_window.password_again_text.bind("<KeyPress>",
                                        reg_password_again_text_event)

    t = Thread(reg_graph())
    t.start()

    reg_window.root.mainloop()