This is the logic you need. Let say you want to create a forward function that will stop when the encoders reach a point and will use the gyro to prevent drifting. Here is an outline:
Start your motors at the desired speed
while(1){
if encoder reached target ticks, break loop and stop all motors
if abs(gyro value) is more than buffer, change the speed of the motors proportional to the gyro value
}
A example of how you can change your speed:
First, you need two variables to store the current speed (lets say they are Lspeed and Rspeed)
Lspeed -= 3*gyrovalue
Rspeed += 3*gyrovalue
LeftMotors = Lspeed
RightMotors = Rspeed
(3 the just a number for example. Test your own magic number)
You dont really have to use classes at this point.
Also, to get the value of a gyro, use [gyro name here].get_value()