boris-behav-obs 9.2.3__py2.py3-none-any.whl → 9.3.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
boris/1.py ADDED
@@ -0,0 +1,45 @@
1
+ import time
2
+ from PIL import Image, ImageDraw, ImageFont
3
+ import mpv
4
+
5
+ player = mpv.MPV()
6
+
7
+ player.loop = True
8
+ player.play('/home/olivier/gdrive_sync/src/python/generate_video_test/video1.mp4')
9
+ player.wait_until_playing()
10
+
11
+ font = ImageFont.truetype('DejaVuSans.ttf', 40)
12
+
13
+ overlay = player.create_image_overlay()
14
+
15
+ img = Image.new('RGBA', (400, 150), (255, 255, 255, 0))
16
+ d = ImageDraw.Draw(img)
17
+ d.text((10, 10), 'Hello World', font=font, fill=(0, 255, 255, 128))
18
+ #d.text((10, 60), f't={ts:.3f}', font=font, fill=(255, 0, 255, 255))
19
+
20
+ pos = 100
21
+
22
+ overlay.update(img, pos=(2*pos, pos))
23
+
24
+
25
+ while not player.core_idle:
26
+ pass
27
+
28
+
29
+ '''
30
+ for pos in range(0, 500, 5):
31
+ ts = player.time_pos
32
+ if ts is None:
33
+ break
34
+
35
+ img = Image.new('RGBA', (400, 150), (255, 255, 255, 0))
36
+ d = ImageDraw.Draw(img)
37
+ d.text((10, 10), 'Hello World', font=font, fill=(0, 255, 255, 128))
38
+ d.text((10, 60), f't={ts:.3f}', font=font, fill=(255, 0, 255, 255))
39
+
40
+ overlay.update(img, pos=(2*pos, pos))
41
+ time.sleep(0.05)
42
+
43
+
44
+ overlay.remove()
45
+ '''
@@ -114,14 +114,14 @@ class BehaviorsMapCreatorWindow(QMainWindow):
114
114
  self.openMapAction.setStatusTip("Open a behaviors coding map")
115
115
  self.openMapAction.triggered.connect(self.openMap)
116
116
 
117
- self.saveMapAction = QAction(QIcon(), "&Save the current behaviors coding map", self)
117
+ self.saveMapAction = QAction(QIcon(), "&Save the behavior coding map", self)
118
118
  self.saveMapAction.setShortcut("Ctrl+S")
119
- self.saveMapAction.setStatusTip("Save the current behaviors coding map")
119
+ self.saveMapAction.setStatusTip("Save the behavior coding map")
120
120
  self.saveMapAction.setEnabled(False)
121
121
  self.saveMapAction.triggered.connect(self.saveMap_clicked)
122
122
 
123
- self.saveAsMapAction = QAction(QIcon(), "Save the current behaviors coding map as ...", self)
124
- self.saveAsMapAction.setStatusTip("Save the current behaviors coding map as ...")
123
+ self.saveAsMapAction = QAction(QIcon(), "Save the behavior coding map as ...", self)
124
+ self.saveAsMapAction.setStatusTip("Save the behavior coding map as ...")
125
125
  self.saveAsMapAction.setEnabled(False)
126
126
  self.saveAsMapAction.triggered.connect(self.saveAsMap_clicked)
127
127
 
@@ -131,6 +131,11 @@ class BehaviorsMapCreatorWindow(QMainWindow):
131
131
  self.mapNameAction.setEnabled(False)
132
132
  self.mapNameAction.triggered.connect(self.mapName_clicked)
133
133
 
134
+ self.resizeAction = QAction(QIcon(), "Resize the image", self)
135
+ self.resizeAction.setStatusTip("Resize the image")
136
+ self.resizeAction.setEnabled(False)
137
+ self.resizeAction.triggered.connect(self.resize_clicked)
138
+
134
139
  self.addToProject = QAction(QIcon(), "Add coding map to project", self)
135
140
  self.addToProject.setStatusTip("Add coding map to project")
136
141
  self.addToProject.setEnabled(False)
@@ -149,16 +154,13 @@ class BehaviorsMapCreatorWindow(QMainWindow):
149
154
  fileMenu.addSeparator()
