โค้ด: เลือกทั้งหมด
from tkinter import *
from tkinter import messagebox as ms
from selenium import webdriver
import sqlite3
โค้ด: เลือกทั้งหมด
with sqlite3.connect('quit.db') as db:
c = db.cursor()
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['text'] = self.username.get() + '\n Loged In'
self.head['pady'] = 150
else:
chromedriver = 'D:\\chromedriver_win32\\chromedriver.exe'
brower = webdriver.Chrome()
brower.get('------------------------------------------------------------'')
โค้ด: เลือกทั้งหมด
def widgets(self):
self.head = Label(self.master,text = 'LOGIN',font = ('',25),pady = 10)
self.head.pack()
self.logf = Frame(self.master,padx =10,pady = 10)
Label(self.logf,text = 'Host Name : ',font = ('',20),pady=5,padx=5).grid(sticky = W)
Entry(self.logf,textvariable = self.hostname,bd = 5,font = ('',15)).grid(row=0,column=1)
Label(self.logf,text = '-------------',font = ('',20),pady=5,padx=5).grid(sticky = W)
Entry(self.logf,textvariable = self.password,bd = 5,font = ('',15)).grid(row=1,column=1)
Label(self.logf,text = 'Username : ',font = ('',20),pady=5,padx=5).grid(sticky = W)
Entry(self.logf,textvariable = self.username,bd = 5,font = ('',15)).grid(row=2,column=1)
Label(self.logf,text = 'Password : ',font = ('',20),pady=5,padx=5).grid(sticky = W)
Entry(self.logf,textvariable = self.password,bd = 5,font = ('',15),show = '*').grid(row=3,column=1)
Label(self.logf,text = '-------------',font = ('',20),pady=5,padx=5).grid(sticky = W)
Entry(self.logf,textvariable = self.password,bd = 5,font = ('',15)).grid(row=4,column=1)
Button(self.logf,text = ' RUN ',bd = 3 ,font = ('',14),padx=5,pady=5,command=self.login).grid(row=7,column=1)
Button(self.logf,text = ' --- ',bd = 3 ,font = ('',14),padx=5,pady=5,command=self.login).grid(row=7,column=2)
self.logf.pack()
ผลรัน
จะขึ้นหน้าต่างนี้มาเมื่อกดปุ่มรันจะขึ้น webdriver ที่เรากำหนดใว้