/
survey.py
212 lines (155 loc) · 6.2 KB
/
survey.py
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import os.path
import tkinter as tk
BASE_DIR = os.path.dirname(__file__)
class IntraRatingFrame(tk.Frame):
def __init__(self, master, logger, progress, continue_callback):
tk.Frame.__init__(self, master)
self.pack()
self._logger = logger
self._continue_callback = continue_callback
self._rating = tk.IntVar()
self._rating.set(0)
tk.Frame(self, height=100).pack() # Top Padding
tk.Label(self,
wraplength=500,
text='How annoying was that set of dragging trials?\n'
'From -5 (extremely frustrating) to +5 (extremely satisfying).',
pady=10).pack()
tk.Scale(self,
from_=-5,
to=5,
length=400,
tickinterval=5,
orient=tk.HORIZONTAL,
variable=self._rating).pack()
wrap_frame = tk.Frame(self)
image = tk.PhotoImage(file=os.path.join(BASE_DIR, 'negative.gif'))
label = tk.Label(wrap_frame, image=image, width=180, anchor=tk.W)
label.image = image
label.pack(side=tk.LEFT)
image = tk.PhotoImage(file=os.path.join(BASE_DIR, 'neutral.gif'))
label = tk.Label(wrap_frame, image=image, width=180, anchor=tk.W)
label.image = image
label.pack(side=tk.LEFT)
image = tk.PhotoImage(file=os.path.join(BASE_DIR, 'positive.gif'))
label = tk.Label(wrap_frame, image=image)
label.image = image
label.pack(side=tk.LEFT)
wrap_frame.pack()
tk.Frame(self, height=30).pack() # Padding
self._next = tk.Button(self,
text=progress,
command=lambda *args: self._continue_clicked())
self._next.pack(side=tk.BOTTOM)
def _continue_clicked(self):
self._logger.WriteLine('RATING', self._rating.get())
self._continue_callback()
class OnOrOffFrame(tk.Frame):
def __init__(self, master, logger, progress, continue_callback, subject_id):
tk.Frame.__init__(self, master)
self.pack()
self._logger = logger
self._continue_callback = continue_callback
tk.Frame(self, height=100).pack() # Top Padding
# The 'Continue' button becomes enabled this is 'True'
self._touched_posneg = False
self._pos_neg = tk.IntVar()
self._pos_neg.set(-1) # Matches neither
self._pos_neg.trace('w', lambda *args: self._posneg_changed())
framing_question = ""
if (subject_id % 2 == 0):
framing_question = "Would you like the Grid Snapping feature enabled?"
else:
framing_question = "Would you like the Grid Snapping feature disabled?"
tk.Label(self,
wraplength=500,
text=framing_question).pack()
# tk.Button(self, text="BUTTON 1 FOR ON/OFF").pack()
# tk.Button(self, text="BUTTON 2 FOR ON/OFF").pack()
#Preferences: value '1' is leaving grid snap ON, value '0' if turning grid snap OFF
wrap_frame = tk.Frame(self, pady=10)
if (subject_id % 2 == 0):
print("POSITIVE FRAMING")
tk.Radiobutton(wrap_frame,
text='Yes',
variable=self._pos_neg,
value=0,
padx=10).pack(side=tk.LEFT)
tk.Radiobutton(wrap_frame,
text='No',
variable=self._pos_neg,
value=1).pack(side=tk.LEFT)
else:
print("NEGATIVE FRAMING")
tk.Radiobutton(wrap_frame,
text='Yes',
variable=self._pos_neg,
value=1,
padx=10).pack(side=tk.LEFT)
tk.Radiobutton(wrap_frame,
text='No',
variable=self._pos_neg,
value=0).pack(side=tk.LEFT)
wrap_frame.pack()
tk.Frame(self, height=30).pack() # Padding
self._next = tk.Button(self,
text=progress,
state=tk.DISABLED,
command=lambda *args: self._continue_clicked())
self._next.pack(side=tk.BOTTOM)
def _posneg_changed(self):
# Enable the 'Continue' button once they've selected an option
self._next.config(state=tk.NORMAL)
def _continue_clicked(self):
#print('PREFERENCE' + str(self._pos_neg.get()))
print("pos_neg.get is: " + str(self._pos_neg.get()))
if (self._pos_neg.get() == 0):
self._logger.WriteLine('PREFERENCE', 'ON')
print("PREFERENCE: ON")
else:
self._logger.WriteLine('PREFERENCE', 'OFF')
print("PREFERENCE: OFF")
self._continue_callback()
class InterRatingFrame(tk.Frame):
def __init__(self, master, logger, progress, continue_callback):
tk.Frame.__init__(self, master)
self.pack()
self._logger = logger
self._continue_callback = continue_callback
tk.Frame(self, height=100).pack() # Top Padding
# The 'Continue' button becomes enabled this is 'True'
self._touched_posneg = False
self._pos_neg = tk.IntVar()
self._pos_neg.set(-1) # Matches neither
self._pos_neg.trace('w', lambda *args: self._posneg_changed())
tk.Label(self,
wraplength=500,
text='If you were to repeat one of the last two sets of trials,\n'
'which would you prefer to do?').pack()
wrap_frame = tk.Frame(self, pady=10)
tk.Radiobutton(wrap_frame,
text='First',
variable=self._pos_neg,
value=1,
padx=10).pack(side=tk.LEFT)
tk.Radiobutton(wrap_frame,
text='Second',
variable=self._pos_neg,
value=0).pack(side=tk.LEFT)
wrap_frame.pack()
tk.Frame(self, height=30).pack() # Padding
self._next = tk.Button(self,
text=progress,
state=tk.DISABLED,
command=lambda *args: self._continue_clicked())
self._next.pack(side=tk.BOTTOM)
def _posneg_changed(self):
# Enable the 'Continue' button once they've selected an option
self._next.config(state=tk.NORMAL)
def _continue_clicked(self):
print("pos_neg.get is: " + self._pos_neg.get)
if (self._pos_neg.get == 0):
self._logger.WriteLine('PREFERENCE', 'ON')
else:
self._logger.WriteLine('PREFERENCE', 'OFF')
self._continue_callback()