Gleason scores are determined by examining tissue. That can be from a biopsy, where the T (stage) is more speculative, or from a post-op pathology, where they have the whole organ to examine.
T (stage) pre-op has to do with how palpable it is on a DRE, and if the cancer is known to be out of the capsule (hence bone and CT scans).
So, you could be initially T1 (stage 1) with a Gleason = 9. That means there was nothing obvious in the DRE, but that something was found in a biopsy.
Post-op T is determined by the pathologist.
My pre-op was T2a (the uro could feel abnormalities in the DRE), Gleason 4+4=8; post-op was T3a Gleason 4+5.
There is a good explanation in the "Cleveland Clinic Guide to Prostate Cancer" (2009).
The Walsh book already mentioned is the best book, but this one is a good summary with diagrams approach.