Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
if self.full or not self.label.visible:
return False
if self.last_clicked is not None:
return (time.time() - self.last_clicked) < 0.5
return False
finally:
self.last_clicked = time.time()
def action(self):
self.label.visible ^= 1
if self.full:
self.unfull()
vpython.scene = vpython.canvas()
vpython.scene.title = "<center><u><b>%s</b></u></center>" % self.listname # noqa: E501
vpython.scene.append_to_caption(
re.sub(
r'\%(.*)\%',
r'<span style="color: red">\1</span>',
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
#
# vpython.scene.bind('keydown', keyboard_press)
# Mouse handling
def mouse_click(ev):
if ev.press == "left":
o = vpython.scene.mouse.pick
if o and isinstance(o, IPsphere):
if o.check_double_click():
if o.ip == "unk":
return
o.fullinfos()
else:
o.action()
vpython.scene.bind('mousedown', mouse_click)
try:
if self.full or not self.label.visible:
return False
if self.last_clicked is not None:
return (time.time() - self.last_clicked) < 0.5
return False
finally:
self.last_clicked = time.time()
def action(self):
self.label.visible ^= 1
if self.full:
self.unfull()
vpython.scene = vpython.canvas()
vpython.scene.title = "<center><u><b>%s</b></u></center>" % self.listname # noqa: E501
vpython.scene.append_to_caption(
re.sub(
r'\%(.*)\%',
r'<span style="color: red">\1</span>',
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
def mouse_click(ev):
if ev.press == "left":
o = vpython.scene.mouse.pick
if o and isinstance(o, IPsphere):
if o.check_double_click():
if o.ip == "unk":
return
o.fullinfos()
else:
o.action()
def hook6(lattice):
draw(lattice)
# Toggle visibility
visible = dict()
for L in lattice.vpobjects:
visible[L] = False
visible['l'] = True
while True:
ev = vp.scene.waitfor("keydown")
if ev.key in lattice.vpobjects:
for L in lattice.vpobjects[ev.key]:
L.visible = visible[ev.key]
visible[ev.key] = not visible[ev.key]
def mouse_click(ev):
if ev.press == "left":
o = vpython.scene.mouse.pick
if o and isinstance(o, IPsphere):
if o.check_double_click():
if o.ip == "unk":
return
o.fullinfos()
else:
o.action()
def check_double_click(self):
try:
if self.full or not self.label.visible:
return False
if self.last_clicked is not None:
return (time.time() - self.last_clicked) < 0.5
return False
finally:
self.last_clicked = time.time()
def action(self):
self.label.visible ^= 1
if self.full:
self.unfull()
vpython.scene = vpython.canvas()
vpython.scene.title = "<center><u><b>%s</b></u></center>" % self.listname # noqa: E501
vpython.scene.append_to_caption(
re.sub(
r'\%(.*)\%',
r'<span style="color: red">\1</span>',
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
)
)
)
vpython.scene.exit = True
start = vpython.box()
rings = {}
tr3d = {}
for i in trace:
tr = trace[i]
tr3d[i] = []
for t in range(1, max(tr) + 1):
if t not in rings:
rings[t] = []
if t in tr:
if tr[t] not in rings[t]:
rings[t].append(tr[t])
tr3d[i].append(rings[t].index(tr[t]))
else:
rings[t].append(("unk", -1))
tr3d[i].append(len(rings[t]) - 1)
if self.full or not self.label.visible:
return False
if self.last_clicked is not None:
return (time.time() - self.last_clicked) < 0.5
return False
finally:
self.last_clicked = time.time()
def action(self):
self.label.visible ^= 1
if self.full:
self.unfull()
vpython.scene = vpython.canvas()
vpython.scene.title = "<center><u><b>%s</b></u></center>" % self.listname # noqa: E501
vpython.scene.append_to_caption(
re.sub(
r'\%(.*)\%',
r'<span style="color: red">\1</span>',
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
)
def check_double_click(self):
try:
if self.full or not self.label.visible:
return False
if self.last_clicked is not None:
return (time.time() - self.last_clicked) < 0.5
return False
finally:
self.last_clicked = time.time()
def action(self):
self.label.visible ^= 1
if self.full:
self.unfull()
vpython.scene = vpython.canvas()
vpython.scene.title = "<center><u><b>%s</b></u></center>" % self.listname # noqa: E501
vpython.scene.append_to_caption(
re.sub(
r'\%(.*)\%',
r'<span style="color: red">\1</span>',
re.sub(
r'\`(.*)\`',
r'<span style="color: #3399ff">\1</span>',
"""<u><b>Commands:</b></u>
%Click% to toggle information about a node.
%Double click% to perform a quick web scan on this node.
<u><b>Camera usage:</b></u>
`Right button drag or Ctrl-drag` to rotate "camera" to view scene.
`Shift-drag` to move the object around.
`Middle button or Alt-drag` to drag up or down to zoom in or out.
On a two-button mouse, `middle is wheel or left + right`.