在Mac OS X,Windows上的Python中获取根对话框? [英] Get root dialog in Python on Mac OS X, Windows?

查看:175
本文介绍了在Mac OS X,Windows上的Python中获取根对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何在我的Python应用程序中弹出一个特权提升对话框?我想要Windows上的UAC对话框和Mac上的密码验证对话框.

How would I go about getting a privilege elevation dialog to pop up in my Python app? I want the UAC dialog on Windows and the password authentication dialog on Mac.

基本上,我需要部分应用程序的root特权,并且需要通过GUI获得这些特权.我正在使用wxPython.有什么想法吗?

Basically, I need root privileges for part of my application and I need to get those privileges through the GUI. I'm using wxPython. Any ideas?

推荐答案

在Windows上,如果不启动新进程就无法获取UAC对话框,甚至无法使用CreateProcess启动该进程.

On Windows you cannot get the UAC dialog without starting a new process, and you cannot even start that process with CreateProcess.

可以通过运行另一个具有适当清单文件的应用程序来打开UAC对话框-请参见

The UAC dialog can be brought about by running another application that has the appropriate manifest file - see Running compiled python (py2exe) as administrator in Vista for an example of how to do this with py2exe.

您还可以将winas动词与Win32 api ShellExecute一起使用,以编程方式使用 http://msdn.microsoft.com/zh-cn/library/bb762153(v = vs.85).aspx -您可以使用ctypes

You can also programatically use the runas verb with the win32 api ShellExecute http://msdn.microsoft.com/en-us/library/bb762153(v=vs.85).aspx - you can call this by using ctypes http://python.net/crew/theller/ctypes/ which is part of the standard library on python 2.5+ iirc.

对不起,您不知道Mac.如果您提供有关要在Windows上完成的任务的更多详细信息,我也许可以提供更具体的帮助.

Sorry don't know about Mac. If you give more detail on what you want to accomplish on Windows I might be able to provide more specific help.

这篇关于在Mac OS X,Windows上的Python中获取根对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