1 from gi.repository
import Gtk
as gtk
14 self.
window = gtk.Window(gtk.WindowType.TOPLEVEL)
15 self.window.set_title(
'Select Batch Number')
16 self.window.connect(
'destroy',
lambda w: self.window.destroy())
17 self.window.set_border_width(10)
18 self.window.set_default_size(210, 100)
26 label = gtk.Label(
'Select the batch number to run: ')
27 batch_spin_adj = gtk.Adjustment(value=1, lower=1, upper=self.
_get_total_batches(db) + 1, step_increment=1, page_increment=1, page_size=1)
29 self.batch_spin.set_adjustment(batch_spin_adj)
30 self.batch_spin.set_snap_to_ticks(
True)
31 self.batch_spin.set_value(next_batch_num)
33 hbox.pack_start(label,
True,
True, 0)
34 hbox.pack_start(self.
batch_spin,
True,
True, 0)
35 vbox.pack_start(hbox,
True,
True, 0)
37 label = gtk.Label(
'Select the participant number to use: ')
38 part_spin_adj = gtk.Adjustment(value=1, lower=1, upper=self.props.max_parts_per_batch + 1, step_increment=1, page_increment=1, page_size=1)
40 self.part_spin.set_adjustment(part_spin_adj)
41 self.part_spin.set_snap_to_ticks(
True)
42 self.part_spin.set_value(next_part_num)
44 hbox.pack_start(label,
True,
True, 0)
45 hbox.pack_start(self.
part_spin,
True,
True, 0)
46 vbox.pack_start(hbox,
True,
True, 0)
49 vbox.pack_start(button_box,
True,
True, 0)
52 self.window.show_all()
61 'clips c join ratings r on c.id = r.clip_id',
63 where_cond =
'r.Participant_Num is not null'
65 if rows
and rows[0][0]
is not None:
66 cur_batch_num = rows[0][0]
68 'clips c join ratings r on c.id = r.clip_id',
69 [
'max(r.Participant_Num)'],
70 where_cond =
'c.Batch_Num = ?',
71 params = [cur_batch_num]
73 if rows
and rows[0][0]
is not None:
74 cur_part_num = rows[0][0]
76 if cur_part_num < self.props.max_parts_per_batch:
77 part_num = cur_part_num + 1
78 batch_num = cur_batch_num
79 elif cur_batch_num < total_batches:
80 batch_num = cur_batch_num + 1
83 return batch_num, part_num
94 'clips c join ratings r on c.id = r.clip_id',
96 where_cond =
'c.Batch_Num = ? and r.Participant_Num = ?',
97 params = [batch_num, participant_num]
102 button_box = gtk.HButtonBox()
103 button_box.set_layout(gtk.ButtonBoxStyle.EDGE)
105 cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL, label=
'Cancel')
106 cancel_button.connect(
'clicked',
lambda w: self.window.destroy())
107 button_box.add(cancel_button)
109 ok_button = gtk.Button(stock=gtk.STOCK_OK, label=
'Run')
110 ok_button.connect(
'clicked',
lambda w: self.
check_input(db))
111 button_box.add(ok_button)
116 batch_num = self.batch_spin.get_value_as_int()
117 participant_num = self.part_spin.get_value_as_int()
119 response = UIUtils.show_confirm_dialog(
'Participant %d has recorded responses for Batch %d.\nContinuing will overwrite the existing data for this participant (in this batch).\nDo you want continue?' % (participant_num, batch_num))
123 where_cond =
'clip_id in (select id from clips where Batch_Num = ?) and Participant_Num = ?',
124 params = [batch_num, participant_num]
134 self.window.destroy()