-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpatientView.py
More file actions
124 lines (109 loc) · 4.2 KB
/
patientView.py
File metadata and controls
124 lines (109 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Minhas Kamal (minhaskamal024@gmail.com)
# 14 Mar 24
import tkinter as tk
from tkinter import filedialog
import patientRecord
import utils
class PatientView:
@classmethod
def show(cls, view_frame: tk.Frame, patient_record: patientRecord.PatientRecord) -> None:
view_frame.name = cls.__name__
tk.Label(
view_frame,
text="Patient").pack(
pady=(10, 0))
name_frame: tk.Frame = tk.Frame(view_frame)
name_frame.pack(pady=(5, 0))
tk.Label(
name_frame,
text="Name").pack(
side=tk.LEFT,
pady=5)
cls._create_entry(
name_frame, patient_record.name, patient_record, cls._record_patient_name)
movement_file_path_frame: tk.Frame = tk.Frame(view_frame)
movement_file_path_frame.pack(pady=(5, 0))
tk.Label(
movement_file_path_frame,
text="Movement file path").pack(
side=tk.LEFT,
padx=(10, 0),
pady=5)
movement_file_path_entry = cls._create_entry(
movement_file_path_frame, patient_record.movement_file_path,
patient_record, cls._record_movement_file_path)
tk.Button(
movement_file_path_frame,
text="Browse"
,command=lambda: cls._browse_file(
view_frame,
patient_record,
movement_file_path_entry)).pack(
padx=10,
pady=10)
repeat_frame: tk.Frame = tk.Frame(view_frame)
repeat_frame.pack(pady=(5, 0))
tk.Label(
repeat_frame,
text="Repeat").pack(
side=tk.LEFT,
padx=(10, 0),
pady=5)
cls._create_entry(
repeat_frame, patient_record.repeat, patient_record, cls._record_patient_repeat)
return
@classmethod
def _create_entry(
cls, frame: tk.Frame, value, patient_record: patientRecord.PatientRecord,
record_func) -> tk.Entry:
entry: tk.Entry = tk.Entry(frame)
entry.insert(0, str(value))
entry.pack(side=tk.LEFT, pady=5)
entry.bind(
'<KeyRelease>', lambda event:
record_func(entry, patient_record))
return entry
@classmethod
def _record_patient_name(
cls, name_of_movement_entry: tk.Entry, patient_record: patientRecord.PatientRecord) -> None:
patient_record.name = name_of_movement_entry.get()
return
@classmethod
def _record_movement_file_path(
cls, movement_file_path_entry: tk.Entry, patient_record: patientRecord.PatientRecord) -> None:
patient_record.movement_file_path = movement_file_path_entry.get()
return
@classmethod
def _record_patient_repeat(
cls, number_of_repeats_entry: tk.Entry, patient_record: patientRecord.PatientRecord) -> None:
patient_record.repeat = number_of_repeats_entry.get()
return
@classmethod
def _browse_file(cls, view_frame: tk.Frame, patient_record: patientRecord.PatientRecord,
file_path_entry: tk.Entry) -> None:
file = filedialog.askopenfile(
parent=view_frame,
title='Please select a file',
filetypes=[('Movement file', '*' + utils.movement_file_extension)])
if file:
patient_record.movement_file_path = file.name[:-len(utils.movement_file_extension)]
file_path_entry.delete(0, tk.END)
file_path_entry.insert(0, patient_record.movement_file_path)
return
# test
if __name__ == "__main__":
ui = tk.Tk()
ui.option_add("*Font", ('Arial', 12))
ui.option_add("*Background", "#fff")
view_frame = tk.Frame(ui)
view_frame.pack(fill="both")
patient_record = patientRecord.PatientRecord()
PatientView.show(view_frame, patient_record)
button_frame = tk.Frame(ui, bg='#eee')
button_frame.pack(pady=10)
cancel_button = tk.Button(button_frame, text="Cancel")
cancel_button.pack(side=tk.LEFT, padx=10)
action_button = tk.Button(button_frame, text="Save")
action_button.pack(side=tk.LEFT, padx=10)
ui.mainloop()
print(patient_record)