How to tune PID parameters via Python?

I have a project that involves making a fuzzy PID controller and then creating a more complex controller based on this. I am running a simulation with PX4, ROS Melodic, and Gazebo 9. Previously, I had tried to implement a PID controller in Python and attempted to run it in a simulation, but it was unsuccessful in the sense that the drone was moving in such a ridiculous way. I figure that I can easily change the parameters of the PID controller through QGroundControl after it is connected to the Gazebo simulation, so I want to ask if there is an easy way to change the parameter of the PID controller through Python.