def onLoad (self, e): """ Open a file""" dlg = wx.FileDialog(self, "Choose a file", os.getcwd() + "\\saves\\", "", "*.*", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetFilename() dlg.Destroy() loaded_planet_list = nbody2.createList(os.getcwd() + '\\saves\\' + self.filename) for p in loaded_planet_list: planet_list.append(nbody2.makePlanet(vector(p[0],p[1],p[2]), p[3], (p[4],p[5],p[6]), vector(p[7],p[8],p[9]), p[10]))
def OnClick3 (self, e): present = False for p in planet_list: if position == p.pos: present = True break if not present: pnew = vector(position.x, position.y, position.z) rnew = float(radius) cnew = (c[0], c[1], c[2]) vnew = vector(velocity.x, velocity.y, velocity.z) mnew = float(mass) planet_list.append(nbody2.makePlanet(pnew, rnew, cnew, vnew, mnew)) self.logger.AppendText('Planet Added Successfully:\n') self.logger.AppendText('Radius: ' + str(radius) + '\n') self.logger.AppendText('Mass: ' + str(mass) + '\n') self.logger.AppendText('Position: ' + str(position) + '\n') self.logger.AppendText('Velocity: ' + str(velocity) + '\n') self.logger.AppendText('\n') else: self.logger.AppendText('Failed to Add Planet\n') dlg = wx.MessageDialog( self,"You cannot put two planets at the same position.","Error", wx.OK) dlg.ShowModal() # Show it dlg.Destroy()