from tkinter import *
from tkinter import ttk
class Vault:
def __init__(self, root):
set_pass = 'hello'
if set_pass!='':
self.root = root
self.root.title("Password Vault")
self.root.geometry("350x150+500+260")
color = 'black'
text_color = '#f3ca20'
title = Label(self.root, text="Password Vault", bd=2, font=("times new roman", 20, "bold"), bg=color, fg=text_color)
title.pack(fill=X)
pass_txt = Label(self.root, text="Password: ", bd=2, font=("times new roman", 18), bg=color, fg=text_color)
pass_txt.place(x=10, y=60)
self.pass_entry = Entry(self.root, font=("times new roman", 15, "bold"), bd=5)
self.pass_entry.place(x=130, y=60)
okbtn = Button(self.root, text="OK", command=self.loginfunc)
okbtn.place(x=280, y=110)
else:
pass
def loginfunc(self):
if self.pass_entry.get()=='hello':
displayinfo = Toplevel()
displayinfo.title("Password Vault")
displayinfo.geometry("700x400+500+260")
color = 'black'
text_color = '#f3ca20'
user_tb_frame = Frame(displayinfo, bd=4, relief=RIDGE, bg='BLACK')
user_tb_frame.place(x=5, y=10, height=600, width=683)
#treeview to display data
user_tb = ttk.Treeview(user_tb_frame, columns=("Email", "Password", "Website","Remark"))
user_tb.pack(fill=BOTH) #### It doesn't fill the Y-axis
displayinfo.mainloop()
else:
print('pass not matched')
root = Tk()
v = Vault(root)
root.mainloop()
I'm using user_tb.pack(fill=BOTH)
but it is not working, it doesn't fill the Y-axis completely. But if I use user_tb.pack(fill=BOTH, expand=1)
then it works just fine.
So, is it necessary to use expand everytime with fill and if not then why it isn't working without using the expand=1
?
And how to close the root window when Toplevel window starts?