BruceSherwood/vpython-wx

window problems (delete_all, documentation, material failure)

Opened this issue · 0 comments

The following program demonstrates three bugs.

  1. window.delete_all() seems to be broken
  2. Upon reset, the earth material is missing from the sphere
  3. failure of documentation to say that one should delete the scene before deleting the window
    (A better structure would be to create the window and display just once, before the main loop, but nevertheless the program does show bugs in VPython.)

from future import division
from visual import *
import wx

Display scale parameters

Vertical_Window_Size = 800 #Number of vertical pixels for display window

x_window = round(0.2_Vertical_Window_Size) #Coordinates of display window upper left corner
y_window = round(0.1_Vertical_Window_Size)

while True: # Program exits the animation while loop and returns here when "START OVER" button is pressed
rate(15)

#Windows, scene, and frame

#Create a window containing a 3D display and a panel for control widgets
L = round(Vertical_Window_Size)         #Size and spacing parameters for display window in units of pixels   
W = round(1.25*L)   
d = round(0.025*L)


w = window(x = x_window, y = y_window,width=W, height=L+window.dheight+window.menuheight, menus=True)
scene = display(window = w, x=d, y=d, width=L-2*d , height=L- 2*d)
scene.range = 7
scene.forward = (-.4,-.25,-1)
p = w.panel

E_F = frame()


#Display objects
earth = sphere(frame = E_F,pos = vector(0,0,0), radius = 2, material = materials.earth)
dot = sphere(frame = E_F, pos = vector(0,1.414,1.414), radius = .15, color = color.green)
sphere(pos = vector(0,0,0),radius = 5, color = color.white, opacity = 0.20)

#ToggleButton for animation CONTINUE control
tb1= wx.ToggleButton(p,pos = (L + d,round(.55*L)),label = 'CONTINUE')
tb1.Show(True)
tb1.SetValue(False)

#Toggle button for program restart
tb2 = wx.ToggleButton(p,pos = (L + d,round(.8*L)),label = 'START OVER')
tb2.Show(False)
tb2.SetValue(False)

#Wait for CONTINUE to be clicked
while tb1.GetValue()==False and tb1.GetValue()==False:
    rate(15)

tb1.Show(False)
tb2.Show(True)

#Rotate earth until START OVER is clicked
while tb2.GetValue()==False:
    rate(10)
    E_F.rotate(angle = radians(10),axis = (0,1,0))

#Delete the window and loop back to beginning
window.delete_all()
continue