Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- from tkinter import *
- from tkinter import messagebox
- import tkinter
- from tkinter import ttk
- from tkinter import *
- from tkinter import messagebox
- import json
- import requests
- import os
- from tkcalendar import DateEntry
- from datetime import date
- ###########################################################
- #Database Connection
- with sqlite3.connect('quit.db') as db:
- c = db.cursor()
- c.execute('CREATE TABLE IF NOT EXISTS user (username TEXT NOT NULL ,password TEXT NOT NULL);')
- db.commit()
- db.close()
- #Login Class
- class login:
- def __init__(self,master):
- # Window
- self.master = master
- # Some Usefull variables
- self.username = StringVar()
- self.password = StringVar()
- self.n_username = StringVar()
- self.n_password = StringVar()
- #Create Widgets
- self.widgets()
- #Login Function
- def login(self):
- #Establish Connection
- with sqlite3.connect('quit.db') as db:
- c = db.cursor()
- #Find user If there is any take proper action
- find_user = ('SELECT * FROM user WHERE username = ? and password = ?')
- c.execute(find_user,[(self.username.get()),(self.password.get())])
- result = c.fetchall()
- if result:
- self.logf.pack_forget()
- self.head.pack_forget()
- miLabel3 = Label(text="DASHBOARD", font=("Lucida Console", 18), background="gray")
- miLabel3.pack()
- #----Precio BTC en el index-----#
- def draw():
- global text
- frame=tkinter.Frame(root, width=50, height=20, relief='solid', bd=1,)
- frame.place(x=10,y=10)
- root["bg"] = "black"
- root["width"] = 100
- root["height"] = 20
- text=tkinter.Label(frame,text='Ticker', font=("Lucida Console", 8, "bold"), background="black", foreground="magenta1")
- text.pack()
- def refresher():
- global text
- r = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
- json_dump = json.dumps(r.json())
- data = json.loads(json_dump)
- text.configure(text=data['time']['updated'] + " : $" + data['bpi']['USD']['rate'])
- root.after(60000, refresher)
- draw()
- refresher()
- #----Notebook----#
- nb = ttk.Notebook(width=800, height=400)
- nb.pressed_index = None
- #----Pestaña Portfolio----#
- Portfolio = tkinter.Frame(nb, background="grey50")
- nb.add(Portfolio, text='Portfolio', padding=5)
- #----Combobox Shitcoins----#
- combo = ttk.Combobox(Portfolio)
- combo.grid(column=1, row=1, padx=5, pady=2)
- labelShitcoins = Label(Portfolio, text="Shitcoin", font=("Lucida Console", 9, "bold"), bg="gray50")
- labelShitcoins.grid(column=0, row=1, padx=5, pady=2)
- #----Entry Cantidad Monedas----#
- ent1portfolio = tkinter.Entry(Portfolio)
- ent1portfolio.grid(column=1, row=2, padx=5, pady=2)
- ent1portfolio.config(justify="center")
- nombreLabel1 = Label(Portfolio, text="Cantidad", font=("Lucida Console", 9, "bold"), bg="gray50")
- nombreLabel1.grid(column=0, row=2, padx=5, pady=2)
- #----Entry Precio Pagado Por Moneda----#
- ent2portfolio = tkinter.Entry(Portfolio)
- ent2portfolio.grid(column=1, row=3, padx=5, pady=2)
- ent2portfolio.config(justify="center")
- nombreLabel2 = Label(Portfolio, text="Precio BTC", font=("Lucida Console", 9, "bold"), bg="gray50")
- nombreLabel2.grid(column=0, row=3, padx=5, pady=2)
- #----Entry Fecha Portfolio-----#
- nombreLabel3 = Label(Portfolio, text="Fecha de compra", font=("Lucida Console", 9, "bold"), bg="gray50")
- nombreLabel3.grid(column=0, row=4, padx=5, pady=2)
- #---- Boton Save ----#
- botonSave = Button(Portfolio, text="Save")
- botonSave.place(x=238,y=105)
- #----Lista Datos Portfolio----#
- file = open('Bags.txt', 'wb')
- file.close()
- #----Pestaña Charts----#
- Charts = tkinter.Frame(nb, background="gray50")
- nb.add(Charts, text='Charts', padding=5)
- #----Market Stats----#
- f3 = tkinter.Frame(nb, background="gray50")
- #----News----#
- f4 = tkinter.Frame(nb, background="gray50")
- #----Others----#
- f5 = tkinter.Frame(nb, background="gray50")
- nb.add(f3, text='Market Stats', padding=0)
- nb.add(f4, text='News', padding=0)
- nb.add(f5, text='Others', padding=0)
- nb.pack(expand=0, fill='both')
- else:
- messagebox.showerror('Oops!','Username Not Found.')
- def new_user(self):
- #Establish Connection
- with sqlite3.connect('quit.db') as db:
- c = db.cursor()
- #Find Existing username if any take proper action
- find_user = ('SELECT * FROM user WHERE username = ?')
- c.execute(find_user,[(self.username.get())])
- if c.fetchall():
- messagebox.showerror('Error!','Username Taken Try a Diffrent One.')
- else:
- messagebox.showinfo('Success!','Account Created!')
- self.log()
- #Create New Account
- insert = 'INSERT INTO user(username,password) VALUES(?,?)'
- c.execute(insert,[(self.n_username.get()),(self.n_password.get())])
- db.commit()
- #Frame Packing Methods
- def log(self):
- self.username.set('')
- self.password.set('')
- self.crf.pack_forget()
- self.head['text'] = 'LOGIN'
- self.logf.pack()
- def cr(self):
- self.n_username.set('')
- self.n_password.set('')
- self.logf.pack_forget()
- self.head['text'] = 'Create Account'
- self.crf.pack()
- ################################################
- def widgets(self):
- self.head = Label(self.master,text = 'LOGIN',font = ('Lucida Console',20),pady = 8)
- self.head.pack()
- self.logf = Frame(self.master,padx =10,pady = 14)
- Label(self.logf,text = 'Username: ',font = ('Lucida Console',14),pady=6,padx=5).grid(sticky = W)
- Entry(self.logf,textvariable = self.username,bd = 5,font = ('Lucida Console',14)).grid(row=0,column=1)
- Label(self.logf,text = 'Password: ',font = ('Lucida Console',14),pady=6,padx=5).grid(sticky = W)
- Entry(self.logf,textvariable = self.password,bd = 5,font = ('Lucida Console',14),show = '*').grid(row=1,column=1)
- #Boton Login
- Button(self.logf,text = ' Login ',bd = 3 ,font = ('Lucida Console',14),padx=5,pady=8,command=self.login).grid()
- #Boton Create Account
- Button(self.logf,text = ' Create Account ',bd = 3 ,font = ('Lucida Console',14),padx=5,pady=8,command=self.cr).grid(row=2,column=1)
- self.logf.pack()
- self.crf = Frame(self.master,padx =10,pady = 10)
- Label(self.crf,text = 'Username: ',font = ('Lucida Console',14),pady=5,padx=5).grid(sticky = W)
- Entry(self.crf,textvariable = self.n_username,bd = 5,font = ('Lucida Console',14)).grid(row=0,column=1)
- Label(self.crf,text = 'Password: ',font = ('Lucida Console',14),pady=5,padx=5).grid(sticky = W)
- Entry(self.crf,textvariable = self.n_password,bd = 5,font = ('Lucida Console',14),show = '*').grid(row=1,column=1)
- Button(self.crf,text = 'Create Account',bd = 3 ,font = ('Lucida Console',14),padx=5,pady=5,command=self.new_user).grid()
- Button(self.crf,text = 'Go to Login',bd = 3 ,font = ('Lucida Console',14),padx=5,pady=5,command=self.log).grid(row=2,column=1)
- root=Tk()
- login(root)
- style = ttk.Style(root)
- style.theme_use('clam')
- #Toolbar Menu#
- def infoAbout():
- messagebox.showinfo("VaporBot", "Built on 2019 by Mr. Wagecuck")
- def warningLicense():
- messagebox.showwarning("VaporBot License", "Free-License, Non registered")
- def exitBot():
- value=messagebox.askquestion("Exit", "Do you want to exit this program?")
- if value=="yes":
- root.destroy()
- menuBar=Menu(root)
- root.config(menu=menuBar)
- fileFile=Menu(menuBar, tearoff=0)
- fileFile.add_separator()
- fileFile.add_command(label="Quit", command=exitBot)
- fileEdit=Menu(menuBar, tearoff=0)
- fileTools=Menu(menuBar, tearoff=0)
- fileHelp=Menu(menuBar, tearoff=0)
- fileHelp.add_command(label="License", command=warningLicense)
- fileHelp.add_separator()
- fileHelp.add_command(label="About", command=infoAbout)
- menuBar.add_cascade(label="File", menu=fileFile)
- menuBar.add_cascade(label="Edit", menu=fileEdit)
- menuBar.add_cascade(label="Tools", menu=fileTools)
- menuBar.add_cascade(label="Help", menu=fileHelp)
- root.title("VaporBot")
- miFrame=Frame(root, "")
- miFrame.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement