-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathcontact_list.py
More file actions
57 lines (44 loc) · 1.65 KB
/
contact_list.py
File metadata and controls
57 lines (44 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
import tkinter as tk
from tkinter import ttk
class AddressBookApp(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master.title('Address Book')
self.pack()
self._create_widgets()
def _create_widgets(self):
tree_view_entries = ["Entry 1", "Entry 2",
"Entry 3", "Entry 4"]
treeview_widget = ttk.Treeview(self.master)
index = 1
for entry in tree_view_entries:
treeview_widget.insert('', 'end', index, text = entry)
index += 1
treeview_widget.pack()
self._create_menus()
def _create_menus(self):
menu_widget = tk.Menu(self.master)
file_menu = tk.Menu(menu_widget)
contact_menu = tk.Menu(menu_widget)
file_menu.add_command(label="New", command=self._new_addressbook)
file_menu.add_command(label="Open...", command=self._open_addressbook)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.quit)
contact_menu.add_command(label="Add Contact", command=self._add_contact)
contact_menu.add_command(label="Remove Contact", command=self._remove_contact)
menu_widget.add_cascade(label="File", menu=file_menu)
menu_widget.add_cascade(label="Contact", menu=contact_menu)
self.master.config(menu=menu_widget)
def _new_addressbook(self):
pass
def _open_addressbook(self):
pass
def _add_contact(self):
pass
def _remove_contact(self):
pass
# Main entry point
root = tk.Tk()
app = AddressBookApp(master=root)
app.mainloop()