Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在TKINTER Python中显示主页之前,如何在顶级窗口中添加登录/身份验证?_Python_Tkinter - Fatal编程技术网

在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()