Popes who were legally married either as Pope or before they became clergy and were in fact widowed at the time of their election as Supreme Pontiff are as follows:
St. Peter (30/33-64/67) Mother-in-law is mentioned in the Gospel verses Matthew 8:14–15, Luke 4:38, Mark 1:29–31 and who was healed by Jesus at her home in Capernaum. 1 Cor. 9:5 asks whether others have the right to be accompanied by Christian wives as does "Cephas" (Peter). Clement of Alexandria wrote: "When the blessed Peter saw his own wife led out to die, he rejoiced because of her summons and her return home, and called to her very encouragingly and comfortingly, addressing her by name, and saying, 'Remember the Lord.' Such was the marriage of the blessed, and their perfect disposition toward those dearest to them.”
Pope Felix III (483–492) Married and widowed before he was elected as pope.
Pope Hormisdas (514–523) Married and widowed before he took Holy Orders.
Pope Adrian II (867–872) Married to Stephania before he took Holy Orders,[9] she was still living when he was elected Pope and resided with him in the Lateran Palace
Pope John XVII (1003) Married before his election as Pope.
Pope Clement IV (1265–1268) Married before taking holy orders.
Pope Honorius IV (1285–1287) Married before he took Holy Orders, widowed before entered the clergy.
Popes who were legally married
The last pope to be married and pope at the same time was Pope John XVII (1003). In 1075, Pope Gregory VII made celibacy mandatory in the Latin Rite.
From 1075 and on no individual could become pope while still married. If a pope remained true to his vow of celibacy that is another matter.
In 1075 Pope Gregory VII issued a decree effectively barring married priests from ministry, a discipline formalized by the First Lateran Council in 1123. Since then celibacy has been required of Roman Catholic priests, though the Catholic churches of the East have continued to allow priests to marry before their ordination. - Why are priests celibate?
Widowers have always been permitted to become priests and bishops.