Skip to content

Commit

Permalink
Preparing for Microsoft Store
Browse files Browse the repository at this point in the history
- Added issue reporting interface
- Added new user interface images
- Moved the Empatica Streaming Server exe
- Added download link to Streaming Server
- Lowered screen size for small screen size
- Added protocol files to session output
- Bump minor revision number, clear patch number
  • Loading branch information
wsarce committed Aug 2, 2022
1 parent 09fbe3c commit 8ecb510
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 97 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,6 @@ weights/violence/
experiments/
/reference/e4_streaming_server/
func_testing/
external_bin/
external_bin/
/e4_streaming_server/
/pat.py
Binary file added gui_images/ble_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui_images/box_art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui_images/e4_demo_crop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui_images/recorder_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui_images/woodway_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion menu_bar.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import os
import pathlib
import webbrowser
from tkinter import *
from analysis_ui import AccuracyPopup
from config_utils import ConfigUtils
from ksf_utils import export_columnwise_csv, populate_spreadsheet
from tkinter_utils import ConfigPopup, ExternalButtonPopup
from tkinter_utils import ConfigPopup, ExternalButtonPopup, GitHubIssue
from e4_utils import export_e4_metrics
from pat import token
from ui_params import cometrics_ver_root


class MenuBar(Frame):
Expand Down Expand Up @@ -37,8 +40,29 @@ def __init__(self, parent, caller, *args, **kwargs):
help_menu.add_command(label="Open Documentation", command=self.open_user_guide)
help_menu.add_command(label="Open Logs", command=self.open_logs)
help_menu.add_command(label="Open Current Directory", command=self.open_current_dir)
help_menu.add_command(label="Download E4 Streaming Server", command=self.download_e4_ss)
help_menu.add_command(label="Open Source Code", command=self.open_source_code)
help_menu.add_command(label="Submit Feedback", command=self.submit_feedback)
menu.add_cascade(label="Help", menu=help_menu)

def submit_feedback(self):
log_pattern = r'*.txt'
latest_log_file = max(pathlib.Path(os.path.join(cometrics_ver_root, 'logs')).glob(log_pattern),
key=lambda f: f.stat().st_ctime)
GitHubIssue(self.caller.root, token, latest_log_file)

@staticmethod
def open_source_code():
source_code_link = 'https://github.com/Munroe-Meyer-Institute-VR-Laboratory/cometrics'
webbrowser.open_new_tab(source_code_link)

@staticmethod
def download_e4_ss():
e4_ss_link = 'http://get.empatica.com/win/EmpaticaBLEServer.html'
webbrowser.open_new_tab(e4_ss_link)
e4_doc_link = 'https://developer.empatica.com/windows-streaming-server-usage.html'
webbrowser.open_new_tab(e4_doc_link)

def get_e4_metrics(self):
export_e4_metrics(self.caller.root, self.caller.prim_dir, self.caller.reli_dir, self.caller.export_dir)

Expand Down
10 changes: 9 additions & 1 deletion output_view_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,15 @@ def get_session_data(self):
self.e4_view.e4.bat, self.e4_view.e4.bat_timestamps,
self.e4_view.e4.hr, self.e4_view.e4.hr_timestamps
]
return self.key_view.event_history, e4_data, video_data
ble_prot = None
if self.ble_view:
if self.ble_view.prot_file:
ble_prot = self.ble_view.prot_file
woodway_prot = None
if self.woodway_view:
if self.woodway_view.prot_file:
woodway_prot = self.woodway_view.prot_file
return self.key_view.event_history, e4_data, video_data, ble_prot, woodway_prot

def save_session(self, filename, keystrokes):
if self.e4_view:
Expand Down
89 changes: 0 additions & 89 deletions reference/exe_config.json

This file was deleted.

8 changes: 5 additions & 3 deletions session_manager_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, config, project_setup):
self.field_offset = large_field_offset
self.button_size = large_tab_size
self.treeview_rowheight = large_treeview_rowheight
elif 1920 > self.window_width > 1280:
elif 1920 > self.window_width > 1400:
self.treeview_header = medium_treeview_font
self.header_font = medium_header_font
self.field_font = medium_field_font
Expand Down Expand Up @@ -304,7 +304,7 @@ def handle_key_press(self, key):

