I am writing a gui program using wx module in python. In program whenever I am accessing a folder which requires root privilege then it asks password at terminal but I want to display the dialog to user to enter the password and authenticate him. How to call that dialog and authenticate the user in ubuntu?
|
There are two different Q&As at stackoverflow answering your question: here and here. Both answers use the command To implement the suggested solution from the linked answers in python, you can use something as shown by the following example: Create a file
And a file
Then run |
|||
|
|
|
While I'm sure there's a fancier python solution, the down and dirty version is to use gksudo. gksudo does the same thing sudo does, except it creates that dialog for authentication you mentioned instead of asking on the command line. See https://help.ubuntu.com/community/RootSudo#Graphical_sudo |
|||||
|
|
Insert this script in your code:
|
|||
|
|
sudo, but I don't have enough knowledge of Python or PolicyKit to write a good answer explaining how. Perhaps someone else can. – Eliah Kagan May 24 '12 at 5:32