код работает, когда я вызываю функцию для начала, но после входа в систему я получаю ошибку int - PullRequest
0 голосов
/ 25 апреля 2020

, так что моя система входа в систему работает, и все мои показатели эффективности бизнеса работают сами по себе при тестировании, однако, когда я go к одному из параметров на экране входа в систему, я получаю эту ошибку: ValueError: неверный литерал для int () с основание 10: '' здесь указан код для входа в систему:

def register_db():
    username_info = username.get()
    password_info = password.get()

    c.execute('CREATE TABLE IF NOT EXISTS userDetails(id integer primary key autoincrement, username TEXT, password TEXT, fixedcosts INTEGER, vcpu INTEGER, sppu INTEGER)')

    c.execute("INSERT INTO userDetails(username, password) VALUES (?, ?)",
              (username_info, password_info))
    conn.commit()
    main_menu()

def register():
    global screen1
    screen1 = Toplevel(screen)
    screen1.title("Registration")
    screen1.geometry("700x500")
    screen1.configure(bg="white")

    global username
    global password
    username = StringVar()
    password = StringVar()

    Label(screen1, text = "Enter your details below in order to register", bg = "white").pack()
    Label(screen1, text = "", bg = "white").pack()
    Label(screen1, text = "Username*", bg = "white").pack()
    Entry(screen1, textvariable = username, borderwidth=1, relief ="solid").pack()
    Label(screen1, text = "Password*", bg = "white").pack()
    Entry(screen1, textvariable = password, borderwidth=1, relief ="solid", show="*").pack()
    Label(screen1, text = "", bg = "white").pack()
    Label(screen1, text = "", bg = "white").pack()
    Button(screen1, text = "Register", width = 15, height = 1, command = validatepassword).pack() 

def validatepassword():
    val = True
    if len(password.get()) < 6: 
        Label(screen1, text = "The length of your password should be higher than 6", bg = "white").pack() 
        val = False 

    if len(password.get()) > 20: 
        Label(screen1, text = "The length of your password should be not be greater than 20", bg = "white").pack()
        val = False

    if not any(char.isdigit() for char in password.get()): 
        Label(screen1, text = "Password should have at least one number", bg = "white").pack()
        val = False

    if not any(char.isupper() for char in password.get()): 
        Label(screen1, text = "Password should have at least one uppercase letter", bg = "white").pack()
        val = False

    if not any(char.islower() for char in password.get()): 
        Label(screen1, text = "Password should have at least one lowercase letter", bg = "white").pack()
        val = False

    if val == True:
        register_db()


def login_verify():
    username1 = username_verify.get()
    password1 = password_verify.get()

    c.execute('SELECT * FROM userDetails WHERE username = ? AND password = ?', (username1, password1))

    if c.fetchall():
        Label(screen2, text = "Welcome", bg = "white").pack()
        main_menu()
    else:
        Label(screen2, text = "Login failed", bg = "white").pack()






def login():
    global screen2
    screen2 = Toplevel(screen)
    screen2.title("Login")
    screen2.geometry("700x500")
    screen2.configure(bg="white")
    Label(screen2, text = "Enter your details below in order to login", bg = "white").pack()
    Label(screen2, text = "", bg = "white").pack()

    global username_verify
    global password_verify
    username_verify = StringVar()
    password_verify = StringVar()

    Label(screen2, text = "Username*", bg = "white").pack()
    Entry(screen2, textvariable = username_verify, borderwidth=1, relief ="solid").pack()
    Label(screen2, text = "Password*", bg = "white").pack()
    Entry(screen2, textvariable = password_verify, borderwidth=1, relief ="solid", show="*").pack()
    Label(screen2, text = "", bg = "white").pack()
    Label(screen2, text = "", bg = "white").pack()
    Button(screen2, text = "Login", width = 15, height = 1, command = login_verify).pack()

def main_screen():
    global screen

    screen = Tk()
    screen.geometry("700x500")
    screen.title("Enterprise resource manager")
    screen.configure(bg="white")
    Label(text = "Welcome to RK Enterprise Resource Management Tool", bg = "white", font = ("Calibri", 20)).pack()
    Label(text = "", bg = "white").pack()
    Label(text = "", bg = "white").pack()
    Label(text = "", bg = "white").pack()
    Label(text = "", bg = "white").pack()
    Button(text = "Login", height = "2", width = "30", command = login, font = ("Calibri", 15)).pack()
    Label(text = "", bg = "white").pack()
    Label(text = "", bg = "white").pack()
    Button(text = "Register", height = "2", width = "30", command = register, font = ("Calibri", 15)).pack()

    screen.mainloop

, а вот код для одной из мер:

def inventory_turnover():
    global screen8
    screen8 = Tk()
    screen8.geometry("700x500")
    screen8.title("Inventory Turnover")
    screen8.configure(bg="white")

    global cost_of_sales
    global average_inventories_held
    cost_of_sales = StringVar()
    average_inventories_held = StringVar()


    Label(screen8, text = "", bg = "white").pack()
    Label(screen8, text = "", bg = "white").pack()
    Label(screen8, text = "Inventory Turnover Ratio = Cost of sales/Average inventories held", bg = "white", font = ("Calibri", 15)).pack()
    Label(screen8, text = "Cost Of Sales*", bg = "white").pack()
    Entry(screen8, textvariable = cost_of_sales, borderwidth=1, relief ="solid").pack()
    Label(screen8, text = "Average Inventories Held*", bg = "white").pack()
    Entry(screen8, textvariable = average_inventories_held, borderwidth=1, relief ="solid",).pack()
    Label(screen8, text = "", bg = "white").pack()
    Label(screen8, text = "", bg = "white").pack()
    Button(screen8, text = "Calculate", width = 15, height = 1, command = inventory_turnover_calculation).pack()

def inventory_turnover_calculation():

    one = int(cost_of_sales.get())
    two = int(average_inventories_held.get())

    inventory_turnover = one / two
    Label(screen8, text = "", bg = "white").pack()
    Label(screen8, text = ("answer = ",inventory_turnover), bg = "white").pack()
    Label(screen8, text = "", bg = "white").pack()
    Label(screen8, text = ""A low turnover implies weak sales and possibly excess inventory,
while a high ratio implies either strong sales or insufficient inventory"", bg = "white").pack()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...