150
155
  fileMenu.addAction(self.mapNameAction)
151
156
  fileMenu.addSeparator()
157
+ fileMenu.addAction(self.resizeAction)
158
+ fileMenu.addSeparator()
152
159
  fileMenu.addAction(self.addToProject)
153
160
  fileMenu.addSeparator()
154
161
  fileMenu.addAction(self.exitAction)
155
162
 
156
163
  splitter1 = QSplitter(Qt.Vertical)
157
- """
158
- splitter1.addWidget(splitter1)
159
- splitter1.addWidget(bottom)
160
- """
161
- """vlayout_list = QVBoxLayout()"""
162
164
 
163
165
  self.view = self.View(self)
164
166
  self.view.mousePress.connect(self.viewMousePressEvent)
@@ -168,7 +170,6 @@ class BehaviorsMapCreatorWindow(QMainWindow):
168
170
  vlayout_list.addWidget(QLabel("Defined area"))
169
171
 
170
172
  self.area_list = QListWidget(self)
171
- # self.area_list.setMaximumHeight(120)
172
173
  self.area_list.itemClicked.connect(self.area_list_item_click)
173
174
  vlayout_list.addWidget(self.area_list)
174
175
  w = QWidget()
@@ -177,10 +178,6 @@ class BehaviorsMapCreatorWindow(QMainWindow):
177
178
  splitter1.setSizes([300, 100])
178
179
  splitter1.setStretchFactor(2, 8)
179
180
 
180
- self.btLoad = QPushButton("Load bitmap", self)
181
- self.btLoad.clicked.connect(self.loadBitmap)
182
- self.btLoad.setVisible(False)
183
-
184
181
  hlayout_cmd = QHBoxLayout()
185
182
 
186
183
  self.btNewArea = QPushButton("New behavior area", self)
@@ -249,16 +246,9 @@ class BehaviorsMapCreatorWindow(QMainWindow):
249
246
  frame.setLayout(vlayout_frame)
250
247
 
251
248
  vlayout = QVBoxLayout()
252
- """
253
- vlayout.addWidget(self.view)
254
- vlayout.addWidget(QLabel("Defined area"))
255
- vlayout.addWidget(self.area_list)
256
- """
257
- vlayout.addWidget(splitter1)
258
- """vlayout.addLayout(vlayout_view_list)"""
259
249
 
250
+ vlayout.addWidget(splitter1)
260
251
  vlayout.addWidget(frame)
261
- vlayout.addWidget(self.btLoad)
262
252
 
263
253
  main_widget = QWidget(self)
264
254
  main_widget.setLayout(vlayout)
@@ -305,19 +295,21 @@ class BehaviorsMapCreatorWindow(QMainWindow):
305
295
 
