Advertisement
Andydrei

Register program

Oct 21st, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3. import sqlite3
  4. from tkinter.filedialog import askopenfilename
  5.  
  6. gui=Tk()
  7. Tk().withdraw()
  8.  
  9.  
  10. User=StringVar()
  11. Password=StringVar()
  12. def database():
  13.     username=User.get()
  14.     password=Password.get()
  15.     conn = sqlite3.connect('INFO.db')
  16.     with conn:
  17.         cursor=conn.cursor()
  18.     cursor.execute('CREATE TABLE IF NOT EXISTS Student (User TEXT, Password TEXT)')
  19.     cursor.execute('INSERT INTO Student(User,Password) VALUES(?,?)',(username, password))
  20.     conn.commit()
  21.  
  22.    
  23. def login():
  24.     if entry in database:           #The error is here
  25.         filename=askopenfilename('parole.txt')
  26.         print(filename)    
  27.     else:
  28.         error = Label(gui, text='WRONG INFO', bg='red', fg='dark red').grid(x=190,y=190)
  29.  
  30. # @@@@@@@@@@@@ INFO REGISTER @@@@@@@@@@@@@@@@@@
  31. def label():
  32.     a = Label(gui,
  33.               text='Username: ',
  34.               fg='cyan',
  35.               bg='dark blue').grid(row=0,column=0)
  36.  
  37.     b = Label(gui,
  38.               text='Password: ',
  39.               fg='cyan',
  40.               bg='dark blue').grid(row=1,column=0)
  41.  
  42. label()
  43.  
  44. #    @@@@@@@@@@@@@@@  INPUT      @@@@@@@@@@@@@@@@@@@
  45. def entry():
  46.     a1 = Entry(gui, bg='light grey', fg='black').grid(row=0,column=1)
  47.     b1 = Entry(gui, bg='light grey', fg='black').grid(row=1,column=1)
  48.  
  49. entry()
  50. # Make sure fist is capital and second is not
  51. gui. title("First title")
  52.  
  53.  
  54. #    @@@@@@@@@@@@@@@ BUTTONS    @@@@@@@@@@@@@@@@@@@@@@
  55. log = Button(gui, text='Log In', relief=RAISED, command=login).grid(row=2, column=0)
  56. register = Button(gui, text='Register', relief=RAISED, command=database).grid(row=2, column=1)
  57.  
  58.  
  59. gui.geometry('400x400')
  60. gui.configure(bg="black")
  61. gui.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement