Skip to content
This diff is collapsed.
import logging
logger = logging.getLogger(__name__)
try:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
except ImportError:
print "ERR: GTK not available"
sys.exit(1)
from matplotlib.backends.backend_gtk3 \
import NavigationToolbar2GTK3 as NavigationToolbar
def clear_notebook(notebook):
for pages in range(notebook.get_n_pages()):
notebook.remove_page(0)
def add_exp_to_notebook(notebook, exp):
for plot in exp.plots:
label = Gtk.Label.new(plot.name)
notebook.append_page(plot.box, label)
plot.box.show_all()
def replace_notebook_exp(notebook, exp, window):
clear_notebook(notebook)
add_exp_to_notebook(notebook, exp)
add_navigation_toolbars(exp, window)
def add_navigation_toolbars(exp, window):
for plot in exp.plots:
toolbar = NavigationToolbar(plot.canvas, window)
plot.box.pack_start(toolbar, expand=False, fill=False, padding=0)
\ No newline at end of file
...@@ -17,19 +17,20 @@ ...@@ -17,19 +17,20 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import yaml import yaml
from errors import ErrorLogger, InputError from errors import InputError
_logger = ErrorLogger(sender="dstat-interface-params")
logger = logging.getLogger(__name__)
def get_params(window): def get_params(window):
"""Fetches and returns dict of all parameters for saving.""" """Fetches and returns dict of all parameters for saving."""
parameters = {} selection = window.exp_window.expcombobox.get_active_id()
parameters = {'experiment_index' : selection}
selection = window.exp_window.select_to_key[window.expcombobox.get_active()]
parameters['experiment_index'] = selection
try: try:
parameters['version'] = window.version parameters['version'] = window.version
...@@ -45,14 +46,16 @@ def get_params(window): ...@@ -45,14 +46,16 @@ def get_params(window):
return parameters return parameters
def save_params(window, path): def save_params(window, path):
"""Fetches current params and saves to path.""" """Fetches current params and saves to path."""
logger.info("Save to: %s", path)
params = get_params(window) params = get_params(window)
with open(path, 'w') as f: with open(path, 'w') as f:
yaml.dump(params, f) yaml.dump(params, f)
def load_params(window, path): def load_params(window, path):
"""Loads params from a path into UI elements.""" """Loads params from a path into UI elements."""
...@@ -60,20 +63,20 @@ def load_params(window, path): ...@@ -60,20 +63,20 @@ def load_params(window, path):
get_params(window) get_params(window)
except InputError: # Will be thrown because no experiment will be selected except InputError: # Will be thrown because no experiment will be selected
pass pass
except KeyError: # Will be thrown because no experiment will be selected
pass
with open(path, 'r') as f: with open(path, 'r') as f:
params = yaml.load(f) params = yaml.load(f)
set_params(window, params) set_params(window, params)
def set_params(window, params): def set_params(window, params):
window.adc_pot.params = params window.adc_pot.params = params
if 'experiment_index' in params:
if not 'experiment_index' in params: window.exp_window.expcombobox.set_active_id(params['experiment_index'])
logger.warning("Missing experiment parameters.")
return
window.expcombobox.set_active(
window.exp_window.classes[params['experiment_index']][0])
window.exp_window.set_params(params['experiment_index'], params) window.exp_window.set_params(params['experiment_index'], params)
window.analysis_opt_window.params = params window.analysis_opt_window.params = params
window.params_loaded = True window.params_loaded = True
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.