MCPcopy Create free account
hub / github.com/DeepLabCut/DeepLabCut / on_press

Method on_press

deeplabcut/gui/tracklet_toolbox.py:59–94  ·  view source on GitHub ↗

Define the event for the button press!

(self, event)

Source from the content-addressed store, hash-verified

57 self.cidhover = self.point.figure.canvas.mpl_connect("motion_notify_event", self.on_hover)
58
59 def on_press(self, event):
60 """Define the event for the button press!"""
61 if event.inaxes != self.point.axes:
62 return
63 if DraggablePoint.lock is not None:
64 return
65 contains, attrd = self.point.contains(event)
66 if not contains:
67 return
68 if event.button == 1:
69 """This button press corresponds to the left click."""
70 self.press = (self.point.center), event.xdata, event.ydata
71 DraggablePoint.lock = self
72 canvas = self.point.figure.canvas
73 axes = self.point.axes
74 self.point.set_animated(True)
75 canvas.draw()
76 self.background = canvas.copy_from_bbox(self.point.axes.bbox)
77 axes.draw_artist(self.point)
78 canvas.blit(axes.bbox)
79 elif event.button == 2:
80 """To remove a predicted label.
81
82 Internally, the coordinates of the selected predicted label is replaced with
83 nan. The user needs to middle click for the event. After right click the
84 data point is removed from the plot.
85 """
86 message = f"Do you want to remove the label {self.bodyParts}?"
87 if self.likelihood is not None:
88 message += " You cannot undo this step!"
89 msg = QMessageBox()
90 msg.setWindowTitle("Warning!")
91 msg.setText(message)
92 msg.setStandardButtons(msg.Yes | msg.No)
93 if msg.exec() == msg.Yes:
94 self.delete_data()
95
96 def delete_data(self):
97 self.press = None

Callers

nothing calls this directly

Calls 2

delete_dataMethod · 0.95
drawMethod · 0.80

Tested by

no test coverage detected