def bentStructure():
#angle between two outer atoms
angle = math.pi/2.5
singleBondLen = 1
centralAtom = sphere(pos = vector(0, 0, 0), radius = 0.25, color = color.red)
atom1 = sphere(pos = vector(singleBondLen*math.sin(angle/2),
singleBondLen*math.cos(angle/2), 0), radius = 0.15,
color = color.blue)
atom2 = sphere(pos = vector(-singleBondLen*math.sin(angle/2),
singleBondLen*math.cos(angle/2), 0), radius = 0.2,
color = color.green)
bond1 = cylinder(pos = atom1.pos, radius = 0.07,
axis = centralAtom.pos - atom1.pos,
color = vector(0.3, 0.3, 0.3))
bond1 = cylinder(pos = atom2.pos, radius = 0.07,
axis = centralAtom.pos - atom2.pos,
color = vector(0.3, 0.3, 0.3))
#accept user input: keyboard right/left/up/down arrows
ev = scene.waitfor('keydown')
if ev.event == "left":
atom1.rotate(angle = math.pi/8, axis = vec(0, 1, 0))
atom2.rotate(angle = math.pi/8, axis = vec(0, 1, 0))
elif ev.event == "right":
atom1.rotate(angle = -math.pi/8, axis = vec(0, 1, 0))
atom2.rotate(angle = -math.pi/8, axis = vec(0, 1, 0))
elif ev.event == "up":
angle += math.pi/8
elif ev.event == "down":
angle -= math.pi/8
When I run this, the screen opens in a browser and I'm unable to press any keys to make the user interact with the graphics. Is there a way I can get this to work?
part1Text = text(text = """With this option, you will be able to simulate a
molecule with a chemical formula of your choice.
It needs to be an existing compound, of course.
First, select an element from the provided
selection. Then, select a number corresponding
to the number of atoms of the chosen element.
Repeat until you have the chemical formula you
wish to simulate.""")
so far, but VPython doesn't seem to display the whole text. It gets cut off at the third line.