Going to the gym makes me happy, so I can understand your pain (no pun intended
)
I think you need to ask the doctor what benefit you will gain from resting your body. It could be that he doesn't want you doing weights but cardio is really ok. And as long as you are not clear on the benefits, you will keep going to the gym. Take it from me, I know.
A couple of years ago I had hip surgery and my doctor said no gym for 6!!!! weeks. Well. THAT wasn't going to work for me, nope, not at all. So the doc and I talked it through and he, if I promised to stick to the program, allowed me to do things that didn't involve my hip. My upper arms have never looked better
YMMV