I am not sure if the weight gain is caused completely by the surgery but it could very well be!
I had major liver surgery 2 years ago (and they removed my gallbladder too, to save medicare money;)), my weight fluctuated in the 10 week recovery. I think part of it has to do with the amount of different drugs that pump through you during and after surgery. My body took about a year to settle back down, unfortunately my thick hair is now very thin (supposedly a possible side effect of anaethesia).
Have patience and take the recovery time seriously. It is a lot for your body to deal with and it is telling you it is upset, confused and generally fed up with what's happened to it (well that's what I thought it was saying lol)
Don't give up, things will get back on track!