-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVista_p1.py
152 lines (133 loc) · 4.98 KB
/
Vista_p1.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/python
#coding: utf-8
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class View(object):
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("uiP1.glade")
main_window = self.builder.get_object("main_window")
main_window.show()
self.tree_view = self.builder.get_object("treeview_movies")
self.liststore = self.builder.get_object("liststore_movies")
self.scrolled_list = self.builder.get_object("scrolledwindow_movies")
def confirm_movie(self, b, w):
lista = []
# Preparamos los contenedores
title_entry = self.builder.get_object("entry_title")
release_entry = self.builder.get_object("entry_release")
runtime_entry = self.builder.get_object("entry_runtime")
synopsis_entry = self.builder.get_object("entry_synopsis")
rating_entry = self.builder.get_object("entry_rating")
combo_entry = self.builder.get_object("comboboxtext_film_info")
# Recuperamos el valor
try:
lista.append(title_entry.get_text())
lista.append(int(release_entry.get_text()))
lista.append(int(runtime_entry.get_text()))
lista.append(synopsis_entry.get_text())
lista.append(int(rating_entry.get_text()))
lista.append(combo_entry.get_active())
except:
w = self.builder.get_object("err_dialog")
w.run()
w.hide()
return []
# Nos servimos de tree iterator para recuperar los datos de la fila seleccionada
select = self.tree_view.get_selection()
model, treeiter = select.get_selected()
try:
id_num = self.liststore[treeiter][0]
lista.append(id_num)
# Limpiamos las entradas de los datos anteriores
title_entry.set_text("")
runtime_entry.set_text("")
release_entry.set_text("")
synopsis_entry.set_text("")
rating_entry.set_text("")
return lista
except:
lista.append(None)
# Limpiamos las entradas de los datos anteriores
title_entry.set_text("")
runtime_entry.set_text("")
release_entry.set_text("")
synopsis_entry.set_text("")
rating_entry.set_text("")
return lista
def cancel_add(self, b, w):
title_entry = self.builder.get_object("entry_title")
release_entry = self.builder.get_object("entry_release")
runtime_entry = self.builder.get_object("entry_runtime")
synopsis_entry = self.builder.get_object("entry_synopsis")
rating_entry = self.builder.get_object("entry_rating")
combo_entry = self.builder.get_object("comboboxtext_film_info")
# Limpiamos las entradas de los datos anteriores
title_entry.set_text("")
runtime_entry.set_text("")
release_entry.set_text("")
synopsis_entry.set_text("")
rating_entry.set_text("")
combo_entry.set_active(0)
def edit_film(self, b, w):
# Nos servimos de tree iterator para recuperar los datos de la fila seleccionada
select = self.tree_view.get_selection()
model, treeiter = select.get_selected()
title = self.liststore[treeiter][1]
release = int(self.liststore[treeiter][2])
runtime = int(self.liststore[treeiter][3])
synopsis = self.liststore[treeiter][4]
rating = int(self.liststore[treeiter][5])
watched = int(self.liststore[treeiter][6])
# Preparamos los contenedores
title_entry = self.builder.get_object("entry_title")
release_entry = self.builder.get_object("entry_release")
runtime_entry = self.builder.get_object("entry_runtime")
synopsis_entry = self.builder.get_object("entry_synopsis")
rating_entry = self.builder.get_object("entry_rating")
combo_entry = self.builder.get_object("comboboxtext_film_info")
title_entry.set_text(title)
release_entry.set_text(str(release))
runtime_entry.set_text(str(runtime))
synopsis_entry.set_text(synopsis)
rating_entry.set_text(str(rating))
if watched == 1:
combo_entry.set_active(1)
else:
combo_entry.set_active(0)
def delete_film(self, b, w):
select = self.tree_view.get_selection()
model, treeiter = select.get_selected()
id_num = self.liststore[treeiter][0]
model.remove(treeiter)
return id_num
def search_clicked(self, b, w):
search_entry = self.builder.get_object("searchentry")
key = search_entry.get_text()
search_entry.set_text("")
return key.lower()
def show_list(self, lista):
self.liststore.clear()
for i in range(len(lista)):
self.liststore.append([lista[i][0], lista[i][1], lista[i][2], lista[i][3], lista[i][4], lista[i][5], lista[i][6] ])
def show_list_restoreCombo(self, lista):
self.liststore.clear()
for i in range(len(lista)):
self.liststore.append([lista[i][0], lista[i][1], lista[i][2], lista[i][3], lista[i][4], lista[i][5], lista[i][6] ])
combo_info = self.builder.get_object("comboboxtext")
combo_info.set_active(0)
def check_combobox(self, b):
combo_info = self.builder.get_object("comboboxtext")
return combo_info.get_active()
def recommended_clicked(self, b):
select = self.tree_view.get_selection()
model, treeiter = select.get_selected()
title = self.liststore[treeiter][1]
return title
def show_recom_dialog(self):
w_r = self.builder.get_object("recom_dialog")
w_r.show()
def hide_recom_dialog(self):
w_r = self.builder.get_object("recom_dialog")
w_r.hide()