How to launch elevated privileges window?

When I uninstall some snaps using the Snap Store, a window pops up telling me that I need to enter a password to uninstall. The same thing happens when installing some snaps. Installing Notepad++ on Ubuntu via the Snap Store is one example. I am assuming this a system permissions popup rather than a custom GUI actually created by the Snap Store folks.

14%20AM

My own python snap needs root privileges at one point in its setup process, while running in a GUI as the user. Examples that I find online for requesting root privileges in python inevitably only work when running in the terminal, which is not what my snap is doing.

How do I prompt the user to enter their root password (in a non-scary way) from my python GUI exactly like the Snap Store does on install/uninstall?

I found my solution on Stack Overflow! Hope this helps someone else…

import os
os.system("pkexec ls -l")

EDIT: I take it back. Apparently, pkexec is not allowed.