在TKINTER Python中显示主页之前,如何在顶级窗口中添加登录/身份验证?
我指的是一些链接,如:和 有人能建议如何将它们整合到我的计划中吗?下面是我的主程序,程序的顶部和底部(主页)部分。就像我运行程序一样,它会打开一个窗口询问用户用户名和密码,然后验证它是否正确,然后只允许他们访问主程序。谢谢在TKINTER Python中显示主页之前,如何在顶级窗口中添加登录/身份验证?,python,tkinter,Python,Tkinter,我指的是一些链接,如:和 有人能建议如何将它们整合到我的计划中吗?下面是我的主程序,程序的顶部和底部(主页)部分。就像我运行程序一样,它会打开一个窗口询问用户用户名和密码,然后验证它是否正确,然后只允许他们访问主程序。谢谢 from tkinter import * tab2_timerID = "" tab3_timerID = "" #Connection to Database try: connection = mysql.c
from tkinter import *
tab2_timerID = ""
tab3_timerID = ""
#Connection to Database
try:
connection = mysql.connector.connect(host='localhost', database='21july',
user='root', password='pass')
if connection.is_connected():
db_Info = connection.get_server_info()
print("Connected to MySQL Server version ", db_Info)
mycursor = connection.cursor()
mycursor.execute("select database();")
record = mycursor.fetchone()
print("You're connected to database: ", record)
except mysql.connector.Error as error:
print("Failed to create table in MySQL: {}".format(error))
class HomePage(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
self.notebook = ttk.Notebook() #Create a notebook widget
self.add_tab()
self.notebook.grid(row=0)
self.notebook.pack(expand=1, fill="both")
def add_tab(self):
tab1 = tab_one(self.notebook)
self.notebook.add(tab1, text="Inventory")
tab2 = tab_two(self.notebook)
self.notebook.add(tab2, text="Monitoring")
tab3 = tab_three(self.notebook)
self.notebook.add(tab3, text="Assets")
class tab_one(Frame):
def __init__(self, *args, **kwargs):
Frame.__init__(self, *args, **kwargs)
#Creating a frame, frame1, on the window/canvas for the first tab
frame1 = tk.LabelFrame(self, text="Entry of Assets", bd=6) #Frame1 on the w
homePage = HomePage()
homePage.title("DB") #Window title
screen_width = homePage.winfo_screenwidth()
screen_height = homePage.winfo_screenheight()
width = 1500
height = 900
x = (screen_width/2)-(width/2)
y = (screen_height/2)-(height/2)
homePage.geometry("%dx%d+%d+%d" % (width, height, x, y))
homePage.resizable(0,0)
homePage.mainloop()