What is The Roman Catholic law for electing the Pope in regards to a married person? If a married person is elected, what will happen to his wife after becoming the Pope?
A married person cannot be elected, because the pope is Bishop of Rome and married people cannot be bishops.
Canon law does allow married men to become deacons (as stated there), and also priests with the individual approval of the Holy See, but it does not extend that relaxation of Canon 1042 to bishops.
These restrictions and relaxations are the same as in the Eastern Churches, so as not to rule out eventual reunification.
Although it is true that any Catholic can become Pope they are typically chosen from higher level clergy such as a cardinal. These men are very likely not married because the Canon prohibits it unless the Pope allows it for his particular case.
The catechism says this concerning marriage for the clergy:
The Canon Law, that Andrew Leach found first, says this concerning marriage and clergy receiving orders (becoming part of the clergy).
The Canon Law also makes room to allow for dispensation of these laws in 1047 - 1049. It is, however, reserved to the Apostolic See only (the Pope). This is called motu proprio. This is basically the right of a monarch to change laws. The Pope has this right over Canon Law
So we might suppose that a married man might be selected as the next Pope, however, Can. 1042 would prohibit him from receiving orders, if he had not already as a deacon, but being a deacon would not allow him to take the seat of Rome because it is a bishop's seat, who are explicitly denied marriage. He would not be able to take the seat in Rome unless the previous Pope made dispensation for him. He could have already received dispensation and been serving as a bishop or priest for some time, although, I do not think there actually are any married bishops today. I am not sure but I would think that if a married priest, having received dispensation, were to be promoted I would think that he would need dispensation for his new post as well. The Canon Law on dispensation for marriage of the clergy is obviously for a case-by-case basis. A married priest's promotion would be a new case.
Because of motu proprio the Pope could also change the Cannon Law to allow marriage to just himself or all of clergy or anywhere in between. That is extremely unlikely to happen. Clerical celibacy is a long standing tradition. It would be taboo to suddenly allow marriage to all or any clergy.
The Sacrament of Marriage to the Catholic Church is sacred and will not and cannot be broken. If a man were elected Pope and was married as well they would surely accommodate both him and his wife, but there would still remain the problem with receiving orders unless dispensation was given previously. There are Canon lawyers that would surely have it well planed out if they ever did intend to elect a married man as the Pope.