Source code for load_file_gtk

# load_folders_gtk.py
# By MW, Jul 2013
# GPLv3+
#
# Graphical interface to load a CellTracking file

import gtk, logging, imp, sys
sys.path.append("./bin/ImportExport/")
import ImportExport

[docs]class Loader : def __init__(self) : self.main_label = "Loads a CellTracking file" self.name = "CellTracking file" self.loader = ImportExport.ImportExport() self.filename = None
[docs] def get_frames_object(self) : """Queries an object like : {type: " ", value: 'path'}""" self.loader.set_path(self.filename) return self.loader.get_frames_object()
[docs] def get_panel(self) : mainbox = gtk.VBox() main_l = gtk.Label(self.main_label) main_l.set_line_wrap_mode(True) mainbox.pack_start(main_l, fill=False, expand=False) frame = gtk.Frame("File") mainbox.pack_start(frame, fill=True, expand=False) frame_box = gtk.HBox() frame.add(frame_box) path_l = gtk.Label("File:") path_e = gtk.Entry() browse_b = gtk.Button("Browse...") browse_b.connect('clicked', self.browse_evt, path_e) frame_box.pack_start(path_l, fill=False, expand=False) frame_box.pack_start(path_e, fill=True, expand=True) frame_box.pack_start(browse_b, fill=False, expand=False) mainbox.show_all() return mainbox
[docs] def get_name(self) : return self.name
[docs] def browse_evt(self, w, path_e) : filefilter_all = gtk.FileFilter() filefilter_all.set_name("All files") filefilter_all.add_pattern('*') filefilter_ct = gtk.FileFilter() filefilter_ct.set_name("CellTracking files") filefilter_ct.add_pattern('*.ct') dialog = gtk.FileChooserDialog("Select CellTracking .ct file", action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) dialog.add_filter(filefilter_ct) dialog.add_filter(filefilter_all) resp = dialog.run() if resp == gtk.RESPONSE_OK : f = dialog.get_filename() logging.info("CellTracking file selected %s", f) path_e.set_text(f) self.filename = f dialog.destroy()