Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
options_window.py
Go to the documentation of this file.
1 from gi.repository import Gtk as gtk
2 from utils.ui_utils import UIUtils
3 from utils.progress_dialog import ProgressDialog
4 from parsers.trs_splitter import TRSSplitter
5 
6 class OptionsWindow():
7  def __init__(self, filename, dest_folder):
8  self.filename = filename
9  self.dest_folder = dest_folder
10 
11  self.window = gtk.Window(gtk.WindowType.TOPLEVEL)
12  self.window.set_title('Select Options')
13  self.window.set_border_width(10)
14  self.window.set_default_size(150, 100)
15 
16  vbox = gtk.VBox()
17 
18  entry_box, hours_spinner, mins_spinner, secs_spinner = UIUtils.get_time_spinners(mins=15)
19 
20  button_box = gtk.HButtonBox()
21  cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
22  cancel_button.connect('clicked', lambda w: self.window.destroy())
23  button_box.pack_start(cancel_button, True, True, 0)
24  ok_button = gtk.Button(stock=gtk.STOCK_OK)
25  ok_button.connect('clicked', lambda w: self.split_file(
26  hours_spinner.get_value_as_int(),
27  mins_spinner.get_value_as_int(),
28  secs_spinner.get_value_as_int()))
29  button_box.pack_start(ok_button, True, True, 0)
30  button_box.set_layout(gtk.ButtonBoxStyle.EDGE)
31 
32  vbox.pack_start(gtk.Label('Please enter a length for the split segments (hour:min:sec):'), True, True, 0)
33  vbox.pack_start(entry_box, True, True, 0)
34  vbox.pack_end(button_box, True, True, 0)
35 
36  self.window.add(vbox)
37 
38  self.window.show_all()
39 
40  def split_file(self, hours, mins, secs):
41  win_len = hours * 60 * 60 + mins * 60 + secs
42 
43  progress_dialog = ProgressDialog(title='Splitting file', phases=['Splitting TRS file...'])
44  splitter = TRSSplitter(self.filename, self.dest_folder)
45 
46  self.window.destroy()
47 
48  progress_dialog.show()
49  splitter.split(win_len, progress_dialog.set_fraction)
50