def save_session(self):
session_fields = self.pdf.get_session_fields()
session_data, e4_data, video_file = self.ovu.get_session_data()
session_data, e4_data, video_file, ble_prot, woodway_prot = self.ovu.get_session_data()
# If no session data is recorded, ask before saving it
if not session_data:
response = messagebox.askyesno("Session Data Empty", "There was no session data recorded, "
Expand All @@ -327,6 +327,8 @@ def save_session(self):
session_fields["KSF"] = self.ovu.key_view.keystroke_json
session_fields["Reviewer"] = ""
session_fields["Reviewed"] = False
session_fields["BLE Protocol"] = ble_prot
session_fields["Woodway Protocol"] = woodway_prot
reli = '_R' if session_fields["Primary Data"] == "Reliability" else ''
output_session_file = path.join(self.session_dir,
self.config.get_data_folders()[1],
Expand Down Expand Up @@ -397,7 +399,7 @@ def start_session(self):
"Woodway view is not present when it should be!")
print("ERROR: Something went wrong with starting session, Woodway view is not present when it should be")
return
# self.session_time = datetime.datetime.now().strftime("%H:%M:%S")

self.now = now = datetime.datetime.today()
self.session_date = now.strftime("%B %d, %Y")
self.session_file_date = now.strftime("%B")[:3] + now.strftime("%d") + now.strftime("%Y")
Expand Down
122 changes: 121 additions & 1 deletion tkinter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import time
import tkinter
import traceback
from tkinter import TOP, W, N, NW, messagebox, END, ttk, filedialog
from tkinter import TOP, W, N, NW, messagebox, END, ttk, filedialog, INSERT
from tkinter.ttk import Style, Combobox
from tkinter.ttk import Treeview

import numpy as np
from PIL import ImageTk as itk
from github import Github
from logger_util import parse_log
from tkvideoutils import ImageLabel

from ui_params import treeview_default_tag_dict, cometrics_ver_root
Expand Down Expand Up @@ -949,3 +951,121 @@ def close_win(self):
self.caller.calibrate_return(self.calibrated_left, self.calibrated_right)
self.calibrating = False
self.popup_root.destroy()


class GitHubIssue:
def __init__(self, root, token, current_log_file):
self.log_file = parse_log(current_log_file)
self.token = token
self.entry = None
self.popup_root = None
self.label_options = [
'Bug',
'Enhancement',
'Documentation'
]
self.name = "Submit Feedback to Developer"
self.popup_entry(root)

def popup_entry(self, root, field_font=('Purisa', 12)):
# Create a Toplevel window
self.popup_root = popup_root = tkinter.Toplevel(root)
popup_root.config(bg="white", bd=-2)
popup_root.geometry("800x350")
popup_root.title(self.name)

self.title_var = tkinter.StringVar(popup_root, value='Feedback Title')
self.title_entry = tkinter.Entry(popup_root, textvariable=self.title_var, font=field_font, bd=2, fg='grey')
self.title_entry.bind("<FocusIn>", self.title_handle_focus_in)
self.title_entry.bind("<FocusOut>", self.title_handle_focus_out)
self.title_entry.place(x=10, y=10)

self.label_var = tkinter.StringVar(popup_root, value='Select a Label')
dropdown_box = Combobox(popup_root, textvariable=self.label_var, font=field_font)
dropdown_box['values'] = self.label_options
dropdown_box['state'] = 'readonly'
dropdown_box.config(font=field_font)
dropdown_box.option_add('*TCombobox*Listbox.font', field_font)
dropdown_box.place(x=10, y=40)

self.default_desc_text = "Enter a description of the problem you encountered.\n"\
"Please be descriptive!\n"\
"If possible, include steps to recreate the problem and contact "\
"information if you would like the developer to reach out for more "\
"information and updates."
self.desc_var = tkinter.StringVar(popup_root)
self.description_entry = tkinter.Text(popup_root, bg="white", fg='grey',
cursor="arrow",
exportselection=0,
highlightcolor="black",
width=10,
xscrollcommand="scrollbar")
self.description_entry.bind("<FocusIn>", self.handle_focus_in)
self.description_entry.bind("<FocusOut>", self.handle_focus_out)
self.description_entry.insert(INSERT, self.default_desc_text)
self.description_entry.place(x=10, y=70, height=210, width=780)

cancel_button = tkinter.Button(popup_root, text='Cancel', command=self.cancel, font=field_font)
cancel_button.place(x=790, y=300, width=120, anchor=tkinter.NE)

submit_button = tkinter.Button(popup_root, text='Submit', command=self.submit_issue, font=field_font)
submit_button.place(x=660, y=300, width=120, anchor=tkinter.NE)

center(popup_root)
popup_root.focus_force()

def title_handle_focus_in(self, _):
title = self.title_var.get()
if title == "Feedback Title":
self.title_entry.delete(0, END)
self.title_entry.config(fg='black')

def title_handle_focus_out(self, _):
title = self.title_var.get()
if not title:
self.title_entry.delete(0, END)
self.title_entry.config(fg='grey')
self.title_entry.insert(0, "Feedback Title")

def handle_focus_in(self, _):
desc = self.description_entry.get('1.0', END)
if desc == self.default_desc_text + '\n':
self.description_entry.delete('1.0', END)
self.description_entry.config(fg='black')

def handle_focus_out(self, _):
desc = self.description_entry.get('1.0', END)
if desc == '\n':
self.description_entry.insert(INSERT, self.default_desc_text)
self.description_entry.config(fg='grey')

def cancel(self):
self.popup_root.destroy()

def submit_issue(self):
desc = self.description_entry.get('1.0', END)
if desc == '\n' or desc == self.default_desc_text + '\n':
messagebox.showerror("Error", "Enter a description of the issue encountered!")
return
desc = desc + '\n'.join(self.log_file[0]) + '\n'.join(self.log_file[3])
label_set = self.label_var.get()
if label_set == "Select a Label":
messagebox.showerror("Error", "Select a label for the issue encountered!")
return
title = self.title_var.get()
if not title or title == 'Feedback Title':
messagebox.showerror("Error", "Enter a title for the issue encountered!")
return

g = Github(self.token)
repo = g.get_repo("Munroe-Meyer-Institute-VR-Laboratory/cometrics")

repo.create_issue(
title=title,
body=desc,
labels=[
repo.get_label(label_set.lower())
]
)
messagebox.showinfo("Success!", "Feedback has been submitted!")
self.popup_root.destroy()
2 changes: 1 addition & 1 deletion ui_params.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cometrics_version = "1.2.7"
cometrics_version = "1.3.0"
ui_title = f"cometrics v{cometrics_version}"

cometrics_data_root = fr'C:\cometrics'
Expand Down

0 comments on commit 8ecb510

Please sign in to comment.