Hey I'm trying to write a UI for an orbital simulator using PyQt5. I have created 8 planet objects and written functions for the UI to read to and from the class so that it can display the right information to the user.
if planet == "Planet 1":
self.slider1.setValue(p.p1.radius)
self.colors.setId(p.p1.color)
self.slider2.setValue(p.p1.mass)
self.x_slider.setValue(p.p1.x)
self.y_slider.setValue(p.p1.y)
self.z_slider.setValue(p.p1.z)`
This code basically says if planet 1 is selected set the values on the UI to display the attributes of planet 1. I created a similar method to write to the planet when the user wanted to change the attributes of the planet. When I try either routes I get an attribute error.
P.s I also tried to write a method within the planet class to change the attributes inside the class as I thought this may have been the issue.
def change(attribute,value):
if attribute == "radius":
self.radius = value
elif attribute == "colour":
self.colour = colour
elif attribute == "mass":
self.mass = value
elif attribute == "x":
self.x = value
elif attribute == "y":
self.y = value
elif attribute == "z":
self.z = value
elif attribute == "vx":
self.vx = value
elif attribute == "vy":
self.vy = value
elif attribute == "vz":
self.vz = value