def get_moses_dir(self):
"""@brief Gets Moses directory."""
directory = self.moses_dir
response = Gtk.ResponseType.ACCEPT
while response == Gtk.ResponseType.ACCEPT and not self.is_moses_dir_valid(directory):
label = Gtk.Label("Enter MOSES installation directory")
entry = Gtk.Entry()
button = Gtk.Button("Choose File")
button.connect("clicked", self._on_dir_clicked, entry)
dialog = Gtk.Dialog("Moses configuration",
None,
Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
box = dialog.get_content_area()
box.add(label)
box.add(entry)
box.add(button)
label.show()
entry.show()
button.show()
response = dialog.run()
directory = entry.get_text()
dialog.destroy()
# If it is not valid, keep asking until valid or user leaves.
if response != Gtk.ResponseType.ACCEPT:
exit(1)
self.moses_dir = directory
return directory
评论列表
文章目录