Mask the whole canopy with masking tape
Cut around the frames with a fine tipped blade, such as a Swan Morton #11 scalpel blade
Peel off the tape from the frames
Paint the canopy frames, and the rest of the model if necessary
When the paint has dried, but not set absolutely hard, peel off the rest of the masking tape from the canopy
OR -
Cut masking tape into very narrow strips and line the frames with them, leaving the frames themselves exposed
Fill in the rest of the canopy with tape or liquid masking fluid
Paint the frames, and the rest of the model if necessary
When the paint has dried, but not set absolutely hard, remove the masking from the canopy
OR -
Paint the frames as well as you can with a fine brush, but don't worry too much if it spreads slightly onto the canopy
When the paint has dried, but not set absolutely hard, scrape off any excess paint with a cocktail stick
It helps if you trim the end of the cocktail stick into a very small chisel shape
This method is known as 'paint and scrape'
Practice & experience will show you how set/dried/cured the paint needs to be
You can get canopy masks for some kits
Search YouTube for 'painting model aircraft canopies' ; there are several videos