I've been building and ROV for a while now and made a pretty sweet GUI first with Arduino IDE, then with MATLAB, everything worked great. I upgraded to a Raspberry Pi 5 and now I want to make the same GUI with python but I'm pretty new with python, so bear with me.
Here's what I want to do and nothing I can think of is fixing the problem, my code is below. I want to have a tkinter scale from 0 to 100, then I want to convert those values to a pwm signal, so 1100 to 1900. I have five sliders that all do the same thing, one light intensity, forward thrust, reverse thrust, ascend, and descend thrust. As you adjust the slider I want a label that notifies the user on how fast they are going. These values are meant to be limits for the thruster, so if you set the scale to 80 its converted to a pwm signal of 1740 and now the forward thrusters can only recieve a pwm signal of 1500 to 1740 . Hopefully all of that makes sense.
Here's the problem, I have my labels set to specific values of the slider, when I slide back and forth the labels show up but I cant them to go away when the value changes. Instead they overall and I cant figure out how to get rid of them. I'll figure out the rest of these things later. Any ideas? Thanks!
Here's what I want to do and nothing I can think of is fixing the problem, my code is below. I want to have a tkinter scale from 0 to 100, then I want to convert those values to a pwm signal, so 1100 to 1900. I have five sliders that all do the same thing, one light intensity, forward thrust, reverse thrust, ascend, and descend thrust. As you adjust the slider I want a label that notifies the user on how fast they are going. These values are meant to be limits for the thruster, so if you set the scale to 80 its converted to a pwm signal of 1740 and now the forward thrusters can only recieve a pwm signal of 1500 to 1740 . Hopefully all of that makes sense.
Here's the problem, I have my labels set to specific values of the slider, when I slide back and forth the labels show up but I cant them to go away when the value changes. Instead they overall and I cant figure out how to get rid of them. I'll figure out the rest of these things later. Any ideas? Thanks!
def ascend_thruster_modification(self): thrust_mid = 1500 thrust_ascend_var = round(ascend_scale_int.get()) new_thrust_ascend_var = (thrust_ascend_var/100)*400 final_thrust_forward_var = new_thrust_ascend_var + thrust_mid if thrust_ascend_var == 0: forward_label1 = ttk.Label(vic_settings_frame, text = 'Off') forward_label1.place(relx = .24, rely = .23) if 1 <= thrust_ascend_var <= 50: forward_label1 = ttk.Label(vic_settings_frame, text = 'Low Speed') forward_label1.place(relx = .24, rely = .23) if 51 <= thrust_ascend_var <= 75: forward_label1 = ttk.Label(vic_settings_frame, text = 'High Speed') forward_label1.place(relx = .24, rely = .23) if thrust_ascend_var >= 76: forward_label1 = ttk.Label(vic_settings_frame, text = 'Maximum Speed') forward_label1.place(relx = .24, rely = .23) forward_scale_int = tk.IntVar(value = 100) thrust_forward_scale = ttk.Scale(vic_settings_frame, from_ = 0, to = 100, length = 300, orient = 'horizontal', variable = forward_scale_int, command = forward_thruster_modification) forward_text = ttk.Label(vic_settings_frame, text = 'Forward Thruster Speed Settings') forward_label = ttk.Label(vic_settings_frame, text = 'Current Forward Thruster Speed: ') forward_text.place(relx = .03, rely = .16) forward_label.place(relx = .03, rely = .23) thrust_forward_scale.place(relx = .03, rely = .19)idk why but some of my indentations are weird and I cant figure out how to change them. The labels and scale bar are not part of the function. All of this is part of a larger function. Thanks!