1 from gi.repository
import Gtk
as gtk
2 from gi.repository
import GObject
as gobject
16 self.
window = gtk.Window(gtk.WindowType.TOPLEVEL)
17 self.window.set_title(
'Statistics Application')
18 self.window.set_border_width(10)
19 self.window.set_default_size(600, 450)
20 self.window.connect(
'destroy',
lambda x: gtk.main_quit())
25 scrolled_win = gtk.ScrolledWindow()
26 scrolled_win.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
27 scrolled_win.add(treeview)
28 vbox.pack_start(scrolled_win,
True,
True, 0)
30 button_box = gtk.HButtonBox()
31 button_box.set_layout(gtk.ButtonBoxStyle.EDGE)
33 create_button = UIUtils.create_button(
'Create Configuration', UIUtils.BUTTON_ICONS.CREATE)
34 create_button.connect(
'clicked',
lambda w:
ConfigWindow(
lambda new_config: self.
_add_callback(treeview.get_model(), new_config)))
35 button_box.pack_start(create_button,
True,
True, 0)
37 edit_button = UIUtils.create_button(
'Edit Configuration', UIUtils.BUTTON_ICONS.EDIT)
38 edit_button.connect(
'clicked',
lambda w: self.
_edit_config(treeview))
39 button_box.pack_start(edit_button,
True,
True, 0)
41 run_button = UIUtils.create_button(
'Run Configuration', UIUtils.BUTTON_ICONS.RUN)
42 run_button.connect(
'clicked',
lambda w: self.
_run_config(treeview))
43 button_box.pack_start(run_button,
True,
True, 0)
45 delete_button = UIUtils.create_button(
'Delete', UIUtils.BUTTON_ICONS.DELETE)
46 delete_button.connect(
'clicked',
lambda w: self.
_delete_config(treeview))
47 button_box.pack_start(delete_button,
True,
True, 0)
49 exit_button = UIUtils.create_button(
'Exit', UIUtils.BUTTON_ICONS.EXIT)
50 exit_button.connect(
'clicked',
lambda w: gtk.main_quit())
51 button_box.pack_start(exit_button,
True,
True, 0)
53 vbox.pack_end(button_box,
False,
False, 0)
56 self.window.show_all()
59 model.append([new_config.name,
61 UIUtils.get_db_timestamp_str(new_config.created)
if new_config.created
else '-',
67 model, it = treeview.get_selection().get_selected()
69 config = model.get(it, 4)[0]
73 UIUtils.show_message_dialog(
'Please select a row.', gtk.MessageTYpe.WARNING)
76 model.set_value(row_it, 0, edited_config.name)
77 model.set_value(row_it, 1, edited_config.desc)
78 model.set_value(row_it, 2, UIUtils.get_db_timestamp_str(edited_config.created)
if edited_config.created
else '-')
80 model.set_value(row_it, 4, edited_config)
85 while i < len(outputs):
86 output_names += outputs[i].name
87 if i < len(outputs) - 1:
97 list_store = gtk.ListStore(
102 gobject.TYPE_PYOBJECT,
106 configs = OutputConfig.db_select(db)
107 for cur_config
in configs:
109 created_str = UIUtils.get_db_timestamp_str(cur_config.created)
if cur_config.created
else '-'
125 treeview = gtk.TreeView(list_store)
127 col_names = [
'Name',
'Description',
'Created',
'Outputs']
128 for i
in range(len(col_names)):
129 col = gtk.TreeViewColumn(col_names[i], gtk.CellRendererText(), text=(i))
130 col.set_resizable(
True)
131 col.set_min_width( UIUtils.calc_treeview_col_min_width(col_names[i]) )
132 treeview.append_column(col)
137 model, it = treeview.get_selection().get_selected()
139 if UIUtils.show_confirm_dialog(
'Are you sure you want to delete this configuration?'):
140 config = model.get(it, 4)[0]
144 if config.db_id !=
None:
149 UIUtils.show_no_sel_dialog()
193 model, it = treeview.get_selection().get_selected()
195 config = model.get(it, 4)[0]
196 trs_folder = UIUtils.open_folder(
197 title=
'Select TRS Folder...'
201 export_folder = UIUtils.open_folder(
202 title=
'Select Output Folder...'
207 export_filenames = map(
lambda name:
'%s\\%s-stats.csv' % (export_folder, os.path.basename(name)[:-4]), trs_filenames)
209 phases = [
'File %d of %d' % (i + 1, len(trs_filenames))
for i
in range(len(trs_filenames))]
213 for j
in range(len(trs_filenames)):
214 exporter =
StatsExporter(config, trs_filenames[j], export_filenames[j])
216 dialog.set_fraction(1.0)
217 if j < len(trs_filenames) - 1:
220 dialog.ensure_finish()
222 UIUtils.show_message_dialog(
'Export successful.')
225 UIUtils.show_no_sel_dialog()
229 in_filenames = glob.glob(root_dir +
'\\*')
231 for cur_name
in in_filenames:
232 if os.path.isdir(cur_name):
234 elif os.path.isfile(cur_name)
and cur_name.lower().endswith(
'.trs'):
235 out_filenames.append(cur_name)