forked from buckyroberts/Source-Code-from-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleft.py
More file actions
39 lines (30 loc) · 1.15 KB
/
Copy pathleft.py
File metadata and controls
39 lines (30 loc) · 1.15 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
from gi.repository import Gtk
import toolbar
websites = [("thenewboston.com", "https://thenewboston.com"),
("reddit.com", "https://reddit.com"),
("youtube.com", "https://youtube.com"),
("amazon.com", "https://amazon.com")]
def create_left(area):
# ListStore
people_list_store = Gtk.ListStore(str, str)
for item in websites:
people_list_store.append(list(item))
# View
websites_tree_view = Gtk.TreeView(people_list_store)
for i, title in enumerate(["Websites"]):
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(title, renderer, text=i)
column.set_sort_column_id(i)
websites_tree_view.append_column(column)
# Handle selected
selected_row = websites_tree_view.get_selection()
selected_row.connect("changed", item_selected)
area.pack_start(websites_tree_view, False, False, 0)
# User selected row
def item_selected(selection):
model, row = selection.get_selected()
if row is not None:
print("Website: ", model[row][0])
print("URL: ", model[row][1])
print("")
toolbar.change_button_text(model[row][1])