Source code for python programs
Login Python Source code
- Get link
- X
- Other Apps
Hi Guys if you are a beginner in python so that code will improve your programming skill, i will give here simple login program for python that you can use in your program and add more functionality
First import all library
from tkinter import *
from PIL import ImageTk,Image
from tkinter import messagebox
from tkinter import ttk
import os
import csv
def open_win():
top = Toplevel()
def fun():
with
open("username_info.txt","r") as file1:
file_reader = csv.reader(file1)
file1.close()
login_b1 =
Button(root, text="Log in", command=log()).pack()
def log(file1):
user =
username_verify.get()
pas =
password_verify.get()
for row in file1:
if
row[0] == user and row[1] == pas:
open_win()
else:
messagebox.show("Password incorrect")
"""
list_file =
os.listdir()
if user in
list_file:
file1 = open(user,"r")
verify = file1.read().splitlines()
if
pas in verify:
open_win()
else:
messagebox._show("Password incorrect")
else:
messagebox._show("No user found")
#if (user ==
str("Monic") and pas == str("1234")):
#
open_win()
#else:
#
messagebox.askyesno("Monic Login System", "Invalid Login")
#
user.set("")
#
pas.set("")
"""
def reg():
global register
register =
Toplevel(root)
register.title("Register")
register.geometry("300x250")
global username
global password
global
username_entry
global
password_entry
username =
StringVar()
password =
StringVar()
username_label =
Label(register, text="Username").pack()
username_entry =
Entry(register, textvariable=username).pack()
password_label =
Label(register, text="Password").pack()
password_entry =
Entry(register, textvariable=password, show = '*').pack()
b1 =
Button(register, text="Submit", command=register_user).pack()
def register_user():
username_info =
username.get()
password_info =
password.get()
file =
open("username_info.txt","w")
file.write(username_info +"\n")
file.write(password_info)
file.close()
messagebox.showinfo("Registration successful")
Label(register,
text = "Registration Success", fg = "blue", font =
("calibri", 11)).pack()
def main_account():
global root
root = Tk()
root.title("tittat")
root.geometry("450x450")
# global register
global
username_verify
global
password_verify
global
username_loginentry
global
password_loginentry
username_verify =
StringVar()
password_verify =
StringVar()
login_l1 =
Label(root, text ="Username").pack()
username_loginentry = Entry(root, textvariable = username_verify).pack()
login_l2 =
Label(root, text ="Password").pack()
password_loginentry = Entry(root, textvariable = password_verify).pack()
login_b1 =
Button(root, text = "Log in", command = fun).pack()
login_b2 =
Button(root, text = "Register", command = reg).pack()
root.mainloop()
main_account()
- Get link
- X
- Other Apps
Comments
Post a Comment