-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.py
executable file
·8070 lines (5817 loc) · 409 KB
/
Main.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# coding=utf-8
# *************** UCL Experiment *************************************** #
#Install PYQT 4 from https://www.riverbankcomputing.com/static/Docs/PyQt4/installation.html
#Instrucions http://www.noktec.be/python/how-to-install-pyqt4-on-osx
#https://stackoverflow.com/questions/26021882/installing-pyqt4-on-mac-osx-mavericks
#unset PYTHONPATH
#brew install sip --with-python3
#brew install pyqt --with-python3
#1) USER INTERFACE (UI):
# ExperimentInterface.ui: Contains the initial user interface (UI) of the program. It is basically a Stacked Widget with 5 pages
# (Page 1: pageConsent, Page 2: demographicsPage , Page 3: simulationExpPage , Page 4: choiceExpPage Page 5:debriefPage). "ExperimentInterface.ui" must be in the same folder than this py.file
# * Most of the UI is created in the main class and the code is very well documented in case you want to make changes in the UI
# ** The GUI is totally separated from the code. It is only use to show the output of the program but not to read information from any variable.
# *** The folder "Screenshots" contains pictures of the program running
#2) PYTHON FILES:
# a) StackedWidget.py is a autogenerated python file
# b) ExperimentInterface.py is the output obtained by executing the following command in the terminal
## c) "pyuic4-3.4 ExperimentInterface.ui -o ExperimentInterface.py". This command must be executed in the terminal before running Main.py.
# c) "pyuic5 ExperimentInterface.ui -o ExperimentInterface.py". This command must be executed in the terminal before running Main.py.
# In windows computers the following command must be executed: pyuic4 ExperimentInterface.ui -o ExperimentInterface.py
# d) Main.py contains the code for the main execution of the program.
# e) Functions.py contains several functions used during the program. They might be created in the main class, but this might decrease readability
# f) Journey.py define the classes Mode, TravelTime, WaitingTime, Trip and TripStages
# g) .py define the class .
# 3) INPUT FILES (txt extension)
# a) consentExperiment.txt: Contains the instructions shown in the first page (consentPage of the Stacked Widget)
# *********************************************************************** #
# *************** Import libraries *************************************** #
import site
import os
from os import listdir # This library has some functions to read the list of files names in a folder
import sys
QTPY_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'vendor', 'Qt.py')
site.addsitedir(QTPY_PATH)
sys.path.append(QTPY_PATH)
import os
os.environ['QT_SIP_API_HINT'] = "2"
os.environ["QT_VERBOSE"] = "True"
# import Qt
from PyQt5 import QtGui, QtCore, uic, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtGui import * # QPalette, QColor, QFont
from PyQt5.QtCore import QTimer
from Animations import * #Mode class
from Scripts.Experiment import *
from Scripts.ITS import * #Import class 'ITS'
from Scripts.Location import * # class
from Scripts.Mode import * #Import class 'Bus', 'Vehicle', 'Car', 'Bike'
from Scripts.Network import * #Import class 'Route'
from Scripts.Participant import * # Class participant
from Scripts.Person import * #Import class 'Person'
from myWidgets import *
# *************** Creation and Formatting of Main Window *************************************** #
#os.environ["QT_PREFERRED_BINDING"] = "1"
#Default command to create the main window and launch the UI.
app = QApplication(sys.argv)
window = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(window)
# # The following function set the size of the main window as a percentage of the screen's width and height (percentageScreen)
windowMaximized(window = window,fullScreen=True,showMainWindowTitle = False) # If it is true, the percentage margin in the screen is 0 and the user cannot see anything more than the experiment
#Set the size of the window to their size and set the position (close to the origin)
windowWidth = window.width()
windowHeight = window.height()
# window.setGeometry(0, 0, windowWidth, windowHeight) #If the x,y parameters are set in 0, the window is not completely shown in the computer labs
window.setGeometry(0, 0, windowWidth, windowHeight) #If the x,y parameters are set in 0, the window is not completely shown in the computer labs
window.setFixedSize(windowWidth ,windowHeight) # The user cannot change the size of the window
#Other formatting options for the main window
removeUpperButtonsWindow(window) #This function remove the upper buttons of the main window
window.statusBar().setVisible(False) #Remove status bar of the main window
#Set title of the window
# window.setWindowTitle("")
window.fontSizeTitle = 26 #Size of the titles in the stacked widget pages' of the experiment
# *************** Experiment Parameters *************************************** #
#id of the experiment
window.experimentId = 1 #This value should be changed if a experiment with new parameters will be run (for example, number of participants of the experiment)
#Experiment description
window.experimentDescription = ''
#Conditions for the experiments (waiting time)
window.waitingTimes = [1,2,3,4,5] #More conditions can be added and the program will automatically modify output. IN this example, the conditions are 1..5 minutes of waiting time
window.waitingTime = window.waitingTimes[randint(1, len(window.waitingTimes))-1] # Generate a random waiting time depending on the conditions
#Participant information
# window.currentParticipant = None #Object for the current participant in the experiment
# window.currentParticipant = Participant(age = 27, gender = "Male", educationLevel = "Graduate", country = "UK")
window.participantTrips = [] #List wit the information of each trip chosen by the participant
window.currentTrip = Trip()
# #Experimental conditions
# window.simulatedExperimentConditions = ["control","treatment"]
# window.simulatedExperimentCondition = window.simulatedExperimentConditions[1]
# *************** Creation and Formatting of the Stacked Widget (5 pages) *************************************** #
#The 'next' buttons will always have the same position (lower left corner) and format.
# The third line in each coding block, create the nexxt buttons in each page.
def createNextButtonsActions():
# Consent: Link the signal emmited by the button next, with its corresponding function
ui.buttonNextConsent1Page.clicked.connect(buttonNextConsent1Clicked)
ui.buttonNextConsent2Page.clicked.connect(buttonNextConsent2Clicked)
# Next button for description of the scenarios
ui.buttonNextScenarioDescriptionPage.clicked.connect(buttonNextScenarioDescriptionPageClicked)
# Link the signal emmited by the button next, with its corresponding function
ui.buttonNextSimulationExperimentGeneralDescription.clicked.connect(buttonNextSimulationExperimentGeneralDescriptionClicked)
ui.buttonBackSimulationExperimentGeneralDescription.clicked.connect(buttonBackSimulationExperimentGeneralDescriptionClicked)
ui.buttonNextSimulationExperimentDescriptionPage.clicked.connect(buttonNextExperimentDescriptionClicked)
# Link the signal emmited by the button next, with its corresponding function
ui.buttonNextSimulationExpChoicePage.clicked.connect(buttonNextSimulationExpChoicePageClicked)
ui.startJourneyButton.clicked.connect(startJourneyClicked)
ui.nextJourneyButton.clicked.connect(nextJourneyClicked)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextDecisionExpDescriptionPage.clicked.connect(nextButtonDecisionExpDescriptionPage)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextDecisionSeparateExpPage.clicked.connect(nextButtonDecisionSeparateExpPage)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonBackSimulationExpChoicePage.clicked.connect(buttonBackSimulationExpChoicePageClicked)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextProspectExpPage.clicked.connect(nextButtonProspectExpPage)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextDemographicsPage.clicked.connect(buttonNextDemographicsClicked)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextTravelBehaviourPage.clicked.connect(buttonNextTravelBehaviourPageClicked)
# This link the signal sent by the button next with its corresponding function (above)
ui.buttonNextExperimentDebriefPage.clicked.connect(buttonNextExperimentDebriefPageClicked)
ui.buttonNextDebriefPage.clicked.connect(buttonNextDebriefPageClicked)
def createWidgetAndNextButtons():
#Centering the whole stacked widget in the screen
centerStackedWidget(stackedWidget = ui.stackedWidget, mainWindow = window)
backgroundStackedWidget(window, "white") #Background colour of main window
ui.stackedWidget.setFrameShape(QFrame.NoFrame) #Remove the coloured border in the stacked widget
#1) Consent Pages
# a)Centering the Consent1 page and adding next button
centerWidget(mainWidget = ui.consent1Page, subWidget = ui.consent1Panel)
backgroundStackedWidget(ui.consent1Panel, "white") #Background colour of main window
ui.buttonNextConsent1Page = QPushButton() #Creation of 'Next' buttons
ui.pushButtonConsent1Grid.addWidget(ui.buttonNextConsent1Page,0,0) #Add button to a grid
# B)Centering the Consent2 page and adding next button
centerWidget(mainWidget=ui.consent2Page, subWidget=ui.consent2Panel)
backgroundStackedWidget(ui.consent2Panel, "white") # Background colour of main window
ui.buttonNextConsent2Page = QPushButton() # Creation of 'Next' buttons
ui.pushButtonConsent2Grid.addWidget(ui.buttonNextConsent2Page, 0, 0) # Add button to a grid
#3) Main Page
centerWidget(mainWidget=ui.scenarioDescriptionPage, subWidget=ui.scenarioDescriptionPanel)
backgroundStackedWidget(ui.scenarioDescriptionPanel, "white") # Background colour of main window
ui.buttonNextScenarioDescriptionPage = QPushButton() #Creation of 'Next' buttons
ui.pushButtonsScenarioDescriptionGrid.addWidget(ui.buttonNextScenarioDescriptionPage, 0,
0) # Add button to a grid
#4) Experiment Decision-from-Simulation pages
# Centering the Description Experiment and adding next button
centerWidget(mainWidget=ui.simulationExpGeneralDescriptionPage, subWidget=ui.simulationExpGeneralDescriptionPanel)
backgroundStackedWidget(ui.simulationExpGeneralDescriptionPanel, "white") # Background colour of main window
# ui.buttonNextSimulationExperimentDescriptionPage = QPushButton() # Creation of 'Next' buttons
# ui.pushButtonsSimulationExpDescriptionGrid.addWidget(ui.buttonNextSimulationExperimentDescriptionPage, 0,
# 0) # Add button to a grid
#a) Description Sections
centerWidget(mainWidget = ui.simulationExpDescriptionPage, subWidget = ui.simulationExpDescriptionPanel)
backgroundStackedWidget(ui.simulationExpDescriptionPanel, "white") #Background colour of main window
ui.buttonNextSimulationExperimentDescriptionPage = QPushButton() #Creation of 'Next' buttons
ui.pushButtonsSimulationExpDescriptionGrid.addWidget(ui.buttonNextSimulationExperimentDescriptionPage,0,0) #Add button to a grid
#b) Learning and Consequence Sections
centerWidget(mainWidget = ui.simulationExpPage, subWidget = ui.simulationExpPanel)
backgroundStackedWidget(ui.simulationExpPanel, "white") #Background colour of main window
#Start JourneyButton
ui.startJourneyButton = QPushButton(ui.simulationExpPanel)
ui.startJourneyGrid.addWidget(ui.startJourneyButton)
#Next Journey Button
ui.nextJourneyButton = QPushButton(ui.simulationExpPanel)
ui.nextJourneyGrid.addWidget(ui.nextJourneyButton)
ui.nextJourneyButton.setVisible(False) #At the beginning
#c) Choice Section
centerWidget(mainWidget = ui.simulationExpChoicePage, subWidget = ui.simulationExpChoicePanel)
backgroundStackedWidget(ui.simulationExpChoicePanel, "white") #Background colour of main window
#4) Centering the Experiment Decision-from-Description Pages and adding next button
#a) Description
centerWidget(mainWidget = ui.decisionExpDescriptionPage, subWidget = ui.decisionExpDescriptionPanel)
backgroundStackedWidget(ui.decisionExpDescriptionPanel, "white") #Background colour of main window
ui.buttonNextDecisionExpDescriptionPage = QPushButton() #Creation of 'Next' button
ui.pushButtonsDecisionExpDescriptionGrid.addWidget(ui.buttonNextDecisionExpDescriptionPage)
#b) Control Condition (table)
centerWidget(mainWidget=ui.decisionSeparateExpPage, subWidget=ui.decisionSeparateExpPanel)
backgroundStackedWidget(ui.decisionSeparateExpPanel, "white") # Background colour of main window
ui.buttonNextDecisionSeparateExpPage = QPushButton() # Creation of 'Next' button
ui.pushButtonsDecisionSeparateExpGrid.addWidget(ui.buttonNextDecisionSeparateExpPage, 0, 0) # Add button to a grid
#c) Treatment Condition (prospect)
centerWidget(mainWidget=ui.prospectExpPage, subWidget=ui.prospectExpPanel)
backgroundStackedWidget(ui.prospectExpPanel, "white") # Background colour of main window
ui.buttonNextProspectExpPage = QPushButton() # Creation of 'Next' button
ui.pushButtonsProspectExpGrid.addWidget(ui.buttonNextProspectExpPage, 0, 0) # Add button to a grid
#6) Centering the Demographics page and adding next button
centerWidget(mainWidget = ui.demographicsPage, subWidget = ui.demographicsPanel)
backgroundStackedWidget(ui.demographicsPanel, "white") #Background colour of main window
ui.buttonNextDemographicsPage = QPushButton() #Creation of 'Next' buttons
ui.pushButtonsDemographicsGrid.addWidget(ui.buttonNextDemographicsPage, 0, 0)
#7) Centering the Individual Travel Behaviour page and adding next button
centerWidget(mainWidget = ui.travelBehaviourPage, subWidget = ui.travelBehaviourPanel)
backgroundStackedWidget(ui.travelBehaviourPanel, "white") #Background colour of main window
ui.buttonNextTravelBehaviourPage = QPushButton() #Creation of 'Next' buttons
ui.pushButtonsTravelBehaviourGrid.addWidget(ui.buttonNextTravelBehaviourPage,0,0)
#8) Centering the Experiment Question page and adding next button
centerWidget(mainWidget = ui.experimentDebriefPage, subWidget = ui.experimentDebriefPanel)
backgroundStackedWidget(ui.experimentDebriefPanel, "white") #Background colour of main window
ui.buttonNextExperimentDebriefPage = QPushButton(ui.experimentDebriefPanel) #Creation of 'Next' button
ui.pushButtonsExperimentDebriefGrid.addWidget(ui.buttonNextExperimentDebriefPage,0,0)
#9) Centering the Debrief Page and adding next button
centerWidget(mainWidget = ui.debriefPage, subWidget = ui.debriefPanel)
backgroundStackedWidget(ui.debriefPanel, "white") #Background colour of main window
ui.buttonNextDebriefPage = QPushButton() #Creation of 'Next' button
ui.pushButtonsDebriefGrid.addWidget(ui.buttonNextDebriefPage)
# ui.buttonNextDebriefPage.setText("Finish Experiment")
def formatNextButtons(language):
#This apply the function to format and locate the next button within the pages of the stackedWidget
for button in [ui.buttonNextExperimenterScreenPage, ui.buttonNextSimulationExperimentDescriptionPage,ui.buttonNextConsent1Page,ui.buttonNextConsent2Page,
ui.buttonNextScenarioDescriptionPage, ui.buttonNextDemographicsPage,ui.buttonNextDebriefPage
, ui.buttonNextDecisionExpDescriptionPage, ui.buttonNextDecisionSeparateExpPage,ui.buttonNextDecisionSeparateExpPage,
ui.buttonNextTravelBehaviourPage, ui.buttonNextExperimentDebriefPage,ui.buttonNextDebriefPage]:
nextButtonFormat(button,language = language, fontLetter = window.fontLetter, fontFactor = window.fontFactor, small = False)
#This is for buttons added in a grid
for buttonInGrid in [ui.buttonNextExperimenterScreenPage, ui.startJourneyButton,ui.nextJourneyButton,ui.buttonNextScenarioDescriptionPage
,ui.buttonNextSimulationExperimentDescriptionPage
,ui.buttonBackSimulationExperimentGeneralDescription,ui.buttonNextSimulationExperimentGeneralDescription
,ui.buttonNextConsent1Page,ui.buttonNextConsent2Page, ui.buttonNextDecisionSeparateExpPage,ui.buttonNextProspectExpPage
,ui.buttonNextDecisionExpDescriptionPage
, ui.buttonNextDemographicsPage,ui.buttonNextTravelBehaviourPage, ui.buttonNextExperimentDebriefPage
,ui.buttonNextDebriefPage]:
buttonInGrid.setFont(QFont(window.fontLetter, window.fontFactor * 19))
buttonInGrid.setFixedHeight(ui.buttonNextConsent1Page.height())
buttonInGrid.setFixedWidth(ui.buttonNextConsent1Page.width())
buttonInGrid.setFocusPolicy(QtCore.Qt.NoFocus)
createNextButtonsActions()
def setGridsFormat():
# Grids with no spacing
for grid in [ui.experimenterScreenTitleGrid, ui.experimenterScreenGrid, ui.consent1TitleGrid,ui.consent2TitleGrid, ui.simulationExpGeneralDescriptionTitleGrid
,ui.simulationExpGrid,ui.simulationExpDescriptionTitleGrid,ui.scenarioDescriptionTitleGrid
,ui.mapGrid,ui.simulationExpStatusGrid,ui.preferredJourneyGrid,ui.simulationExpChoiceProgressBarGrid
,ui.moreJourneysGrid,ui.pushButtonsDecisionSeparateExpGrid,ui.pushButtonsProspectExpGrid
, ui.preferredDescriptiveRouteGrid,ui.completedTripsGrid,ui.nextDescriptiveQuestionGrid
, ui.preferredProspectRouteGrid
, ui.altADecisionExpGrid,ui.altBDecisionExpGrid,ui.simulationExpStageGrid,ui.pushButtonsDebriefGrid
, ui.demographicsTitleGrid,ui.decisionExpDescriptionTitleGrid,ui.debriefTitleGrid,ui.debriefGrid
,ui.prospectExpProgressBarGrid,ui.altADecisionExpTitleGrid,ui.altBDecisionExpTitleGrid
,ui.altAProspectExpTitleGrid,ui.altAWaitingProspectExpGrid, ui.altATravelProspectExpGrid
, ui.altBProspectExpTitleGrid, ui.altBWaitingProspectExpGrid, ui.altBTravelProspectExpGrid
,ui.consent1LogoGrid,ui.simulationExpChoiceStageGrid
, ui.decisionSeparateExpProgressBarGrid
, ui.travelBehaviourGrid, ui.travelBehaviourTitleGrid
, ui.experimentDebriefGrid, ui.experimentDebriefTitleGrid
, ui.debriefLogoGrid]:
grid.setHorizontalSpacing(0)
grid.setVerticalSpacing(0)
# grid.setContentsMargins(1,1,1,1)# grid.setMargin(0)
for lowMarginGrid in [ui.experimentDescriptionGrid,ui.consent1TextGrid,ui.experimentLongDescriptionGrid]:
lowMarginGrid.setHorizontalSpacing(2.5)
lowMarginGrid.setVerticalSpacing(2.5)
lowMarginGrid.setContentsMargins(2.5, 2.5, 2.5, 2.5) # .setMargin(2.5)
for midHorizontalSpacingGrid in [ui.experimentPicturesGrid
,ui.horizontalSliderConfirmationGrid
,ui.experiencedExperimentIdentificationSliderGrid,ui.journeyTimeImportanceSliderGrid
,ui.waitingTimeImportanceSliderGrid,ui.waitingTimeReliabilityImportanceSliderGrid
,ui.inVehicleTimeImportanceSliderGrid,ui.inVehicleTimeReliabilityImportanceSliderGrid
]:
midHorizontalSpacingGrid.setHorizontalSpacing(20)
midHorizontalSpacingGrid.setVerticalSpacing(0)
for highMarginGrid in [ui.preferredDescriptiveJourneyClickableGrid, ui.preferredDescriptiveJourneyGrid]:
# highMarginGrid.setHorizontalSpacing(250)
# highMarginGrid.setMargin(15)
#Grids for buttons
# Buttons ligned in center
for centerButtonGrid in [ui.pushButtonsSimulationExpGeneralDescriptionGrid
,ui.altADecisionExpGrid,ui.altBDecisionExpGrid]:
centerButtonGrid.setAlignment(QtCore.Qt.AlignCenter)
# Buttons aligned right
for rightButtonGrid in [ui.pushButtonExperimenterScreenGrid, ui.pushButtonConsent1Grid, ui.pushButtonConsent2Grid,ui.pushButtonsScenarioDescriptionGrid
, ui.pushButtonsSimulationExpDescriptionGrid,ui.pushButtonsDecisionSeparateExpGrid
,ui.pushButtonsProspectExpGrid,ui.pushButtonsDecisionExpDescriptionGrid
, ui.pushButtonsDemographicsGrid,ui.pushButtonsTravelBehaviourGrid
,ui.pushButtonsExperimentDebriefGrid, ui.pushButtonsDebriefGrid]:
rightButtonGrid.setAlignment(QtCore.Qt.AlignRight)
def setFrameQLabels():
for QLabel in [ui.preferredJourneyLbl,ui.moreJourneysLbl,ui.preferredDescriptiveRouteLbl, ui.preferredProspectRouteLbl
,ui.decisionPreferredJourneyPanel, ui.prospectPreferredJourneyPanel
,ui.nextDescriptiveQuestionLbl,ui.debriefLbl]:
QLabel.setFrameShape(QFrame.Box)
# UCLTheme(QLabel)
#The panels are by default in lower
for QLabel in [ui.experimenterScreenTextAndPicturesPanel, ui.pushButtonsSimulationExpChoicePanel
,ui.pushButtonsDecisionSeparateExpPanel,ui.nextButtonDecisionExpDescriptionPanel
,ui.Consent1BoxAndTextPanel, ui.consent2TextAndPicturesPanel
,ui.simulationExpDescriptionTextAndPicturesPanel, ui.simulationExpGeneralDescriptionTextAndPicturesPanel
, ui.pushButtonsProspectExpPanel,ui.prospectProgressBarPanel, ui.prospectPreferredJourneyPanel
, ui.pushButtonsSimulationExpChoicePanel,ui.nextButtonSimulationExpDescriptionPanel
, ui.pushButtonsDemographicsPanel,ui.pushButtonsTravelBehaviourPanel,ui.pushButtonsExperimentDebriefPanel
,ui.pushButtonsDebriefPanel]:
QLabel.lower()
def setLabelsUCLTheme():
for QLabel in [ui.simulationExpStageLbl,ui.simulationExpRemainingDaysLbl,ui.completedTripsPanel,ui.prospectProgressBarPanel
,ui.decisionSeparateProgressBarPanel,ui.nDecisionExpLbl,ui.nProspectExpLbl, ui.simulationExpChoiceStageLbl
,ui.simulationExpChoiceStagePanel, ui.simulationExpDecisionProblemCounterLbl]:
UCLTheme(QLabel)
def setBlackSpacingGrids():
# Spacing grid between heading and body
for blackSpacingGrid in [ui.experimenterScreenBlackSpacingGrid,ui.consent1BlackSpacingGrid,ui.consent2BlackSpacingGrid
, ui.simulationExpDescriptionGridBlackSpacingGrid
, ui.simulationExpGeneralDescriptionBlackSpacingGrid, ui.simulationExpPageBlackSpacingGrid
, ui.simulationExpChoiceBlackSpacingGrid,ui.decisionExpDescriptionBlackSpacingGrid,ui.decisionExpBlackSpacingGrid
, ui.debriefBlackSpacingGrid]:
blackSpacingGrid.addWidget(QLabel(), 0, 0)
ui.blackSpacingLbl = blackSpacingGrid.itemAtPosition(0, 0).widget()
setBackgroundColorQLabel(QLabel=ui.blackSpacingLbl, colorString="black")
blackSpacingGrid.setHorizontalSpacing(0)
blackSpacingGrid.setVerticalSpacing(0)
#blackSpacingGrid.setMargin(0)
# blackSpacingGrid.setContentsMargins(0,0,0,0)
def createProgressBars():
# Style Progress Bars
window.styleProgressBar1 = "QProgressBar::chunk {""background-color: yellow;""}"
window.styleProgressBar1 = window.styleProgressBar1 + "QProgressBar {""border: 1px solid grey;""border-radius: 2px;""text-align: center;""background: #eeeeee;""}"
window.styleProgressBar2 = "QProgressBar::chunk {""background-color: yellow;""}"
window.styleProgressBar2 = window.styleProgressBar2 + "QProgressBar {""border: 1px solid grey;""border-radius: 2px;""text-align: center;""background: #eeeeee;""}"
window.styleProgressBar3 = "QProgressBar::chunk {""background-color: yellow;""}"
window.styleProgressBar3 = window.styleProgressBar3 + "QProgressBar {""border: 1px solid grey;""border-radius: 2px;""text-align: center;""background: #eeeeee;""}"
ui.progressBarCompletedTrips.setValue(0)
ui.simulationExpChoiceProgressBar.setValue(0)
ui.decisionSeparateExpProgressBar.setValue(0)
ui.prospectExpProgressBar.setValue(0)
def updateInstruction(txtInstructions, experiment = None, folder = None):
# paperBasedInstruction = "write down your decision below. You will draw a marble from your chosen urn straight afterwards." #Participants where instructed to write this, after they picked the marble
# computerBasedInstruction = "in the following page, click one of the two alternatives and press 'Next.'" #This is the new instruction
# Readtxt file with the generic instruction
if folder is not None:
fileInstruction = open("Descriptions/" +folder + "/" +txtInstructions, 'r', encoding='utf-8')
else:
fileInstruction = open("Descriptions/" + txtInstructions, 'r', encoding='utf-8')
infoFileInstruction = fileInstruction.readlines()
fileInstruction.close()
#This are the fields updated in the generla instructions. At this point there are no experiments created yet.
if experiment is not None:
dictNewLabels = {'_nLearningTrials_': int(experiment.nLearningTrials)
# Equal to 30 pounds in the paper-based experiment
, '_nLearningTrialsByRoute_': int(experiment.nLearningTrialsByRoute)
, '_nConsequenceTrials_': int(experiment.nConsequenceTrials)
, '_nExtraLearningTrials_': int(experiment.nExtraLearningTrials)
, '_nExtraLearningTrialsPerRoute_': int(experiment.nExtraLearningTrials/2)
, '_messageInstructionExperimentalCondition_': window.messageInstructionExperimentalCondition
, '_buttonNextExperimentDescriptionPage_': str(ui.buttonNextSimulationExperimentDescriptionPage.text())
, '_buttonNextSimulationExperimentDescriptionPage_': str(ui.buttonNextSimulationExperimentDescriptionPage.text())
, '_buttonNextExperimentGeneralDescriptionPage_': str(ui.buttonNextSimulationExperimentGeneralDescription.text())
, '_startJourneyButton_': str(ui.startJourneyButton.text())
, '_nStages_': str(window.mainExperiment.nStages)
, '_firstSliderLevel_': window.firstSliderLevel
, '_lastSliderLevel_': window.lastSliderLevel
, '_totalChoiceSets_': str(window.totalChoiceSets)
, '_confirmationAlternatives_': str(getConfirmationAlternatives(all = False))
, '_nConfirmationAlternatives_': str(getNConfirmationAlternatives())
, '_nameNextStageExperiment_':str(window.nextStageName)
, '_nameCurrentExperiment_':window.mainExperiment.getNameCurrentExperimentBlock(language = window.mainExperiment.languageCondition, short = False)
, '_buttonBackSimulationExpChoicePage_':str(ui.buttonBackSimulationExpChoicePage.text())
, '_buttonNextSimulationExpChoicePage_': str(ui.buttonNextSimulationExpChoicePage.text())
, '_buttonNextDecisionSeparateExpPage_':str(ui.buttonNextDecisionSeparateExpPage.text())
, '_buttonNextDecisionExpDescriptionPage_': str(ui.buttonNextDecisionExpDescriptionPage.text())
, '_origin_': experiment.randomOrigin
, '_destination_': experiment.randomDestination
, '_nExperiment_': int(experiment.expType)
, '_nChoiceSet_': int(experiment.id)
, '_nCardinalChoiceSet_': getNumberToWord(number = int(experiment.id), language = window.mainExperiment.languageCondition, cardinal = True,capitalLetter = False)
, '_nChoiceSetsTrainingBlock_': int(len(window.timeChoiceSetsBlock1))
, '_nLearningTrials_': int(experiment.nLearningTrials)
, '_nLearningTrialsPerRoute_': int(experiment.nLearningTrials/2)
, '_nChoiceSets_': int(experiment.maxId)
, '_nBlockDecisionProblem_': int(window.mainExperiment.nBlockDecisionProblem)
, '_nCardinalBlockDecisionProblem_': getNumberToWord(number=int(window.mainExperiment.nBlockDecisionProblem),
language=window.mainExperiment.languageCondition, cardinal=True,
capitalLetter=False)
, '_city_': window.city
, '_buttonNextDebriefPage_':str(ui.buttonNextDebriefPage.text())
# ,
# '_prize_': self.prize #Equal to 30 pounds in the paper-based experiment
# ,'_colorPrize_':self.colorPrize #Blue in the paper-based experiment and with lowercase
# ,'_labelUrnA_':self.urnA.label
# ,'_labelUrnB_': self.urnB.label
# ,'_randomColor_':self.randomColor #Color of the marble selected to do the random allocation of balls (blue in the paper experiment)
# ,'_nRedNonRandomUrn_':self.nonRandomUrn().nRed
# ,'_nRedRandomUrn_':self.randomUrn().nRed
# ,'_nBlueNonRandomUrn_':self.nonRandomUrn().nBlue
# ,'_nBlueRandomUrn_':self.randomUrn().nBlue
# ,'_nMarbles_': self.nMarbles
# ,'_numberSequence_':self.numberSequence(self.nMarbles)
# ,'_labelRandomUrn_':self.randomUrn().label
# ,'_labelNonRandomUrn_':self.nonRandomUrn().label
# ,'_marblePickedInstruction_': computerBasedInstruction
}
else:
dictNewLabels = {
'_nLearningTrials_': 1
, '_buttonNextExperimentGeneralDescriptionPage_': str(ui.buttonNextSimulationExperimentGeneralDescription.text())
, '_buttonNextSimulationExperimentDescriptionPage_': str(ui.buttonNextSimulationExperimentDescriptionPage.text())
, '_buttonNextExperimentGeneralDescriptionPage_': str(ui.buttonNextSimulationExperimentGeneralDescription.text())
, '_messageInstructionExperimentalCondition_': window.messageInstructionExperimentalCondition
, '_totalChoiceSets_': str(window.totalChoiceSets)
, '_firstSliderLevel_': window.firstSliderLevel
, '_lastSliderLevel_': window.lastSliderLevel
, '_nStages_': str(window.mainExperiment.nStages)
,'_city_': window.city
}
instructions = ""
lenInfoFileInstruction = len(infoFileInstruction)
counterParagraph = 0
for paragraph in infoFileInstruction:
for label in dictNewLabels.keys():
paragraph = paragraph.replace(str(label), str(dictNewLabels[label]))
# if counterParagraph<len(infoFileInstruction)-1:
# instructions += paragraph+"\n"
# else:
instructions += paragraph
counterParagraph += 1
return instructions
def setBodyTextPage(grid,text, fontLetter,fontSize, fontFactor, fontIncreaseFactor = 1):
if grid.itemAtPosition(0, 0) is None:
title = QLabel()
# title.setStyleSheet("color: white ; border: 1px solid black ; background: black ;")
# This need to be above the code for changing the background color
# setLettersColorQLabel(QLabel=titleLbl, colorString = colorText)
# setBackgroundColorQLabel(QLabel=title, colorString=colorBackground)
grid.addWidget(title, 0, 0)
titleLbl = grid.itemAtPosition(0, 0).widget()
titleLbl.setText(text)
titleLbl.setAlignment(QtCore.Qt.AlignTop|QtCore.Qt.AlignLeft)
titleLbl.setFont(QFont(fontLetter, fontFactor * fontSize))
else:
grid.itemAtPosition(0, 0).widget().setText(text)
def setTitlePage(grid, text, fontLetter, fontFactor, capitalLetters, fontIncreaseFactor = 1, fontSize = window.fontSizeTitle, colorBackground = "black", colorText = "white", centered = False):
#Remove any previous element from the grid
# for i in range(grid.count()):
# element = grid.itemAt(i).widget() # ui.journeyClickableGrid is a grid with 4 grids.
# element.setVisible(False)
if capitalLetters is True:
text = text.upper()
#Label for title of the page (Left side of the heading)
# if text == "":
# title = QLabel()
# title.setStyleSheet("color: white ; border: 1px solid black ; background: white ;")
# grid.addWidget(title, 0, 0)
#
# else:
if grid.itemAtPosition(0, 0) is None:
title = QLabel()
title.setStyleSheet("color: white ; border: 1px solid black ; background: black ;")
# This need to be above the code for changing the background color
# setLettersColorQLabel(QLabel=titleLbl, colorString = colorText)
# setBackgroundColorQLabel(QLabel=title, colorString=colorBackground)
grid.addWidget(title, 0, 0)
titleLbl = grid.itemAtPosition(0, 0).widget()
titleLbl.setWordWrap(True)
titleLbl.setText(text)
if centered == True:
titleLbl.setAlignment(QtCore.Qt.AlignCenter)
else:
titleLbl.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignLeft)
titleLbl.setFont(QFont(fontLetter, fontIncreaseFactor * fontFactor * fontSize,QFont.Bold))
else:
grid.itemAtPosition(0, 0).widget().setText(text)
#The heading does not include the thin grid behind the title
def setHeadingPage(grid, text, fontLetter, fontSize, fontFactor, capitalLetters, fontIncreaseFactor = 1, colorBackground = "black", colorText = "white", centered = False):
setTitlePage(grid, text, fontLetter, fontFactor, capitalLetters, fontIncreaseFactor=1, colorBackground="black",
colorText="white", centered=False)
titleLbl = grid.itemAtPosition(0, 0).widget()
titleLbl.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignLeft)
titleLbl.setFont(QFont(fontLetter, fontIncreaseFactor * fontFactor * fontSize, QFont.Bold))
def setGraphicsExperiment():
#GUI Creation for all pages
createWidgetAndNextButtons()
#Graphical Properties Windows.
setBlackSpacingGrids()
setFrameQLabels()
setGridsFormat()
setLabelsUCLTheme()
setGraphicsExperiment()
# *************** (Page 0) Experimenter Screen Page *************************************** #
def minimumFieldsExperimenterScreenCompleted(participantName, participantId, computerId):
allMinimumFieldsCompleted = None
if participantName == "" or participantId == 0 or computerId == "":
allMinimumFieldsCompleted = False
if computerId == "":
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(0, 0).widget(), colorString="red")
else:
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(0, 0).widget(), colorString="white")
if participantId == 0:
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(1, 0).widget(), colorString="red")
else:
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(1, 0).widget(), colorString="white")
if participantName == "":
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(2, 0).widget(), colorString="red")
else:
setBackgroundColorQLabel(QLabel=ui.experimenterScreenFormLayout1.itemAt(2, 0).widget(), colorString="white")
else:
allMinimumFieldsCompleted = True
return allMinimumFieldsCompleted
def buttonNextExperimenterScreenClicked():
computerId = ui.computerIdQLineEdit.text()
participantId = ui.participantIdQSpinBox.value()
participantName = ui.participantNameQLineEdit.text()
participantLastName = ui.participantLastNameQLineEdit.text()
languageCondition = ui.languageCBox.currentText().lower()
experimentCountry = ui.countryCBox.currentText()
fontFactor = ui.fontSizeQSpinBox.value()
animationSpeedFactor = ui.animationSpeedQSpinBox.value()
#Experimental Session
experimentalSession = ui.experimentalSessionQLineEdit.text()
#Experimental Conditions
simulatedExperimentConditionCBox = ui.simulatedExperimentConditionCBox.currentText()
simulatedExperimentCondition = ""
if simulatedExperimentConditionCBox == "Control":
simulatedExperimentCondition = "simulatedControlCondition"
if simulatedExperimentConditionCBox == "Treatment":
simulatedExperimentCondition = "simulatedTreatmentCondition1" #"simulatedTreatmentCondition2"(without timer)
descriptiveExperimentConditionCBox = ui.descriptiveExperimentConditionCBox.currentText()
descriptiveExperimentCondition = ""
if descriptiveExperimentConditionCBox == "Control":
descriptiveExperimentCondition = "descriptiveControl"
if descriptiveExperimentConditionCBox == "Treatment":
descriptiveExperimentCondition = "descriptiveTreatmentCondition1"
descriptiveDays =ui.descriptiveDaysCBox.currentText()
onlyDescriptiveTestingMode = None
if ui.onlyDescriptiveExperimentCheckBox.checkState() == 2:
onlyDescriptiveTestingMode = True
window.firstPage = ui.decisionExpDescriptionPage
else:
onlyDescriptiveTestingMode = False
window.firstPage = ui.consent1Page
allConsentBoxesChecked = None
if ui.allConsentCheckedExperimentCheckBox.checkState() == 2:
allConsentBoxesChecked = True
else:
allConsentBoxesChecked = False
fullScreen = None
if ui.fullScreenCheckBox.checkState() == 2:
fullScreen = True
else:
fullScreen = False
trialsExperimentTrainingBlock= ui.trialsExperimentTrainingBlockCBox.currentText()
trialsExperimentBlock1 = ui.trialsExperimentBlock1CBox.currentText()
trialsExperimentBlock2 = ui.trialsExperimentBlock2CBox.currentText()
experimentBreakMinutes = ui.experimentBreakSpinBox.value()
experimentBreakIntervalSeconds = ui.experimentBreakIntervalSpinBox.value()
minimumFieldsCompleted = minimumFieldsExperimenterScreenCompleted(participantName = participantName, participantId = participantId
, computerId = computerId)
# minimumFieldsCompleted = True
if minimumFieldsCompleted is True:
setupProgram(firstPage = window.firstPage, computerId = computerId,experimentCountry = experimentCountry
, participantId = participantId
, participantName = participantName
, participantLastName=participantLastName
, experimentalSession = experimentalSession
, animationSpeedFactor=animationSpeedFactor
, fontFactor=fontFactor
, languageCondition=languageCondition
, descriptiveExperimentCondition=descriptiveExperimentCondition
, simulatedExperimentCondition=simulatedExperimentCondition
, trialsExperimentTrainingBlock=trialsExperimentTrainingBlock
, trialsExperimentBlock1=trialsExperimentBlock1
, trialsExperimentBlock2=trialsExperimentBlock2
, experimentBreakMinutes=experimentBreakMinutes
, experimentBreakIntervalSeconds=experimentBreakIntervalSeconds
, onlyDescriptiveTestingMode=onlyDescriptiveTestingMode
, descriptiveDays=descriptiveDays
, allConsentBoxesChecked = allConsentBoxesChecked
, fullScreen = fullScreen)
# setFirstPageProgram(firstPage = ui.demographicsPage)
# setFirstPageProgram(firstPage = ui.experimentDebriefPage)
#
# setupTravelBehaviourPage(city="London")
# window.currentParticipant.cityOfResidence = "London"
# # Temporary Initial page in the experiment
# setFirstPageProgram(firstPage = ui.travelBehaviourPage)
def resetFormatModeButtons():
# Format Mode Buttons
for modeButton in [ui.slowTestingModeButton, ui.realTestingUKModeButton, ui.realTestingChileModeButton, ui.descriptiveTestingModeButton
, ui.fastTestingModeButton, ui.fastSpeedTestingModeButton, ui.minimumScenariosTestingModeButton
,ui.controlConditionButton,ui.treatmentConditionButton,ui.windowsFontSizeButton,ui.macFontSizeButton]:
modeButton.setFont(QFont("Times", 15*window.fontFactor))
def setExperimenterScreenMode(mode):
completed = False
def setDefaultTestingMode():
realTestingUKModeButtonClicked()
ui.realTestingUKModeButton.setFont(QFont("Times", 15*window.fontFactor))
def fastSpeedTestingModeButtonClicked():
# setDefaultTestingMode()
resetFormatModeButtons()
controlConditionButtonClicked()
ui.fastSpeedTestingModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
ui.animationSpeedQSpinBox.setValue(0.01)
def fastTestingModeButtonClicked():
setDefaultTestingMode()
minimumScenariosTestingModeButtonClicked()
fastSpeedTestingModeButtonClicked()
ui.participantIdQSpinBox.setValue(99)
ui.participantNameQLineEdit.setText("Test")
ui.participantLastNameQLineEdit.setText("Test")
ui.experimentalSessionQLineEdit.setText("99")
ui.experimentBreakSpinBox.setValue(0)
ui.experimentBreakIntervalSpinBox.setValue(1)
ui.allConsentCheckedExperimentCheckBox.setChecked(2)
ui.computerIdQLineEdit.setText(str(99))
ui.fontSizeQSpinBox.setValue(1.0) # In Chile I used 0.8, but now we will use 0.75
resetFormatModeButtons()
ui.fastTestingModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
def minimumScenariosTestingModeButtonClicked():
setDefaultTestingMode()
resetFormatModeButtons()
ui.minimumScenariosTestingModeButton.setFont(QFont("Times", 15, QFont.Bold))
ui.trialsExperimentTrainingBlockCBox.setCurrentIndex(0)
ui.trialsExperimentBlock1CBox.setCurrentIndex(0)
ui.trialsExperimentBlock2CBox.setCurrentIndex(0)
def realTestingUKModeButtonClicked():
resetFormatModeButtons()
ui.realTestingUKModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
ui.fontSizeQSpinBox.setValue(0.75) #In Chile I use 0.8
ui.languageCBox.setCurrentIndex(2) #Spanish(1), English(2)
ui.countryCBox.setCurrentIndex(2) # Chile(1), UK(2)
ui.animationSpeedQSpinBox.setValue(1)
ui.experimentBreakIntervalSpinBox.setValue(10)
ui.trialsExperimentTrainingBlockCBox.setCurrentIndex(ui.trialsExperimentTrainingBlockCBox.count()-1)
ui.trialsExperimentBlock1CBox.setCurrentIndex(ui.trialsExperimentBlock1CBox.count() - 1)
ui.trialsExperimentBlock2CBox.setCurrentIndex(ui.trialsExperimentBlock2CBox.count() - 1)
ui.experimentBreakSpinBox.setValue(3)
ui.onlyDescriptiveExperimentCheckBox.setCheckState(0)
ui.fullScreenCheckBox.setCheckState(2)
def realTestingChileModeButtonClicked():
resetFormatModeButtons()
ui.realTestingChileModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
ui.fontSizeQSpinBox.setValue(0.75) #In Chile I use 0.8
ui.languageCBox.setCurrentIndex(1) #Spanish(1), English(2)
ui.countryCBox.setCurrentIndex(1) # Chile(1), UK(2)
ui.animationSpeedQSpinBox.setValue(1)
ui.trialsExperimentTrainingBlockCBox.setCurrentIndex(ui.trialsExperimentTrainingBlockCBox.count()-1)
ui.trialsExperimentBlock1CBox.setCurrentIndex(ui.trialsExperimentBlock1CBox.count() - 1)
ui.trialsExperimentBlock2CBox.setCurrentIndex(ui.trialsExperimentBlock2CBox.count() - 1)
ui.experimentBreakSpinBox.setValue(3)
ui.experimentBreakIntervalSpinBox.setValue(10)
ui.onlyDescriptiveExperimentCheckBox.setCheckState(0)
ui.fullScreenCheckBox.setCheckState(2)
def descriptiveTestingModeButtonClicked():
setDefaultTestingMode()
resetFormatModeButtons()
ui.descriptiveTestingModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
ui.onlyDescriptiveExperimentCheckBox.setCheckState(2)
def slowTestingModeButtonClicked():
# setDefaultTestingMode()
resetFormatModeButtons()
ui.animationSpeedQSpinBox.setValue(1)
ui.slowTestingModeButton.setFont(QFont("Times", 15*window.fontFactor, QFont.Bold))
def controlConditionButtonClicked():
ui.simulatedExperimentConditionCBox.setCurrentIndex(1)
ui.descriptiveExperimentConditionCBox.setCurrentIndex(1)
def treatmentConditionButtonClicked():
ui.simulatedExperimentConditionCBox.setCurrentIndex(2)
ui.descriptiveExperimentConditionCBox.setCurrentIndex(2)
def windowsFontSizeButtonClicked():
ui.fontSizeQSpinBox.setValue(0.75)
def macFontSizeButtonClicked():
ui.fontSizeQSpinBox.setValue(1)
def setupExperimenterScreenPage(language,version,fontFactor):
window.fontFactor = fontFactor
# Set the first page in the experiment
ui.stackedWidget.setCurrentWidget(ui.experimenterScreenPage)
#Title of the page
#0) Experimenter Screen
centerWidget(mainWidget = ui.experimenterScreenPage, subWidget = ui.experimenterScreenPanel)
backgroundStackedWidget(ui.experimenterScreenPanel, "white") #Background colour of main window
ui.buttonNextExperimenterScreenPage = QPushButton() #Creation of 'Next' buttons
ui.pushButtonExperimenterScreenGrid.addWidget(ui.buttonNextExperimenterScreenPage,0,0) #Add button to a grid
#Next Button Experimenter Screen:
ui.buttonNextExperimenterScreenPage.clicked.connect(buttonNextExperimenterScreenClicked)
ui.buttonNextExperimenterScreenPage.setFont(QFont("Times", fontFactor * 19))
ui.buttonNextExperimenterScreenPage.setFixedWidth(100)
ui.buttonNextExperimenterScreenPage.setFixedHeight(50)
ui.buttonNextExperimenterScreenPage.setFocusPolicy(QtCore.Qt.NoFocus)
ui.buttonNextExperimenterScreenPage.setText("Next")
# Id for computer (Row 0)
ui.computerIdQLineEdit = QLineEdit()
ui.experimenterScreenFormLayout1.addRow("Computer ID", ui.computerIdQLineEdit)
#Id for the participant (Row 1)
ui.participantIdQSpinBox = QSpinBox()
ui.experimenterScreenFormLayout1.addRow("Participant ID", ui.participantIdQSpinBox)
#Name of the participant (Text Edit, Row 2...)
ui.participantNameQLineEdit = QLineEdit()
ui.experimenterScreenFormLayout1.addRow("Participant Name", ui.participantNameQLineEdit)
#Given Name
ui.participantLastNameQLineEdit = QLineEdit()
ui.experimenterScreenFormLayout1.addRow("Participant Last Name", ui.participantLastNameQLineEdit)
#Language Configuration (Combo box, (Row 2)
ui.languageCBox = QComboBox()
ui.languageCBox.addItems(["","spanish", "english"])
ui.experimenterScreenFormLayout1.addRow("Language",ui.languageCBox)
#Country
ui.countryCBox = QComboBox()
ui.countryCBox.addItems(["", "Chile", "UK"])
ui.experimenterScreenFormLayout1.addRow("Country", ui.countryCBox)
#Font Size Factor (SpinBox, Row 3)
ui.fontSizeQSpinBox = QDoubleSpinBox()
ui.fontSizeQSpinBox.setSingleStep(0.1)
ui.fontSizeQSpinBox.setDecimals(2)
ui.experimenterScreenFormLayout1.addRow("Font Size Factor", ui.fontSizeQSpinBox)
#Animation Speed Factor (SpinBox, Row 4)
ui.animationSpeedQSpinBox = QDoubleSpinBox()
ui.animationSpeedQSpinBox.setSingleStep(0.01)
ui.animationSpeedQSpinBox.setDecimals(2)
ui.experimenterScreenFormLayout1.addRow("Animation Speed Factor", ui.animationSpeedQSpinBox)
ui.allConsentCheckedExperimentCheckBox = QCheckBox()
ui.experimenterScreenFormLayout1.addRow("All Consent Boxes Checked", ui.allConsentCheckedExperimentCheckBox)
ui.fullScreenCheckBox = QCheckBox()
ui.experimenterScreenFormLayout1.addRow("Full Screen", ui.fullScreenCheckBox)
#Experimental Session
ui.experimentalSessionQLineEdit = QLineEdit()
ui.experimenterScreenFormLayout2.addRow("Experimental Session", ui.experimentalSessionQLineEdit)
# # Experimental Condition (Control and Treatment, it is the same for the simulated and descriptive experiment)
# Experimental
# Condition
#Experimental Condition in Simulated Experiment (ComboBox, Row 5)
ui.simulatedExperimentConditionCBox = QComboBox()
ui.simulatedExperimentConditionCBox.addItems([" ", "Control", "Treatment"])
ui.simulatedExperimentConditionCBox.setEnabled(False)
ui.simulatedExperimentConditionCBox.setCurrentIndex(0)
ui.experimenterScreenFormLayout2.addRow("Simulated Experiment", ui.simulatedExperimentConditionCBox)
# Experimental Condition in Descriptive Experiment (ComboBox, Row 6)
ui.descriptiveExperimentConditionCBox = QComboBox()
ui.descriptiveExperimentConditionCBox.addItems([" ", "Control", "Treatment"])
ui.descriptiveExperimentConditionCBox.setEnabled(False)
ui.descriptiveExperimentConditionCBox.setCurrentIndex(0)
ui.experimenterScreenFormLayout2.addRow("Descriptive Experiment",ui.descriptiveExperimentConditionCBox)
#Trials per block (ComboBox, Row 7-8-9)
ui.trialsExperimentTrainingBlockCBox = QComboBox()
ui.trialsExperimentTrainingBlockCBox.addItems(["1","2"])
ui.experimenterScreenFormLayout2.addRow("Trials Training Block",
ui.trialsExperimentTrainingBlockCBox)
ui.trialsExperimentBlock1CBox = QComboBox()
ui.trialsExperimentBlock1CBox.addItems(["1","2","3","4","5","6"])
ui.experimenterScreenFormLayout2.addRow("Trials Block 1",
ui.trialsExperimentBlock1CBox)
ui.trialsExperimentBlock2CBox = QComboBox()
ui.trialsExperimentBlock2CBox.addItems(["1","2","3","4","5","6"])
ui.experimenterScreenFormLayout2.addRow("Trials Block 2",
ui.trialsExperimentBlock2CBox)
ui.descriptiveDaysCBox = QComboBox()
ui.descriptiveDaysCBox.addItems(["2", "4", "6"])
ui.experimenterScreenFormLayout2.addRow("Descriptive Days",
ui.descriptiveDaysCBox)
ui.onlyDescriptiveExperimentCheckBox = QCheckBox()
ui.experimenterScreenFormLayout2.addRow("Only Descriptive",ui.onlyDescriptiveExperimentCheckBox)
# ui.cBoxConsent.checkState() == 2
#Duration of the experimental break
ui.experimentBreakSpinBox = QSpinBox()
ui.experimenterScreenFormLayout2.addRow("Break Duration (mins)",
ui.experimentBreakSpinBox)
#Interval to refresh the experiment break progress bar
ui.experimentBreakIntervalSpinBox = QSpinBox()
ui.experimenterScreenFormLayout2.addRow("Interval Update Break Bar (seconds)",
ui.experimentBreakIntervalSpinBox)
# ui.consent2FormLayout.addRow(QCheckBox(), tickLabel)
#Events associated to testing modes
ui.slowTestingModeButton.clicked.connect(slowTestingModeButtonClicked)
ui.realTestingChileModeButton.clicked.connect(realTestingChileModeButtonClicked)
ui.realTestingUKModeButton.clicked.connect(realTestingUKModeButtonClicked)
ui.descriptiveTestingModeButton.clicked.connect(descriptiveTestingModeButtonClicked)
ui.fastTestingModeButton.clicked.connect(fastTestingModeButtonClicked)
ui.fastSpeedTestingModeButton.clicked.connect(fastSpeedTestingModeButtonClicked)
ui.minimumScenariosTestingModeButton.clicked.connect(minimumScenariosTestingModeButtonClicked)
ui.controlConditionButton.clicked.connect(controlConditionButtonClicked)
ui.treatmentConditionButton.clicked.connect(treatmentConditionButtonClicked)
ui.windowsFontSizeButton.clicked.connect(windowsFontSizeButtonClicked)
ui.macFontSizeButton.clicked.connect(macFontSizeButtonClicked)