I'm not sure how reliant on pain meds you are, but constipation is a sure bet while you are on them. I have chronic diarrhea - anywhere from 3-20 times a day - and more than Imodium, Lomotil, calcium, fiber supplements, etc., I found that narcotics were the only meds that stopped me up. It was a welcome relief for me, but I don't want to be on narcotics if I'm not in pain, so I only take them when I have excrutiating pain. After gallbladder surgery I took pain meds for a week and that was the only time in my life I was ever remotely "constipated" (i.e., going less than twice a day). I don't know how feasible it would be for you to take a trial week without the pain meds, or try a different medication, but you might find it's the meds that are making you so constipated and bloated, which in turn could cause further gut pain.
Colonoscopies can mess up your guts a bit too, although I can't imagine for any more than a few days. They pump air in there to visualize the intestines better, which causes gasiness and bloating.