from tkinter import *
from tkinter import ttk
bgcolor1="#FFB6C1"
bgcolor2="#FFEACC"
grey = "#606060"
chalk = "Chalkduster"
white = "#FFFFFF"
black = "#000000"
window = Tk()
window.geometry("640x415")
window.columnconfigure(0,weight=1)
window.columnconfigure(1,weight=1)
window.rowconfigure(0, weight=1)
window.rowconfigure(1, weight=8)
window.rowconfigure(2, weight=1)
pinkframe=Frame(window,bg=bgcolor1)
pinkframe.grid(
row=0,
column=0,
rowspan=3,
sticky='WENS'
)
searchFrame=Frame(
window,
bg=bgcolor2
)
searchFrame.grid(
row=0,
column=1,
sticky='WENS'
)
listframe=Frame(
window,
bg=white
)
listframe.grid(
row=1,
column=1,
sticky='NSEW'
)
delFrame=Frame(
window,
bg=bgcolor2
)
delFrame.grid(
row=2,
column=1,
sticky='WENS'
)
welcome = Label(
pinkframe,
text="Welcome!",
height=1,
font=(chalk, 30),
fg=black,
bg=bgcolor1
)
welcome.place(x=80,y=5)
addNew = Label(
pinkframe,
text="Add new contact",
height=1,
font=(chalk, 18),
fg=black,
bg=bgcolor1
)
addNew.place(x=70,y=100)
#First name
fName = Label(
pinkframe,
text="First name",
height=1,
font=(chalk, 13),
fg=grey,
bg=bgcolor1
)
fName.place(x=8,y=140)
fEntry = Entry(
pinkframe,
width=20,
justify='left',
relief = "ridge",
highlightthickness=0
)
fEntry.place(x=100,y=140)
#Last name
lName = Label(
pinkframe,
text="Last name",
height=1,
font=(chalk, 13),
fg=grey,
bg=bgcolor1
)
lName.place(x=8,y=180)
lEntry = Entry(
pinkframe,
width=20,
justify='left',
relief = "ridge",
highlightthickness=0
)
lEntry.place(x=100,y=180)
#Phone number
pNum = Label(
pinkframe,
text="Phone",
height=1,
font=(chalk, 13),
fg=grey,
bg=bgcolor1
)
pNum.place(x=8,y=220)
pEntry = Entry(
pinkframe,
width=20,
justify='left',
relief = "ridge",
highlightthickness=0
)
pEntry.place(x=100,y=220)
#email
eMail = Label(
pinkframe,
text="email",
height=1,
font=(chalk, 13),
fg=grey,
bg=bgcolor1
)
eMail.place(x=8,y=260)
eEntry = Entry(
pinkframe,
width=20,
justify='left',
relief = "ridge",
highlightthickness=0
)
eEntry.place(x=100,y=260)
#add
addButton= Button(
pinkframe,
text="ADD",
height=2,
bg = "#FF5FDB",
fg = black,
font=(chalk,16 ))
addButton.place(x=150,y=300)
searchEntry = Entry(
searchFrame,
width=25,
justify='left',
relief = "ridge",
highlightthickness=0
)
searchEntry.place(x=10,y=8)
searchButton= Button(
searchFrame,
text="Search",
height=1,
bg = "#FF5FDB",
fg = black,
font=(chalk,10))
searchButton.place(x=245,y=7)
editButton= Button(
listframe,
text="Edit",
height=1,
bg = "#FF5FDB",
fg = black,
font=(chalk,10))
editButton.place(x=260,y=0)
#contacts list
def showList():
global tree
listFields = ['First name','Last name', 'Number', 'Email']
tree = ttk.Treeview(listframe,columns=listFields)
tree.grid(row=1, column=0, columnspan=2, sticky="nsew") # columnspan=2 goes here.
scroll = ttk.Scrollbar(listframe)
scroll.grid(row=1, column=2, sticky="nse") # set this to column=2 so it sits in the correct spot.
scroll.configure(command=tree.yview)
tree.configure(yscrollcommand=scroll.set)
listframe.columnconfigure(1, weight=1)
listframe.rowconfigure(1, weight=1)
tree.heading(0,text='First name', anchor=NW)
tree.column("#0", anchor=CENTER, stretch=NO, width=80)
tree.heading(1, text='Last name', anchor=NW)
tree.column("#1", anchor=CENTER, stretch=NO, width=80)
tree.heading(2, text='Phone', anchor=NW)
tree.column("#2", anchor=CENTER, stretch=NO, width=80)
tree.heading(3, text='Email', anchor=NW)
tree.column("#3", anchor=CENTER, stretch=NO, width=80)
showList()
window.resizable(False, False)
window.mainloop()