Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter as tk
- import tkinter.ttk as ttk
- from tkinter.ttk import Combobox
- import psycopg2
- import time
- from tkinter import messagebox as mb
- from PIL import Image
- from PIL import ImageTk
- con = psycopg2.connect(
- #данные
- )
- TITLE = "Authentification"
- WIDTH = 200
- HEIGHT = 200
- # Classes and Utils functions
- root = tk.Tk()
- root.title(TITLE)
- root.geometry(str(WIDTH) + 'x' + str(HEIGHT))
- root.resizable(False, False)
- tries = 0
- # Programm functions and Event handlers
- def page():
- label_login = tk.Label(root, text='Login:', )
- entry_login = tk.Entry(root)
- label_password = tk.Label(root, text='Password:')
- entry_password = tk.Entry(root, show='*')
- button_login = tk.Button(root, text='LogIn', command=lambda: log_in(entry_login, entry_password, button_login))
- button_signup = tk.Button(root, text='SignUp', command=lambda: signup(entry_login, entry_password))
- label_login.place(x=10, y=10)
- entry_login.place(x=10, y=35)
- label_password.place(x=10, y=60)
- entry_password.place(x=10, y=85)
- button_login.place(x=10, y=115, width=50, height=25)
- button_signup.place(x=10, y=155, width=50, height=25)
- def log_in(entry_login, entry_password, button_login):
- global tries
- login1 = entry_login.get()
- password1 = entry_password.get()
- cur = con.cursor()
- cur.execute(f"SELECT count(*) FROM users WHERE login = '{login1}' and password = '{password1}'")
- rows = cur.fetchall()
- print(rows)
- if rows[0][0] == 1:
- start_page()
- if rows[0][0] == 0:
- tries += 1
- lbl_t = Label(root, text="Wrong login/password")
- lbl_t.place(x=60, y=115)
- print('wrong')
- print(tries)
- if tries >= 3:
- print('more 3 tries')
- button_login.place_forget()
- entry_login.place_forget()
- entry_password.place_forget()
- time.sleep(5)
- button_login.place(x=10, y=115, width=50, height=25)
- entry_login.place(x=10, y=35)
- entry_password.place(x=10, y=85)
- tries = 0
- def start_page():
- root.iconify()
- top = Toplevel()
- top.wm_state('zoomed')
- menu = Menu(top)
- new_item = Menu(menu)
- new_item.add_command(label='exit', command=lambda: destroy(top))
- menu.add_cascade(label='menu', menu=new_item)
- top.config(menu=menu)
- tab_control = ttk.Notebook(top)
- t_textile = ttk.Frame(tab_control)
- t_ingridients = ttk.Frame(tab_control)
- t_products = ttk.Frame(tab_control)
- ################################################################################
- t_workshop = ttk.Frame(tab_control)
- tab_control.add(t_textile, text='Utensils')
- tab_control.add(t_ingridients, text='Ingridients')
- tab_control.add(t_products, text='Cake decoration')
- tab_control.add(t_workshop, text='Workshops')
- tab_control.pack(expand=1, fill='both')
- # tab utensils
- tree_u = ttk.Treeview(t_textile, columns=('name', 'type', 'age', 'value'), show='headings', height=50)
- tree_u.column('name', width=100, anchor=tk.CENTER)
- tree_u.column('type', width=165, anchor=tk.CENTER)
- tree_u.column('age', width=150, anchor=tk.CENTER)
- tree_u.column('value', width=100, anchor=tk.CENTER)
- tree_u.heading('name', text='name')
- tree_u.heading('type', text='type')
- tree_u.heading('age', text='age')
- tree_u.heading('value', text='value')
- tree_u.pack()
- show = Button(t_textile, text="Show", command=lambda: show_utensils(tree_u))
- show.place(x=350, y=0)
- # tab cake decoration
- tree = ttk.Treeview(t_products,columns=('art','name','ed.izm', 'value','shelf life','cost', 'supplier'),show='headings', height=50)
- tree.column('art', width=50, anchor=tk.CENTER)
- tree.column('name', width=100, anchor=tk.CENTER)
- tree.column('value', width=100, anchor=tk.CENTER)
- tree.column('ed.izm', width=100, anchor=tk.CENTER)
- tree.column('cost', width=60, anchor=tk.CENTER)
- tree.column('shelf life', width=100, anchor=tk.CENTER)
- tree.column('supplier', width=100, anchor=tk.CENTER)
- tree.heading('art', text='art')
- tree.heading('name', text='name')
- tree.heading('value', text='value')
- tree.heading('ed.izm', text='ed.izm')
- tree.heading('cost', text='cost')
- tree.heading('shelf life', text='shelf life')
- tree.heading('supplier', text='supplier')
- tree.pack()
- show = Button(t_products, text="Show", command=lambda: show_records(tree))
- show.place(x=250, y=0)
- edit = Button(t_products, text="add", command=lambda: add_records(tree))
- edit.place(x=250, y=50)
- delete = Button(t_products, text="Del", command=lambda: del_records(tree))
- delete.place(x=250, y=100)
- interval = Button(t_products, text="interval of dates",command=lambda: interval_decor(tree))
- interval.place(x=250, y=150)
- # tab ingridients
- tree_i = ttk.Treeview(t_ingridients,
- columns=('name', 'value', 'delivery time', 'supplier', 'art', 'ed.izm', 'cost',),
- show='headings', height=50)
- tree_i.column('art', width=50, anchor=tk.CENTER)
- tree_i.column('name', width=100, anchor=tk.CENTER)
- tree_i.column('value', width=100, anchor=tk.CENTER)
- tree_i.column('ed.izm', width=100, anchor=tk.CENTER)
- tree_i.column('cost', width=60, anchor=tk.CENTER)
- tree_i.column('delivery time', width=100, anchor=tk.CENTER)
- tree_i.column('supplier', width=100, anchor=tk.CENTER)
- tree_i.heading('art', text='art')
- tree_i.heading('name', text='name')
- tree_i.heading('value', text='value')
- tree_i.heading('ed.izm', text='ed.izm')
- tree_i.heading('cost', text='cost')
- tree_i.heading('delivery time', text='delivery time')
- tree_i.heading('supplier', text='supplier')
- tree_i.pack()
- show = Button(t_ingridients, text="Show", command=lambda: show_ingridients(tree_i))
- show.place(x=250, y=0)
- edit = Button(t_ingridients, text="add", command=lambda: add_ingridients())
- edit.place(x=250, y=50)
- delete = Button(t_ingridients, text="Del", command=lambda: del_ingridients(tree_i))
- delete.place(x=250, y=100)
- interval = Button(t_ingridients, text="interval of dates", command=lambda: interval_ingridients(tree_i))
- interval.pack()
- ################################################################################
- #tab workshops
- labelTop = tk.Label(t_workshop,text = "Choose workshop:")
- labelTop.pack()
- comboExample = ttk.Combobox(t_workshop, values=("Assembly", "Backing","Design","Packing","Production"))
- comboExample.pack()
- choosed = Button(t_workshop,text='Ok',command=lambda:current_workshop(comboExample,t_workshop))
- choosed.pack()
- ################################################################################
- # defs
- def current_workshop(comboExample,t_workshop):
- shop = comboExample.get()
- if shop == 'Design':
- img = ImageTk.PhotoImage(Image.open("icons/FirstAid.png"))
- panel = Label(t_workshop, image=img)
- panel.pack(side="bottom", fill="both", expand="yes")
- print('suc')
- else:
- print('No')
- def destroy(top):
- top.iconify()
- root.deiconify()
- start_page()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement