Skip to content

Commit

Permalink
Added comment box
Browse files Browse the repository at this point in the history
renamed views/plots.py to views/settings.py

Added comment box, implementation in progress

Co-Authored-By: adenlam <adenlam@users.noreply.github.com>
Co-Authored-By: Henry Liu <henry@liuhenry.com>
  • Loading branch information
3 people committed May 26, 2020
1 parent 5b22b9a commit 0cfcb6f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
6 changes: 3 additions & 3 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ detuning=1.0
linewidth=9.7946

[plot]
colormap=Greys
colormap=viridis

[atoms]
repump_time=0.3
mass=3.84e-26

[fit]
fix_theta=True
fix_theta=False
roi=300,300,900,700
threeroi=300,300,900,700,400,400,900,700,0,0,200,200
tof=3.0,4.0,5.0,6.0,7.0
center=300.0,400.0
fix_z0=True
fix_z0=False
fit_optical_density=True

2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def center(self, tup):
@property
def logheader(self):
"""Defines the headers of the logging.csv file saved in '../Raw Data/' folder."""
return ["filename", "magnification", "atom number", "fitted shot", "tof_sequence", "time_sequence", "average_T (uK)"]
return ["filename", "magnification", "atom number", "fitted shot", "tof_sequence", "time_sequence", "average_T (uK)", "Comments"]


config = Config("config.ini")
6 changes: 4 additions & 2 deletions presenters/shots.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from config import config
from models import shots

from views.settings import Settings

class ShotPresenter:
def __init__(self, app, worker, *, plot_view, fit_view, list_view, threeroi_view):
Expand Down Expand Up @@ -51,8 +51,10 @@ def process_shot(self, name, paths):
shot.plot(figure)
figure.savefig(_output_path(name), dpi=150)
# Saves fit params to log file
logging.info("Updating log for shot %s ", name)

cmnts = Settings.get_comment

logging.info("Updating logging.csv for shot %s with comment %s ", name, cmnts)

# Checks if log file already exists, if not creates a new one
if not path.exists(_output_log_path(name)):
Expand Down
6 changes: 3 additions & 3 deletions views/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import tkinter.ttk as ttk

from views.logs import LogTextBox
from views.plots import MplFigure, PlotSettings
from views.settings import MplFigure, Settings
from views.shots import ShotList, ShotFit, ExperimentParams, ThreeROI
from views.sequences import ToFFit, AtomNumberOptimization

Expand Down Expand Up @@ -90,11 +90,11 @@ def __init__(self, master, presenter):
self.atom_number_fit = AtomNumberOptimization(self, self.presenter)
self.three_roi_atom_count = ThreeROI(self, self.presenter)
exp = ExperimentParams(self)
settings = PlotSettings(self)
settings = Settings(self)

self.add(self.shot_fit, text="Gaussian", padding=10)
self.add(self.tof_fit, text="Temperature", padding=10)
self.add(self.atom_number_fit, text="Atom # Optimization", padding=10)
self.add(self.three_roi_atom_count, text="Three ROIs", padding=10)
self.add(exp, text="Experiment Settings", padding=10)
self.add(settings, text="Plot Settings", padding=10)
self.add(settings, text="Settings", padding=10)
27 changes: 26 additions & 1 deletion views/plots.py → views/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import tkinter as tk
import tkinter.ttk as ttk

Expand Down Expand Up @@ -27,13 +29,14 @@ def display(self, obj):
self.canvas.draw()


class PlotSettings(ttk.Frame):
class Settings(ttk.Frame):
def __init__(self, master):
super().__init__(master)

frame = ttk.Frame(self)
frame.pack(expand=True)

# Defines GUI for colormaps in plot
self.colormap = tk.StringVar(
frame, name="colormap", value=config.get("plot", "colormap")
)
Expand All @@ -47,9 +50,31 @@ def __init__(self, master):
command=lambda val: self.save_config("colormap", val),
).grid(row=0, column=1)

# Defines comment box for saving in logging.csv
ttk.Label(frame, text="Logging comments").grid(row=2, column=0, columnspan=2)
self.comment_string = ""
self.var = tk.StringVar()
comments_entry = ttk.Entry(frame, textvariable=self.var)
comments_entry.grid(row=3, column=0, columnspan=3, padx=5, pady=5)
#ttk.Label(frame, text="Any comments are automatically appended in 'logging.csv' .").grid(row=5, column=0, columnspan=3)

# Updating comments strategy
self.update_comments = ttk.Button(frame, text="Update", command=self._update_comments)
self.update_comments.grid(row=4, column=1)
comments_entry.bind('<Return>', self._update_comments)

def save_config(self, name, val):
if val == "Professor Mode":
config.set("plot", name, value="Greys")
else:
config.set("plot", name, value=val)
config.save()

def get_comment(self):
return self.comment_string

def _update_comments(self, event=None):
self.comment_string = self.var.get()
logging.info("Updated comments: %s", self.comment_string)

# Include a comments section in GUI where the exported output goes to logging.csv.

0 comments on commit 0cfcb6f

Please sign in to comment.