НАДЯ
unknown
python
3 years ago
9.0 kB
14
Indexable
from tkinter import *
from tkinter import ttk, messagebox
import csv
mdm = ['0']*14
md = []
mcom = ['New']
mcom1 = ['']
mcom2 = ['']
def users():
rootu=Toplevel(root)
rootu.title("Пользователи")
rootu.geometry("650x450x+300+200")
rootu.resizable(0, 0)
rootu.wn_attributes("-topmost", 1)
Label1=Label(rootu, text = "Работа пользователей", font="14")
Label1.pack()
def click_button1():
rootu.destroy()
bts16['state'] = NORMAL
def click_button2():
pass
def click_button3():
pass
def click_button4():
pass
bts1 = Button(
rootu,
text = "В главное меню",
padx="10",
pady="8",
font="10",
command=click_button1()
)
bts1.place(x=450, y=360)
bts2 = Button(
rootu,
text="Файл 1",
padx="10",
pady="8",
font="10",
command=click_button2()
)
bts2.place(x=70, y=180)
bts3 = Button(
rootu,
text="Файл 2",
padx="10",
pady="8",
font="10",
command=click_button3()
)
bts3.place(x=260, y=180)
bts4 = Button(
rootu,
text="Файл 3»",
padx="10",
pady="8",
font="10",
command=click_button4()
)
bts4.place(x=450, y=180)
rootu.mainloop()
def admin():
global mdm, md, mcom, mcom1, mcom2
j=0
def click_button1():
global md, mdm, mcom, mcom1, mcom2
mdm[0] = login.get()
mdm[1] = parol.get()
if conbo_user != 0:
del md[conbo_user.current()-1]
md.append(mdm)
mcom=['New']
mcom1=['']
mcom2=['']
i=1
for row in md:
mcom.append(str(i))
mcom1.append(row[0])
mcom2.append(row[1])
i+=1
conbo_user["value"] = mcom
bts2['state'] = NORMAL
def click_button2():
pass
def click_button3():
global j
j=1
if j == 1:
with open("data.csv","w",newline="",encoding="utf8") as file:
writer=csv.writer(file)
writer.writerow(*md)
rootad.destroy()
bts16['state'] = NORMAL
j=0
def click_button4():
global mdm
if bts4['fg'] == '#000000':
bts4['fg'] = '#00ff00'
mdm[2] = '1'
else:
bts4['fg'] = '#000000'
mdm[2] = '0'
def click_button5():
if bts5['fg'] == '#000000':
bts5['fg'] = '#00ff00'
mdm[3] = '1'
else:
bts5['fg'] = '#000000'
mdm[3] = '0'
def click_button6():
if bts6['fg'] == '#000000':
bts6['fg'] = '#00ff00'
mdm[4] = '1'
else:
bts6['fg'] = '#000000'
mdm[4] = '0'
def click_button7():
if bts7['bg'] == '#F0F0F0':
bts7['bg'] = '#00ff00'
mdm[5] = '1'
else:
bts7['bg'] = '#F0F0F0'
mdm[5] = '0'
def fun1(event):
global mdm
j=0
entry1.delete(0, END)
entry2.delete(0, END)
i = conbo_user.current()
entry1.insert(END, mcom1[i])
entry2.insert(END, mcom2[i])
mm = []
mm = md[i-1]
mdm = mm
if mm[2] == '1':
bts4['fg'] = '#00ff00'
else:
bts4['fg'] = '000000'
if mm[3] == '1':
bts5['fg'] = '#00ff00'
else:
bts5['fg'] = '000000'
if mm[4] == '1':
bts6['fg'] = '#00ff00'
else:
bts6['fg'] = '000000'
if mm[5] == '1':
bts7['bg'] = '#00ff00'
else:
bts7['bg'] = 'F0F0F0'
rootad = Toplevel(root)
rootad.title("Администратор")
rootad.geometry("650x450+300+200")
rootad.resizable(0, 0)
rootad.wm_attributes("-topmost", 1)
login = StringVar()
parol = StringVar()
Label1 = Label(rootad, text="Администратор", font="14")
Label1.pack()
Label2 = Label(rootad, text="Логин:", font="12")
Label2.place(x=240, y=50)
Label3 = Label(rootad, text="Пароль:", font="12")
Label3.place(x=450, y=50)
Label4 = Label(rootad, text="Порядковый номер:", font="12")
Label4.place(x=10, y=50)
conbo_user = ttk.Combobox(rootad, values=mcom, font="11", width=15)
conbo_user.current(0)
conbo_user.bind("<<ComboboxSelected>>", fun1)
conbo_user.place(x=10, y=80)
entry1=Entry(rootad, textvariable=login, font="12", width=15)
entry1.place(x=240, y=80)
entry2=Entry(rootad, textvariable=parol, font="12", width=15)
entry2.place(x=450, y=80)
Label5=Label(rootad, text="Файл 1", font="10")
Label5.place(x=240, y=120)
Label6 = Label(rootad, text="Файл 2", font="10")
Label6.place(x=390, y=120)
Label7 = Label(rootad, text="Файл 3", font="10")
Label7.place(x=540, y=120)
bts1 = Button(
rootad,
text="Добавить пользователя",
padx="10",
pady="8",
font="10",
command=click_button1
)
bts1.place(x=10, y=360)
bts2 = Button(
rootad,
text="Сохранить",
padx="10",
pady="8",
font="10",
command=click_button2
)
bts2.place(x=293, y=360)
bts2['state'] = DISABLED
bts3 = Button(
rootad,
text="В главное меню",
padx="10",
pady="8",
font="10",
command=click_button3
)
bts3.place(x=450, y=360)
bts4 = Button(
rootad,
text="Все права",
padx="3",
pady="3",
font="8", width=8,
command=click_button4
)
bts4.place(x=240, y=148)
bts5 = Button(
rootad,
text="Запрет",
padx="3",
pady="3",
font="8", width=8,
command=click_button5
)
bts5.place(x=240, y=197)
bts6 = Button(
rootad,
text="Чтение",
padx="3",
pady="3",
font="8", width=8,
command=click_button6
)
bts6.place(x=240, y=251)
bts7 = Button(
rootad,
text="Запись",
padx="3",
pady="3",
font="8", width=8,
command=click_button7
)
bts7.place(x=240, y=300)
rootad.mainloop()
with open("data.csv", "r", encoding="utf8") as file:
reader = csv.reader(file)
i = 1
for row in reader:
md.append(row)
mcom.append(str(i))
mcom1.append(row[0])
mcom2.append(row[1])
i+=1
def click_button16():
if Login.get() == 'Admin':
if Parol.get() == 'Admin':
bts16['state']=DISABLED
admin()
else:
messagebox.showinfo("", "Не правильно введены Логин и Пароль")
return
for i in range(len(mcom1)-1):
if Login.get() == mcom1[i+1]:
if Parol.get() == mcom2[i+1]:
bts16['state'] = DISABLED
users()
else:
messagebox.showinfo("", "Не правильно введены Логин и Пароль")
return
messagebox.showinfo("", "Не правильно введены Логин и Пароль")
def click_button17():
root.destroy()
root=Tk()
root.title("Главное меню")
root.geometry("650x450+300+200")
root.resizable(0, 0)
Login = StringVar()
Parol = StringVar()
Label1 = Label(root, text="Программа моделирования и управления доступом", font="14")
Label1.pack()
Label2 = Label(root, text="Введите логин:", font="14")
Label2.place(x=130, y=100)
Label3 = Label(root, text="Введите пароль:", font="14")
Label3.place(x=130, y=150)
entry1 = Entry(root, textvariable=Login, font="14")
entry1.place(x=300, y=100)
entry2 = Entry(root, textvariable=Parol, font="14", show='*')
entry2.place(x=300, y=150)
bts16 = Button(
root,
text="Вход",
padx="10",
pady="8",
font="14",
command=click_button16
)
bts16.place(x=200, y=360)
bts17 = Button(
root,
text="Выход",
padx="10",
pady="8",
font="14",
command=click_button17
)
bts17.place(x=350, y=360)
root.mainloop()Editor is loading...