306
296
  self.selectedPolygon.setPen(QPen(QColor(255, 0, 0, 255), 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
307
297
 
308
- self.lb.setVisible(True)
309
298
  self.leAreaCode.setText(ac)
310
- self.leAreaCode.setVisible(True)
311
- self.btEditAreaCode.setVisible(True)
312
299
 
313
- self.btDeleteArea.setVisible(True)
300
+ for widget in (
301
+ self.lb,
302
+ self.leAreaCode,
303
+ self.btEditAreaCode,
304
+ self.btDeleteArea,
305
+ self.btColor,
306
+ self.slAlpha,
307
+ ):
308
+ widget.setVisible(True)
314
309
 
315
310
  self.areaColor = self.selectedPolygon.brush().color()
316
311
  self.btColor.setStyleSheet(f"QWidget {{background-color:{self.selectedPolygon.brush().color().name()}}}")
317
- self.btColor.setVisible(True)
318
-
319
- self.slAlpha.setValue(int(self.selectedPolygon.brush().color().alpha() / 255 * 100))
320
- self.slAlpha.setVisible(True)
312
+ self.slAlpha.setValue(int(self.areaColor.alpha() / 255 * 100))
321
313
 
322
314
  def edit_area_code(self):
323
315
  """
@@ -369,9 +361,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
369
361
  cd.setWindowFlags(Qt.WindowStaysOnTopHint)
370
362
  cd.setOptions(QColorDialog.DontUseNativeDialog)
371
363
 
372
- # col = cd.getColor()
373
- # if col.isValid():
374
- if cd.exec_():
364
+ if cd.exec():
375
365
  self.areaColor = cd.currentColor()
376
366
  self.btColor.setStyleSheet(f"QWidget {{background-color:{self.areaColor.name()}}}")
377
367
  self.areaColor.setAlpha(int(self.slAlpha.value() / 100 * 255))
@@ -440,30 +430,29 @@ class BehaviorsMapCreatorWindow(QMainWindow):
440
430
  self.selectedPolygon = None
441
431
  self.selectedPolygonMemBrush = None
442
432
 
433
+ print(self.polygonsList2)
434
+ idx = 0
443
435
  for areaCode, pg in self.polygonsList2:
444
436
  if pg.contains(test):
445
437
  self.selectedPolygon = pg
446
-
447
438
  self.selectedPolygonMemBrush = self.selectedPolygon.brush()
448
-
449
439
  self.selectedPolygon.setPen(QPen(QColor(255, 0, 0, 255), 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
450
-
451
- self.lb.setVisible(True)
452
440
  self.leAreaCode.setText(areaCode)
453
- self.leAreaCode.setVisible(True)
454
- # self.leAreaCode.setEnabled(False)
455
- self.btEditAreaCode.setVisible(True)
456
441
 
457
- self.btDeleteArea.setVisible(True)
442
+ for widget in (self.lb, self.leAreaCode, self.btEditAreaCode, self.btColor, self.slAlpha, self.btDeleteArea):
443
+ widget.setVisible(True)
458
444
 
459
445
  self.areaColor = self.selectedPolygon.brush().color()
460
446
  self.btColor.setStyleSheet(f"QWidget {{background-color:{self.selectedPolygon.brush().color().name()}}}")
461
- self.btColor.setVisible(True)
462
447
 
463
- self.slAlpha.setValue(int(self.selectedPolygon.brush().color().alpha() / 255 * 100))
464
- self.slAlpha.setVisible(True)
448
+ self.slAlpha.setValue(int(self.areaColor.alpha() / 255 * 100))
449
+
450
+ # select area in list widget
451
+ item = self.area_list.item(idx)
452
+ self.area_list.setCurrentItem(item)
465
453
 
466
454
  break
455
+ idx += 1
467
456
 
468
457
  if not self.selectedPolygon:
469
458
  self.leAreaCode.setVisible(False)
@@ -489,6 +478,20 @@ class BehaviorsMapCreatorWindow(QMainWindow):
489
478
  self.view.scene().removeItem(self.view.elList[-1])
490
479
  self.view.elList = self.view.elList[0:-1]
491
480
 
481
+ # middle button automatically close the polygon
482
+ if (event.buttons() & Qt.MiddleButton) and not self.closedPolygon:
483
+ line = QGraphicsLineItem(QLineF(self.view._start, QPoint(self.view.points[0][0], self.view.points[0][1])))
484
+ line.setPen(QPen(designColor, penWidth, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
485
+
486
+ self.view.scene().addItem(line)
487
+ self.view.elList.append(line)
488
+
489
+ self.statusBar().showMessage("Area completed")
490
+
491
+ # create polygon
492
+ add_polygon()
493
+ return
494
+
492
495
  # add line item
493
496
  if event.buttons() == Qt.LeftButton and not self.closedPolygon:
494
497
  if self.view._start:
@@ -642,9 +645,6 @@ class BehaviorsMapCreatorWindow(QMainWindow):
642
645
 
643
646
  self.loadBitmap()
644
647
 
645
- # self.btLoad.setVisible(True)
646
- # self.statusBar().showMessage('Click "Load bitmap" button to select and load a bitmap into the viewer')
647
-
648
648
  def openMap(self):
649
649
  """
650
650
  open a coding map from file
@@ -667,7 +667,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
667
667
  )
668
668
 
669
669
  if not fileName:
670
- self.statusBar().showMessage("No file", 5000)
670
+ return
671
671
  try:
672
672
  self.codingMap = json.loads(open(fileName, "r").read())
673
673
  except Exception:
@@ -676,6 +676,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
676
676
 
677
677
  if "coding_map_type" not in self.codingMap or self.codingMap["coding_map_type"] != "BORIS behaviors coding map":
678
678
  QMessageBox.critical(self, cfg.programName, f"The file {fileName} is not a BORIS behaviors coding map.")
679
+ return
679
680
 
680
681
  self.cancelMap()
681
682
 
@@ -707,7 +708,6 @@ class BehaviorsMapCreatorWindow(QMainWindow):
707
708
  newPolygon.append(QPoint(p[0], p[1]))
708
709
 
709
710
  # draw polygon
710
- """polygon = QGraphicsPolygonItem(None, None) if QT_VERSION_STR[0] == "4" else QGraphicsPolygonItem()"""
711
711
  polygon = QGraphicsPolygonItem()
712
712
  polygon.setPolygon(newPolygon)
713
713
  clr = QColor()
@@ -720,12 +720,15 @@ class BehaviorsMapCreatorWindow(QMainWindow):
720
720
  self.polygonsList2.append([areaCode, polygon])
721
721
 
722
722
  self.btNewArea.setVisible(True)
723
- self.btLoad.setVisible(False)
724
723
 
725
- self.saveMapAction.setEnabled(True)
726
- self.saveAsMapAction.setEnabled(True)
727
- self.addToProject.setEnabled(True)
728
- self.mapNameAction.setEnabled(True)
724
+ for action in (
725
+ self.saveMapAction,
726
+ self.saveAsMapAction,
727
+ self.addToProject,
728
+ self.mapNameAction,
729
+ self.resizeAction,
730
+ ):
731
+ action.setEnabled(True)
729
732
 
730
733
  self.update_area_list()
731
734
 
@@ -811,7 +814,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
811
814
 
812
815
  def newArea(self):
813
816
  if not self.bitmapFileName:
814
- QMessageBox.critical(self, cfg.programName, "A bitmap must be loaded before to define areas")
817
+ QMessageBox.critical(self, cfg.programName, "An image must be loaded before to define areas")
815
818
  return
816
819
 
817
820
  if self.selectedPolygon:
@@ -832,7 +835,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
832
835
  self.btDeleteArea.setVisible(False)
833
836
 
834
837
  self.statusBar().showMessage(
835
- ("Click on bitmap to set the vertices of the area with the mouse " "(right click will cancel the last point)")
838
+ ("Click on bitmap to set the vertices of the area with the mouse (right click will cancel the last point)")
836
839
  )
837
840
 
838
841
  def saveArea(self):
@@ -840,7 +843,7 @@ class BehaviorsMapCreatorWindow(QMainWindow):
840
843
  QMessageBox.critical(
841
844
  self,
842
845
  cfg.programName,
843
- ("You must close your area before saving it.\n" "The last vertex must correspond to the first one."),
846
+ ("You must close your area before saving it.\nThe last vertex must correspond to the first one."),
844
847
  )
845
848
 
846
849
  if len(self.view.points) < 3:
@@ -858,14 +861,15 @@ class BehaviorsMapCreatorWindow(QMainWindow):
858
861
 
859
862
  # draw polygon
860
863
  self.closedPolygon.setBrush(QBrush(self.areaColor, Qt.SolidPattern))
861
- # self.polygonsList2[self.leAreaCode.text()] = self.closedPolygon
862
864
  self.polygonsList2.append([self.leAreaCode.text(), self.closedPolygon])
863
865
 
864
- self.closedPolygon, self.flagNewArea = None, None
866
+ self.flagNewArea = None
867
+ self.closedPolygon = None
865
868
  self.view._start = 0
866
- self.view.points, self.view.elList = [], []
869
+ self.view.points = []
870
+ self.view.elList = []
867
871
 
868
- for widget in [
872
+ for widget in (
869
873
  self.btSaveArea,
870
874
  self.btCancelAreaCreation,
871
875
  self.lb,
@@ -875,18 +879,18 @@ class BehaviorsMapCreatorWindow(QMainWindow):
875
879
  self.slAlpha,
876
880
  self.btDeleteArea,
877
881
  self.btNewArea,
878
- ]:
882
+ ):
879
883
  widget.setVisible(False)
880
884
 
881
885
  self.btNewArea.setVisible(True)
882
886
 
883
887
  self.leAreaCode.setText("")
884
888
 
889
+ self.update_area_list()
890
+
885
891
  self.flag_map_changed = True
886
892
  self.statusBar().showMessage("New area saved", 5000)
887
893
 
888
- self.update_area_list()
889
-
890
894
  def cancelAreaCreation(self):
891
895
  if self.closedPolygon:
892
896
  self.view.scene().removeItem(self.closedPolygon)
@@ -945,18 +949,15 @@ class BehaviorsMapCreatorWindow(QMainWindow):
945
949
  self.view._start = 0
946
950
  self.view.points = []
947
951
  self.flagNewArea = False
948
- self.btSaveArea.setVisible(False)
949
- self.lb.setVisible(False)
950
952
 
951
- self.btColor.setVisible(False)
952
- self.slAlpha.setVisible(False)
953
+ for widget in (self.btSaveArea, self.lb, self.btColor, self.slAlpha, self.leAreaCode, self.btDeleteArea):
954
+ widget.setVisible(False)
955
+
953
956
  self.btNewArea.setVisible(True)
954
957
 
955
- self.leAreaCode.setVisible(False)
956
958
  self.leAreaCode.setText("")
957
959
  self.btEditAreaCode.setVisible(False)
958
960
 
959
- self.btDeleteArea.setVisible(False)
960
961
  self.statusBar().showMessage("")
961
962
 
962
963
  self.update_area_list()
@@ -967,16 +968,22 @@ class BehaviorsMapCreatorWindow(QMainWindow):
967
968
  """
968
969
  self.flagNewArea = False
969
970
  self.polygonsList2 = []
971
+ self.closedPolygon = None
972
+ self.selectedPolygon = None
973
+ self.area_list.clear()
970
974
  self.view.scene().clear()
971
- self.btLoad.setVisible(False)
972
975
  self.btDeleteArea.setVisible(False)
973
976
  self.btNewArea.setVisible(False)
974
977
  self.saveMapAction.setEnabled(False)
975
978
  self.saveAsMapAction.setEnabled(False)
976
979
  self.addToProject.setEnabled(False)
977
980
  self.mapNameAction.setEnabled(False)
981
+ self.resizeAction.setEnabled(False)
978
982
  self.statusBar().showMessage("")
979
983
 
984
+ self.btNewArea.setVisible(True)
985
+ self.btNewArea.setEnabled(True)
986
+
980
987
  self.flag_map_changed = False
981
988
 
982
989
  def loadBitmap(self):
@@ -1017,16 +1024,59 @@ class BehaviorsMapCreatorWindow(QMainWindow):
1017
1024
 
1018
1025
  self.btNewArea.setVisible(True)
1019
1026
 
1020
- self.btLoad.setVisible(False)
1021
1027
  self.saveMapAction.setEnabled(True)
1022
1028
  self.saveAsMapAction.setEnabled(True)
1023
1029
  self.addToProject.setEnabled(True)
1024
1030
  self.mapNameAction.setEnabled(True)
1031
+ self.resizeAction.setEnabled(True)
1025
1032
 
1026
1033
  self.statusBar().showMessage("""Click "New behavior area" to create a new behavior area""")
1027
1034
 
1028
1035
  self.flag_map_changed = True
1029
1036
 
1037
+ def resize_clicked(self):
1038
+ """
1039
+ resize the bitmap
1040
+ """
1041
+
1042
+ if self.polygonsList2:
1043
+ if (
1044
+ dialog.MessageDialog(
1045
+ "BORIS - Behaviors map creator",
1046
+ "The map contains modifiers. Erase all modifiers",
1047
+ (cfg.NO, cfg.YES),
1048
+ )
1049
+ == cfg.NO
1050
+ ):
1051
+ return
1052
+
1053
+ integer, ok = QInputDialog.getInt(
1054
+ self, "Resize image", "New horizontal size (in pixels)", value=self.pixmap.size().width(), minValue=100, maxValue=3048, step=10
1055
+ )
1056
+ if not ok:
1057
+ return
1058
+
1059
+ self.cancelMap()
1060
+
1061
+ h = int(self.pixmap.size().width() / (self.pixmap.size().width() / integer))
1062
+
1063
+ self.pixmap = self.pixmap.scaled(integer, h, Qt.KeepAspectRatio)
1064
+
1065
+ self.view.scene().clear()
1066
+ self.view.setSceneRect(0, 0, self.pixmap.size().width(), self.pixmap.size().height())
1067
+ pixitem = QGraphicsPixmapItem(self.pixmap)
1068
+ pixitem.setPos(0, 0)
1069
+ self.view.scene().addItem(pixitem)
1070
+
1071
+ QMessageBox.information(
1072
+ self,
1073
+ cfg.programName,
1074
+ (
1075
+ f"The bitmap was resized to {self.pixmap.size().width()}x{self.pixmap.size().height()} pixels\n"
1076
+ "The original file was not modified"
1077
+ ),
1078
+ )
1079
+
1030
1080
 
1031
1081
  def behaviors_coding_map_creator(self):
1032
1082
  """
@@ -1034,7 +1084,9 @@ def behaviors_coding_map_creator(self):
1034
1084
  """
1035
1085
 
1036
1086
  if not self.project:
1037
- QMessageBox.warning(self, cfg.programName, "No project found", QMessageBox.Ok | QMessageBox.Default, QMessageBox.NoButton)
1087
+ QMessageBox.warning(
1088
+ self, cfg.programName, "Create or open a project first", QMessageBox.Ok | QMessageBox.Default, QMessageBox.NoButton
1089
+ )
1038
1090
  return
1039
1091
 
1040
1092
  codes_list = [self.pj[cfg.ETHOGRAM][key][cfg.BEHAVIOR_CODE] for key in self.pj[cfg.ETHOGRAM]]
@@ -1053,6 +1105,11 @@ if __name__ == "__main__":
1053
1105
 
1054
1106
  app = QApplication(sys.argv)
1055
1107
  window = BehaviorsMapCreatorWindow(["North zone", "East zone", "South zone", "West zone"])
1108
+ window.bcm_list = []
1056
1109
  window.resize(cfg.CODING_MAP_RESIZE_W, cfg.CODING_MAP_RESIZE_H)
1110
+ screen_geometry = app.primaryScreen().geometry()
1111
+ center_x = (screen_geometry.width() - window.width()) // 2
1112
+ center_y = (screen_geometry.height() - window.height()) // 2
1113
+ window.move(center_x, center_y)
1057
1114
  window.show()
1058
- sys.exit(app.exec_())
1115
+ sys.exit(app.exec())
@@ -20,6 +20,9 @@ This file is part of BORIS.
20
20
 
21
21
  """
22
22
 
23
+ import json
24
+ import binascii
25
+
23
26
  from PySide6.QtGui import QMouseEvent, QPixmap, QPolygonF, QColor, QBrush, QPen
24
27
  from PySide6.QtCore import Qt, Signal, QEvent, QPoint
25
28
  from PySide6.QtWidgets import (
@@ -38,12 +41,10 @@ from PySide6.QtWidgets import (
38
41
  QApplication,
39
42
  )
40
43
 
41
- import json
42
- import binascii
43
44
  from . import config as cfg
44
45
 
45
- codeSeparator = ","
46
- penWidth = 0
46
+ codeSeparator: str = ","
47
+ penWidth: int = 0
47
48
  penStyle = Qt.NoPen
48
49
 
49
50
 
boris/connections.py CHANGED
@@ -49,7 +49,6 @@ from . import (
49
49
  video_operations,
50
50
  project_functions,
51
51
  external_processes,
52
- plugins,
53
52
  )
54
53
 
55
54
  from . import state_events as state_events
boris/core.py CHANGED
@@ -93,7 +93,7 @@ from PIL.ImageQt import Image
93
93
  from . import dialog
94
94
  from . import gui_utilities
95
95
  from . import events_cursor
96
- from . import map_creator
96
+ from . import modifier_coding_map_creator
97
97
  from . import geometric_measurement
98
98
  from . import modifiers_coding_map
99
99
  from . import advanced_event_filtering
@@ -1336,7 +1336,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
1336
1336
  """
1337
1337
  show modifiers coding map creator window and hide program main window
1338
1338
  """
1339
- self.mapCreatorWindow = map_creator.ModifiersMapCreatorWindow()
1339
+ self.mapCreatorWindow = modifier_coding_map_creator.ModifiersMapCreatorWindow()
1340
1340
  self.mapCreatorWindow.move(self.pos())
1341
1341
  self.mapCreatorWindow.resize(cfg.CODING_MAP_RESIZE_W, cfg.CODING_MAP_RESIZE_H)
1342
1342
  self.mapCreatorWindow.show()
@@ -4047,11 +4047,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
4047
4047
  try:
4048
4048
  behavior_idx = [key for key in self.pj[cfg.ETHOGRAM] if self.pj[cfg.ETHOGRAM][key][cfg.BEHAVIOR_CODE] == code][0]
4049
4049
  except Exception:
4050
- QMessageBox.critical(
4051
- self,
4052
- cfg.programName,
4053
- f"The code <b>{code}</b> of behavior coding map does not exist in ethogram.",
4050
+ msg_box = QMessageBox(
4051
+ QMessageBox.Critical, cfg.programName, f"The code <b>{code}</b> of behavior coding map does not exist in ethogram."
4054
4052
  )
4053
+ msg_box.setWindowFlags(msg_box.windowFlags() | Qt.WindowStaysOnTopHint)
4054
+ msg_box.exec()
4055
4055
  return
4056
4056
 
4057
4057
  event = self.full_event(behavior_idx)
@@ -4072,8 +4072,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
4072
4072
  else:
4073
4073
  write_event.write_event(self, event, cumulative_time)
4074
4074
 
4075
- # write_event.write_event(self.event, self.getLaps())
4076
-
4077
4075
  def keypress_signal_from_behaviors_coding_map(self, event):
4078
4076
  """
4079
4077
  receive signal from behaviors coding map
@@ -4786,12 +4784,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
4786
4784
  return dec("0")
4787
4785
 
4788
4786
  if self.pj[cfg.OBSERVATIONS][self.observationId][cfg.TYPE] == cfg.LIVE:
4789
- if "Live observation finished" in self.pb_live_obs.text():
4790
- return dec("NaN"), None
4787
+ if "finished" in self.pb_live_obs.text():
4788
+ return dec("NaN"), dec("NaN")
4791
4789
  if self.liveObservationStarted:
4792
- return dec(str(round(self.liveStartTime.elapsed() / 1000, 3))), None
4790
+ t = dec(str(round(self.liveStartTime.elapsed() / 1000, 3)))
4791
+ return t, t
4793
4792
  else:
4794
- return dec("0"), None
4793
+ return dec("0"), dec("0")
4795
4794
 
4796
4795
  if self.pj[cfg.OBSERVATIONS][self.observationId][cfg.TYPE] == cfg.IMAGES:
4797
4796
  if self.playerType == cfg.VIEWER_IMAGES:
boris/event_operations.py CHANGED
@@ -906,15 +906,18 @@ def paste_clipboard_to_events(self):
906
906
  content.append(line.split("\t"))
907
907
 
908
908
  if set(length) != set([len(cfg.PJ_EVENTS_FIELDS[self.playerType])]):
909
- QMessageBox.warning(
910
- self,
909
+ msg_box = QMessageBox(
910
+ QMessageBox.Warning,
911
911
  cfg.programName,
912
912
  (
913
- "The clipboard does not contain events!\n"
913
+ "The clipboard does not contain events!<br>"
914
914
  f"For an observation from <b>{self.playerType}</b> "
915
915
  f"the events must be organized in {len(cfg.PJ_EVENTS_FIELDS[self.playerType])} columns separated by <TAB> character"
916
916
  ),
917
917
  )
918
+ msg_box.setWindowFlags(msg_box.windowFlags() | Qt.WindowStaysOnTopHint)
919
+ msg_box.exec()
920
+
918
921
  return
919
922
 
920
923
  for event in content: